Mercurial > jhg
changeset 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 | 37f3d4a596e4 |
children | c9b305df0b89 |
files | src/org/tmatesoft/hg/core/HgIncomingCommand.java src/org/tmatesoft/hg/core/HgOutgoingCommand.java |
diffstat | 2 files changed, 40 insertions(+), 9 deletions(-) [+] |
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(); }
--- 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<String> 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 <code>this</code> 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<String>(); + } + 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 {