sapling/tests/test-phabdiff.t
Adam Simpkins 675d0280a6 phabdiff: only match at the start of a line
Summary:
Only match the "Differential Revision" label at the start of a line.  We
have some diffs that include legitimate-looking Differential Revision label
strings inside parts of their test plan, which previously confused the phabdiff
output.

Test Plan: Included a unit test.

Reviewers: #sourcecontrol, quark, akushner

Reviewed By: akushner

Subscribers: net-systems-diffs@fb.com, yogeshwer, mjpieters

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

Signature: t1:4793483:1490756514:05b2c49d5d65e1a3eadd5eb78ed0b91ef3bea42c
2017-03-28 20:53:07 -07:00

51 lines
1.5 KiB
Perl

$ PYTHONPATH=$TESTDIR/..:$PYTHONPATH
$ echo "[extensions]" >> $HGRCPATH
$ echo "phabdiff=" >> $HGRCPATH
Setup repo
$ hg init repo
$ cd repo
Test phabdiff template mapping
$ echo a > a
$ hg commit -Aqm "Differential Revision: https://phabricator.fb.com/D1234
> Task ID: 2312"
$ hg log --template "{phabdiff}\n"
D1234
$ echo c > c
$ hg commit -Aqm "Differential Revision: http://phabricator.intern.facebook.com/D1245
> Task ID: 2312"
$ hg log -r . --template "{phabdiff}\n"
D1245
$ echo b > b
$ hg commit -Aqm "Differential Revision: https://phabricator.fb.com/D5678
> Tasks:32, 44 55"
$ hg log -r . --template "{phabdiff}: {tasks}\n"
D5678: 32 44 55
$ echo d > d
$ hg commit -Aqm "Differential Revision: http://phabricator.intern.facebook.com/D1245
> Task: t123456,456"
$ hg log -r . --template "{phabdiff}: {tasks}\n"
D1245: 123456 456
Only match the Differential Revision label at the start of a line
$ echo e > e
$ hg commit -Aqm "Test Commit
> Test Plan: tested on Differential Revision: http://phabricator.intern.facebook.com/D1000
> Differential Revision: http://phabricator.intern.facebook.com/D6789
> "
$ hg log -r . --template "{phabdiff}\n"
D6789
Make sure the template keywords are documented correctly
$ hg help templates | egrep 'phabdiff|tasks'
phabdiff String. Return the phabricator diff id for a given hg rev.
tasks String. Return the tasks associated with given hg rev.