mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 09:17:30 +03:00
63b7bb19c5
Summary: Many of the template keywords in our extensions were being registered incorrectly, causing their help output to be rendered incorrectly in the "hg help templates" output. The ones in smartlog.py were particularly bad, as most of them showed only their description, without displaying the name of the template. In smartlog.py only singlepublicsuccessor was being displayed correctly, because it's docstring explicitly included it's own name at the start. This fixes all of our extensions to consistently use the registrar.templatekeyword() decorator to register the keywords. This decorator automatically prefixes the help message with the keyword name. The mercurial/extensions.py code will explicitly check to see if an extension contains an "templatekeyword" attribute, and if so it will register any keywords contained in this registry after calling extsetup(). Test Plan: Added new unit tests to check the output of "hg help templates" for the affected keywords. Reviewers: #sourcecontrol, kulshrax, ikostia, rmcelroy Reviewed By: rmcelroy Subscribers: rmcelroy, net-systems-diffs@, yogeshwer, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D4427729 Signature: t1:4427729:1484831476:17b478a5e867dfc3f85402588c381bf8b1831107
30 lines
934 B
Python
30 lines
934 B
Python
# phabdiff.py
|
|
#
|
|
# Copyright 2013 Facebook, Inc.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
from mercurial import registrar, templatekw
|
|
from phabricator import diffprops
|
|
import re
|
|
|
|
templatekeyword = registrar.templatekeyword()
|
|
|
|
@templatekeyword('phabdiff')
|
|
def showphabdiff(repo, ctx, templ, **args):
|
|
"""String. Return the phabricator diff id for a given hg rev."""
|
|
descr = ctx.description()
|
|
revision = diffprops.parserevfromcommitmsg(descr)
|
|
return 'D' + revision if revision else ''
|
|
|
|
@templatekeyword('tasks')
|
|
def showtasks(**args):
|
|
"""String. Return the tasks associated with given hg rev."""
|
|
tasks = []
|
|
descr = args['ctx'].description()
|
|
match = re.search('(Tasks?|Task ID):(.*)', descr)
|
|
if match:
|
|
tasks = re.findall('\d+', match.group(0))
|
|
return templatekw.showlist('task', tasks, **args)
|