mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 09:17:30 +03:00
a42808982c
Summary: This diff is part of a series to cleanup fb-hgext and make it pass check-code. Test Plan: all tests pass Reviewers: #sourcecontrol, ttung Differential Revision: https://phabricator.fb.com/D2811926
33 lines
1019 B
Python
33 lines
1019 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
|