[PATCH 1 of 8] revset: better naming of variables containing the value of a single argument

Mads Kiilerich mads at kiilerich.com
Wed Oct 15 03:09:08 UTC 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1413338886 -7200
#      Wed Oct 15 04:08:06 2014 +0200
# Node ID 6475983d4ed263172d1b54b1bc487fc857e4f7fb
# Parent  48c0b101a9de1fdbd638daa858da845cd05a6be7
revset: better naming of variables containing the value of a single argument

Calling them args is not helpful.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -343,10 +343,10 @@ def ancestor(repo, subset, x):
     return baseset()
 
 def _ancestors(repo, subset, x, followfirst=False):
-    args = getset(repo, spanset(repo), x)
-    if not args:
+    heads = getset(repo, spanset(repo), x)
+    if not heads:
         return baseset()
-    s = _revancestors(repo, args, followfirst)
+    s = _revancestors(repo, heads, followfirst)
     return subset.filter(s.__contains__)
 
 def ancestors(repo, subset, x):
@@ -656,14 +656,14 @@ def desc(repo, subset, x):
     return subset.filter(matches)
 
 def _descendants(repo, subset, x, followfirst=False):
-    args = getset(repo, spanset(repo), x)
-    if not args:
+    roots = getset(repo, spanset(repo), x)
+    if not roots:
         return baseset()
-    s = _revdescendants(repo, args, followfirst)
+    s = _revdescendants(repo, roots, followfirst)
 
     # Both sets need to be ascending in order to lazily return the union
     # in the correct order.
-    base = subset & args
+    base = subset & roots
     desc = subset & s
     result = base + desc
     if subset.isascending():
@@ -692,15 +692,15 @@ def destination(repo, subset, x):
     is the same as passing all().
     """
     if x is not None:
-        args = getset(repo, spanset(repo), x)
+        sources = getset(repo, spanset(repo), x)
     else:
-        args = getall(repo, spanset(repo), x)
+        sources = getall(repo, spanset(repo), x)
 
     dests = set()
 
     # subset contains all of the possible destinations that can be returned, so
-    # iterate over them and see if their source(s) were provided in the args.
-    # Even if the immediate src of r is not in the args, src's source (or
+    # iterate over them and see if their source(s) were provided in the arg set.
+    # Even if the immediate src of r is not in the arg set, src's source (or
     # further back) may be.  Scanning back further than the immediate src allows
     # transitive transplants and rebases to yield the same results as transitive
     # grafts.
@@ -720,7 +720,7 @@ def destination(repo, subset, x):
             # different iteration over subset.  Likewise, if the src was already
             # selected, the current lineage can be selected without going back
             # further.
-            if src in args or src in dests:
+            if src in sources or src in dests:
                 dests.update(lineage)
                 break
 
@@ -1151,9 +1151,9 @@ def origin(repo, subset, x):
     for the first operation is selected.
     """
     if x is not None:
-        args = getset(repo, spanset(repo), x)
+        dests = getset(repo, spanset(repo), x)
     else:
-        args = getall(repo, spanset(repo), x)
+        dests = getall(repo, spanset(repo), x)
 
     def _firstsrc(rev):
         src = _getrevsource(repo, rev)
@@ -1167,7 +1167,7 @@ def origin(repo, subset, x):
                 return src
             src = prev
 
-    o = set([_firstsrc(r) for r in args])
+    o = set([_firstsrc(r) for r in dests])
     o -= set([None])
     return subset & o
 



More information about the Mercurial-devel mailing list