Show More
@@ -0,0 +1,58 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | # Script to get stable diff output on any platform. | |||
|
4 | # | |||
|
5 | # Output of this script is almost equivalent to GNU diff with "-Nru". | |||
|
6 | # | |||
|
7 | # Use this script as "hg pdiff" via extdiff extension with preparation | |||
|
8 | # below in test scripts: | |||
|
9 | # | |||
|
10 | # $ cat >> $HGRCPATH <<EOF | |||
|
11 | # > [extdiff] | |||
|
12 | # > pdiff = sh "$RUNTESTDIR/pdiff" | |||
|
13 | # > EOF | |||
|
14 | ||||
|
15 | filediff(){ | |||
|
16 | # USAGE: filediff file1 file2 [header] | |||
|
17 | ||||
|
18 | # compare with /dev/null if file doesn't exist (as "-N" option) | |||
|
19 | file1="$1" | |||
|
20 | if test ! -f "$file1"; then | |||
|
21 | file1=/dev/null | |||
|
22 | fi | |||
|
23 | file2="$2" | |||
|
24 | if test ! -f "$file2"; then | |||
|
25 | file2=/dev/null | |||
|
26 | fi | |||
|
27 | ||||
|
28 | if cmp -s "$file1" "$file2"; then | |||
|
29 | # Return immediately, because comparison isn't needed. This | |||
|
30 | # also avoids redundant message of diff like "No differences | |||
|
31 | # encountered" (on Solaris) | |||
|
32 | return | |||
|
33 | fi | |||
|
34 | ||||
|
35 | if test -n "$3"; then | |||
|
36 | # show header only in recursive case | |||
|
37 | echo "$3" | |||
|
38 | fi | |||
|
39 | ||||
|
40 | # replace "/dev/null" by corresponded filename (as "-N" option) | |||
|
41 | diff -u "$file1" "$file2" | | |||
|
42 | sed "s@^--- /dev/null\(.*\)\$@--- $1\1@" | | |||
|
43 | sed "s@^\+\+\+ /dev/null\(.*\)\$@+++ $2\1@" | |||
|
44 | } | |||
|
45 | ||||
|
46 | if test -d "$1" -o -d "$2"; then | |||
|
47 | # ensure comparison in dictionary order | |||
|
48 | ( | |||
|
49 | if test -d "$1"; then (cd "$1" && find . -type f); fi | |||
|
50 | if test -d "$2"; then (cd "$2" && find . -type f); fi | |||
|
51 | ) | | |||
|
52 | sed 's@^\./@@g' | sort | uniq | | |||
|
53 | while read file; do | |||
|
54 | filediff "$1/$file" "$2/$file" "diff -Nru $1/$file $2/$file" | |||
|
55 | done | |||
|
56 | else | |||
|
57 | filediff "$1" "$2" | |||
|
58 | fi |
@@ -1,7 +1,7 b'' | |||||
1 | $ cat >> $HGRCPATH <<EOF |
|
1 | $ cat >> $HGRCPATH <<EOF | |
2 | > [defaults] |
|
2 | > [extdiff] | |
3 | > # for portability |
|
3 | > # for portability: | |
4 | > extdiff = --option -Nru |
|
4 | > pdiff = sh "$RUNTESTDIR/pdiff" | |
5 | > EOF |
|
5 | > EOF | |
6 |
|
6 | |||
7 | Create a repo with some stuff in it: |
|
7 | Create a repo with some stuff in it: | |
@@ -348,7 +348,7 b' Disallow grafting an already grafted cse' | |||||
348 | skipping already grafted revision 7:ef0ef43d49e7 (was grafted from 2:5c095ad7e90f) |
|
348 | skipping already grafted revision 7:ef0ef43d49e7 (was grafted from 2:5c095ad7e90f) | |
349 | [255] |
|
349 | [255] | |
350 |
|
350 | |||
351 |
$ hg |
|
351 | $ hg pdiff --config extensions.extdiff= --patch -r 2 -r 13 | |
352 | --- */hg-5c095ad7e90f.patch * (glob) |
|
352 | --- */hg-5c095ad7e90f.patch * (glob) | |
353 | +++ */hg-7a4785234d87.patch * (glob) |
|
353 | +++ */hg-7a4785234d87.patch * (glob) | |
354 | @@ -1,18 +1,18 @@ |
|
354 | @@ -1,18 +1,18 @@ | |
@@ -379,7 +379,7 b' Disallow grafting an already grafted cse' | |||||
379 | ++a |
|
379 | ++a | |
380 | [1] |
|
380 | [1] | |
381 |
|
381 | |||
382 |
$ hg |
|
382 | $ hg pdiff --config extensions.extdiff= --patch -r 2 -r 13 -X . | |
383 | --- */hg-5c095ad7e90f.patch * (glob) |
|
383 | --- */hg-5c095ad7e90f.patch * (glob) | |
384 | +++ */hg-7a4785234d87.patch * (glob) |
|
384 | +++ */hg-7a4785234d87.patch * (glob) | |
385 | @@ -1,8 +1,8 @@ |
|
385 | @@ -1,8 +1,8 @@ |
@@ -6,9 +6,9 b' directory (and ".hg/largefiles/dirstate"' | |||||
6 | > merge = internal:fail |
|
6 | > merge = internal:fail | |
7 | > [extensions] |
|
7 | > [extensions] | |
8 | > largefiles = |
|
8 | > largefiles = | |
9 | > [defaults] |
|
9 | > [extdiff] | |
10 | > # for portability |
|
10 | > # for portability: | |
11 | > extdiff = --option -Nru |
|
11 | > pdiff = sh "$RUNTESTDIR/pdiff" | |
12 | > EOF |
|
12 | > EOF | |
13 |
|
13 | |||
14 | $ hg init repo |
|
14 | $ hg init repo | |
@@ -23,7 +23,7 b' directory (and ".hg/largefiles/dirstate"' | |||||
23 | $ echo 'large1 in #1' > large1 |
|
23 | $ echo 'large1 in #1' > large1 | |
24 | $ echo 'normal1 in #1' > normal1 |
|
24 | $ echo 'normal1 in #1' > normal1 | |
25 | $ hg commit -m '#1' |
|
25 | $ hg commit -m '#1' | |
26 |
$ hg |
|
26 | $ hg pdiff -r '.^' --config extensions.extdiff= | |
27 | diff -Nru repo.0d9d9b8dc9a3/.hglf/large1 repo/.hglf/large1 |
|
27 | diff -Nru repo.0d9d9b8dc9a3/.hglf/large1 repo/.hglf/large1 | |
28 | --- repo.0d9d9b8dc9a3/.hglf/large1 * (glob) |
|
28 | --- repo.0d9d9b8dc9a3/.hglf/large1 * (glob) | |
29 | +++ repo/.hglf/large1 * (glob) |
|
29 | +++ repo/.hglf/large1 * (glob) |
@@ -1,7 +1,7 b'' | |||||
1 | $ cat >> $HGRCPATH <<EOF |
|
1 | $ cat >> $HGRCPATH <<EOF | |
2 | > [defaults] |
|
2 | > [extdiff] | |
3 | > # for portability |
|
3 | > # for portability: | |
4 | > extdiff = --option -Nru |
|
4 | > pdiff = sh "$RUNTESTDIR/pdiff" | |
5 | > EOF |
|
5 | > EOF | |
6 |
|
6 | |||
7 | Preparing the subrepository 'sub2' |
|
7 | Preparing the subrepository 'sub2' | |
@@ -717,9 +717,9 b' Restore the trashed subrepo tracking' | |||||
717 |
|
717 | |||
718 | Interaction with extdiff, largefiles and subrepos |
|
718 | Interaction with extdiff, largefiles and subrepos | |
719 |
|
719 | |||
720 |
$ hg --config extensions.extdiff= |
|
720 | $ hg --config extensions.extdiff= pdiff -S | |
721 |
|
721 | |||
722 |
$ hg --config extensions.extdiff= |
|
722 | $ hg --config extensions.extdiff= pdiff -r '.^' -S | |
723 | diff -Nru cloned.*/.hgsub cloned/.hgsub (glob) |
|
723 | diff -Nru cloned.*/.hgsub cloned/.hgsub (glob) | |
724 | --- cloned.*/.hgsub * (glob) |
|
724 | --- cloned.*/.hgsub * (glob) | |
725 | +++ cloned/.hgsub * (glob) |
|
725 | +++ cloned/.hgsub * (glob) | |
@@ -734,7 +734,7 b' Interaction with extdiff, largefiles and' | |||||
734 | -b1a26de6f2a045a9f079323693614ee322f1ff7e sub3 |
|
734 | -b1a26de6f2a045a9f079323693614ee322f1ff7e sub3 | |
735 | [1] |
|
735 | [1] | |
736 |
|
736 | |||
737 |
$ hg --config extensions.extdiff= |
|
737 | $ hg --config extensions.extdiff= pdiff -r 0 -r '.^' -S | |
738 | diff -Nru cloned.*/.hglf/b.dat cloned.*/.hglf/b.dat (glob) |
|
738 | diff -Nru cloned.*/.hglf/b.dat cloned.*/.hglf/b.dat (glob) | |
739 | --- cloned.*/.hglf/b.dat * (glob) |
|
739 | --- cloned.*/.hglf/b.dat * (glob) | |
740 | +++ cloned.*/.hglf/b.dat * (glob) |
|
740 | +++ cloned.*/.hglf/b.dat * (glob) | |
@@ -799,7 +799,7 b' Interaction with extdiff, largefiles and' | |||||
799 | [1] |
|
799 | [1] | |
800 |
|
800 | |||
801 | $ echo mod > sub1/sub2/sub2 |
|
801 | $ echo mod > sub1/sub2/sub2 | |
802 |
$ hg --config extensions.extdiff= |
|
802 | $ hg --config extensions.extdiff= pdiff -S | |
803 | --- */cloned.*/sub1/sub2/sub2 * (glob) |
|
803 | --- */cloned.*/sub1/sub2/sub2 * (glob) | |
804 | +++ */cloned/sub1/sub2/sub2 * (glob) |
|
804 | +++ */cloned/sub1/sub2/sub2 * (glob) | |
805 | @@ -1* +1* @@ (glob) |
|
805 | @@ -1* +1* @@ (glob) |
General Comments 0
You need to be logged in to leave comments.
Login now