[PATCH 6 of 6 V2] tests: add alias to detect external diff invocation via extdiff

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue Feb 9 14:40:00 EST 2016


At Tue, 9 Feb 2016 23:44:33 +0900,
Yuya Nishihara wrote:
> 
> On Mon, 08 Feb 2016 18:39:22 +0900, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> > # Date 1454923758 -32400
> > #      Mon Feb 08 18:29:18 2016 +0900
> > # Node ID 8bfab6803b7ef9c4e26c5834c9d2deeccc4f074b
> > # Parent  2d91a08cbf07bcb0413f5de8cc880571d9522987
> > tests: add alias to detect external diff invocation via extdiff
> > 
> > As previous patch described, direct usage of external "diff" command
> > via extdiff extension isn't portable.
> > 
> > To detect unintentional external "diff" command invocation via extdiff
> > immediately, this patch adds HGRCPATH file an alias definition below,
> > which shadows original "hg extdiff".
> > 
> >     [alias]
> >     extdiff = !echo use tests/pdiff via extdiff extension for portability
> 
> Can't it be a check-code rule?
> I think "hg extdiff" with no -p/-o will catch most of errors.

If we add new check-code rule "hg( .+)* extdiff" or so, it should
ignore checking "test-extdiff.t", which tests "hg extdiff" itself.

To ignore it safely, is adding list "checks" a new entry like as below
reasonable ?

====================
diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -386,6 +386,7 @@ checks = [
     ('test script', r'(.*/)?test-[^.~]*$', '', testfilters, testpats),
     ('c', r'.*\.[ch]$', '', cfilters, cpats),
     ('unified test', r'.*\.t$', '', utestfilters, utestpats),
+    ('unified test, r'(?!test-extdiff\.t).*\.t$', utestfilters, extdiffats),
     ('layering violation repo in revlog', r'mercurial/revlog\.py', '',
      pyfilters, inrevlogpats),
     ('layering violation ui in util', r'mercurial/util\.py', '', pyfilters,
====================

BTW, in that case, usage of extdiff in "test-extension.t" should be
fully replaced by another one, too :-)


> The patch 5 looks good but I've not pushed yet as you might want to fold
> check-code rule into it.


----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list