diff src/org/tmatesoft/hg/core/HgOutgoingCommand.java @ 195:c9b305df0b89

Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 15 Apr 2011 05:17:44 +0200
parents 344e8d7e4d6e
children ffc5f6d59f7e
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgOutgoingCommand.java	Fri Apr 15 03:35:08 2011 +0200
+++ b/src/org/tmatesoft/hg/core/HgOutgoingCommand.java	Fri Apr 15 05:17:44 2011 +0200
@@ -38,6 +38,7 @@
 	private HgRemoteRepository remoteRepo;
 	private boolean includeSubrepo;
 	private RepositoryComparator comparator;
+	private HgChangelog.ParentWalker parentHelper;
 	private Set<String> branches;
 
 	public HgOutgoingCommand(HgRepository hgRepo) {
@@ -104,7 +105,7 @@
 		if (handler == null) {
 			throw new IllegalArgumentException("Delegate can't be null");
 		}
-		ChangesetTransformer inspector = new ChangesetTransformer(localRepo, handler);
+		ChangesetTransformer inspector = new ChangesetTransformer(localRepo, handler, getParentHelper());
 		inspector.limitBranches(branches);
 		getComparator(handler).visitLocalOnlyRevisions(inspector);
 	}
@@ -114,11 +115,18 @@
 			throw new IllegalArgumentException("Shall specify remote repository to compare against");
 		}
 		if (comparator == null) {
-			HgChangelog.ParentWalker pw = localRepo.getChangelog().new ParentWalker();
-			pw.init();
-			comparator = new RepositoryComparator(pw, remoteRepo);
+			comparator = new RepositoryComparator(getParentHelper(), remoteRepo);
 			comparator.compare(context);
 		}
 		return comparator;
 	}
+	
+	private HgChangelog.ParentWalker getParentHelper() {
+		if (parentHelper == null) {
+			parentHelper = localRepo.getChangelog().new ParentWalker();
+			parentHelper.init();
+		}
+		return parentHelper;
+	}
+
 }