Patchwork [3,of,4,V2] revrange: evaluate all revset specs at once

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 7, 2015, 2:45 p.m.
Message ID <fd7a0e50142b8d933be1.1438958746@mimosa>
Download mbox | patch
Permalink /patch/10132/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 7, 2015, 2:45 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1436067342 -32400
#      Sun Jul 05 12:35:42 2015 +0900
# Node ID fd7a0e50142b8d933be19414ac55b57dbd5e4612
# Parent  0355c8788321b887e9e3e3b41149e801ac111e37
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)".

Patch

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.matchany(repo.ui, allspecs, repo)
+    return m(repo)
 
 def expandpats(pats):
     '''Expand bare globs when running on windows.