Debian Codegraph @

tests/test-rebase-rename.t

raw
1 $ cat >> $HGRCPATH <<EOF
2 > [extensions]
3 > rebase=
4 >
5 > [alias]
6 > tlog = log --template "{rev}: {node|short} '{desc}' {branches}\n"
7 > tglog = tlog --graph
8 > EOF
9
10
11 $ hg init a
12 $ cd a
13
14 $ mkdir d
15 $ echo a > a
16 $ hg ci -Am A
17 adding a
18
19 $ echo b > d/b
20 $ hg ci -Am B
21 adding d/b
22
23 $ hg mv d d-renamed
24 moving d/b to d-renamed/b
25 $ hg ci -m 'rename B'
26
27 $ hg up -q -C 1
28
29 $ hg mv a a-renamed
30 $ echo x > d/x
31 $ hg add d/x
32
33 $ hg ci -m 'rename A'
34 created new head
35
36 $ hg tglog
37 @ 3: 73a3ee40125d 'rename A'
38 |
39 | o 2: 220d0626d185 'rename B'
40 |/
41 o 1: 3ab5da9a5c01 'B'
42 |
43 o 0: 1994f17a630e 'A'
44
45
46 Rename is tracked:
47
48 $ hg tlog -p --git -r tip
49 3: 73a3ee40125d 'rename A'
50 diff --git a/a b/a-renamed
51 rename from a
52 rename to a-renamed
53 diff --git a/d/x b/d/x
54 new file mode 100644
55 --- /dev/null
56 +++ b/d/x
57 @@ -0,0 +1,1 @@
58 +x
59
60 Rebase the revision containing the rename:
61
62 $ hg rebase -s 3 -d 2
63 rebasing 3:73a3ee40125d tip "rename A"
64 saved backup bundle to $TESTTMP/a/.hg/strip-backup/73a3ee40125d-1d78ebcf-rebase.hg
65
66 $ hg tglog
67 @ 3: 032a9b75e83b 'rename A'
68 |
69 o 2: 220d0626d185 'rename B'
70 |
71 o 1: 3ab5da9a5c01 'B'
72 |
73 o 0: 1994f17a630e 'A'
74
75
76 Rename is not lost:
77
78 $ hg tlog -p --git -r tip
79 3: 032a9b75e83b 'rename A'
80 diff --git a/a b/a-renamed
81 rename from a
82 rename to a-renamed
83 diff --git a/d-renamed/x b/d-renamed/x
84 new file mode 100644
85 --- /dev/null
86 +++ b/d-renamed/x
87 @@ -0,0 +1,1 @@
88 +x
89
90
91 Rebased revision does not contain information about b (issue3739)
92
93 $ hg log -r 3 --debug
94 changeset: 3:032a9b75e83bff1dcfb6cbfa4ef50a704bf1b569
95 tag: tip
96 phase: draft
97 parent: 2:220d0626d185f372d9d8f69d9c73b0811d7725f7
98 parent: -1:0000000000000000000000000000000000000000
99 manifest: 3:035d66b27a1b06b2d12b46d41a39adb7a200c370
100 user: test
101 date: Thu Jan 01 00:00:00 1970 +0000
102 files+: a-renamed d-renamed/x
103 files-: a
104 extra: branch=default
105 extra: rebase_source=73a3ee40125d6f0f347082e5831ceccb3f005f8a
106 description:
107 rename A
108
109
110
111 $ repeatchange() {
112 > hg checkout $1
113 > hg cp a z
114 > echo blah >> z
115 > hg commit -Am "$2" --user "$3"
116 > }
117 $ repeatchange 1 "E" "user1"
118 2 files updated, 0 files merged, 3 files removed, 0 files unresolved
119 created new head
120 $ repeatchange 1 "E" "user2"
121 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
122 created new head
123 $ hg tglog
124 @ 5: af8ad1f97097 'E'
125 |
126 | o 4: 60f545c27784 'E'
127 |/
128 | o 3: 032a9b75e83b 'rename A'
129 | |
130 | o 2: 220d0626d185 'rename B'
131 |/
132 o 1: 3ab5da9a5c01 'B'
133 |
134 o 0: 1994f17a630e 'A'
135
136 $ hg rebase -s 5 -d 4
137 rebasing 5:af8ad1f97097 tip "E"
138 note: not rebasing 5:af8ad1f97097 tip "E", its destination already has all its changes
139 saved backup bundle to $TESTTMP/a/.hg/strip-backup/af8ad1f97097-c3e90708-rebase.hg
140 $ hg tglog
141 @ 4: 60f545c27784 'E'
142 |
143 | o 3: 032a9b75e83b 'rename A'
144 | |
145 | o 2: 220d0626d185 'rename B'
146 |/
147 o 1: 3ab5da9a5c01 'B'
148 |
149 o 0: 1994f17a630e 'A'
150
151 $ hg export tip
152 # HG changeset patch
153 # User user1
154 # Date 0 0
155 # Thu Jan 01 00:00:00 1970 +0000
156 # Node ID 60f545c277846e6bad309919bae3ae106f59cb39
157 # Parent 3ab5da9a5c01faa02c20f2ec4870a4f689c92da6
158 E
159
160 diff -r 3ab5da9a5c01 -r 60f545c27784 z
161 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
162 +++ b/z Thu Jan 01 00:00:00 1970 +0000
163 @@ -0,0 +1,2 @@
164 +a
165 +blah
166
167 $ cd ..
168
169
170 $ hg init b
171 $ cd b
172
173 $ echo a > a
174 $ hg ci -Am A
175 adding a
176
177 $ echo b > b
178 $ hg ci -Am B
179 adding b
180
181 $ hg cp b b-copied
182 $ hg ci -Am 'copy B'
183
184 $ hg up -q -C 1
185
186 $ hg cp a a-copied
187 $ hg ci -m 'copy A'
188 created new head
189
190 $ hg tglog
191 @ 3: 0a8162ff18a8 'copy A'
192 |
193 | o 2: 39e588434882 'copy B'
194 |/
195 o 1: 6c81ed0049f8 'B'
196 |
197 o 0: 1994f17a630e 'A'
198
199 Copy is tracked:
200
201 $ hg tlog -p --git -r tip
202 3: 0a8162ff18a8 'copy A'
203 diff --git a/a b/a-copied
204 copy from a
205 copy to a-copied
206
207 Rebase the revision containing the copy:
208
209 $ hg rebase -s 3 -d 2
210 rebasing 3:0a8162ff18a8 tip "copy A"
211 saved backup bundle to $TESTTMP/b/.hg/strip-backup/0a8162ff18a8-dd06302a-rebase.hg
212
213 $ hg tglog
214 @ 3: 98f6e6dbf45a 'copy A'
215 |
216 o 2: 39e588434882 'copy B'
217 |
218 o 1: 6c81ed0049f8 'B'
219 |
220 o 0: 1994f17a630e 'A'
221
222
223 Copy is not lost:
224
225 $ hg tlog -p --git -r tip
226 3: 98f6e6dbf45a 'copy A'
227 diff --git a/a b/a-copied
228 copy from a
229 copy to a-copied
230
231
232 Rebased revision does not contain information about b (issue3739)
233
234 $ hg log -r 3 --debug
235 changeset: 3:98f6e6dbf45ab54079c2237fbd11066a5c41a11d
236 tag: tip
237 phase: draft
238 parent: 2:39e588434882ff77d01229d169cdc77f29e8855e
239 parent: -1:0000000000000000000000000000000000000000
240 manifest: 3:2232f329d66fffe3930d43479ae624f66322b04d
241 user: test
242 date: Thu Jan 01 00:00:00 1970 +0000
243 files+: a-copied
244 extra: branch=default
245 extra: rebase_source=0a8162ff18a8900df8df8ef7ac0046955205613e
246 description:
247 copy A
248
249
250
251 $ cd ..
252
253
254 Test rebase across repeating renames:
255
256 $ hg init repo
257
258 $ cd repo
259
260 $ echo testing > file1.txt
261 $ hg add file1.txt
262 $ hg ci -m "Adding file1"
263
264 $ hg rename file1.txt file2.txt
265 $ hg ci -m "Rename file1 to file2"
266
267 $ echo Unrelated change > unrelated.txt
268 $ hg add unrelated.txt
269 $ hg ci -m "Unrelated change"
270
271 $ hg rename file2.txt file1.txt
272 $ hg ci -m "Rename file2 back to file1"
273
274 $ hg update -r -2
275 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
276
277 $ echo Another unrelated change >> unrelated.txt
278 $ hg ci -m "Another unrelated change"
279 created new head
280
281 $ hg tglog
282 @ 4: b918d683b091 'Another unrelated change'
283 |
284 | o 3: 1ac17e43d8aa 'Rename file2 back to file1'
285 |/
286 o 2: 480101d66d8d 'Unrelated change'
287 |
288 o 1: be44c61debd2 'Rename file1 to file2'
289 |
290 o 0: 8ce9a346991d 'Adding file1'
291
292
293 $ hg rebase -s 4 -d 3
294 rebasing 4:b918d683b091 tip "Another unrelated change"
295 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/b918d683b091-3024bc57-rebase.hg
296
297 $ hg diff --stat -c .
298 unrelated.txt | 1 +
299 1 files changed, 1 insertions(+), 0 deletions(-)
300
301 $ cd ..
302
303 Verify that copies get preserved (issue4192).
304 $ hg init copy-gets-preserved
305 $ cd copy-gets-preserved
306
307 $ echo a > a
308 $ hg add a
309 $ hg commit --message "File a created"
310 $ hg copy a b
311 $ echo b > b
312 $ hg commit --message "File b created as copy of a and modified"
313 $ hg copy b c
314 $ echo c > c
315 $ hg commit --message "File c created as copy of b and modified" ##
316 $ hg copy c d
317 $ echo d > d
318 $ hg commit --message "File d created as copy of c and modified (child of 327f772bc074)"
319
320 Note that there are four entries in the log for d
321 $ hg tglog --follow d
322 @ 3: 6be224292cfa 'File d created as copy of c and modified (child of 327f772bc074)'
323 |
324 o 2: 327f772bc074 'File c created as copy of b and modified'
325 |
326 o 1: 79d255d24ad2 'File b created as copy of a and modified'
327 |
328 o 0: b220cd6d2326 'File a created'
329
330 Update back to before we performed copies, and inject an unrelated change.
331 $ hg update 0
332 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
333
334 $ echo unrelated > unrelated
335 $ hg add unrelated
336 $ hg commit --message "Unrelated file created"
337 created new head
338 $ hg update 4
339 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
340
341 Rebase the copies on top of the unrelated change.
342 $ hg rebase --source 1 --dest 4
343 rebasing 1:79d255d24ad2 "File b created as copy of a and modified"
344 rebasing 2:327f772bc074 "File c created as copy of b and modified"
345 rebasing 3:6be224292cfa "File d created as copy of c and modified (child of 327f772bc074)"
346 saved backup bundle to $TESTTMP/copy-gets-preserved/.hg/strip-backup/79d255d24ad2-a3e674e3-rebase.hg
347 $ hg update 4
348 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
349
350 There should still be four entries in the log for d
351 $ hg tglog --follow d
352 @ 4: afbdde3a60d5 'File d created as copy of c and modified (child of af74b229bc02)'
353 |
354 o 3: af74b229bc02 'File c created as copy of b and modified'
355 |
356 o 2: 68bf06433839 'File b created as copy of a and modified'
357 :
358 o 0: b220cd6d2326 'File a created'
359
360 Same steps as above, but with --collapse on rebase to make sure the
361 copy records collapse correctly.
362 $ hg co 1
363 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
364 $ echo more >> unrelated
365 $ hg ci -m 'unrelated commit is unrelated'
366 created new head
367 $ hg rebase -s 2 --dest 5 --collapse
368 rebasing 2:68bf06433839 "File b created as copy of a and modified"
369 rebasing 3:af74b229bc02 "File c created as copy of b and modified"
370 merging b and c to c
371 rebasing 4:afbdde3a60d5 "File d created as copy of c and modified (child of af74b229bc02)"
372 merging c and d to d
373 saved backup bundle to $TESTTMP/copy-gets-preserved/.hg/strip-backup/68bf06433839-29d5057f-rebase.hg
374 $ hg co tip
375 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
376
377 This should show both revision 3 and 0 since 'd' was transitively a
378 copy of 'a'.
379
380 $ hg tglog --follow d
381 @ 3: 75708a266e56 'Collapsed revision
382 : * File b created as copy of a and modified
383 : * File c created as copy of b and modified
384 : * File d created as copy of c and modified (child of af74b229bc02)'
385 o 0: b220cd6d2326 'File a created'
386
387 $ hg log -G -Tcompact
388 @ 3[tip] 75708a266e56 1970-01-01 00:00 +0000 test
389 | Collapsed revision
390 |
391 o 2 15258cf0cf10 1970-01-01 00:00 +0000 test
392 | unrelated commit is unrelated
393 |
394 o 1 1d689898494b 1970-01-01 00:00 +0000 test
395 | Unrelated file created
396 |
397 o 0 b220cd6d2326 1970-01-01 00:00 +0000 test
398 File a created
399
400
401 $ cd ..