Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/RepositoryComparator.java @ 645:14dac192aa26
Push: phase2 - upload bundle with changes to remote server
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Thu, 20 Jun 2013 19:15:09 +0200 |
| parents | 6526d8adbc0f |
| children | cd77bf51b562 |
comparison
equal
deleted
inserted
replaced
| 644:1deea2f33218 | 645:14dac192aa26 |
|---|---|
| 52 | 52 |
| 53 private final boolean debug = Boolean.parseBoolean(System.getProperty("hg4j.remote.debug")); | 53 private final boolean debug = Boolean.parseBoolean(System.getProperty("hg4j.remote.debug")); |
| 54 private final HgParentChildMap<HgChangelog> localRepo; | 54 private final HgParentChildMap<HgChangelog> localRepo; |
| 55 private final HgRemoteRepository remoteRepo; | 55 private final HgRemoteRepository remoteRepo; |
| 56 private List<Nodeid> common; | 56 private List<Nodeid> common; |
| 57 private List<Nodeid> remoteHeads; | |
| 57 | 58 |
| 58 public RepositoryComparator(HgParentChildMap<HgChangelog> pwLocal, HgRemoteRepository hgRemote) { | 59 public RepositoryComparator(HgParentChildMap<HgChangelog> pwLocal, HgRemoteRepository hgRemote) { |
| 59 localRepo = pwLocal; | 60 localRepo = pwLocal; |
| 60 remoteRepo = hgRemote; | 61 remoteRepo = hgRemote; |
| 61 } | 62 } |
| 79 throw new HgInvalidStateException("Call #compare(Object) first"); | 80 throw new HgInvalidStateException("Call #compare(Object) first"); |
| 80 } | 81 } |
| 81 return common; | 82 return common; |
| 82 } | 83 } |
| 83 | 84 |
| 85 public List<Nodeid> getRemoteHeads() { | |
| 86 assert remoteHeads != null; | |
| 87 return remoteHeads; | |
| 88 } | |
| 89 | |
| 84 /** | 90 /** |
| 85 * @return revisions that are children of common entries, i.e. revisions that are present on the local server and not on remote. | 91 * @return revisions that are children of common entries, i.e. revisions that are present on the local server and not on remote. |
| 86 */ | 92 */ |
| 87 public List<Nodeid> getLocalOnlyRevisions() { | 93 public List<Nodeid> getLocalOnlyRevisions() { |
| 88 return localRepo.childrenOf(getCommon()); | 94 final List<Nodeid> c = getCommon(); |
| 95 if (c.isEmpty()) { | |
| 96 return localRepo.all(); | |
| 97 } else { | |
| 98 return localRepo.childrenOf(c); | |
| 99 } | |
| 89 } | 100 } |
| 90 | 101 |
| 91 /** | 102 /** |
| 92 * Similar to @link {@link #getLocalOnlyRevisions()}, use this one if you need access to changelog entry content, not | 103 * Similar to @link {@link #getLocalOnlyRevisions()}, use this one if you need access to changelog entry content, not |
| 93 * only its revision number. | 104 * only its revision number. |
| 126 } | 137 } |
| 127 changelog.range(earliestRevision+1, changelog.getLastRevision(), inspector); | 138 changelog.range(earliestRevision+1, changelog.getLastRevision(), inspector); |
| 128 } | 139 } |
| 129 | 140 |
| 130 private List<Nodeid> findCommonWithRemote() throws HgRemoteConnectionException { | 141 private List<Nodeid> findCommonWithRemote() throws HgRemoteConnectionException { |
| 131 List<Nodeid> remoteHeads = remoteRepo.heads(); | 142 remoteHeads = remoteRepo.heads(); |
| 132 LinkedList<Nodeid> resultCommon = new LinkedList<Nodeid>(); // these remotes are known in local | 143 LinkedList<Nodeid> resultCommon = new LinkedList<Nodeid>(); // these remotes are known in local |
| 133 LinkedList<Nodeid> toQuery = new LinkedList<Nodeid>(); // these need further queries to find common | 144 LinkedList<Nodeid> toQuery = new LinkedList<Nodeid>(); // these need further queries to find common |
| 134 for (Nodeid rh : remoteHeads) { | 145 for (Nodeid rh : remoteHeads) { |
| 135 if (localRepo.knownNode(rh)) { | 146 if (localRepo.knownNode(rh)) { |
| 136 resultCommon.add(rh); | 147 resultCommon.add(rh); |
