[PATCH 1 of 3 V2] revset: cleanup of algorithm for `destination()` predicate

Hannes Oldenburg hannes.christian.oldenburg at gmail.com
Sun Sep 11 15:05:58 UTC 2016


# HG changeset patch
# User Hannes Oldenburg <hannes.christian.oldenburg at gmail.com>
# Date 1473454098 0
#      Fri Sep 09 20:48:18 2016 +0000
# Node ID aeb4ff2efd119ad5bab99f0c521ca52f71144309
# Parent  770128405002e895d94c92e449609ba33937ee11
revset: cleanup of algorithm for `destination()` predicate

For each iteration of the outer loop just before entering the inner loop
we initialize `lineage` to None.
Immediately after we enter the inner loop we check we reinitialize to an empty
list if `lineage` is None.
Since `lineage` is only used in the inner loop this is equivalent to immediately
initializing `lineage` to an empty list.

diff -r 770128405002 -r aeb4ff2efd11 mercurial/revset.py
--- a/mercurial/revset.py	Sun Aug 21 12:36:23 2016 +0900
+++ b/mercurial/revset.py	Fri Sep 09 20:48:18 2016 +0000
@@ -852,12 +852,9 @@
     # grafts.
     for r in subset:
         src = _getrevsource(repo, r)
-        lineage = None
+        lineage = list()
 
         while src is not None:
-            if lineage is None:
-                lineage = list()
-
             lineage.append(r)
 
             # The visited lineage is a match if the current source is in the arg


More information about the Mercurial-devel mailing list