Patchwork [2,of,4] revset: minor preparatory refactor in _orderedlist

login
register
mail settings
Submitter Boris Feld
Date Jan. 18, 2019, 3:53 p.m.
Message ID <35c9dec1849f6a41f87f.1547826797@localhost.localdomain>
Download mbox | patch
Permalink /patch/37876/
State Accepted
Headers show

Comments

Boris Feld - Jan. 18, 2019, 3:53 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1547818460 -3600
#      Fri Jan 18 14:34:20 2019 +0100
# Node ID 35c9dec1849f6a41f87fdc130798387376bb8345
# Parent  52d20e4fe2e3049eec58140fdcadb43528729b3d
# EXP-Topic intlist
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 35c9dec1849f
revset: minor preparatory refactor in _orderedlist

In order to enforce the new %ld behavior in the cases where _intlist
serialization is still used, we will have to update this function. We do first
some small changes that do not alter the semantic. They just introduce lookup
caching and some pre-computation.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2172,11 +2172,13 @@  def _orderedlist(repo, subset, x):
         except ValueError:
             revs = stringset(repo, subset, t, defineorder)
 
+        full = isinstance(subset, fullreposet)
+        nullrev = node.nullrev
+
         for r in revs:
             if r in seen:
                 continue
-            if (r in subset
-                or r == node.nullrev and isinstance(subset, fullreposet)):
+            if (r in subset or full and r == nullrev):
                 ls.append(r)
             seen.add(r)
     return baseset(ls)