baseset: use default value instead of [] when possible
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 06 Oct 2014 10:41:43 -0700
changeset 22802 1fcd361efaf4
parent 22801 6af9e9b6af39
child 22803 31a591c3fecc
baseset: use default value instead of [] when possible For pure cleanup purposes, we replace all the occurences of `baseset([])` with `baseset()`.
mercurial/revset.py
--- a/mercurial/revset.py	Sat Oct 04 06:17:18 2014 -0700
+++ b/mercurial/revset.py	Mon Oct 06 10:41:43 2014 -0700
@@ -76,7 +76,7 @@
     """Return all paths between roots and heads, inclusive of both endpoint
     sets."""
     if not roots:
-        return baseset([])
+        return baseset()
     parentrevs = repo.changelog.parentrevs
     visit = list(heads)
     reachable = set()
@@ -95,7 +95,7 @@
             if parent >= minroot and parent not in seen:
                 visit.append(parent)
     if not reachable:
-        return baseset([])
+        return baseset()
     for rev in sorted(seen):
         for parent in seen[rev]:
             if parent in reachable:
@@ -257,7 +257,7 @@
         return baseset([-1])
     if len(subset) == len(repo) or x in subset:
         return baseset([x])
-    return baseset([])
+    return baseset()
 
 def symbolset(repo, subset, x):
     if x in symbols:
@@ -270,7 +270,7 @@
     n = getset(repo, cl, y)
 
     if not m or not n:
-        return baseset([])
+        return baseset()
     m, n = m[0], n[-1]
 
     if m < n:
@@ -341,12 +341,12 @@
 
     if anc is not None and anc.rev() in subset:
         return baseset([anc.rev()])
-    return baseset([])
+    return baseset()
 
 def _ancestors(repo, subset, x, followfirst=False):
     args = getset(repo, spanset(repo), x)
     if not args:
-        return baseset([])
+        return baseset()
     s = _revancestors(repo, args, followfirst)
     return subset.filter(s.__contains__)
 
@@ -400,7 +400,7 @@
     include = getset(repo, spanset(repo), args[0]).set()
     if len(args) == 1:
         if len(include) == 0:
-            return baseset([])
+            return baseset()
 
         descendants = set(_revdescendants(repo, include, False))
         exclude = [rev for rev in cl.headrevs()
@@ -659,7 +659,7 @@
 def _descendants(repo, subset, x, followfirst=False):
     args = getset(repo, spanset(repo), x)
     if not args:
-        return baseset([])
+        return baseset()
     s = _revdescendants(repo, args, followfirst)
 
     # Both sets need to be ascending in order to lazily return the union
@@ -830,7 +830,7 @@
             # include the revision responsible for the most recent version
             s.add(cx.linkrev())
         else:
-            return baseset([])
+            return baseset()
     else:
         s = _revancestors(repo, baseset([c.rev()]), followfirst)
 
@@ -1015,7 +1015,7 @@
         raise error.ParseError(_("limit expects a number"))
     ss = subset.set()
     os = getset(repo, spanset(repo), l[0])
-    bs = baseset([])
+    bs = baseset()
     it = iter(os)
     for x in xrange(lim):
         try:
@@ -1043,7 +1043,7 @@
     ss = subset.set()
     os = getset(repo, spanset(repo), l[0])
     os.reverse()
-    bs = baseset([])
+    bs = baseset()
     it = iter(os)
     for x in xrange(lim):
         try:
@@ -1063,7 +1063,7 @@
         m = os.max()
         if m in subset:
             return baseset([m])
-    return baseset([])
+    return baseset()
 
 def merge(repo, subset, x):
     """``merge()``
@@ -1082,7 +1082,7 @@
     getargs(x, 0, 0, _("branchpoint takes no arguments"))
     cl = repo.changelog
     if not subset:
-        return baseset([])
+        return baseset()
     baserev = min(subset)
     parentscount = [0]*(len(repo) - baserev)
     for r in cl.revs(start=baserev + 1):
@@ -1100,7 +1100,7 @@
         m = os.min()
         if m in subset:
             return baseset([m])
-    return baseset([])
+    return baseset()
 
 def modifies(repo, subset, x):
     """``modifies(pattern)``
@@ -1200,7 +1200,7 @@
         p = repo[x].p1().rev()
         if p >= 0:
             return subset & baseset([p])
-        return baseset([])
+        return baseset()
 
     ps = set()
     cl = repo.changelog
@@ -1219,9 +1219,9 @@
             p = ps[1].rev()
             if p >= 0:
                 return subset & baseset([p])
-            return baseset([])
+            return baseset()
         except IndexError:
-            return baseset([])
+            return baseset()
 
     ps = set()
     cl = repo.changelog
@@ -1281,7 +1281,7 @@
     try:
         return getset(repo, subset, x)
     except error.RepoLookupError:
-        return baseset([])
+        return baseset()
 
 def public(repo, subset, x):
     """``public()``
@@ -1324,7 +1324,7 @@
         r = repo[n].rev()
         if r in subset:
             return baseset([r])
-    return baseset([])
+    return baseset()
 
 def removes(repo, subset, x):
     """``removes(pattern)``
@@ -1652,7 +1652,7 @@
 def _list(repo, subset, x):
     s = getstring(x, "internal error")
     if not s:
-        return baseset([])
+        return baseset()
     ls = [repo[r].rev() for r in s.split('\0')]
     s = subset.set()
     return baseset([r for r in ls if r in s])
@@ -1661,7 +1661,7 @@
 def _intlist(repo, subset, x):
     s = getstring(x, "internal error")
     if not s:
-        return baseset([])
+        return baseset()
     ls = [int(r) for r in s.split('\0')]
     s = subset.set()
     return baseset([r for r in ls if r in s])
@@ -1670,7 +1670,7 @@
 def _hexlist(repo, subset, x):
     s = getstring(x, "internal error")
     if not s:
-        return baseset([])
+        return baseset()
     cl = repo.changelog
     ls = [cl.rev(node.bin(r)) for r in s.split('\0')]
     s = subset.set()