2014-10-17 04:43:58 +04:00
|
|
|
# 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
|
2016-04-27 19:50:13 +03:00
|
|
|
from phabricator import diffprops
|
2014-10-17 04:43:58 +04:00
|
|
|
import re
|
|
|
|
|
|
|
|
def showphabdiff(repo, ctx, templ, **args):
|
2015-12-17 02:53:53 +03:00
|
|
|
""":phabdiff: String. Return the phabricator diff id for a given hg rev."""
|
2014-10-17 04:43:58 +04:00
|
|
|
descr = ctx.description()
|
2016-04-27 19:50:13 +03:00
|
|
|
revision = diffprops.parserevfromcommitmsg(descr)
|
|
|
|
return 'D' + revision if revision else ''
|
2014-10-17 04:43:58 +04:00
|
|
|
|
2015-12-14 22:20:43 +03:00
|
|
|
def showtasks(**args):
|
2015-12-17 02:53:53 +03:00
|
|
|
""":tasks: String. Return the tasks associated with given hg rev."""
|
2015-12-14 22:20:43 +03:00
|
|
|
descr = args['ctx'].description()
|
2015-12-17 02:53:53 +03:00
|
|
|
match = re.search('(Tasks|Task ID): (\d+)(,\s*\d+)*', descr)
|
2015-12-14 22:20:43 +03:00
|
|
|
|
2015-12-17 02:53:53 +03:00
|
|
|
tasks = []
|
2015-12-14 22:20:43 +03:00
|
|
|
if match:
|
|
|
|
tasksline = match.group(0)
|
|
|
|
tasks = re.findall("\d+", tasksline)
|
2015-12-17 02:53:53 +03:00
|
|
|
return templatekw.showlist('task', tasks, **args)
|
2015-12-14 22:20:43 +03:00
|
|
|
|
2014-10-17 04:43:58 +04:00
|
|
|
def extsetup(ui):
|
|
|
|
templatekw.keywords['phabdiff'] = showphabdiff
|
2015-12-14 22:20:43 +03:00
|
|
|
templatekw.keywords['tasks'] = showtasks
|