comparison tests/test-extdiff.t @ 12304:41dd368b6fe8

tests: unify test-extdiff
author Adrian Buehlmann <adrian@cadifra.com>
date Wed, 15 Sep 2010 16:27:39 +0200
parents tests/test-extdiff@c52057614c72
children 4134686b83e1
comparison
equal deleted inserted replaced
12303:4ab87473029d 12304:41dd368b6fe8
1 $ echo "[extensions]" >> $HGRCPATH
2 $ echo "extdiff=" >> $HGRCPATH
3
4 $ hg init a
5 $ cd a
6 $ echo a > a
7 $ echo b > b
8 $ hg add
9 adding a
10 adding b
11
12 Should diff cloned directories:
13
14 $ hg extdiff -o -r $opt
15 Only in a: a
16 Only in a: b
17
18 $ echo "[extdiff]" >> $HGRCPATH
19 $ echo "cmd.falabala=echo" >> $HGRCPATH
20 $ echo "opts.falabala=diffing" >> $HGRCPATH
21
22 $ hg falabala
23 diffing a.000000000000 a
24
25 $ hg help falabala
26 hg falabala [OPTION]... [FILE]...
27
28 use 'echo' to diff repository (or selected files)
29
30 Show differences between revisions for the specified files, using the
31 'echo' program.
32
33 When two revision arguments are given, then changes are shown between
34 those revisions. If only one revision is specified then that revision is
35 compared to the working directory, and, when no revisions are specified,
36 the working directory files are compared to its parent.
37
38 options:
39
40 -o --option OPT [+] pass option to comparison program
41 -r --rev REV [+] revision
42 -c --change REV change made by revision
43 -I --include PATTERN [+] include names matching the given patterns
44 -X --exclude PATTERN [+] exclude names matching the given patterns
45
46 [+] marked option can be specified multiple times
47
48 use "hg -v help falabala" to show global options
49
50 $ hg ci -d '0 0' -mtest1
51
52 $ echo b >> a
53 $ hg ci -d '1 0' -mtest2
54
55 Should diff cloned files directly:
56
57 $ hg falabala -r 0:1
58 diffing a.8a5febb7f867/a a.34eed99112ab/a
59
60 Test diff during merge:
61
62 $ hg update -C 0
63 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
64 $ echo c >> c
65 $ hg add c
66 $ hg ci -m "new branch" -d '1 0'
67 created new head
68 $ hg merge 1
69 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
70 (branch merge, don't forget to commit)
71
72 Should diff cloned file against wc file:
73
74 $ hg falabala > out
75
76 Cleanup the output since the wc is a tmp directory:
77
78 $ sed 's:\(diffing [^ ]* \).*\(\/test-extdiff\):\1[tmp]\2:' out
79 diffing a.2a13a4d2da36/a [tmp]/test-extdiff.t/a/a
80
81 Test --change option:
82
83 $ hg ci -d '2 0' -mtest3
84 $ hg falabala -c 1
85 diffing a.8a5febb7f867/a a.34eed99112ab/a
86
87 Check diff are made from the first parent:
88
89 $ hg falabala -c 3 || echo "diff-like tools yield a non-zero exit code"
90 diffing a.2a13a4d2da36/a a.46c0e4daeb72/a
91 diff-like tools yield a non-zero exit code
92
93 Test extdiff of multiple files in tmp dir:
94
95 $ hg update -C 0 > /dev/null
96 $ echo changed > a
97 $ echo changed > b
98 $ chmod +x b
99
100 Diff in working directory, before:
101
102 $ hg diff --git
103 diff --git a/a b/a
104 --- a/a
105 +++ b/a
106 @@ -1,1 +1,1 @@
107 -a
108 +changed
109 diff --git a/b b/b
110 old mode 100644
111 new mode 100755
112 --- a/b
113 +++ b/b
114 @@ -1,1 +1,1 @@
115 -b
116 +changed
117
118
119 Edit with extdiff -p:
120
121 Prepare custom diff/edit tool:
122
123 $ cat > 'diff tool.py' << EOT
124 > #!/usr/bin/env python
125 > import time
126 > time.sleep(1) # avoid unchanged-timestamp problems
127 > file('a/a', 'ab').write('edited\n')
128 > file('a/b', 'ab').write('edited\n')
129 > EOT
130
131 $ chmod +x 'diff tool.py'
132
133 # will change to /tmp/extdiff.TMP and populate directories a.TMP and a
134 # and start tool
135 $ hg extdiff -p "`pwd`/diff tool.py"
136
137 Diff in working directory, after:
138
139 $ hg diff --git
140 diff --git a/a b/a
141 --- a/a
142 +++ b/a
143 @@ -1,1 +1,2 @@
144 -a
145 +changed
146 +edited
147 diff --git a/b b/b
148 old mode 100644
149 new mode 100755
150 --- a/b
151 +++ b/b
152 @@ -1,1 +1,2 @@
153 -b
154 +changed
155 +edited
156
157 Test extdiff with --option:
158
159 $ hg extdiff -p echo -o this -c 1
160 this a.8a5febb7f867/a a.34eed99112ab/a
161
162 $ hg falabala -o this -c 1
163 diffing this a.8a5febb7f867/a a.34eed99112ab/a
164
165 $ true
166