Patchwork [3,of,7] dagop: bulk rename variables in revancestors() generator

login
register
mail settings
Submitter Yuya Nishihara
Date June 22, 2017, 3:52 p.m.
Message ID <d6cdc30de037445140bf.1498146736@mimosa>
Download mbox | patch
Permalink /patch/21614/
State Accepted
Headers show

Comments

Yuya Nishihara - June 22, 2017, 3:52 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1497774177 -32400
#      Sun Jun 18 17:22:57 2017 +0900
# Node ID d6cdc30de037445140bf2e0f8c7f7a1d2b6bc7ac
# Parent  2288ecd79fca3e8ac9a6211b81410c8d78271add
dagop: bulk rename variables in revancestors() generator

 - h -> pendingheap: "h" seems too short for variable of long lifetime
 - current -> currev: future patches will add current "depth" variable
 - parent -> prev or pctx: short lifetime, follows common naming rules

Patch

diff --git a/mercurial/dagop.py b/mercurial/dagop.py
--- a/mercurial/dagop.py
+++ b/mercurial/dagop.py
@@ -31,30 +31,30 @@  def _genrevancestors(repo, revs, followf
     # without fully computing the input revs
     revs.sort(reverse=True)
     irevs = iter(revs)
-    h = []
+    pendingheap = []
 
     inputrev = next(irevs, None)
     if inputrev is not None:
-        heapq.heappush(h, -inputrev)
+        heapq.heappush(pendingheap, -inputrev)
 
     seen = set()
-    while h:
-        current = -heapq.heappop(h)
-        if current == inputrev:
+    while pendingheap:
+        currev = -heapq.heappop(pendingheap)
+        if currev == inputrev:
             inputrev = next(irevs, None)
             if inputrev is not None:
-                heapq.heappush(h, -inputrev)
-        if current not in seen:
-            seen.add(current)
-            yield current
+                heapq.heappush(pendingheap, -inputrev)
+        if currev not in seen:
+            seen.add(currev)
+            yield currev
             try:
-                for parent in cl.parentrevs(current)[:cut]:
-                    if parent != node.nullrev:
-                        heapq.heappush(h, -parent)
+                for prev in cl.parentrevs(currev)[:cut]:
+                    if prev != node.nullrev:
+                        heapq.heappush(pendingheap, -prev)
             except error.WdirUnsupported:
-                for parent in repo[current].parents()[:cut]:
-                    if parent.rev() != node.nullrev:
-                        heapq.heappush(h, -parent.rev())
+                for pctx in repo[currev].parents()[:cut]:
+                    if pctx.rev() != node.nullrev:
+                        heapq.heappush(pendingheap, -pctx.rev())
 
 def revancestors(repo, revs, followfirst):
     """Like revlog.ancestors(), but supports followfirst."""