Patchwork [5,of,5] revset: work around x:y range where x or y is wdir()

login
register
mail settings
Submitter Yuya Nishihara
Date July 9, 2015, 2:42 p.m.
Message ID <af8d14c0b573e640efde.1436452973@mimosa>
Download mbox | patch
Permalink /patch/9936/
State Accepted
Headers show

Comments

Yuya Nishihara - July 9, 2015, 2:42 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1435475287 -32400
#      Sun Jun 28 16:08:07 2015 +0900
# Node ID af8d14c0b573e640efde93e516cbfb5521cd1730
# Parent  152dec0b10b0e6505866b94a389db40f96fc7d16
revset: work around x:y range where x or y is wdir()

All revisions must be contiguous in spanset, so we need the special case
for the wdir revision.
Matt Mackall - July 10, 2015, 7:08 p.m.
On Thu, 2015-07-09 at 23:42 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1435475287 -32400
> #      Sun Jun 28 16:08:07 2015 +0900
> # Node ID af8d14c0b573e640efde93e516cbfb5521cd1730
> # Parent  152dec0b10b0e6505866b94a389db40f96fc7d16
> revset: work around x:y range where x or y is wdir()

These are queued for default, thanks.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -362,7 +362,13 @@  def rangeset(repo, subset, x, y):
         return baseset()
     m, n = m.first(), n.last()
 
-    if m < n:
+    if m == n:
+        r = baseset([m])
+    elif n == node.wdirrev:
+        r = spanset(repo, m, len(repo)) + baseset([n])
+    elif m == node.wdirrev:
+        r = baseset([m]) + spanset(repo, len(repo) - 1, n - 1)
+    elif m < n:
         r = spanset(repo, m, n + 1)
     else:
         r = spanset(repo, m, n - 1)
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -726,6 +726,16 @@  Test working-directory revision
   9
   2147483647
   $ hg debugrevspec '0:tip and wdir()'
+  $ log '0:wdir()' | tail -3
+  8
+  9
+  2147483647
+  $ log 'wdir():0' | head -3
+  2147483647
+  9
+  8
+  $ log 'wdir():wdir()'
+  2147483647
   $ log '(all() + wdir()) & min(. + wdir())'
   9
   $ log '(all() + wdir()) & max(. + wdir())'