[PATCH] templatekw: automatically maintain documentation
timeless at mozdev.org
timeless at mozdev.org
Thu Sep 24 18:18:58 UTC 2015
# HG changeset patch
# User timeless at mozdev.org
# Date 1443117498 14400
# Thu Sep 24 13:58:18 2015 -0400
# Node ID 6e37b8ec2b01d944ea1c116712d18f9471be085b
# Parent db4c192cb9b3744c42b85af45ea6c8015d271bcc
templatekw: automatically maintain documentation
without this, extension keywords do not appear in `hg help templates`
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -448,6 +448,30 @@
""":tags: List of strings. Any tags associated with the changeset."""
return shownames('tags', **args)
+def _showparents(**args):
+ """:parents: List of strings. The parents of the changeset in "rev:node"
+ format. If the changeset has only one "natural" parent (the predecessor
+ revision) nothing is shown."""
+ pass
+
+dockeywords = {
+ 'parents': _showparents,
+}
+
+class keywordsdict(dict):
+ def __init__(self, *args, **kwargs):
+ dict.__init__(self, *args, **kwargs)
+ self.update(*args, **kwargs)
+
+ def __setitem__(self, key, val):
+ dict.__setitem__(self, key, val)
+ self.update()
+
+ def update(self, *args, **kwargs):
+ super(keywordsdict, self).update(*args, **kwargs)
+ dockeywords.update(self)
+ del dockeywords['branches']
+
# keywords are callables like:
# fn(repo, ctx, templ, cache, revcache, **args)
# with:
@@ -456,7 +480,7 @@
# templ - the templater instance
# cache - a cache dictionary for the whole templater run
# revcache - a cache dictionary for the current revision
-keywords = {
+keywords = keywordsdict({
'activebookmark': showactivebookmark,
'author': showauthor,
'bisect': showbisect,
@@ -490,19 +514,7 @@
'rev': showrev,
'subrepos': showsubrepos,
'tags': showtags,
-}
-
-def _showparents(**args):
- """:parents: List of strings. The parents of the changeset in "rev:node"
- format. If the changeset has only one "natural" parent (the predecessor
- revision) nothing is shown."""
- pass
-
-dockeywords = {
- 'parents': _showparents,
-}
-dockeywords.update(keywords)
-del dockeywords['branches']
+})
# tell hggettext to extract docstrings from these functions:
i18nfunctions = dockeywords.values()
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -278,6 +278,8 @@
transplant command to transplant changesets from another branch
win32mbcs allow the use of MBCS paths with problematic encodings
zeroconf discover and advertise repositories on the local network
+ $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
+
Test short command list with verbose option
$ hg -v help shortlist
More information about the Mercurial-devel
mailing list