Patchwork [3,of,4,evolve-ext] evolve: use registrar.revsetpredicate to register revset predicate functions

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Sept. 14, 2017, 4:33 p.m.
Message ID <dea894973e8faddafe06.1505406794@speaknoevil>
Download mbox | patch
Permalink /patch/23890/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Sept. 14, 2017, 4:33 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1505041612 -32400
#      Sun Sep 10 20:06:52 2017 +0900
# Node ID dea894973e8faddafe06cc53fbfe6a4f109c3143
# Parent  c89a40ef1e93c733a8ecd2a88efd83c72e5c6ac9
# Available At https://foozy@bitbucket.org/foozy/hgext-evolve
#              hg pull https://foozy@bitbucket.org/foozy/hgext-evolve -r dea894973e8f
# EXP-Topic doc-improvement
evolve: use registrar.revsetpredicate to register revset predicate functions

Now, using registrar.revsetpredicate of Mercurial directly in evolve
extension should be safe enough. because it has been available since
Mercurial 3.8, and minimum Mercurial version for evolve extension is
3.8, too.

Patch

diff --git a/hgext3rd/evolve/__init__.py b/hgext3rd/evolve/__init__.py
--- a/hgext3rd/evolve/__init__.py
+++ b/hgext3rd/evolve/__init__.py
@@ -482,10 +482,9 @@  def _installalias(ui):
 
 ### Troubled revset symbol
 
-@eh.revset('troubled')
+@eh.revset('troubled()')
 def revsettroubled(repo, subset, x):
-    """``troubled()``
-    Changesets with troubles.
+    """Changesets with troubles.
     """
     revset.getargs(x, 0, 0, 'troubled takes no arguments')
     troubled = set()
@@ -589,10 +588,9 @@  def _allsuccessors(repo, s, haltonflags=
 
 
 ### XXX I'm not sure this revset is useful
-@eh.revset('suspended')
+@eh.revset('suspended()')
 def revsetsuspended(repo, subset, x):
-    """``suspended()``
-    Obsolete changesets with non-obsolete descendants.
+    """Obsolete changesets with non-obsolete descendants.
     """
     revset.getargs(x, 0, 0, 'suspended takes no arguments')
     suspended = revset.baseset(getrevs(repo, 'suspended'))
@@ -600,10 +598,9 @@  def revsetsuspended(repo, subset, x):
     return subset & suspended
 
 
-@eh.revset('precursors')
+@eh.revset('precursors(set)')
 def revsetprecursors(repo, subset, x):
-    """``precursors(set)``
-    Immediate precursors of changesets in set.
+    """Immediate precursors of changesets in set.
     """
     s = revset.getset(repo, revset.fullreposet(repo), x)
     s = revset.baseset(_precursors(repo, s))
@@ -611,10 +608,9 @@  def revsetprecursors(repo, subset, x):
     return subset & s
 
 
-@eh.revset('allprecursors')
+@eh.revset('allprecursors(set)')
 def revsetallprecursors(repo, subset, x):
-    """``allprecursors(set)``
-    Transitive precursors of changesets in set.
+    """Transitive precursors of changesets in set.
     """
     s = revset.getset(repo, revset.fullreposet(repo), x)
     s = revset.baseset(_allprecursors(repo, s))
@@ -622,20 +618,18 @@  def revsetallprecursors(repo, subset, x)
     return subset & s
 
 
-@eh.revset('successors')
+@eh.revset('successors(set)')
 def revsetsuccessors(repo, subset, x):
-    """``successors(set)``
-    Immediate successors of changesets in set.
+    """Immediate successors of changesets in set.
     """
     s = revset.getset(repo, revset.fullreposet(repo), x)
     s = revset.baseset(_successors(repo, s))
     s.sort()
     return subset & s
 
-@eh.revset('allsuccessors')
+@eh.revset('allsuccessors(set)')
 def revsetallsuccessors(repo, subset, x):
-    """``allsuccessors(set)``
-    Transitive successors of changesets in set.
+    """Transitive successors of changesets in set.
     """
     s = revset.getset(repo, revset.fullreposet(repo), x)
     s = revset.baseset(_allsuccessors(repo, s))
diff --git a/hgext3rd/evolve/exthelper.py b/hgext3rd/evolve/exthelper.py
--- a/hgext3rd/evolve/exthelper.py
+++ b/hgext3rd/evolve/exthelper.py
@@ -93,8 +93,12 @@  class exthelper(object):
         - Register revset functions
         """
         knownexts = {}
+
+        revsetpredicate = registrar.revsetpredicate()
         for name, symbol in self._revsetsymbols:
-            revset.symbols[name] = symbol
+            revsetpredicate(name)(symbol)
+        revset.loadpredicate(ui, 'evolve', revsetpredicate)
+
         for name, kw in self._templatekws:
             templatekw.keywords[name] = kw
         for ext, command, wrapper, opts in self._extcommandwrappers: