# HG changeset patch # User Yuya Nishihara # Date 2015-03-16 07:17:06 # Node ID 5e1b0739611cd496a094986f9d7bf173735430f6 # Parent 22049b565d57a7d46fb359b0415a0ce2b3602264 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. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -1481,7 +1481,7 @@ def parents(repo, subset, x): 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 user(repo, subset, x): 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 diff --git a/tests/test-glog.t b/tests/test-glog.t --- a/tests/test-glog.t +++ b/tests/test-glog.t @@ -2392,4 +2392,12 @@ should not draw line down to null due to summary: add a +working-directory revision + + $ hg log -G -qr '. + wdir()' + o 2147483647:ffffffffffff + | + @ 3:5918b8d165d1 + | + $ cd .. diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -721,11 +721,19 @@ BROKEN: should be '-1' 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