diff src/org/tmatesoft/hg/core/HgIncomingCommand.java @ 194:344e8d7e4d6e

Use common low to hi-level changeset api transformer
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 15 Apr 2011 03:35:08 +0200
parents e5407b5a586a
children c9b305df0b89
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgIncomingCommand.java	Fri Apr 15 03:28:12 2011 +0200
+++ b/src/org/tmatesoft/hg/core/HgIncomingCommand.java	Fri Apr 15 03:35:08 2011 +0200
@@ -21,6 +21,8 @@
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
 
 import org.tmatesoft.hg.internal.RepositoryComparator;
 import org.tmatesoft.hg.internal.RepositoryComparator.BranchChain;
@@ -45,6 +47,7 @@
 	private RepositoryComparator comparator;
 	private List<BranchChain> missingBranches;
 	private HgChangelog.ParentWalker parentHelper;
+	private Set<String> branches;
 
 	public HgIncomingCommand(HgRepository hgRepo) {
 	 	localRepo = hgRepo;
@@ -58,13 +61,23 @@
 	}
 
 	/**
-	 * PLACEHOLDER, NOT IMPLEMENTED YET.
+	 * Select specific branch to push.
+	 * Multiple branch specification possible (changeset from any of these would be included in result).
+	 * Note, {@link #executeLite(Object)} does not respect this setting.
 	 * 
-	 * Select specific branch to pull
+	 * @param branch - branch name, case-sensitive, non-null.
 	 * @return <code>this</code> for convenience
+	 * @throws IllegalArgumentException when branch argument is null
 	 */
 	public HgIncomingCommand branch(String branch) {
-		throw HgRepository.notImplemented();
+		if (branch == null) {
+			throw new IllegalArgumentException();
+		}
+		if (branches == null) {
+			branches = new TreeSet<String>();
+		}
+		branches.add(branch);
+		return this;
 	}
 	
 	/**
@@ -79,7 +92,8 @@
 	}
 
 	/**
-	 * Lightweight check for incoming changes, gives only list of revisions to pull. 
+	 * Lightweight check for incoming changes, gives only list of revisions to pull.
+	 * Reported changes are from any branch (limits set by {@link #branch(String)} are not taken into account. 
 	 *   
 	 * @param context anything hg4j can use to get progress and/or cancel support
 	 * @return list of nodes present at remote and missing locally
@@ -120,6 +134,7 @@
 				
 				{
 					transformer = new ChangesetTransformer(localRepo, handler);
+					transformer.limitBranches(branches);
 					parentHelper = getParentHelper();
 					changelog = localRepo.getChangelog();
 				}