##// END OF EJS Templates
tests: add more tests of copy tracing with removed and re-added files...
Martin von Zweigbergk -
r42793:ab416b5d default
parent child Browse files
Show More
@@ -1,97 +1,387
1 1 #testcases filelog compatibility changeset
2 2
3 3 $ cat >> $HGRCPATH << EOF
4 4 > [extensions]
5 5 > rebase=
6 6 > [alias]
7 7 > l = log -G -T '{rev} {desc}\n{files}\n'
8 8 > EOF
9 9
10 10 #if compatibility
11 11 $ cat >> $HGRCPATH << EOF
12 12 > [experimental]
13 13 > copies.read-from = compatibility
14 14 > EOF
15 15 #endif
16 16
17 17 #if changeset
18 18 $ cat >> $HGRCPATH << EOF
19 19 > [experimental]
20 20 > copies.read-from = changeset-only
21 21 > copies.write-to = changeset-only
22 22 > EOF
23 23 #endif
24 24
25 25 $ REPONUM=0
26 26 $ newrepo() {
27 27 > cd $TESTTMP
28 28 > REPONUM=`expr $REPONUM + 1`
29 29 > hg init repo-$REPONUM
30 30 > cd repo-$REPONUM
31 31 > }
32 32
33 33 Copy a file, then delete destination, then copy again. This does not create a new filelog entry.
34 34 $ newrepo
35 35 $ echo x > x
36 36 $ hg ci -Aqm 'add x'
37 $ echo x2 > x
38 $ hg ci -m 'modify x'
39 $ hg co -q 0
37 40 $ hg cp x y
38 $ hg ci -m 'copy x to y'
41 $ hg ci -qm 'copy x to y'
39 42 $ hg rm y
40 43 $ hg ci -m 'remove y'
41 44 $ hg cp -f x y
42 45 $ hg ci -m 'copy x onto y (again)'
43 46 $ hg l
44 @ 3 copy x onto y (again)
47 @ 4 copy x onto y (again)
48 | y
49 o 3 remove y
45 50 | y
46 o 2 remove y
51 o 2 copy x to y
47 52 | y
48 o 1 copy x to y
49 | y
53 | o 1 modify x
54 |/ x
50 55 o 0 add x
51 56 x
52 $ hg debugp1copies -r 3
57 $ hg debugp1copies -r 4
53 58 x -> y
54 $ hg debugpathcopies 0 3
59 $ hg debugpathcopies 0 4
55 60 x -> y
61 $ hg graft -r 1
62 grafting 1:* "modify x" (glob)
63 merging y and x to y
64 $ hg co -qC 1
65 $ hg graft -r 4
66 grafting 4:* "copy x onto y (again)" (glob)
67 merging x and y to y
56 68
57 Copy x to y, then remove y, then add back y. With copy metadata in the changeset, this could easily
58 end up reporting y as copied from x (if we don't unmark it as a copy when it's removed).
69 Copy x to y, then remove y, then add back y. With copy metadata in the
70 changeset, this could easily end up reporting y as copied from x (if we don't
71 unmark it as a copy when it's removed). Despite x and y not being related, we
72 want grafts to propagate across the rename.
59 73 $ newrepo
60 74 $ echo x > x
61 75 $ hg ci -Aqm 'add x'
76 $ echo x2 > x
77 $ hg ci -m 'modify x'
78 $ hg co -q 0
62 79 $ hg mv x y
63 $ hg ci -m 'rename x to y'
80 $ hg ci -qm 'rename x to y'
64 81 $ hg rm y
65 82 $ hg ci -qm 'remove y'
66 83 $ echo x > y
67 84 $ hg ci -Aqm 'add back y'
68 85 $ hg l
69 @ 3 add back y
86 @ 4 add back y
87 | y
88 o 3 remove y
70 89 | y
71 o 2 remove y
72 | y
73 o 1 rename x to y
90 o 2 rename x to y
91 | x y
92 | o 1 modify x
93 |/ x
94 o 0 add x
95 x
96 $ hg debugpathcopies 0 4
97 BROKEN: This should succeed and merge the changes from x into y
98 $ hg graft -r 1
99 grafting 1:* "modify x" (glob)
100 file 'x' was deleted in local [local] but was modified in other [graft].
101 You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
102 What do you want to do? u
103 abort: unresolved conflicts, can't continue
104 (use 'hg resolve' and 'hg graft --continue')
105 [255]
106
107 Add x, remove it, then add it back, then rename x to y. Similar to the case
108 above, but here the break in history is before the rename.
109 $ newrepo
110 $ echo x > x
111 $ hg ci -Aqm 'add x'
112 $ echo x2 > x
113 $ hg ci -m 'modify x'
114 $ hg co -q 0
115 $ hg rm x
116 $ hg ci -qm 'remove x'
117 $ echo x > x
118 $ hg ci -Aqm 'add x again'
119 $ hg mv x y
120 $ hg ci -m 'rename x to y'
121 $ hg l
122 @ 4 rename x to y
74 123 | x y
124 o 3 add x again
125 | x
126 o 2 remove x
127 | x
128 | o 1 modify x
129 |/ x
130 o 0 add x
131 x
132 $ hg debugpathcopies 0 4
133 x -> y
134 $ hg graft -r 1
135 grafting 1:* "modify x" (glob)
136 merging y and x to y
137 $ hg co -qC 1
138 $ hg graft -r 4
139 grafting 4:* "rename x to y" (glob)
140 merging x and y to y
141
142 Add x, modify it, remove it, then add it back, then rename x to y. Similar to
143 the case above, but here the re-added file's nodeid is different from before
144 the break.
145
146 $ newrepo
147 $ echo x > x
148 $ hg ci -Aqm 'add x'
149 $ echo x2 > x
150 $ hg ci -m 'modify x'
151 $ echo x3 > x
152 $ hg ci -qm 'modify x again'
153 $ hg co -q 1
154 $ hg rm x
155 $ hg ci -qm 'remove x'
156 # Same content to avoid conflicts
157 $ hg revert -r 1 x
158 $ hg ci -Aqm 'add x again'
159 $ hg mv x y
160 $ hg ci -m 'rename x to y'
161 $ hg l
162 @ 5 rename x to y
163 | x y
164 o 4 add x again
165 | x
166 o 3 remove x
167 | x
168 | o 2 modify x again
169 |/ x
170 o 1 modify x
171 | x
75 172 o 0 add x
76 173 x
77 $ hg debugp1copies -r 3
78 $ hg debugpathcopies 0 3
174 $ hg debugpathcopies 0 5
175 x -> y (no-filelog !)
176 #if no-filelog
177 $ hg graft -r 2
178 grafting 2:* "modify x again" (glob)
179 merging y and x to y
180 #else
181 BROKEN: This should succeed and merge the changes from x into y
182 $ hg graft -r 2
183 grafting 2:* "modify x again" (glob)
184 file 'x' was deleted in local [local] but was modified in other [graft].
185 You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
186 What do you want to do? u
187 abort: unresolved conflicts, can't continue
188 (use 'hg resolve' and 'hg graft --continue')
189 [255]
190 #endif
191 $ hg co -qC 2
192 BROKEN: This should succeed and merge the changes from x into y
193 $ hg graft -r 5
194 grafting 5:* "rename x to y"* (glob)
195 file 'x' was deleted in other [graft] but was modified in local [local].
196 You can use (c)hanged version, (d)elete, or leave (u)nresolved.
197 What do you want to do? u
198 abort: unresolved conflicts, can't continue
199 (use 'hg resolve' and 'hg graft --continue')
200 [255]
201
202 Add x, remove it, then add it back, rename x to y from the first commit.
203 Similar to the case above, but here the break in history is parallel to the
204 rename.
205 $ newrepo
206 $ echo x > x
207 $ hg ci -Aqm 'add x'
208 $ hg rm x
209 $ hg ci -qm 'remove x'
210 $ echo x > x
211 $ hg ci -Aqm 'add x again'
212 $ echo x2 > x
213 $ hg ci -m 'modify x'
214 $ hg co -q 0
215 $ hg mv x y
216 $ hg ci -qm 'rename x to y'
217 $ hg l
218 @ 4 rename x to y
219 | x y
220 | o 3 modify x
221 | | x
222 | o 2 add x again
223 | | x
224 | o 1 remove x
225 |/ x
226 o 0 add x
227 x
228 $ hg debugpathcopies 2 4
229 x -> y
230 $ hg graft -r 3
231 grafting 3:* "modify x" (glob)
232 merging y and x to y
233 $ hg co -qC 3
234 $ hg graft -r 4
235 grafting 4:* "rename x to y" (glob)
236 merging x and y to y
237
238 Add x, remove it, then add it back, rename x to y from the first commit.
239 Similar to the case above, but here the re-added file's nodeid is different
240 from the base.
241 $ newrepo
242 $ echo x > x
243 $ hg ci -Aqm 'add x'
244 $ hg rm x
245 $ hg ci -qm 'remove x'
246 $ echo x2 > x
247 $ hg ci -Aqm 'add x again with different content'
248 $ hg co -q 0
249 $ hg mv x y
250 $ hg ci -qm 'rename x to y'
251 $ hg l
252 @ 3 rename x to y
253 | x y
254 | o 2 add x again with different content
255 | | x
256 | o 1 remove x
257 |/ x
258 o 0 add x
259 x
260 $ hg debugpathcopies 2 3
261 x -> y
262 BROKEN: This should merge the changes from x into y
263 $ hg graft -r 2
264 grafting 2:* "add x again with different content" (glob)
265 $ hg co -qC 2
266 BROKEN: This should succeed and merge the changes from x into y
267 $ hg graft -r 3
268 grafting 3:* "rename x to y" (glob)
269 file 'x' was deleted in other [graft] but was modified in local [local].
270 You can use (c)hanged version, (d)elete, or leave (u)nresolved.
271 What do you want to do? u
272 abort: unresolved conflicts, can't continue
273 (use 'hg resolve' and 'hg graft --continue')
274 [255]
275
276 Add x on two branches, then rename x to y on one side. Similar to the case
277 above, but here the break in history is via the base commit.
278 $ newrepo
279 $ echo a > a
280 $ hg ci -Aqm 'base'
281 $ echo x > x
282 $ hg ci -Aqm 'add x'
283 $ echo x2 > x
284 $ hg ci -m 'modify x'
285 $ hg co -q 0
286 $ echo x > x
287 $ hg ci -Aqm 'add x again'
288 $ hg mv x y
289 $ hg ci -qm 'rename x to y'
290 $ hg l
291 @ 4 rename x to y
292 | x y
293 o 3 add x again
294 | x
295 | o 2 modify x
296 | | x
297 | o 1 add x
298 |/ x
299 o 0 base
300 a
301 $ hg debugpathcopies 1 4
302 BROKEN: This should succeed and merge the changes from x into y
303 $ hg graft -r 2
304 grafting 2:* "modify x" (glob)
305 file 'x' was deleted in local [local] but was modified in other [graft].
306 What do you want to do?
307 use (c)hanged version, leave (d)eleted, or leave (u)nresolved? u
308 abort: unresolved conflicts, can't continue
309 (use 'hg resolve' and 'hg graft --continue')
310 [255]
311 $ hg co -qC 2
312 $ hg graft -r 4
313 grafting 4:* "rename x to y"* (glob)
314 merging x and y to y
315
316 Add x on two branches, with same content but different history, then rename x
317 to y on one side. Similar to the case above, here the file's nodeid is
318 different between the branches.
319 $ newrepo
320 $ echo a > a
321 $ hg ci -Aqm 'base'
322 $ echo x > x
323 $ hg ci -Aqm 'add x'
324 $ echo x2 > x
325 $ hg ci -m 'modify x'
326 $ hg co -q 0
327 $ touch x
328 $ hg ci -Aqm 'add empty x'
329 # Same content to avoid conflicts
330 $ hg revert -r 1 x
331 $ hg ci -m 'modify x to match commit 1'
332 $ hg mv x y
333 $ hg ci -qm 'rename x to y'
334 $ hg l
335 @ 5 rename x to y
336 | x y
337 o 4 modify x to match commit 1
338 | x
339 o 3 add empty x
340 | x
341 | o 2 modify x
342 | | x
343 | o 1 add x
344 |/ x
345 o 0 base
346 a
347 $ hg debugpathcopies 1 5
348 BROKEN: This should succeed and merge the changes from x into y
349 $ hg graft -r 2
350 grafting 2:* "modify x" (glob)
351 file 'x' was deleted in local [local] but was modified in other [graft].
352 You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
353 What do you want to do? u
354 abort: unresolved conflicts, can't continue
355 (use 'hg resolve' and 'hg graft --continue')
356 [255]
357 $ hg co -qC 2
358 BROKEN: This should succeed and merge the changes from x into y
359 $ hg graft -r 5
360 grafting 5:* "rename x to y"* (glob)
361 file 'x' was deleted in other [graft] but was modified in local [local].
362 You can use (c)hanged version, (d)elete, or leave (u)nresolved.
363 What do you want to do? u
364 abort: unresolved conflicts, can't continue
365 (use 'hg resolve' and 'hg graft --continue')
366 [255]
79 367
80 368 Copies via null revision (there shouldn't be any)
81 369 $ newrepo
82 370 $ echo x > x
83 371 $ hg ci -Aqm 'add x'
84 372 $ hg cp x y
85 373 $ hg ci -m 'copy x to y'
86 374 $ hg co -q null
87 375 $ echo x > x
88 376 $ hg ci -Aqm 'add x (again)'
89 377 $ hg l
90 378 @ 2 add x (again)
91 379 x
92 380 o 1 copy x to y
93 381 | y
94 382 o 0 add x
95 383 x
96 384 $ hg debugpathcopies 1 2
97 385 $ hg debugpathcopies 2 1
386 $ hg graft -r 1
387 grafting 1:* "copy x to y" (glob)
@@ -1,235 +1,186
1 1 $ hg init
2 2
3 3 $ echo "[merge]" >> .hg/hgrc
4 4 $ echo "followcopies = 1" >> .hg/hgrc
5 5
6 6 $ echo foo > a
7 7 $ echo foo > a2
8 8 $ hg add a a2
9 9 $ hg ci -m "start"
10 10
11 11 $ hg mv a b
12 12 $ hg mv a2 b2
13 13 $ hg ci -m "rename"
14 14
15 15 $ hg co 0
16 16 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
17 17
18 18 $ echo blahblah > a
19 19 $ echo blahblah > a2
20 20 $ hg mv a2 c2
21 21 $ hg ci -m "modify"
22 22 created new head
23 23
24 24 $ hg merge -y --debug
25 25 unmatched files in local:
26 26 c2
27 27 unmatched files in other:
28 28 b
29 29 b2
30 30 all copies found (* = to merge, ! = divergent, % = renamed and deleted):
31 31 src: 'a' -> dst: 'b' *
32 32 src: 'a2' -> dst: 'b2' !
33 33 src: 'a2' -> dst: 'c2' !
34 34 checking for directory renames
35 35 resolving manifests
36 36 branchmerge: True, force: False, partial: False
37 37 ancestor: af1939970a1c, local: 044f8520aeeb+, remote: 85c198ef2f6c
38 38 note: possible conflict - a2 was renamed multiple times to:
39 39 b2
40 40 c2
41 41 preserving a for resolve of b
42 42 removing a
43 43 b2: remote created -> g
44 44 getting b2
45 45 b: remote moved from a -> m (premerge)
46 46 picked tool ':merge' for b (binary False symlink False changedelete False)
47 47 merging a and b to b
48 48 my b@044f8520aeeb+ other b@85c198ef2f6c ancestor a@af1939970a1c
49 49 premerge successful
50 50 1 files updated, 1 files merged, 0 files removed, 0 files unresolved
51 51 (branch merge, don't forget to commit)
52 52
53 53 $ hg status -AC
54 54 M b
55 55 a
56 56 M b2
57 57 R a
58 58 C c2
59 59
60 60 $ cat b
61 61 blahblah
62 62
63 63 $ hg ci -m "merge"
64 64
65 65 $ hg debugindex b
66 66 rev linkrev nodeid p1 p2
67 67 0 1 57eacc201a7f 000000000000 000000000000
68 68 1 3 4727ba907962 000000000000 57eacc201a7f
69 69
70 70 $ hg debugrename b
71 71 b renamed from a:dd03b83622e78778b403775d0d074b9ac7387a66
72 72
73 73 This used to trigger a "divergent renames" warning, despite no renames
74 74
75 75 $ hg cp b b3
76 76 $ hg cp b b4
77 77 $ hg ci -A -m 'copy b twice'
78 78 $ hg up '.^'
79 79 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
80 80 $ hg up
81 81 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
82 82 $ hg rm b3 b4
83 83 $ hg ci -m 'clean up a bit of our mess'
84 84
85 85 We'd rather not warn on divergent renames done in the same changeset (issue2113)
86 86
87 87 $ hg cp b b3
88 88 $ hg mv b b4
89 89 $ hg ci -A -m 'divergent renames in same changeset'
90 90 $ hg up '.^'
91 91 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
92 92 $ hg up
93 93 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
94 94
95 95 Check for issue2642
96 96
97 97 $ hg init t
98 98 $ cd t
99 99
100 100 $ echo c0 > f1
101 101 $ hg ci -Aqm0
102 102
103 103 $ hg up null -q
104 104 $ echo c1 > f1 # backport
105 105 $ hg ci -Aqm1
106 106 $ hg mv f1 f2
107 107 $ hg ci -qm2
108 108
109 109 $ hg up 0 -q
110 110 $ hg merge 1 -q --tool internal:local
111 111 $ hg ci -qm3
112 112
113 113 $ hg merge 2
114 114 merging f1 and f2 to f2
115 115 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
116 116 (branch merge, don't forget to commit)
117 117
118 118 $ cat f2
119 119 c0
120 120
121 121 $ cd ..
122 122
123 123 Check for issue2089
124 124
125 125 $ hg init repo2089
126 126 $ cd repo2089
127 127
128 128 $ echo c0 > f1
129 129 $ hg ci -Aqm0
130 130
131 131 $ hg up null -q
132 132 $ echo c1 > f1
133 133 $ hg ci -Aqm1
134 134
135 135 $ hg up 0 -q
136 136 $ hg merge 1 -q --tool internal:local
137 137 $ echo c2 > f1
138 138 $ hg ci -qm2
139 139
140 140 $ hg up 1 -q
141 141 $ hg mv f1 f2
142 142 $ hg ci -Aqm3
143 143
144 144 $ hg up 2 -q
145 145 $ hg merge 3
146 146 merging f1 and f2 to f2
147 147 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
148 148 (branch merge, don't forget to commit)
149 149
150 150 $ cat f2
151 151 c2
152 152
153 153 $ cd ..
154 154
155 155 Check for issue3074
156 156
157 157 $ hg init repo3074
158 158 $ cd repo3074
159 159 $ echo foo > file
160 160 $ hg add file
161 161 $ hg commit -m "added file"
162 162 $ hg mv file newfile
163 163 $ hg commit -m "renamed file"
164 164 $ hg update 0
165 165 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
166 166 $ hg rm file
167 167 $ hg commit -m "deleted file"
168 168 created new head
169 169 $ hg merge --debug
170 170 unmatched files in other:
171 171 newfile
172 172 all copies found (* = to merge, ! = divergent, % = renamed and deleted):
173 173 src: 'file' -> dst: 'newfile' %
174 174 checking for directory renames
175 175 resolving manifests
176 176 branchmerge: True, force: False, partial: False
177 177 ancestor: 19d7f95df299, local: 0084274f6b67+, remote: 5d32493049f0
178 178 note: possible conflict - file was deleted and renamed to:
179 179 newfile
180 180 newfile: remote created -> g
181 181 getting newfile
182 182 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
183 183 (branch merge, don't forget to commit)
184 184 $ hg status
185 185 M newfile
186 186 $ cd ..
187
188 Check that file is considered unrelated when deleted and recreated
189
190 $ hg init unrelated
191 $ cd unrelated
192 $ echo foo > file
193 $ hg add file
194 $ hg commit -m "added file"
195 $ hg cp file newfile
196 $ hg commit -m "copy file"
197 $ hg update 0
198 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
199 $ hg rm file
200 $ hg commit -m "deleted file"
201 created new head
202 $ echo bar > file
203 $ hg add file
204 $ hg ci -m 'recreate file'
205 $ hg log -G -T '{rev} {desc}\n'
206 @ 3 recreate file
207 |
208 o 2 deleted file
209 |
210 | o 1 copy file
211 |/
212 o 0 added file
213
214 BROKEN: this is inconsistent with `hg merge` (below), which doesn't consider
215 'file' renamed same since it was deleted for a while
216 $ hg st --copies --rev 3 --rev 1
217 M file
218 A newfile
219 file
220 $ hg merge --debug 1
221 unmatched files in other:
222 newfile
223 all copies found (* = to merge, ! = divergent, % = renamed and deleted):
224 src: 'file' -> dst: 'newfile'
225 checking for directory renames
226 resolving manifests
227 branchmerge: True, force: False, partial: False
228 ancestor: 19d7f95df299, local: 4e4a42b1cbdf+, remote: 45b14aae7432
229 newfile: remote created -> g
230 getting newfile
231 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
232 (branch merge, don't forget to commit)
233 $ hg status
234 M newfile
235 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now