sapling/hgext3rd/phabdiff.py
Wez Furlong 9b5499d572 phabdiff: don't require a space when parsing the Tasks field
Summary: Allow for any number of spaces after the colon

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: markisaa

Differential Revision: https://phabricator.intern.facebook.com/D4179619

Tasks: 14532985
2016-11-15 12:28:21 -08:00

32 lines
999 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
from phabricator import diffprops
import re
def showphabdiff(repo, ctx, templ, **args):
""":phabdiff: String. Return the phabricator diff id for a given hg rev."""
descr = ctx.description()
revision = diffprops.parserevfromcommitmsg(descr)
return 'D' + revision if revision else ''
def showtasks(**args):
""":tasks: String. Return the tasks associated with given hg rev."""
descr = args['ctx'].description()
match = re.search('(Tasks|Task ID):\s*(\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