Patchwork D3713: revsets: define a none() revset

login
register
mail settings
Submitter phabricator
Date June 11, 2018, 6:37 p.m.
Message ID <differential-rev-PHID-DREV-ws3rpnvgxchtwhnasfkh-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32064/
State Superseded
Headers show

Comments

phabricator - June 11, 2018, 6:37 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This can be useful for default values in corp-wide configuration
  (e.g. for commits to hide, which defaults to none()), and perhaps in
  scripts. I named it none() rather than empty() to match all().

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3713

AFFECTED FILES
  mercurial/revset.py
  tests/test-revset2.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-revset2.t b/tests/test-revset2.t
--- a/tests/test-revset2.t
+++ b/tests/test-revset2.t
@@ -584,6 +584,9 @@ 
   hg: parse error: empty string is not a valid revision
   [255]
 
+test empty revset
+  $ hg log 'none()'
+
 we can use patterns when searching for tags
 
   $ log 'tag("1..*")'
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1346,6 +1346,14 @@ 
     result = baseset([rn])
     return result & subset
 
+@predicate('none()', safe=True)
+def none(repo, subset, x):
+    """No changesets.
+    """
+    # i18n: "none" is a keyword
+    getargs(x, 0, 0, _("none takes no arguments"))
+    return baseset()
+
 @predicate('obsolete()', safe=True)
 def obsolete(repo, subset, x):
     """Mutable changeset with a newer version."""