[PATCH 1 of 2] reachableroots: construct and sort baseset in revset module

Yuya Nishihara yuya at tcha.org
Fri Aug 28 02:51:48 UTC 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1440728064 -32400
#      Fri Aug 28 11:14:24 2015 +0900
# Node ID 054babf5b3a0f0f5a2bdaa95e0abd1469aa1f165
# Parent  cf3212174adb57b7699a77e20295e9c8d36d9aa2
reachableroots: construct and sort baseset in revset module

This can remove dependency from changelog to revset, which seems a bit awkward
for me.

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -18,7 +18,6 @@ from . import (
     encoding,
     error,
     revlog,
-    revset,
     util,
 )
 
@@ -186,10 +185,7 @@ class changelog(revlog.revlog):
         return self._nodecache
 
     def reachableroots(self, minroot, heads, roots, includepath=False):
-        rroots = self.index.reachableroots2(minroot, heads, roots, includepath)
-        rroots = revset.baseset(rroots)
-        rroots.sort()
-        return rroots
+        return self.index.reachableroots2(minroot, heads, roots, includepath)
 
     def headrevs(self):
         if self.filteredrevs:
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -92,7 +92,7 @@ def reachablerootspure(repo, minroot, ro
 
     If includepath is True, return (<roots>::<heads>)."""
     if not roots:
-        return baseset()
+        return []
     parentrevs = repo.changelog.parentrevs
     roots = set(roots)
     visit = list(heads)
@@ -123,8 +123,6 @@ def reachablerootspure(repo, minroot, ro
         for parent in seen[rev]:
             if parent in reachable:
                 reached(rev)
-    reachable = baseset(reachable)
-    reachable.sort()
     return reachable
 
 def reachableroots(repo, roots, heads, includepath=False):
@@ -139,9 +137,12 @@ def reachableroots(repo, roots, heads, i
     roots = list(roots)
     heads = list(heads)
     try:
-        return repo.changelog.reachableroots(minroot, heads, roots, includepath)
+        revs = repo.changelog.reachableroots(minroot, heads, roots, includepath)
     except AttributeError:
-        return reachablerootspure(repo, minroot, roots, heads, includepath)
+        revs = reachablerootspure(repo, minroot, roots, heads, includepath)
+    revs = baseset(revs)
+    revs.sort()
+    return revs
 
 elements = {
     # token-type: binding-strength, primary, prefix, infix, suffix
diff --git a/tests/test-parseindex.t b/tests/test-parseindex.t
--- a/tests/test-parseindex.t
+++ b/tests/test-parseindex.t
@@ -96,9 +96,9 @@ Test SEGV caused by bad revision passed 
   >         print inst
   > EOF
   good heads:
-  0: <baseset+ [0]>
-  1: <baseset+ [0]>
-  -1: <baseset+ []>
+  0: [0]
+  1: [0]
+  -1: []
   bad heads:
   2: head out of range
   10000: head out of range
@@ -106,14 +106,14 @@ Test SEGV caused by bad revision passed 
   -10000: head out of range
   None: an integer is required
   good roots:
-  0: <baseset+ [0]>
-  1: <baseset+ [1]>
-  -1: <baseset+ [-1]>
+  0: [0]
+  1: [1]
+  -1: [-1]
   out-of-range roots are ignored:
-  2: <baseset+ []>
-  10000: <baseset+ []>
-  -2: <baseset+ []>
-  -10000: <baseset+ []>
+  2: []
+  10000: []
+  -2: []
+  -10000: []
   bad roots:
   None: an integer is required
 


More information about the Mercurial-devel mailing list