Patchwork [V3] check-code: add rule to detect usage of external diff via extdiff

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Feb. 10, 2016, 5:22 p.m.
Message ID <d4eda799aa2943c3e6ce.1455124945@feefifofum>
Download mbox | patch
Permalink /patch/13103/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Katsunori FUJIWARA - Feb. 10, 2016, 5:22 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1455124545 -32400
#      Thu Feb 11 02:15:45 2016 +0900
# Node ID d4eda799aa2943c3e6ce077a9b71ec20e93817be
# Parent  ff42887a888bdeaf5caedd7466ce8e2d9bdd12bd
check-code: add rule to detect usage of external diff via extdiff

This rule detects "hg extdiff" invocation without -p/--program and
-o/--option.

This patch specifies "-p diff" explicitly in test-extdiff.t to avoid
false positive matching.
Yuya Nishihara - Feb. 11, 2016, 6:36 a.m.
On Thu, 11 Feb 2016 02:22:25 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1455124545 -32400
> #      Thu Feb 11 02:15:45 2016 +0900
> # Node ID d4eda799aa2943c3e6ce077a9b71ec20e93817be
> # Parent  ff42887a888bdeaf5caedd7466ce8e2d9bdd12bd
> check-code: add rule to detect usage of external diff via extdiff

Pushed to the clowncopter, thanks.

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -186,6 +186,9 @@  utestpats = [
      "use '@@ -N,n +N* @@ (glob)' style chunk header for portability"),
     (r'^  @@ -[0-9]+ [+][0-9]+ @@',
      "use '@@ -N* +N* @@ (glob)' style chunk header for portability"),
+    (uprefix + r'hg( +-[^ ]+( +[^ ]+)?)* +extdiff'
+     r'( +(-[^ po-]+|--(?!program|option)[^ ]+|[^-][^ ]*))*$',
+     "use $RUNTESTDIR/pdiff via extdiff (or -o/-p for false-positives)"),
   ],
   # warnings
   [
diff --git a/tests/test-extdiff.t b/tests/test-extdiff.t
--- a/tests/test-extdiff.t
+++ b/tests/test-extdiff.t
@@ -72,7 +72,7 @@  Should diff cloned files directly:
 
 Specifying an empty revision should abort.
 
-  $ hg extdiff --patch --rev 'ancestor()' --rev 1
+  $ hg extdiff -p diff --patch --rev 'ancestor()' --rev 1
   abort: empty revision on one side of range
   [255]