tests: make chunk header of external diff glob-ed for portability
Before this patch, some tests using external "diff" command via
extdiff extension fail on Solaris, because system standard "diff" (=
/usr/bin/diff) on Solaris always formats chunk header in the style
below:
@@ -X.x +Y.y @@
even though "diff" on Linux sometimes omits ".x" and/or ".y" in it.
This patch makes chunk header of external diff glob-ed for portability
of tests, and adds check-code.py rules to detect such diff output in
tests.
This patch also changes "hg diff" output in test-subrepo-git to
simplify detection rules, even though it is certainly portable because
these lines are generated by "git" command.
This patch is a part of making tests using external "diff" portable,
and tests below aren't yet portable even after this patch.
test-largefiles-update.t
test-subrepo-deep-nested-change.t
--- a/contrib/check-code.py Mon Feb 08 18:29:17 2016 +0900
+++ b/contrib/check-code.py Mon Feb 08 18:29:17 2016 +0900
@@ -180,6 +180,12 @@
"don't use (external) diff with -p for portability"),
(r'^ [-+][-+][-+] .* [-+]0000 \(glob\)',
"glob timezone field in diff output for portability"),
+ (r'^ @@ -[0-9]+ [+][0-9]+,[0-9]+ @@',
+ "use '@@ -N* +N,n @@ (glob)' style chunk header for portability"),
+ (r'^ @@ -[0-9]+,[0-9]+ [+][0-9]+ @@',
+ "use '@@ -N,n +N* @@ (glob)' style chunk header for portability"),
+ (r'^ @@ -[0-9]+ [+][0-9]+ @@',
+ "use '@@ -N* +N* @@ (glob)' style chunk header for portability"),
],
# warnings
[
--- a/tests/test-largefiles-update.t Mon Feb 08 18:29:17 2016 +0900
+++ b/tests/test-largefiles-update.t Mon Feb 08 18:29:17 2016 +0900
@@ -27,13 +27,13 @@
diff -Nru repo.0d9d9b8dc9a3/.hglf/large1 repo/.hglf/large1
--- repo.0d9d9b8dc9a3/.hglf/large1 * (glob)
+++ repo/.hglf/large1 * (glob)
- @@ -1 +1 @@
+ @@ -1* +1* @@ (glob)
-4669e532d5b2c093a78eca010077e708a071bb64
+58e24f733a964da346e2407a2bee99d9001184f5
diff -Nru repo.0d9d9b8dc9a3/normal1 repo/normal1
--- repo.0d9d9b8dc9a3/normal1 * (glob)
+++ repo/normal1 * (glob)
- @@ -1 +1 @@
+ @@ -1* +1* @@ (glob)
-normal1
+normal1 in #1
[1]
--- a/tests/test-subrepo-deep-nested-change.t Mon Feb 08 18:29:17 2016 +0900
+++ b/tests/test-subrepo-deep-nested-change.t Mon Feb 08 18:29:17 2016 +0900
@@ -723,13 +723,13 @@
diff -Nru cloned.*/.hgsub cloned/.hgsub (glob)
--- cloned.*/.hgsub * (glob)
+++ cloned/.hgsub * (glob)
- @@ -1,2 +1 @@
+ @@ -1,2 +1* @@ (glob)
sub1 = ../sub1
-sub3 = sub3
diff -Nru cloned.*/.hgsubstate cloned/.hgsubstate (glob)
--- cloned.*/.hgsubstate * (glob)
+++ cloned/.hgsubstate * (glob)
- @@ -1,2 +1 @@
+ @@ -1,2 +1* @@ (glob)
7a36fa02b66e61f27f3d4a822809f159479b8ab2 sub1
-b1a26de6f2a045a9f079323693614ee322f1ff7e sub3
[1]
@@ -738,63 +738,63 @@
diff -Nru cloned.*/.hglf/b.dat cloned.*/.hglf/b.dat (glob)
--- cloned.*/.hglf/b.dat * (glob)
+++ cloned.*/.hglf/b.dat * (glob)
- @@ -0,0 +1 @@
+ @@ -0,0 +1* @@ (glob)
+da39a3ee5e6b4b0d3255bfef95601890afd80709
diff -Nru cloned.*/.hglf/foo/bar/large.dat cloned.*/.hglf/foo/bar/large.dat (glob)
--- cloned.*/.hglf/foo/bar/large.dat * (glob)
+++ cloned.*/.hglf/foo/bar/large.dat * (glob)
- @@ -0,0 +1 @@
+ @@ -0,0 +1* @@ (glob)
+2f6933b5ee0f5fdd823d9717d8729f3c2523811b
diff -Nru cloned.*/.hglf/large.bin cloned.*/.hglf/large.bin (glob)
--- cloned.*/.hglf/large.bin * (glob)
+++ cloned.*/.hglf/large.bin * (glob)
- @@ -0,0 +1 @@
+ @@ -0,0 +1* @@ (glob)
+7f7097b041ccf68cc5561e9600da4655d21c6d18
diff -Nru cloned.*/.hgsub cloned.*/.hgsub (glob)
--- cloned.*/.hgsub * (glob)
+++ cloned.*/.hgsub * (glob)
- @@ -1 +1,2 @@
+ @@ -1* +1,2 @@ (glob)
sub1 = ../sub1
+sub3 = sub3
diff -Nru cloned.*/.hgsubstate cloned.*/.hgsubstate (glob)
--- cloned.*/.hgsubstate * (glob)
+++ cloned.*/.hgsubstate * (glob)
- @@ -1 +1,2 @@
+ @@ -1* +1,2 @@ (glob)
-fc3b4ce2696f7741438c79207583768f2ce6b0dd sub1
+7a36fa02b66e61f27f3d4a822809f159479b8ab2 sub1
+b1a26de6f2a045a9f079323693614ee322f1ff7e sub3
diff -Nru cloned.*/foo/bar/def cloned.*/foo/bar/def (glob)
--- cloned.*/foo/bar/def * (glob)
+++ cloned.*/foo/bar/def * (glob)
- @@ -0,0 +1 @@
+ @@ -0,0 +1* @@ (glob)
+changed
diff -Nru cloned.*/main cloned.*/main (glob)
--- cloned.*/main * (glob)
+++ cloned.*/main * (glob)
- @@ -1 +1 @@
+ @@ -1* +1* @@ (glob)
-main
+foo
diff -Nru cloned.*/sub1/.hgsubstate cloned.*/sub1/.hgsubstate (glob)
--- cloned.*/sub1/.hgsubstate * (glob)
+++ cloned.*/sub1/.hgsubstate * (glob)
- @@ -1 +1 @@
+ @@ -1* +1* @@ (glob)
-c57a0840e3badd667ef3c3ef65471609acb2ba3c sub2
+c77908c81ccea3794a896c79e98b0e004aee2e9e sub2
diff -Nru cloned.*/sub1/sub2/folder/test.txt cloned.*/sub1/sub2/folder/test.txt (glob)
--- cloned.*/sub1/sub2/folder/test.txt * (glob)
+++ cloned.*/sub1/sub2/folder/test.txt * (glob)
- @@ -0,0 +1 @@
+ @@ -0,0 +1* @@ (glob)
+subfolder
diff -Nru cloned.*/sub1/sub2/sub2 cloned.*/sub1/sub2/sub2 (glob)
--- cloned.*/sub1/sub2/sub2 * (glob)
+++ cloned.*/sub1/sub2/sub2 * (glob)
- @@ -1 +1 @@
+ @@ -1* +1* @@ (glob)
-sub2
+modified
diff -Nru cloned.*/sub3/a.txt cloned.*/sub3/a.txt (glob)
--- cloned.*/sub3/a.txt * (glob)
+++ cloned.*/sub3/a.txt * (glob)
- @@ -0,0 +1 @@
+ @@ -0,0 +1* @@ (glob)
+xyz
[1]
@@ -802,7 +802,7 @@
$ hg --config extensions.extdiff= extdiff -S
--- */cloned.*/sub1/sub2/sub2 * (glob)
+++ */cloned/sub1/sub2/sub2 * (glob)
- @@ -1 +1 @@
+ @@ -1* +1* @@ (glob)
-modified
+mod
[1]
--- a/tests/test-subrepo-git.t Mon Feb 08 18:29:17 2016 +0900
+++ b/tests/test-subrepo-git.t Mon Feb 08 18:29:17 2016 +0900
@@ -785,7 +785,7 @@
index 0000000..257cc56
--- /dev/null
+++ b/s/barfoo
- @@ -0,0 +1 @@
+ @@ -0,0 +1* @@ (glob)
+foo
$ hg diff --subrepos s/foobar
diff --git a/s/foobar b/s/foobar
@@ -827,7 +827,7 @@
index 0000000..257cc56
--- /dev/null
+++ b/s/barfoo
- @@ -0,0 +1 @@
+ @@ -0,0 +1* @@ (glob)
+foo
moving a file should show a removal and an add