changeset 25765:5e1b0739611c

revset: use integer representation of wdir() in revset This is the simplest way to handle wdir() revision in revset. None didn't work well because revset heavily depends on integer operations such as min(), max(), sorted(), x:y, etc. One downside is that we cannot do "wctx.rev() in set" because wctx.rev() is still None. We could wrap the result set by wdirproxyset that translates None to wdirrev, but it seems overengineered at this point. result = getset(repo, subset, tree) if 'wdir' in funcsused(tree): result = wdirproxyset(result) Test cases need the '(all() + wdir()) &' hack because we have yet to fix the bootstrapping issue of null and wdir.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 16 Mar 2015 16:17:06 +0900
parents 22049b565d57
children d51dac68ec98
files mercurial/revset.py tests/test-glog.t tests/test-revset.t
diffstat 3 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Sat Aug 16 13:25:45 2014 +0900
+++ b/mercurial/revset.py	Mon Mar 16 16:17:06 2015 +0900
@@ -1481,7 +1481,7 @@
         up = ps.update
         parentrevs = cl.parentrevs
         for r in getset(repo, fullreposet(repo), x):
-            if r is None:
+            if r == node.wdirrev:
                 up(p.rev() for p in repo[r].parents())
             else:
                 up(parentrevs(r))
@@ -1986,8 +1986,8 @@
 def wdir(repo, subset, x):
     # i18n: "wdir" is a keyword
     getargs(x, 0, 0, _("wdir takes no arguments"))
-    if None in subset or isinstance(subset, fullreposet):
-        return baseset([None])
+    if node.wdirrev in subset or isinstance(subset, fullreposet):
+        return baseset([node.wdirrev])
     return baseset()
 
 # for internal use
--- a/tests/test-glog.t	Sat Aug 16 13:25:45 2014 +0900
+++ b/tests/test-glog.t	Mon Mar 16 16:17:06 2015 +0900
@@ -2392,4 +2392,12 @@
      summary:     add a
   
 
+working-directory revision
+
+  $ hg log -G -qr '. + wdir()'
+  o  2147483647:ffffffffffff
+  |
+  @  3:5918b8d165d1
+  |
+
   $ cd ..
--- a/tests/test-revset.t	Sat Aug 16 13:25:45 2014 +0900
+++ b/tests/test-revset.t	Mon Mar 16 16:17:06 2015 +0900
@@ -721,11 +721,19 @@
 
 Test working-directory revision
   $ hg debugrevspec 'wdir()'
-  None
+  2147483647
   $ hg debugrevspec 'tip or wdir()'
   9
-  None
+  2147483647
   $ hg debugrevspec '0:tip and wdir()'
+  $ log '(all() + wdir()) & min(. + wdir())'
+  9
+  $ log '(all() + wdir()) & max(. + wdir())'
+  2147483647
+  $ log '(all() + wdir()) & first(wdir() + .)'
+  2147483647
+  $ log '(all() + wdir()) & last(. + wdir())'
+  2147483647
 
   $ log 'outgoing()'
   8