Debian Codegraph @

tests/test-diff-patches.t

raw
1 =============================================================
2 Testing comparing changeset regardless of change from parents
3 =============================================================
4
5 Setup
6 =====
7
8 Add a bunch of changes some related to each other some not.
9
10 $ hg init test-repo
11 $ cd test-repo
12 $ cat << EOF > file-a.txt
13 > one
14 > two
15 > three
16 > four
17 > five
18 > six
19 > seven
20 > eight
21 > nine
22 > ten
23 > EOF
24 $ hg add file-a.txt
25 $ hg commit -m 'commit_root'
26
27 $ sed s/two/deux/ file-a.txt > a
28 $ mv a file-a.txt
29 $ hg commit -m 'commit_A1_change'
30
31 $ sed s/five/cinq/ file-a.txt > a
32 $ mv a file-a.txt
33 $ hg commit -m 'commit_A2_change'
34
35 $ cat << EOF > file-b.txt
36 > egg
37 > salade
38 > orange
39 > EOF
40 $ hg add file-b.txt
41 $ hg commit -m 'commit_A3_change'
42
43 $ cat << EOF > file-b.txt
44 > butter
45 > egg
46 > salade
47 > orange
48 > EOF
49 $ hg commit -m 'commit_A4_change'
50
51 $ hg up 'desc("commit_root")'
52 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
53 $ sed s/two/deux/ file-a.txt > a
54 $ mv a file-a.txt
55 $ sed s/ten/dix/ file-a.txt > a
56 $ mv a file-a.txt
57 $ hg commit -m 'commit_B1_change'
58 created new head
59
60 $ sed s/five/funf/ file-a.txt > a
61 $ mv a file-a.txt
62 $ sed s/eight/acht/ file-a.txt > a
63 $ mv a file-a.txt
64 $ hg commit -m 'commit_B2_change'
65
66 $ cat << EOF > file-b.txt
67 > milk
68 > egg
69 > salade
70 > apple
71 > EOF
72 $ hg add file-b.txt
73 $ hg commit -m 'commit_B3_change'
74
75 $ cat << EOF > file-b.txt
76 > butter
77 > milk
78 > egg
79 > salade
80 > apple
81 > EOF
82 $ hg commit -m 'commit_B4_change'
83
84 $ hg log -G --patch
85 @ changeset: 8:0d6b02d59faf
86 | tag: tip
87 | user: test
88 | date: Thu Jan 01 00:00:00 1970 +0000
89 | summary: commit_B4_change
90 |
91 | diff -r 59c9679fd24c -r 0d6b02d59faf file-b.txt
92 | --- a/file-b.txt Thu Jan 01 00:00:00 1970 +0000
93 | +++ b/file-b.txt Thu Jan 01 00:00:00 1970 +0000
94 | @@ -1,3 +1,4 @@
95 | +butter
96 | milk
97 | egg
98 | salade
99 |
100 o changeset: 7:59c9679fd24c
101 | user: test
102 | date: Thu Jan 01 00:00:00 1970 +0000
103 | summary: commit_B3_change
104 |
105 | diff -r 1e73118ddc3a -r 59c9679fd24c file-b.txt
106 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000
107 | +++ b/file-b.txt Thu Jan 01 00:00:00 1970 +0000
108 | @@ -0,0 +1,4 @@
109 | +milk
110 | +egg
111 | +salade
112 | +apple
113 |
114 o changeset: 6:1e73118ddc3a
115 | user: test
116 | date: Thu Jan 01 00:00:00 1970 +0000
117 | summary: commit_B2_change
118 |
119 | diff -r 30a40f18d81e -r 1e73118ddc3a file-a.txt
120 | --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
121 | +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
122 | @@ -2,9 +2,9 @@
123 | deux
124 | three
125 | four
126 | -five
127 | +funf
128 | six
129 | seven
130 | -eight
131 | +acht
132 | nine
133 | dix
134 |
135 o changeset: 5:30a40f18d81e
136 | parent: 0:9c17110ca844
137 | user: test
138 | date: Thu Jan 01 00:00:00 1970 +0000
139 | summary: commit_B1_change
140 |
141 | diff -r 9c17110ca844 -r 30a40f18d81e file-a.txt
142 | --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
143 | +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
144 | @@ -1,5 +1,5 @@
145 | one
146 | -two
147 | +deux
148 | three
149 | four
150 | five
151 | @@ -7,4 +7,4 @@
152 | seven
153 | eight
154 | nine
155 | -ten
156 | +dix
157 |
158 | o changeset: 4:e6f5655bdf2e
159 | | user: test
160 | | date: Thu Jan 01 00:00:00 1970 +0000
161 | | summary: commit_A4_change
162 | |
163 | | diff -r 074ad64f5cd7 -r e6f5655bdf2e file-b.txt
164 | | --- a/file-b.txt Thu Jan 01 00:00:00 1970 +0000
165 | | +++ b/file-b.txt Thu Jan 01 00:00:00 1970 +0000
166 | | @@ -1,3 +1,4 @@
167 | | +butter
168 | | egg
169 | | salade
170 | | orange
171 | |
172 | o changeset: 3:074ad64f5cd7
173 | | user: test
174 | | date: Thu Jan 01 00:00:00 1970 +0000
175 | | summary: commit_A3_change
176 | |
177 | | diff -r 37c330f02452 -r 074ad64f5cd7 file-b.txt
178 | | --- /dev/null Thu Jan 01 00:00:00 1970 +0000
179 | | +++ b/file-b.txt Thu Jan 01 00:00:00 1970 +0000
180 | | @@ -0,0 +1,3 @@
181 | | +egg
182 | | +salade
183 | | +orange
184 | |
185 | o changeset: 2:37c330f02452
186 | | user: test
187 | | date: Thu Jan 01 00:00:00 1970 +0000
188 | | summary: commit_A2_change
189 | |
190 | | diff -r 7bcbc987bcfe -r 37c330f02452 file-a.txt
191 | | --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
192 | | +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
193 | | @@ -2,7 +2,7 @@
194 | | deux
195 | | three
196 | | four
197 | | -five
198 | | +cinq
199 | | six
200 | | seven
201 | | eight
202 | |
203 | o changeset: 1:7bcbc987bcfe
204 |/ user: test
205 | date: Thu Jan 01 00:00:00 1970 +0000
206 | summary: commit_A1_change
207 |
208 | diff -r 9c17110ca844 -r 7bcbc987bcfe file-a.txt
209 | --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
210 | +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
211 | @@ -1,5 +1,5 @@
212 | one
213 | -two
214 | +deux
215 | three
216 | four
217 | five
218 |
219 o changeset: 0:9c17110ca844
220 user: test
221 date: Thu Jan 01 00:00:00 1970 +0000
222 summary: commit_root
223
224 diff -r 000000000000 -r 9c17110ca844 file-a.txt
225 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
226 +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
227 @@ -0,0 +1,10 @@
228 +one
229 +two
230 +three
231 +four
232 +five
233 +six
234 +seven
235 +eight
236 +nine
237 +ten
238
239
240 Then compare the resulting revisions:
241 ====================================
242
243 A1 and B1 has the same parent, so the same output is expected.
244
245
246 $ hg diff --from 'desc("commit_A1_change")' --to 'desc("commit_B1_change")'
247 diff -r 7bcbc987bcfe -r 30a40f18d81e file-a.txt
248 --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
249 +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
250 @@ -7,4 +7,4 @@
251 seven
252 eight
253 nine
254 -ten
255 +dix
256 $ hg diff --from 'desc("commit_A1_change")' --to 'desc("commit_B1_change")' --ignore-changes-from-ancestors
257 diff -r 7bcbc987bcfe -r 30a40f18d81e file-a.txt
258 --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
259 +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
260 @@ -7,4 +7,4 @@
261 seven
262 eight
263 nine
264 -ten
265 +dix
266
267 Skipping B1 change mean the final "ten" change is no longer part of the diff
268
269 $ hg diff --from 'desc("commit_A1_change")' --to 'desc("commit_B2_change")'
270 diff -r 7bcbc987bcfe -r 1e73118ddc3a file-a.txt
271 --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
272 +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
273 @@ -2,9 +2,9 @@
274 deux
275 three
276 four
277 -five
278 +funf
279 six
280 seven
281 -eight
282 +acht
283 nine
284 -ten
285 +dix
286 $ hg diff --from 'desc("commit_A1_change")' --to 'desc("commit_B2_change")' --ignore-changes-from-ancestors
287 diff -r 1e73118ddc3a file-a.txt
288 --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
289 +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
290 @@ -2,9 +2,9 @@
291 deux
292 three
293 four
294 -five
295 +funf
296 six
297 seven
298 -eight
299 +acht
300 nine
301 dix
302
303 Skipping A1 changes means the "two" changes introduced by "B1" (but also
304 present in A2 parent, A1) is back on the table.
305
306 $ hg diff --from 'desc("commit_A2_change")' --to 'desc("commit_B1_change")'
307 diff -r 37c330f02452 -r 30a40f18d81e file-a.txt
308 --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
309 +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
310 @@ -2,9 +2,9 @@
311 deux
312 three
313 four
314 -cinq
315 +five
316 six
317 seven
318 eight
319 nine
320 -ten
321 +dix
322 $ hg diff --from 'desc("commit_A2_change")' --to 'desc("commit_B1_change")' --ignore-changes-from-ancestors
323 diff -r 30a40f18d81e file-a.txt
324 --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
325 +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
326 @@ -1,10 +1,10 @@
327 one
328 -two
329 +deux
330 three
331 four
332 -cinq
333 +five
334 six
335 seven
336 eight
337 nine
338 -ten
339 +dix
340
341 All changes from A1 and B1 are no longer in the picture as we compare A2 and B2
342
343 $ hg diff --from 'desc("commit_A2_change")' --to 'desc("commit_B2_change")'
344 diff -r 37c330f02452 -r 1e73118ddc3a file-a.txt
345 --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
346 +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
347 @@ -2,9 +2,9 @@
348 deux
349 three
350 four
351 -cinq
352 +funf
353 six
354 seven
355 -eight
356 +acht
357 nine
358 -ten
359 +dix
360 $ hg diff --from 'desc("commit_A2_change")' --to 'desc("commit_B2_change")' --ignore-changes-from-ancestors
361 diff -r 1e73118ddc3a file-a.txt
362 --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
363 +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
364 @@ -2,9 +2,9 @@
365 deux
366 three
367 four
368 -cinq
369 +funf
370 six
371 seven
372 -eight
373 +acht
374 nine
375 dix
376
377 Similar patches
378 ---------------
379
380 comparing A3 and B3 patches is much more terse. focusing on the change to the
381 two similar patches, ignoring the rests of the changes (like comparing apples
382 and oranges)
383
384 $ hg diff --from 'desc("commit_A3_change")' --to 'desc("commit_B3_change")'
385 diff -r 074ad64f5cd7 -r 59c9679fd24c file-a.txt
386 --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
387 +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
388 @@ -2,9 +2,9 @@
389 deux
390 three
391 four
392 -cinq
393 +funf
394 six
395 seven
396 -eight
397 +acht
398 nine
399 -ten
400 +dix
401 diff -r 074ad64f5cd7 -r 59c9679fd24c file-b.txt
402 --- a/file-b.txt Thu Jan 01 00:00:00 1970 +0000
403 +++ b/file-b.txt Thu Jan 01 00:00:00 1970 +0000
404 @@ -1,3 +1,4 @@
405 +milk
406 egg
407 salade
408 -orange
409 +apple
410 $ hg diff --from 'desc("commit_A3_change")' --to 'desc("commit_B3_change")' --ignore-changes-from-ancestors
411 diff -r 59c9679fd24c file-b.txt
412 --- a/file-b.txt Thu Jan 01 00:00:00 1970 +0000
413 +++ b/file-b.txt Thu Jan 01 00:00:00 1970 +0000
414 @@ -1,3 +1,4 @@
415 +milk
416 egg
417 salade
418 -orange
419 +apple
420
421
422 Conflict handling
423 -----------------
424
425 Conflict should not be a big deal and its resolution should be presented to the user.
426
427 $ hg diff --from 'desc("commit_A4_change")' --to 'desc("commit_B4_change")'
428 diff -r e6f5655bdf2e -r 0d6b02d59faf file-a.txt
429 --- a/file-a.txt Thu Jan 01 00:00:00 1970 +0000
430 +++ b/file-a.txt Thu Jan 01 00:00:00 1970 +0000
431 @@ -2,9 +2,9 @@
432 deux
433 three
434 four
435 -cinq
436 +funf
437 six
438 seven
439 -eight
440 +acht
441 nine
442 -ten
443 +dix
444 diff -r e6f5655bdf2e -r 0d6b02d59faf file-b.txt
445 --- a/file-b.txt Thu Jan 01 00:00:00 1970 +0000
446 +++ b/file-b.txt Thu Jan 01 00:00:00 1970 +0000
447 @@ -1,4 +1,5 @@
448 butter
449 +milk
450 egg
451 salade
452 -orange
453 +apple
454 $ hg diff --from 'desc("commit_A4_change")' --to 'desc("commit_B4_change")' --ignore-changes-from-ancestors
455 diff -r 0d6b02d59faf file-b.txt
456 --- a/file-b.txt Thu Jan 01 00:00:00 1970 +0000
457 +++ b/file-b.txt Thu Jan 01 00:00:00 1970 +0000
458 @@ -1,9 +1,5 @@
459 -<<<<<<< from: e6f5655bdf2e - test: commit_A4_change
460 butter
461 -||||||| parent-of-from: 074ad64f5cd7 - test: commit_A3_change
462 -=======
463 milk
464 ->>>>>>> parent-of-to: 59c9679fd24c - test: commit_B3_change
465 egg
466 salade
467 apple