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

Yuya Nishihara yuya at tcha.org
Thu Jul 9 09:42:53 CDT 2015


# HG changeset patch
# User Yuya Nishihara <yuya at 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.

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())'


More information about the Mercurial-devel mailing list