Mercurial > hg4j
comparison src/org/tmatesoft/hg/core/HgIncomingCommand.java @ 208:ef8eba4aa215
Correct index of revisions to be added into a repository
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Thu, 28 Apr 2011 03:17:50 +0200 |
| parents | ffc5f6d59f7e |
| children | 41a778e3fd31 |
comparison
equal
deleted
inserted
replaced
| 207:1bf0a5af2d5d | 208:ef8eba4aa215 |
|---|---|
| 130 } | 130 } |
| 131 final List<Nodeid> common = getCommon(handler); | 131 final List<Nodeid> common = getCommon(handler); |
| 132 HgBundle changegroup = remoteRepo.getChanges(common); | 132 HgBundle changegroup = remoteRepo.getChanges(common); |
| 133 try { | 133 try { |
| 134 changegroup.changes(localRepo, new HgChangelog.Inspector() { | 134 changegroup.changes(localRepo, new HgChangelog.Inspector() { |
| 135 private int localIndex = -1; // in case we start with empty repo and localIndex would not get initialized in regular way | 135 private int localIndex; |
| 136 private final HgChangelog.ParentWalker parentHelper; | 136 private final HgChangelog.ParentWalker parentHelper; |
| 137 private final ChangesetTransformer transformer; | 137 private final ChangesetTransformer transformer; |
| 138 private final HgChangelog changelog; | 138 |
| 139 | |
| 140 { | 139 { |
| 141 transformer = new ChangesetTransformer(localRepo, handler, getParentHelper()); | 140 transformer = new ChangesetTransformer(localRepo, handler, getParentHelper()); |
| 142 transformer.limitBranches(branches); | 141 transformer.limitBranches(branches); |
| 143 parentHelper = getParentHelper(); | 142 parentHelper = getParentHelper(); |
| 144 changelog = localRepo.getChangelog(); | 143 // new revisions, if any, would be added after all existing, and would get numbered started with last+1 |
| 144 localIndex = localRepo.getChangelog().getRevisionCount(); | |
| 145 } | 145 } |
| 146 | 146 |
| 147 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) { | 147 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) { |
| 148 if (parentHelper.knownNode(nodeid)) { | 148 if (parentHelper.knownNode(nodeid)) { |
| 149 if (!common.contains(nodeid)) { | 149 if (!common.contains(nodeid)) { |
| 150 throw new HgBadStateException("Bundle shall not report known nodes other than roots we've supplied"); | 150 throw new HgBadStateException("Bundle shall not report known nodes other than roots we've supplied"); |
| 151 } | 151 } |
| 152 localIndex = changelog.getLocalRevision(nodeid); | |
| 153 return; | 152 return; |
| 154 } | 153 } |
| 155 transformer.next(++localIndex, nodeid, cset); | 154 transformer.next(localIndex++, nodeid, cset); |
| 156 } | 155 } |
| 157 }); | 156 }); |
| 158 } catch (IOException ex) { | 157 } catch (IOException ex) { |
| 159 throw new HgException(ex); | 158 throw new HgException(ex); |
| 160 } | 159 } |
