Mercurial > hg4j
comparison src/org/tmatesoft/hg/core/HgOutgoingCommand.java @ 653:629a7370554c
Tests for recent changes in HgParentChildMap and RepositoryComparator (outgoing to respect drafts and Issue 47)
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 03 Jul 2013 14:38:30 +0200 |
parents | 6526d8adbc0f |
children |
comparison
equal
deleted
inserted
replaced
652:cd77bf51b562 | 653:629a7370554c |
---|---|
19 import java.util.List; | 19 import java.util.List; |
20 import java.util.Set; | 20 import java.util.Set; |
21 import java.util.TreeSet; | 21 import java.util.TreeSet; |
22 | 22 |
23 import org.tmatesoft.hg.internal.Internals; | 23 import org.tmatesoft.hg.internal.Internals; |
24 import org.tmatesoft.hg.internal.PhasesHelper; | |
24 import org.tmatesoft.hg.internal.RepositoryComparator; | 25 import org.tmatesoft.hg.internal.RepositoryComparator; |
26 import org.tmatesoft.hg.internal.RevisionSet; | |
25 import org.tmatesoft.hg.repo.HgChangelog; | 27 import org.tmatesoft.hg.repo.HgChangelog; |
26 import org.tmatesoft.hg.repo.HgParentChildMap; | 28 import org.tmatesoft.hg.repo.HgParentChildMap; |
27 import org.tmatesoft.hg.repo.HgRemoteRepository; | 29 import org.tmatesoft.hg.repo.HgRemoteRepository; |
28 import org.tmatesoft.hg.repo.HgRepository; | 30 import org.tmatesoft.hg.repo.HgRepository; |
29 import org.tmatesoft.hg.repo.HgRuntimeException; | 31 import org.tmatesoft.hg.repo.HgRuntimeException; |
101 * @throws CancelledException if execution of the command was cancelled | 103 * @throws CancelledException if execution of the command was cancelled |
102 */ | 104 */ |
103 public List<Nodeid> executeLite() throws HgRemoteConnectionException, HgException, CancelledException { | 105 public List<Nodeid> executeLite() throws HgRemoteConnectionException, HgException, CancelledException { |
104 final ProgressSupport ps = getProgressSupport(null); | 106 final ProgressSupport ps = getProgressSupport(null); |
105 try { | 107 try { |
106 ps.start(10); | 108 return getOutgoingRevisions(ps, getCancelSupport(null, true)); |
107 return getComparator(new ProgressSupport.Sub(ps, 5), getCancelSupport(null, true)).getLocalOnlyRevisions(); | |
108 } catch (HgRuntimeException ex) { | 109 } catch (HgRuntimeException ex) { |
109 throw new HgLibraryFailureException(ex); | 110 throw new HgLibraryFailureException(ex); |
110 } finally { | 111 } finally { |
111 ps.done(); | 112 ps.done(); |
112 } | 113 } |
126 throw new IllegalArgumentException("Delegate can't be null"); | 127 throw new IllegalArgumentException("Delegate can't be null"); |
127 } | 128 } |
128 final ProgressSupport ps = getProgressSupport(handler); | 129 final ProgressSupport ps = getProgressSupport(handler); |
129 final CancelSupport cs = getCancelSupport(handler, true); | 130 final CancelSupport cs = getCancelSupport(handler, true); |
130 try { | 131 try { |
131 ps.start(-1); | 132 ps.start(200); |
132 ChangesetTransformer inspector = new ChangesetTransformer(localRepo, handler, getParentHelper(), ps, cs); | 133 ChangesetTransformer inspector = new ChangesetTransformer(localRepo, handler, getParentHelper(), new ProgressSupport.Sub(ps, 100), cs); |
133 inspector.limitBranches(branches); | 134 inspector.limitBranches(branches); |
134 getComparator(new ProgressSupport.Sub(ps, 1), cs).visitLocalOnlyRevisions(inspector); | 135 List<Nodeid> out = getOutgoingRevisions(new ProgressSupport.Sub(ps, 100), cs); |
136 int[] outRevIndex = new int[out.size()]; | |
137 int i = 0; | |
138 for (Nodeid o : out) { | |
139 outRevIndex[i++] = localRepo.getChangelog().getRevisionIndex(o); | |
140 } | |
141 localRepo.getChangelog().range(inspector, outRevIndex); | |
135 inspector.checkFailure(); | 142 inspector.checkFailure(); |
136 } catch (HgRuntimeException ex) { | 143 } catch (HgRuntimeException ex) { |
137 throw new HgLibraryFailureException(ex); | 144 throw new HgLibraryFailureException(ex); |
138 } finally { | 145 } finally { |
139 ps.done(); | 146 ps.done(); |
157 parentHelper.init(); | 164 parentHelper.init(); |
158 } | 165 } |
159 return parentHelper; | 166 return parentHelper; |
160 } | 167 } |
161 | 168 |
169 | |
170 private List<Nodeid> getOutgoingRevisions(ProgressSupport ps, CancelSupport cs) throws HgRemoteConnectionException, HgException, CancelledException { | |
171 ps.start(10); | |
172 final RepositoryComparator c = getComparator(new ProgressSupport.Sub(ps, 5), cs); | |
173 List<Nodeid> local = c.getLocalOnlyRevisions(); | |
174 ps.worked(3); | |
175 PhasesHelper phaseHelper = new PhasesHelper(Internals.getInstance(localRepo)); | |
176 if (phaseHelper.isCapableOfPhases() && phaseHelper.withSecretRoots()) { | |
177 local = new RevisionSet(local).subtract(phaseHelper.allSecret()).asList(); | |
178 } | |
179 ps.worked(2); | |
180 return local; | |
181 } | |
162 } | 182 } |