comparison src/org/tmatesoft/hg/internal/PhasesHelper.java @ 648:690e71d29bf6

Introduced RevisionSet to ease update of phase roots on push
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 25 Jun 2013 20:48:37 +0200
parents c75297c17867
children e79cf9a8130b
comparison
equal deleted inserted replaced
647:c75297c17867 648:690e71d29bf6
129 } 129 }
130 } 130 }
131 } 131 }
132 } 132 }
133 return HgPhase.Public; 133 return HgPhase.Public;
134 134 }
135
136
137 /**
138 * @return all revisions with secret phase
139 */
140 public RevisionSet allSecret() {
141 return allOf(HgPhase.Secret);
142 }
143
144 public RevisionSet allDraft() {
145 return allOf(HgPhase.Draft).subtract(allOf(HgPhase.Secret));
146 }
147
148 /**
149 * For a given phase, collect all revisions with phase that is the same or more private (i.e. for Draft, returns Draft+Secret)
150 * The reason is not a nice API intention (which is awful, indeed), but an ease of implementation
151 */
152 private RevisionSet allOf(HgPhase phase) {
153 assert phase != HgPhase.Public;
154 if (!isCapableOfPhases()) {
155 return new RevisionSet(Collections.<Nodeid>emptyList());
156 }
157 final List<Nodeid> roots = getPhaseRoots(phase);
158 if (parentHelper != null) {
159 return new RevisionSet(roots).union(new RevisionSet(parentHelper.childrenOf(roots)));
160 } else {
161 RevisionSet rv = new RevisionSet(Collections.<Nodeid>emptyList());
162 for (RevisionDescendants rd : getPhaseDescendants(phase)) {
163 rv = rv.union(rd.asRevisionSet());
164 }
165 return rv;
166 }
135 } 167 }
136 168
137 private Boolean readRoots() throws HgRuntimeException { 169 private Boolean readRoots() throws HgRuntimeException {
138 File phaseroots = repo.getRepositoryFile(Phaseroots); 170 File phaseroots = repo.getRepositoryFile(Phaseroots);
139 BufferedReader br = null; 171 BufferedReader br = null;