changeset 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 1bf0a5af2d5d
children 9ce3b26798c4
files cmdline/org/tmatesoft/hg/console/ChangesetDumpHandler.java cmdline/org/tmatesoft/hg/console/Incoming.java src/org/tmatesoft/hg/core/HgIncomingCommand.java
diffstat 3 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/ChangesetDumpHandler.java	Thu Apr 28 03:10:56 2011 +0200
+++ b/cmdline/org/tmatesoft/hg/console/ChangesetDumpHandler.java	Thu Apr 28 03:17:50 2011 +0200
@@ -36,7 +36,7 @@
 	// params
 	private boolean complete = false; // roughly --debug
 	private boolean reverseOrder = false;
-	private boolean verbose = true; // roughly -v
+	private boolean verbose = false; // roughly -v
 	// own
 	private LinkedList<String> l = new LinkedList<String>();
 	private final HgRepository repo;
--- a/cmdline/org/tmatesoft/hg/console/Incoming.java	Thu Apr 28 03:10:56 2011 +0200
+++ b/cmdline/org/tmatesoft/hg/console/Incoming.java	Thu Apr 28 03:17:50 2011 +0200
@@ -63,6 +63,7 @@
 		List<Nodeid> missing = cmd.executeLite(null);
 		Collections.reverse(missing); // useful to test output, from newer to older
 		Outgoing.dump("Nodes to fetch:", missing);
+		System.out.printf("Total: %d\n\n", missing.size());
 		//
 		// Complete
 		final ChangesetDumpHandler h = new ChangesetDumpHandler(hgRepo.getRepository());
--- a/src/org/tmatesoft/hg/core/HgIncomingCommand.java	Thu Apr 28 03:10:56 2011 +0200
+++ b/src/org/tmatesoft/hg/core/HgIncomingCommand.java	Thu Apr 28 03:17:50 2011 +0200
@@ -132,16 +132,16 @@
 		HgBundle changegroup = remoteRepo.getChanges(common);
 		try {
 			changegroup.changes(localRepo, new HgChangelog.Inspector() {
-				private int localIndex = -1; // in case we start with empty repo and localIndex would not get initialized in regular way
+				private int localIndex;
 				private final HgChangelog.ParentWalker parentHelper;
 				private final ChangesetTransformer transformer;
-				private final HgChangelog changelog;
-				
+			
 				{
 					transformer = new ChangesetTransformer(localRepo, handler, getParentHelper());
 					transformer.limitBranches(branches);
 					parentHelper = getParentHelper();
-					changelog = localRepo.getChangelog();
+					// new revisions, if any, would be added after all existing, and would get numbered started with last+1
+					localIndex = localRepo.getChangelog().getRevisionCount();
 				}
 				
 				public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
@@ -149,10 +149,9 @@
 						if (!common.contains(nodeid)) {
 							throw new HgBadStateException("Bundle shall not report known nodes other than roots we've supplied");
 						}
-						localIndex = changelog.getLocalRevision(nodeid);
 						return;
 					}
-					transformer.next(++localIndex, nodeid, cset);
+					transformer.next(localIndex++, nodeid, cset);
 				}
 			});
 		} catch (IOException ex) {