phabricator: sanity check Differential Revision from commit message
Previously, we trust Differential Revision in commit message blindly. This
patch adds sanity check so a host name change will be detected and the
commit message will be ignored.
Differential Revision: https://phab.mercurial-scm.org/D35
--- a/contrib/phabricator.py Tue Jul 18 08:14:10 2017 -0400
+++ b/contrib/phabricator.py Mon Jul 10 18:02:03 2017 -0700
@@ -138,7 +138,7 @@
_differentialrevisiontagre = re.compile('\AD([1-9][0-9]*)\Z')
_differentialrevisiondescre = re.compile(
- '^Differential Revision:.*D([1-9][0-9]*)$', re.M)
+ '^Differential Revision:\s*(.*)D([1-9][0-9]*)$', re.M)
def getoldnodedrevmap(repo, nodelist):
"""find previous nodes that has been sent to Phabricator
@@ -172,10 +172,14 @@
toconfirm[node] = (n, set(precnodes), int(m.group(1)))
continue
- # Check commit message
+ # Check commit message (make sure URL matches)
m = _differentialrevisiondescre.search(ctx.description())
if m:
- result[node] = (None, int(m.group(1)))
+ if m.group(1).rstrip('/') == url.rstrip('/'):
+ result[node] = (None, int(m.group(2)))
+ else:
+ unfi.ui.warn(_('%s: Differential Revision URL ignored - host '
+ 'does not match config\n') % ctx)
# Double check if tags are genuine by collecting all old nodes from
# Phabricator, and expect precursors overlap with it.