[PATCH 2 of 3] revrange: evaluate all revset specs at once

Yuya Nishihara yuya at tcha.org
Wed Aug 5 09:44:22 CDT 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1436067342 -32400
#      Sun Jul 05 12:35:42 2015 +0900
# Node ID 2c44502472ba2b8420a9d0f9339a0c5f96bdc692
# Parent  983e70e0f872ff4b273e485526670ccfc8c6738a
revrange: evaluate all revset specs at once

This provides an opportunity for revset to optimize given expressions. For
example, "-r0 -r1 -r2" can be optimized to "_list(0 1 2)".

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -720,14 +720,13 @@ def revpair(repo, revs):
 
 def revrange(repo, revs):
     """Yield revision as strings from a list of revision specifications."""
-    subsets = []
+    allspecs = []
     for spec in revs:
         if isinstance(spec, int):
             spec = revset.formatspec('rev(%d)', spec)
-        m = revset.match(repo.ui, spec, repo)
-        subsets.append(m(repo))
-
-    return revset._combinesets(subsets)
+        allspecs.append(spec)
+    m = revset.match(repo.ui, allspecs, repo)
+    return m(repo)
 
 def expandpats(pats):
     '''Expand bare globs when running on windows.


More information about the Mercurial-devel mailing list