Patchwork [4,of,4] revrange: build spanset from x:y range

login
register
mail settings
Submitter Yuya Nishihara
Date June 1, 2015, 3:21 p.m.
Message ID <1ef9e73a53e0de38faf6.1433172067@mimosa>
Download mbox | patch
Permalink /patch/9423/
State Accepted
Headers show

Comments

Yuya Nishihara - June 1, 2015, 3:21 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1432459827 -32400
#      Sun May 24 18:30:27 2015 +0900
# Node ID 1ef9e73a53e0de38faf654fbe204812df4f194b0
# Parent  61d50109a9e85bcd4e23954f2eebe6d513aa04e3
revrange: build spanset from x:y range

This slightly improves the performance in the optimal case:

% hg log -R mozilla-central -r0:tip -l1 --time
(before)
time: real 0.050 secs (user 0.040+0.000 sys 0.010+0.000)
(after)
time: real 0.020 secs (user 0.000+0.000 sys 0.010+0.000)
Pierre-Yves David - June 1, 2015, 5:49 p.m.
On 06/01/2015 08:21 AM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1432459827 -32400
> #      Sun May 24 18:30:27 2015 +0900
> # Node ID 1ef9e73a53e0de38faf654fbe204812df4f194b0
> # Parent  61d50109a9e85bcd4e23954f2eebe6d513aa04e3
> revrange: build spanset from x:y range

These are pushed to the clowncopter. Nice cleanup.

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -737,8 +737,10 @@  def revrange(repo, revs):
                 end = revfix(repo, end, len(repo) - 1)
                 if end == nullrev and start < 0:
                     start = nullrev
-                rangeiter = repo.changelog.revs(start, end)
-                l = revset.baseset(rangeiter)
+                if start < end:
+                    l = revset.spanset(repo, start, end + 1)
+                else:
+                    l = revset.spanset(repo, start, end - 1)
                 subsets.append(l)
                 continue
             elif spec and spec in repo: # single unquoted rev