Show More
@@ -0,0 +1,393 b'' | |||
|
1 | $ cat >> $HGRCPATH <<EOF | |
|
2 | > [extensions] | |
|
3 | > rebase= | |
|
4 | > drawdag=$TESTDIR/drawdag.py | |
|
5 | > | |
|
6 | > [phases] | |
|
7 | > publish=False | |
|
8 | > | |
|
9 | > [alias] | |
|
10 | > tglog = log -G --template "{rev}: {desc}" | |
|
11 | > EOF | |
|
12 | ||
|
13 | $ rebasewithdag() { | |
|
14 | > N=`$PYTHON -c "print($N+1)"` | |
|
15 | > hg init repo$N && cd repo$N | |
|
16 | > hg debugdrawdag | |
|
17 | > hg rebase "$@" > _rebasetmp | |
|
18 | > r=$? | |
|
19 | > grep -v 'saved backup bundle' _rebasetmp | |
|
20 | > [ $r -eq 0 ] && hg tglog | |
|
21 | > cd .. | |
|
22 | > return $r | |
|
23 | > } | |
|
24 | ||
|
25 | Single branching point, without merge: | |
|
26 | ||
|
27 | $ rebasewithdag -b D -d Z <<'EOS' | |
|
28 | > D E | |
|
29 | > |/ | |
|
30 | > Z B C # C: branching point, E should be picked | |
|
31 | > \|/ # B should not be picked | |
|
32 | > A | |
|
33 | > | | |
|
34 | > R | |
|
35 | > EOS | |
|
36 | rebasing 3:d6003a550c2c "C" (C) | |
|
37 | rebasing 5:4526cf523425 "D" (D) | |
|
38 | rebasing 6:b296604d9846 "E" (E tip) | |
|
39 | o 6: E | |
|
40 | | | |
|
41 | | o 5: D | |
|
42 | |/ | |
|
43 | o 4: C | |
|
44 | | | |
|
45 | o 3: Z | |
|
46 | | | |
|
47 | | o 2: B | |
|
48 | |/ | |
|
49 | o 1: A | |
|
50 | | | |
|
51 | o 0: R | |
|
52 | ||
|
53 | Multiple branching points caused by selecting a single merge changeset: | |
|
54 | ||
|
55 | $ rebasewithdag -b E -d Z <<'EOS' | |
|
56 | > E | |
|
57 | > /| | |
|
58 | > B C D # B, C: multiple branching points | |
|
59 | > | |/ # D should not be picked | |
|
60 | > Z | / | |
|
61 | > \|/ | |
|
62 | > A | |
|
63 | > | | |
|
64 | > R | |
|
65 | > EOS | |
|
66 | rebasing 2:c1e6b162678d "B" (B) | |
|
67 | rebasing 3:d6003a550c2c "C" (C) | |
|
68 | rebasing 6:5251e0cb7302 "E" (E tip) | |
|
69 | o 6: E | |
|
70 | |\ | |
|
71 | | o 5: C | |
|
72 | | | | |
|
73 | o | 4: B | |
|
74 | |/ | |
|
75 | o 3: Z | |
|
76 | | | |
|
77 | | o 2: D | |
|
78 | |/ | |
|
79 | o 1: A | |
|
80 | | | |
|
81 | o 0: R | |
|
82 | ||
|
83 | Rebase should not extend the "--base" revset using "descendants": | |
|
84 | ||
|
85 | $ rebasewithdag -b B -d Z <<'EOS' | |
|
86 | > E | |
|
87 | > /| | |
|
88 | > Z B C # descendants(B) = B+E. With E, C will be included incorrectly | |
|
89 | > \|/ | |
|
90 | > A | |
|
91 | > | | |
|
92 | > R | |
|
93 | > EOS | |
|
94 | rebasing 2:c1e6b162678d "B" (B) | |
|
95 | rebasing 5:5251e0cb7302 "E" (E tip) | |
|
96 | o 5: E | |
|
97 | |\ | |
|
98 | | o 4: B | |
|
99 | | | | |
|
100 | | o 3: Z | |
|
101 | | | | |
|
102 | o | 2: C | |
|
103 | |/ | |
|
104 | o 1: A | |
|
105 | | | |
|
106 | o 0: R | |
|
107 | ||
|
108 | Rebase should not simplify the "--base" revset using "roots": | |
|
109 | ||
|
110 | $ rebasewithdag -b B+E -d Z <<'EOS' | |
|
111 | > E | |
|
112 | > /| | |
|
113 | > Z B C # roots(B+E) = B. Without E, C will be missed incorrectly | |
|
114 | > \|/ | |
|
115 | > A | |
|
116 | > | | |
|
117 | > R | |
|
118 | > EOS | |
|
119 | rebasing 2:c1e6b162678d "B" (B) | |
|
120 | rebasing 3:d6003a550c2c "C" (C) | |
|
121 | rebasing 5:5251e0cb7302 "E" (E tip) | |
|
122 | o 5: E | |
|
123 | |\ | |
|
124 | | o 4: C | |
|
125 | | | | |
|
126 | o | 3: B | |
|
127 | |/ | |
|
128 | o 2: Z | |
|
129 | | | |
|
130 | o 1: A | |
|
131 | | | |
|
132 | o 0: R | |
|
133 | ||
|
134 | The destination is one of the two branching points of a merge: | |
|
135 | ||
|
136 | $ rebasewithdag -b F -d Z <<'EOS' | |
|
137 | > F | |
|
138 | > / \ | |
|
139 | > E D | |
|
140 | > / / | |
|
141 | > Z C | |
|
142 | > \ / | |
|
143 | > B | |
|
144 | > | | |
|
145 | > A | |
|
146 | > EOS | |
|
147 | nothing to rebase | |
|
148 | [1] | |
|
149 | ||
|
150 | Multiple branching points caused by multiple bases (issue5420): | |
|
151 | ||
|
152 | $ rebasewithdag -b E1+E2+C2+B1 -d Z <<'EOS' | |
|
153 | > Z E2 | |
|
154 | > | / | |
|
155 | > F E1 C2 | |
|
156 | > |/ / | |
|
157 | > E C1 B2 | |
|
158 | > |/ / | |
|
159 | > C B1 | |
|
160 | > |/ | |
|
161 | > B | |
|
162 | > | | |
|
163 | > A | |
|
164 | > | | |
|
165 | > R | |
|
166 | > EOS | |
|
167 | rebasing 3:a113dbaa660a "B1" (B1) | |
|
168 | rebasing 5:06ce7b1cc8c2 "B2" (B2) | |
|
169 | rebasing 6:0ac98cce32d3 "C1" (C1) | |
|
170 | rebasing 8:781512f5e33d "C2" (C2) | |
|
171 | rebasing 9:428d8c18f641 "E1" (E1) | |
|
172 | rebasing 11:e1bf82f6b6df "E2" (E2) | |
|
173 | o 12: E2 | |
|
174 | | | |
|
175 | o 11: E1 | |
|
176 | | | |
|
177 | | o 10: C2 | |
|
178 | | | | |
|
179 | | o 9: C1 | |
|
180 | |/ | |
|
181 | | o 8: B2 | |
|
182 | | | | |
|
183 | | o 7: B1 | |
|
184 | |/ | |
|
185 | o 6: Z | |
|
186 | | | |
|
187 | o 5: F | |
|
188 | | | |
|
189 | o 4: E | |
|
190 | | | |
|
191 | o 3: C | |
|
192 | | | |
|
193 | o 2: B | |
|
194 | | | |
|
195 | o 1: A | |
|
196 | | | |
|
197 | o 0: R | |
|
198 | ||
|
199 | Multiple branching points with multiple merges: | |
|
200 | ||
|
201 | $ rebasewithdag -b G+P -d Z <<'EOS' | |
|
202 | > G H P | |
|
203 | > |\ /| |\ | |
|
204 | > F E D M N | |
|
205 | > \|/| /| |\ | |
|
206 | > Z C B I J K L | |
|
207 | > \|/ |/ |/ | |
|
208 | > A A A | |
|
209 | > EOS | |
|
210 | rebasing 2:dc0947a82db8 "C" (C) | |
|
211 | rebasing 8:215e7b0814e1 "D" (D) | |
|
212 | rebasing 9:03ca77807e91 "E" (E) | |
|
213 | rebasing 10:afc707c82df0 "F" (F) | |
|
214 | rebasing 13:018caa673317 "G" (G) | |
|
215 | rebasing 14:4f710fbd68cb "H" (H) | |
|
216 | rebasing 3:08ebfeb61bac "I" (I) | |
|
217 | rebasing 4:a0a5005cec67 "J" (J) | |
|
218 | rebasing 5:83780307a7e8 "K" (K) | |
|
219 | rebasing 6:e131637a1cb6 "L" (L) | |
|
220 | rebasing 11:d6fe3d11d95d "M" (M) | |
|
221 | rebasing 12:fa1e02269063 "N" (N) | |
|
222 | rebasing 15:448b1a498430 "P" (P tip) | |
|
223 | o 15: P | |
|
224 | |\ | |
|
225 | | o 14: N | |
|
226 | | |\ | |
|
227 | o \ \ 13: M | |
|
228 | |\ \ \ | |
|
229 | | | | o 12: L | |
|
230 | | | | | | |
|
231 | | | o | 11: K | |
|
232 | | | |/ | |
|
233 | | o / 10: J | |
|
234 | | |/ | |
|
235 | o / 9: I | |
|
236 | |/ | |
|
237 | | o 8: H | |
|
238 | | |\ | |
|
239 | | | | o 7: G | |
|
240 | | | |/| | |
|
241 | | | | o 6: F | |
|
242 | | | | | | |
|
243 | | | o | 5: E | |
|
244 | | | |/ | |
|
245 | | o | 4: D | |
|
246 | | |\| | |
|
247 | +---o 3: C | |
|
248 | | | | |
|
249 | o | 2: Z | |
|
250 | | | | |
|
251 | | o 1: B | |
|
252 | |/ | |
|
253 | o 0: A | |
|
254 | ||
|
255 | Slightly more complex merge case (mentioned in https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-November/091074.html): | |
|
256 | ||
|
257 | $ rebasewithdag -b A3+B3 -d Z <<'EOF' | |
|
258 | > Z C1 A3 B3 | |
|
259 | > | / / \ / \ | |
|
260 | > M3 C0 A1 A2 B1 B2 | |
|
261 | > | / | | | | | |
|
262 | > M2 M1 C1 C1 M3 | |
|
263 | > | | |
|
264 | > M1 | |
|
265 | > | | |
|
266 | > M0 | |
|
267 | > EOF | |
|
268 | rebasing 4:8817fae53c94 "C0" (C0) | |
|
269 | rebasing 6:06ca5dfe3b5b "B2" (B2) | |
|
270 | rebasing 7:73508237b032 "C1" (C1) | |
|
271 | rebasing 9:fdb955e2faed "A2" (A2) | |
|
272 | rebasing 11:1b2f368c3cb5 "A3" (A3) | |
|
273 | rebasing 10:0a33b0519128 "B1" (B1) | |
|
274 | rebasing 12:bd6a37b5b67a "B3" (B3 tip) | |
|
275 | o 12: B3 | |
|
276 | |\ | |
|
277 | | o 11: B1 | |
|
278 | | | | |
|
279 | | | o 10: A3 | |
|
280 | | | |\ | |
|
281 | | +---o 9: A2 | |
|
282 | | | | | |
|
283 | | o | 8: C1 | |
|
284 | | | | | |
|
285 | o | | 7: B2 | |
|
286 | | | | | |
|
287 | | o | 6: C0 | |
|
288 | |/ / | |
|
289 | o | 5: Z | |
|
290 | | | | |
|
291 | o | 4: M3 | |
|
292 | | | | |
|
293 | o | 3: M2 | |
|
294 | | | | |
|
295 | | o 2: A1 | |
|
296 | |/ | |
|
297 | o 1: M1 | |
|
298 | | | |
|
299 | o 0: M0 | |
|
300 | ||
|
301 | Mixed rebasable and non-rebasable bases (unresolved, issue5422): | |
|
302 | ||
|
303 | $ rebasewithdag -b C+D -d B <<'EOS' | |
|
304 | > D | |
|
305 | > / | |
|
306 | > B C | |
|
307 | > |/ | |
|
308 | > A | |
|
309 | > EOS | |
|
310 | nothing to rebase | |
|
311 | [1] | |
|
312 | ||
|
313 | Disconnected graph: | |
|
314 | ||
|
315 | $ rebasewithdag -b B -d Z <<'EOS' | |
|
316 | > B | |
|
317 | > | | |
|
318 | > Z A | |
|
319 | > EOS | |
|
320 | nothing to rebase from 112478962961 to 48b9aae0607f | |
|
321 | [1] | |
|
322 | ||
|
323 | Multiple roots. Roots are ancestors of dest: | |
|
324 | ||
|
325 | $ rebasewithdag -b B+D -d Z <<'EOF' | |
|
326 | > D Z B | |
|
327 | > \|\| | |
|
328 | > C A | |
|
329 | > EOF | |
|
330 | rebasing 2:112478962961 "B" (B) | |
|
331 | rebasing 3:b70f76719894 "D" (D) | |
|
332 | o 4: D | |
|
333 | | | |
|
334 | | o 3: B | |
|
335 | |/ | |
|
336 | o 2: Z | |
|
337 | |\ | |
|
338 | | o 1: C | |
|
339 | | | |
|
340 | o 0: A | |
|
341 | ||
|
342 | Multiple roots. One root is not an ancestor of dest: | |
|
343 | ||
|
344 | $ rebasewithdag -b B+D -d Z <<'EOF' | |
|
345 | > Z B D | |
|
346 | > \|\| | |
|
347 | > A C | |
|
348 | > EOF | |
|
349 | nothing to rebase from 86d01f49c0d9+b70f76719894 to 262e37e34f63 | |
|
350 | [1] | |
|
351 | ||
|
352 | Multiple roots. One root is not an ancestor of dest. Select using a merge: | |
|
353 | ||
|
354 | $ rebasewithdag -b E -d Z <<'EOF' | |
|
355 | > E | |
|
356 | > |\ | |
|
357 | > Z B D | |
|
358 | > \|\| | |
|
359 | > A C | |
|
360 | > EOF | |
|
361 | rebasing 2:86d01f49c0d9 "B" (B) | |
|
362 | rebasing 5:539a0ff83ea9 "E" (E tip) | |
|
363 | o 5: E | |
|
364 | |\ | |
|
365 | | o 4: B | |
|
366 | | |\ | |
|
367 | | | o 3: Z | |
|
368 | | | | | |
|
369 | o | | 2: D | |
|
370 | |/ / | |
|
371 | o / 1: C | |
|
372 | / | |
|
373 | o 0: A | |
|
374 | ||
|
375 | Multiple roots. Two children share two parents while dest has only one parent: | |
|
376 | ||
|
377 | $ rebasewithdag -b B+D -d Z <<'EOF' | |
|
378 | > Z B D | |
|
379 | > \|\|\ | |
|
380 | > A C A | |
|
381 | > EOF | |
|
382 | rebasing 2:86d01f49c0d9 "B" (B) | |
|
383 | rebasing 3:b7df2ca01aa8 "D" (D) | |
|
384 | o 4: D | |
|
385 | |\ | |
|
386 | +---o 3: B | |
|
387 | | |/ | |
|
388 | | o 2: Z | |
|
389 | | | | |
|
390 | o | 1: C | |
|
391 | / | |
|
392 | o 0: A | |
|
393 |
@@ -724,12 +724,19 b' def _definesets(ui, repo, destf=None, sr' | |||
|
724 | 724 | dest = repo[_destrebase(repo, base, destspace=destspace)] |
|
725 | 725 | destf = str(dest) |
|
726 | 726 | |
|
727 | commonanc = repo.revs('ancestor(%ld, %d)', base, dest).first() | |
|
728 | if commonanc is not None: | |
|
729 | rebaseset = repo.revs('(%d::(%ld) - %d)::', | |
|
730 | commonanc, base, commonanc) | |
|
731 | else: | |
|
732 | rebaseset = [] | |
|
727 | roots = [] # selected children of branching points | |
|
728 | bpbase = {} # {branchingpoint: [origbase]} | |
|
729 | for b in base: # group bases by branching points | |
|
730 | bp = repo.revs('ancestor(%d, %d)', b, dest).first() | |
|
731 | bpbase[bp] = bpbase.get(bp, []) + [b] | |
|
732 | if None in bpbase: | |
|
733 | # emulate the old behavior, showing "nothing to rebase" (a better | |
|
734 | # behavior may be abort with "cannot find branching point" error) | |
|
735 | bpbase.clear() | |
|
736 | for bp, bs in bpbase.iteritems(): # calculate roots | |
|
737 | roots += list(repo.revs('children(%d) & ancestors(%ld)', bp, bs)) | |
|
738 | ||
|
739 | rebaseset = repo.revs('%ld::', roots) | |
|
733 | 740 | |
|
734 | 741 | if not rebaseset: |
|
735 | 742 | # transform to list because smartsets are not comparable to |
General Comments 0
You need to be logged in to leave comments.
Login now