diff src/org/tmatesoft/hg/core/ChangesetTransformer.java @ 328:a674b8590362

Move file tree history to upper API level
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 05 Oct 2011 07:13:57 +0200
parents 41a778e3fd31
children ac8e1ce67730
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/ChangesetTransformer.java	Tue Oct 04 07:24:44 2011 +0200
+++ b/src/org/tmatesoft/hg/core/ChangesetTransformer.java	Wed Oct 05 07:13:57 2011 +0200
@@ -37,9 +37,9 @@
  */
 /*package-local*/ class ChangesetTransformer implements HgChangelog.Inspector {
 	private final HgChangesetHandler handler;
-	private final HgChangeset changeset;
 	private final ProgressSupport progressHelper;
 	private final CancelSupport cancelHelper;
+	private final Transformation t;
 	private Set<String> branches;
 	private HgCallbackTargetException failure;
 	private CancelledException cancellation;
@@ -54,11 +54,7 @@
 			throw new IllegalArgumentException();
 		}
 		HgStatusCollector statusCollector = new HgStatusCollector(hgRepo);
-		// files listed in a changeset don't need their names to be rewritten (they are normalized already)
-		PathPool pp = new PathPool(new PathRewrite.Empty());
-		statusCollector.setPathPool(pp);
-		changeset = new HgChangeset(statusCollector, pp);
-		changeset.setParentHelper(pw);
+		t = new Transformation(statusCollector, pw);
 		handler = delegate;
 		cancelHelper = cs;
 		progressHelper = ps;
@@ -72,7 +68,7 @@
 			return;
 		}
 
-		changeset.init(revisionNumber, nodeid, cset);
+		HgChangeset changeset = t.handle(revisionNumber, nodeid, cset);
 		try {
 			handler.next(changeset);
 			progressHelper.worked(1);
@@ -100,4 +96,22 @@
 	public void limitBranches(Set<String> branches) {
 		this.branches = branches;
 	}
+
+	// part relevant to RawChangeset->HgChangeset transformation
+	static class Transformation {
+		private final HgChangeset changeset;
+
+		public Transformation(HgStatusCollector statusCollector, HgChangelog.ParentWalker pw) {
+			// files listed in a changeset don't need their names to be rewritten (they are normalized already)
+			PathPool pp = new PathPool(new PathRewrite.Empty());
+			statusCollector.setPathPool(pp);
+			changeset = new HgChangeset(statusCollector, pp);
+			changeset.setParentHelper(pw);
+		}
+		
+		HgChangeset handle(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
+			changeset.init(revisionNumber, nodeid, cset);
+			return changeset;
+		}
+	}
 }
\ No newline at end of file