[PATCH 2 of 4 evolve-ext] topic: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Thu Sep 14 12:33:13 EDT 2017
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1502115433 -32400
# Mon Aug 07 23:17:13 2017 +0900
# Node ID c89a40ef1e93c733a8ecd2a88efd83c72e5c6ac9
# Parent 36c09de6c9765c41393c92298b0455b9491b91dc
# Available At https://foozy@bitbucket.org/foozy/hgext-evolve
# hg pull https://foozy@bitbucket.org/foozy/hgext-evolve -r c89a40ef1e93
# EXP-Topic doc-improvement
topic: use registrar.revsetpredicate to register revset predicate functions
Now, using registrar.revsetpredicate of Mercurial directly in topic
extension should be safe enough. because it has been available since
Mercurial 3.8, and minimum Mercurial version for topic extension is
4.0.
This patch also removes modsetup() in topic/revset.py, because it is
useless.
BTW, this patch fixes an issue of "hg help revsets" output that custom
revset predicates are not displayed as same as others, because they
are not "inline literal" in reST syntax (``NAME``).
diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -186,7 +186,6 @@ def _nodemap(repo, node):
def uisetup(ui):
destination.modsetup(ui)
- topicrevset.modsetup(ui)
discovery.modsetup(ui)
topicmap.modsetup(ui)
setupimportexport(ui)
@@ -308,6 +307,9 @@ def reposetup(ui, repo):
'topics', 'topic', namemap=_namemap, nodemap=_nodemap,
listnames=lambda repo: repo.topics))
+# revset predicates are automatically registered at loading via this symbol
+revsetpredicate = topicrevset.revsetpredicate
+
@command('topics', [
('', 'clear', False, 'clear active topic if any'),
('r', 'rev', [], 'revset of existing revisions', _('REV')),
diff --git a/hgext3rd/topic/revset.py b/hgext3rd/topic/revset.py
--- a/hgext3rd/topic/revset.py
+++ b/hgext3rd/topic/revset.py
@@ -1,6 +1,7 @@
from __future__ import absolute_import
from mercurial import (
+ registrar,
revset,
util,
)
@@ -16,10 +17,11 @@ try:
except AttributeError:
mkmatcher = util.stringmatcher
+revsetpredicate = registrar.revsetpredicate()
+ at revsetpredicate('topic([topic])')
def topicset(repo, subset, x):
- """`topic([topic])`
- Specified topic or all changes with any topic specified.
+ """Specified topic or all changes with any topic specified.
If `topic` starts with `re:` the remainder of the name is treated
as a regular expression.
@@ -48,10 +50,9 @@ def topicset(repo, subset, x):
return matcher(topic)
return (subset & mutable).filter(matchtopic)
+ at revsetpredicate('ngtip([branch])')
def ngtipset(repo, subset, x):
- """`ngtip([branch])`
-
- The untopiced tip.
+ """The untopiced tip.
Name is horrible so that people change it.
"""
@@ -62,9 +63,9 @@ def ngtipset(repo, subset, x):
branch = repo['.'].branch()
return subset & revset.baseset(destination.ngtip(repo, branch))
+ at revsetpredicate('stack()')
def stackset(repo, subset, x):
- """`stack()`
- All relevant changes in the current topic,
+ """All relevant changes in the current topic,
This is roughly equivalent to 'topic(.) - obsolete' with a sorting moving
unstable changeset after there future parent (as if evolve where already
@@ -79,9 +80,3 @@ def stackset(repo, subset, x):
if not topic:
branch = repo[None].branch()
return revset.baseset(stack.stack(repo, branch=branch, topic=topic)[1:]) & subset
-
-
-def modsetup(ui):
- revset.symbols.update({'topic': topicset})
- revset.symbols.update({'ngtip': ngtipset})
- revset.symbols.update({'stack': stackset})
More information about the Mercurial-devel
mailing list