##// END OF EJS Templates
phases: reduce code duplication in phasecache.getrevset...
Rodrigo Damazio Bovendorp -
r44521:8eb3c523 default
parent child Browse files
Show More
@@ -243,49 +243,46 b' class phasecache(object):'
243 243 """return a smartset for the given phases"""
244 244 self.loadphaserevs(repo) # ensure phase's sets are loaded
245 245 phases = set(phases)
246 publicphase = public in phases
246 247
247 if public not in phases:
248 # fast path: _phasesets contains the interesting sets,
249 # might only need a union and post-filtering.
250 if len(phases) == 1:
251 [p] = phases
252 revs = self._phasesets[p]
253 else:
254 revs = set.union(*[self._phasesets[p] for p in phases])
248 if publicphase:
249 # In this case, phases keeps all the *other* phases.
250 phases = set(allphases).difference(phases)
251 if not phases:
252 return smartset.fullreposet(repo)
253
254 # fast path: _phasesets contains the interesting sets,
255 # might only need a union and post-filtering.
256 if len(phases) == 1:
257 [p] = phases
258 revs = self._phasesets[p]
259 else:
260 # revs has the revisions in all *other* phases.
261 revs = set.union(*[self._phasesets[p] for p in phases])
262
263 def _addwdir(wdirsubset, wdirrevs):
264 if wdirrev in wdirsubset and repo[None].phase() in phases:
265 # The working dir would never be in the # cache, but it was in
266 # the subset being filtered for its phase (or filtered out,
267 # depending on publicphase), so add it to the output to be
268 # included (or filtered out).
269 wdirrevs.add(wdirrev)
270 return wdirrevs
271
272 if not publicphase:
255 273 if repo.changelog.filteredrevs:
256 274 revs = revs - repo.changelog.filteredrevs
257 275
258 276 if subset is None:
259 277 return smartset.baseset(revs)
260 278 else:
261 if wdirrev in subset and repo[None].phase() in phases:
262 # The working dir would never be in the cache, but it was
263 # in the subset being filtered for its phase, so add it to
264 # the output.
265 revs.add(wdirrev)
266
279 revs = _addwdir(subset, revs)
267 280 return subset & smartset.baseset(revs)
268 281 else:
269 # phases keeps all the *other* phases.
270 phases = set(allphases).difference(phases)
271 if not phases:
272 return smartset.fullreposet(repo)
273
274 # revs has the revisions in all *other* phases.
275 if len(phases) == 1:
276 [p] = phases
277 revs = self._phasesets[p]
278 else:
279 revs = set.union(*[self._phasesets[p] for p in phases])
280
281 282 if subset is None:
282 283 subset = smartset.fullreposet(repo)
283 284
284 if wdirrev in subset and repo[None].phase() in phases:
285 # The working dir is in the subset being filtered, and its
286 # phase is in the phases *not* being returned, so add it to the
287 # set of revisions to filter out.
288 revs.add(wdirrev)
285 revs = _addwdir(subset, revs)
289 286
290 287 if not revs:
291 288 return subset
General Comments 0
You need to be logged in to leave comments. Login now