# HG changeset patch # User Artem Tikhomirov # Date 1302831308 -7200 # Node ID 344e8d7e4d6eb769799d321bcbbe555f64e577db # Parent 37f3d4a596e4dddd57079a9d2bf8fa0c21d44c36 Use common low to hi-level changeset api transformer diff -r 37f3d4a596e4 -r 344e8d7e4d6e src/org/tmatesoft/hg/core/HgIncomingCommand.java --- 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 missingBranches; private HgChangelog.ParentWalker parentHelper; + private Set 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 this 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(); + } + 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(); } diff -r 37f3d4a596e4 -r 344e8d7e4d6e src/org/tmatesoft/hg/core/HgOutgoingCommand.java --- a/src/org/tmatesoft/hg/core/HgOutgoingCommand.java Fri Apr 15 03:28:12 2011 +0200 +++ b/src/org/tmatesoft/hg/core/HgOutgoingCommand.java Fri Apr 15 03:35:08 2011 +0200 @@ -17,6 +17,8 @@ package org.tmatesoft.hg.core; import java.util.List; +import java.util.Set; +import java.util.TreeSet; import org.tmatesoft.hg.internal.RepositoryComparator; import org.tmatesoft.hg.repo.HgChangelog; @@ -36,6 +38,7 @@ private HgRemoteRepository remoteRepo; private boolean includeSubrepo; private RepositoryComparator comparator; + private Set branches; public HgOutgoingCommand(HgRepository hgRepo) { localRepo = hgRepo; @@ -52,13 +55,23 @@ } /** - * PLACEHOLDER, NOT IMPLEMENTED YET. + * Select specific branch to pull. + * 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 this for convenience + * @throws IllegalArgumentException when branch argument is null */ public HgOutgoingCommand branch(String branch) { - throw HgRepository.notImplemented(); + if (branch == null) { + throw new IllegalArgumentException(); + } + if (branches == null) { + branches = new TreeSet(); + } + branches.add(branch); + return this; } /** @@ -72,7 +85,8 @@ } /** - * Lightweight check for outgoing changes. + * Lightweight check for outgoing changes. + * Reported changes are from any branch (limits set by {@link #branch(String)} are not taken into account. * * @param context * @return list on local nodes known to be missing at remote server @@ -90,7 +104,9 @@ if (handler == null) { throw new IllegalArgumentException("Delegate can't be null"); } - getComparator(handler).visitLocalOnlyRevisions(new ChangesetTransformer(localRepo, handler)); + ChangesetTransformer inspector = new ChangesetTransformer(localRepo, handler); + inspector.limitBranches(branches); + getComparator(handler).visitLocalOnlyRevisions(inspector); } private RepositoryComparator getComparator(Object context) throws HgException, CancelledException {