diff src/org/tmatesoft/hg/core/ChangesetTransformer.java @ 193:37f3d4a596e4

Use common low to hi-level changeset api transformer
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 15 Apr 2011 03:28:12 +0200
parents e5407b5a586a
children c9b305df0b89
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/ChangesetTransformer.java	Fri Apr 15 03:17:03 2011 +0200
+++ b/src/org/tmatesoft/hg/core/ChangesetTransformer.java	Fri Apr 15 03:28:12 2011 +0200
@@ -16,6 +16,8 @@
  */
 package org.tmatesoft.hg.core;
 
+import java.util.Set;
+
 import org.tmatesoft.hg.repo.HgChangelog;
 import org.tmatesoft.hg.repo.HgRepository;
 import org.tmatesoft.hg.repo.HgStatusCollector;
@@ -32,12 +34,14 @@
 /*package-local*/ class ChangesetTransformer implements HgChangelog.Inspector {
 	private final HgLogCommand.Handler handler;
 	private final HgChangeset changeset;
+	private Set<String> branches;
 
 	public ChangesetTransformer(HgRepository hgRepo, HgLogCommand.Handler delegate) {
 		if (hgRepo == null || delegate == null) {
 			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);
@@ -45,7 +49,15 @@
 	}
 	
 	public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
+		if (branches != null && !branches.contains(cset.branch())) {
+			return;
+		}
+
 		changeset.init(revisionNumber, nodeid, cset);
 		handler.next(changeset);
 	}
+	
+	public void limitBranches(Set<String> branches) {
+		this.branches = branches;
+	}
 }
\ No newline at end of file