# HG changeset patch # User Yuya Nishihara # Date 1420862198 -32400 # Node ID 310222feb9a8671d48a8df6b57300d0326176ba0 # Parent af73c05e735aecf8c863ceb57a31ae1bc8487412 revset: allow rev(-1) to indicate null revision (BC) This can simplify the conversion from numeric revision to string. Without it, we have to handle -1 specially because repo['-1'] != repo[-1]. The -1 revision is not officially documented, but this change makes sense assuming that "rev(%d)" exists for scripting or third-party tools. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -1545,7 +1545,7 @@ except (TypeError, ValueError): # i18n: "rev" is a keyword raise error.ParseError(_("rev expects a number")) - if l not in fullreposet(repo): + if l not in fullreposet(repo) and l != node.nullrev: return baseset() return subset & baseset([l]) diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -465,7 +465,9 @@ 9 Test explicit numeric revision + $ log 'rev(-2)' $ log 'rev(-1)' + -1 $ log 'rev(0)' 0 $ log 'rev(9)'