mercurial/phases.py
changeset 44064 8eb3c52337a6
parent 44004 9c1fd975e9ac
child 44065 ab41dad7345e
equal deleted inserted replaced
44063:089255b1341e 44064:8eb3c52337a6
   241 
   241 
   242     def getrevset(self, repo, phases, subset=None):
   242     def getrevset(self, repo, phases, subset=None):
   243         """return a smartset for the given phases"""
   243         """return a smartset for the given phases"""
   244         self.loadphaserevs(repo)  # ensure phase's sets are loaded
   244         self.loadphaserevs(repo)  # ensure phase's sets are loaded
   245         phases = set(phases)
   245         phases = set(phases)
   246 
   246         publicphase = public in phases
   247         if public not in phases:
   247 
   248             # fast path: _phasesets contains the interesting sets,
   248         if publicphase:
   249             # might only need a union and post-filtering.
   249             # In this case, phases keeps all the *other* phases.
   250             if len(phases) == 1:
   250             phases = set(allphases).difference(phases)
   251                 [p] = phases
   251             if not phases:
   252                 revs = self._phasesets[p]
   252                 return smartset.fullreposet(repo)
   253             else:
   253 
   254                 revs = set.union(*[self._phasesets[p] for p in phases])
   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             if repo.changelog.filteredrevs:
   273             if repo.changelog.filteredrevs:
   256                 revs = revs - repo.changelog.filteredrevs
   274                 revs = revs - repo.changelog.filteredrevs
   257 
   275 
   258             if subset is None:
   276             if subset is None:
   259                 return smartset.baseset(revs)
   277                 return smartset.baseset(revs)
   260             else:
   278             else:
   261                 if wdirrev in subset and repo[None].phase() in phases:
   279                 revs = _addwdir(subset, revs)
   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 
       
   267                 return subset & smartset.baseset(revs)
   280                 return subset & smartset.baseset(revs)
   268         else:
   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             if subset is None:
   282             if subset is None:
   282                 subset = smartset.fullreposet(repo)
   283                 subset = smartset.fullreposet(repo)
   283 
   284 
   284             if wdirrev in subset and repo[None].phase() in phases:
   285             revs = _addwdir(subset, revs)
   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)
       
   289 
   286 
   290             if not revs:
   287             if not revs:
   291                 return subset
   288                 return subset
   292             return subset.filter(lambda r: r not in revs)
   289             return subset.filter(lambda r: r not in revs)
   293 
   290