comparison 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
comparison
equal deleted inserted replaced
193:37f3d4a596e4 194:344e8d7e4d6e
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.ArrayList; 20 import java.util.ArrayList;
21 import java.util.LinkedHashSet; 21 import java.util.LinkedHashSet;
22 import java.util.LinkedList; 22 import java.util.LinkedList;
23 import java.util.List; 23 import java.util.List;
24 import java.util.Set;
25 import java.util.TreeSet;
24 26
25 import org.tmatesoft.hg.internal.RepositoryComparator; 27 import org.tmatesoft.hg.internal.RepositoryComparator;
26 import org.tmatesoft.hg.internal.RepositoryComparator.BranchChain; 28 import org.tmatesoft.hg.internal.RepositoryComparator.BranchChain;
27 import org.tmatesoft.hg.repo.HgBundle; 29 import org.tmatesoft.hg.repo.HgBundle;
28 import org.tmatesoft.hg.repo.HgChangelog; 30 import org.tmatesoft.hg.repo.HgChangelog;
43 private HgRemoteRepository remoteRepo; 45 private HgRemoteRepository remoteRepo;
44 private boolean includeSubrepo; 46 private boolean includeSubrepo;
45 private RepositoryComparator comparator; 47 private RepositoryComparator comparator;
46 private List<BranchChain> missingBranches; 48 private List<BranchChain> missingBranches;
47 private HgChangelog.ParentWalker parentHelper; 49 private HgChangelog.ParentWalker parentHelper;
50 private Set<String> branches;
48 51
49 public HgIncomingCommand(HgRepository hgRepo) { 52 public HgIncomingCommand(HgRepository hgRepo) {
50 localRepo = hgRepo; 53 localRepo = hgRepo;
51 } 54 }
52 55
56 missingBranches = null; 59 missingBranches = null;
57 return this; 60 return this;
58 } 61 }
59 62
60 /** 63 /**
61 * PLACEHOLDER, NOT IMPLEMENTED YET. 64 * Select specific branch to push.
65 * Multiple branch specification possible (changeset from any of these would be included in result).
66 * Note, {@link #executeLite(Object)} does not respect this setting.
62 * 67 *
63 * Select specific branch to pull 68 * @param branch - branch name, case-sensitive, non-null.
64 * @return <code>this</code> for convenience 69 * @return <code>this</code> for convenience
70 * @throws IllegalArgumentException when branch argument is null
65 */ 71 */
66 public HgIncomingCommand branch(String branch) { 72 public HgIncomingCommand branch(String branch) {
67 throw HgRepository.notImplemented(); 73 if (branch == null) {
74 throw new IllegalArgumentException();
75 }
76 if (branches == null) {
77 branches = new TreeSet<String>();
78 }
79 branches.add(branch);
80 return this;
68 } 81 }
69 82
70 /** 83 /**
71 * PLACEHOLDER, NOT IMPLEMENTED YET. 84 * PLACEHOLDER, NOT IMPLEMENTED YET.
72 * 85 *
77 includeSubrepo = include; 90 includeSubrepo = include;
78 throw HgRepository.notImplemented(); 91 throw HgRepository.notImplemented();
79 } 92 }
80 93
81 /** 94 /**
82 * Lightweight check for incoming changes, gives only list of revisions to pull. 95 * Lightweight check for incoming changes, gives only list of revisions to pull.
96 * Reported changes are from any branch (limits set by {@link #branch(String)} are not taken into account.
83 * 97 *
84 * @param context anything hg4j can use to get progress and/or cancel support 98 * @param context anything hg4j can use to get progress and/or cancel support
85 * @return list of nodes present at remote and missing locally 99 * @return list of nodes present at remote and missing locally
86 * @throws HgException 100 * @throws HgException
87 * @throws CancelledException 101 * @throws CancelledException
118 private final ChangesetTransformer transformer; 132 private final ChangesetTransformer transformer;
119 private final HgChangelog changelog; 133 private final HgChangelog changelog;
120 134
121 { 135 {
122 transformer = new ChangesetTransformer(localRepo, handler); 136 transformer = new ChangesetTransformer(localRepo, handler);
137 transformer.limitBranches(branches);
123 parentHelper = getParentHelper(); 138 parentHelper = getParentHelper();
124 changelog = localRepo.getChangelog(); 139 changelog = localRepo.getChangelog();
125 } 140 }
126 141
127 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) { 142 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {