sapling/phabdiff.py
Mateusz Kwapich 47cc0ea0b8 phabdiff: improve the {tasks} template
Summary:
There were some comments under my diff after landing. Included:

 * Old "Task ID" syntax
 * Removing the "T" prefix
 * Fixing the copypasted docstring

Test Plan: tests

Reviewers: #sourcecontrol, rmcelroy, ttung

Reviewed By: rmcelroy

Differential Revision: https://phabricator.fb.com/D2765417

Signature: t1:2765417:1450294877:4a50ecfdb1fb295ffaf01ecee6fe257b52e359bc
2015-12-16 15:53:53 -08:00

32 lines
996 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 templatekw
import re
def showphabdiff(repo, ctx, templ, **args):
""":phabdiff: String. Return the phabricator diff id for a given hg rev."""
descr = ctx.description()
match = re.search('Differential Revision: https://phabricator.fb.com/(D\d+)', descr)
return match.group(1) if match else ''
def showtasks(**args):
""":tasks: String. Return the tasks associated with given hg rev."""
descr = args['ctx'].description()
match = re.search('(Tasks|Task ID): (\d+)(,\s*\d+)*', descr)
tasks = []
if match:
tasksline = match.group(0)
tasks = re.findall("\d+", tasksline)
return templatekw.showlist('task', tasks, **args)
def extsetup(ui):
templatekw.keywords['phabdiff'] = showphabdiff
templatekw.keywords['tasks'] = showtasks