sapling/phabdiff.py
Mateusz Kwapich 4f207dd263 Added phabdiff template mapping
Summary:
The phabdiff template mapping returns the phabricator diff id for the commit
(based on commit message).

for example:
$ hg log -r master --template '{phabdiff}\n'
D1485506

Test Plan:  - unit tests addded

Reviewers: sid0, durham

Reviewed By: durham

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

Tasks: 5124920
2014-10-16 17:43:58 -07:00

20 lines
567 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):
"""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 extsetup(ui):
templatekw.keywords['phabdiff'] = showphabdiff