D4315: dagutil: remove descendantset() and ancestorset()

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Fri Aug 17 21:30:53 UTC 2018


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  descendantset() is unused after the previous commit. And
  ancestorset() was only used by descendantset(), so it can be removed
  as well.
  
  .. api:: descendantset() and ancestorset() removed from dagutil
  
    Use a revset instead when operating on the changelog. Or use
    various functionality in the ancestor or dagop modules.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4315

AFFECTED FILES
  mercurial/dagutil.py

CHANGE DETAILS

diff --git a/mercurial/dagutil.py b/mercurial/dagutil.py
--- a/mercurial/dagutil.py
+++ b/mercurial/dagutil.py
@@ -36,18 +36,6 @@
         '''inverse DAG, where parents becomes children, etc.'''
         raise NotImplementedError
 
-    def ancestorset(self, starts, stops=None):
-        '''
-        set of all ancestors of starts (incl), but stop walk at stops (excl)
-        '''
-        raise NotImplementedError
-
-    def descendantset(self, starts, stops=None):
-        '''
-        set of all descendants of starts (incl), but stop walk at stops (excl)
-        '''
-        return self.inverse().ancestorset(starts, stops)
-
     def headsetofconnecteds(self, ixs):
         '''
         subset of connected list of ixs so that no node has a descendant in it
@@ -60,20 +48,6 @@
 class genericdag(basedag):
     '''generic implementations for DAGs'''
 
-    def ancestorset(self, starts, stops=None):
-        if stops:
-            stops = set(stops)
-        else:
-            stops = set()
-        seen = set()
-        pending = list(starts)
-        while pending:
-            n = pending.pop()
-            if n not in seen and n not in stops:
-                seen.add(n)
-                pending.extend(self.parents(n))
-        return seen
-
     def headsetofconnecteds(self, ixs):
         hds = set(ixs)
         if not hds:
@@ -128,26 +102,6 @@
             self._inverse = inverserevlogdag(self)
         return self._inverse
 
-    def ancestorset(self, starts, stops=None):
-        rlog = self._revlog
-        idx = rlog.index
-        if stops:
-            stops = set(stops)
-        else:
-            stops = set()
-        seen = set()
-        pending = list(starts)
-        while pending:
-            rev = pending.pop()
-            if rev not in seen and rev not in stops:
-                seen.add(rev)
-                revdata = idx[rev]
-                for i in [5, 6]:
-                    prev = revdata[i]
-                    if prev != nullrev:
-                        pending.append(prev)
-        return seen
-
     def headsetofconnecteds(self, ixs):
         if not ixs:
             return set()



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list