##// END OF EJS Templates
rebase: avoid losing branch commits with --keepbranch (issue4835)
timeless@mozdev.org -
r26360:b2415e94 default
parent child Browse files
Show More
@@ -431,7 +431,8 b' def rebase(ui, repo, **opts):'
431 editform = cmdutil.mergeeditform(merging, 'rebase')
431 editform = cmdutil.mergeeditform(merging, 'rebase')
432 editor = cmdutil.getcommiteditor(editform=editform, **opts)
432 editor = cmdutil.getcommiteditor(editform=editform, **opts)
433 newnode = concludenode(repo, rev, p1, p2, extrafn=extrafn,
433 newnode = concludenode(repo, rev, p1, p2, extrafn=extrafn,
434 editor=editor)
434 editor=editor,
435 keepbranches=keepbranchesf)
435 else:
436 else:
436 # Skip commit if we are collapsing
437 # Skip commit if we are collapsing
437 repo.dirstate.beginparentchange()
438 repo.dirstate.beginparentchange()
@@ -481,7 +482,8 b' def rebase(ui, repo, **opts):'
481 editopt = True
482 editopt = True
482 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
483 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
483 newnode = concludenode(repo, rev, p1, external, commitmsg=commitmsg,
484 newnode = concludenode(repo, rev, p1, external, commitmsg=commitmsg,
484 extrafn=extrafn, editor=editor)
485 extrafn=extrafn, editor=editor,
486 keepbranches=keepbranchesf)
485 if newnode is None:
487 if newnode is None:
486 newrev = target
488 newrev = target
487 else:
489 else:
@@ -561,7 +563,8 b' def externalparent(repo, state, targetan'
561 (max(targetancestors),
563 (max(targetancestors),
562 ', '.join(str(p) for p in sorted(parents))))
564 ', '.join(str(p) for p in sorted(parents))))
563
565
564 def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None):
566 def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None,
567 keepbranches=False):
565 '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
568 '''Commit the wd changes with parents p1 and p2. Reuse commit info from rev
566 but also store useful information in extra.
569 but also store useful information in extra.
567 Return node of committed revision.'''
570 Return node of committed revision.'''
@@ -571,6 +574,7 b' def concludenode(repo, rev, p1, p2, comm'
571 ctx = repo[rev]
574 ctx = repo[rev]
572 if commitmsg is None:
575 if commitmsg is None:
573 commitmsg = ctx.description()
576 commitmsg = ctx.description()
577 keepbranch = keepbranches and repo[p1].branch() != ctx.branch()
574 extra = {'rebase_source': ctx.hex()}
578 extra = {'rebase_source': ctx.hex()}
575 if extrafn:
579 if extrafn:
576 extrafn(ctx, extra)
580 extrafn(ctx, extra)
@@ -579,6 +583,8 b' def concludenode(repo, rev, p1, p2, comm'
579 try:
583 try:
580 targetphase = max(ctx.phase(), phases.draft)
584 targetphase = max(ctx.phase(), phases.draft)
581 repo.ui.setconfig('phases', 'new-commit', targetphase, 'rebase')
585 repo.ui.setconfig('phases', 'new-commit', targetphase, 'rebase')
586 if keepbranch:
587 repo.ui.setconfig('ui', 'allowemptycommit', True)
582 # Commit might fail if unresolved files exist
588 # Commit might fail if unresolved files exist
583 newnode = repo.commit(text=commitmsg, user=ctx.user(),
589 newnode = repo.commit(text=commitmsg, user=ctx.user(),
584 date=ctx.date(), extra=extra, editor=editor)
590 date=ctx.date(), extra=extra, editor=editor)
@@ -97,7 +97,6 b' Branch name containing a dash (issue3181'
97
97
98 $ hg rebase -s dev-one -d 0 --keepbranches
98 $ hg rebase -s dev-one -d 0 --keepbranches
99 rebasing 5:643fc9128048 "dev-one named branch"
99 rebasing 5:643fc9128048 "dev-one named branch"
100 note: rebase of 5:643fc9128048 created no changes to commit
101 rebasing 6:24de4aff8e28 "F"
100 rebasing 6:24de4aff8e28 "F"
102 rebasing 7:4b988a958030 "G"
101 rebasing 7:4b988a958030 "G"
103 rebasing 8:31d0e4ba75e6 "H"
102 rebasing 8:31d0e4ba75e6 "H"
@@ -105,13 +104,15 b' Branch name containing a dash (issue3181'
105 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/643fc9128048-c4ee9ef5-backup.hg (glob)
104 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/643fc9128048-c4ee9ef5-backup.hg (glob)
106
105
107 $ hg tglog
106 $ hg tglog
108 @ 8: 'dev-two named branch' dev-two
107 @ 9: 'dev-two named branch' dev-two
109 |
108 |
110 o 7: 'H'
109 o 8: 'H'
111 |
110 |
112 | o 6: 'G'
111 | o 7: 'G'
113 |/|
112 |/|
114 o | 5: 'F'
113 o | 6: 'F'
114 | |
115 o | 5: 'dev-one named branch' dev-one
115 | |
116 | |
116 | o 4: 'E'
117 | o 4: 'E'
117 |/
118 |/
@@ -125,20 +126,23 b' Branch name containing a dash (issue3181'
125
126
126 $ hg update 3
127 $ hg update 3
127 3 files updated, 0 files merged, 3 files removed, 0 files unresolved
128 3 files updated, 0 files merged, 3 files removed, 0 files unresolved
128 $ hg branch dev-one
129 $ hg branch -f dev-one
129 marked working directory as branch dev-one
130 marked working directory as branch dev-one
130 $ hg ci -m 'dev-one named branch'
131 $ hg ci -m 'dev-one named branch'
132 created new head
131
133
132 $ hg tglog
134 $ hg tglog
133 @ 9: 'dev-one named branch' dev-one
135 @ 10: 'dev-one named branch' dev-one
134 |
136 |
135 | o 8: 'dev-two named branch' dev-two
137 | o 9: 'dev-two named branch' dev-two
138 | |
139 | o 8: 'H'
136 | |
140 | |
137 | o 7: 'H'
141 | | o 7: 'G'
138 | |
139 | | o 6: 'G'
140 | |/|
142 | |/|
141 | o | 5: 'F'
143 | o | 6: 'F'
144 | | |
145 | o | 5: 'dev-one named branch' dev-one
142 | | |
146 | | |
143 | | o 4: 'E'
147 | | o 4: 'E'
144 | |/
148 | |/
@@ -151,11 +155,13 b' Branch name containing a dash (issue3181'
151 o 0: 'A'
155 o 0: 'A'
152
156
153 $ hg rebase -b 'max(branch("dev-two"))' -d dev-one --keepbranches
157 $ hg rebase -b 'max(branch("dev-two"))' -d dev-one --keepbranches
154 rebasing 5:77854864208c "F"
158 rebasing 5:bc8139ee757c "dev-one named branch"
155 rebasing 6:63b4f9c788a1 "G"
159 note: rebase of 5:bc8139ee757c created no changes to commit
156 rebasing 7:87861e68abd3 "H"
160 rebasing 6:42aa3cf0fa7a "F"
157 rebasing 8:ec00d4e0efca "dev-two named branch"
161 rebasing 7:1a1e6f72ec38 "G"
158 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/77854864208c-74d59436-backup.hg (glob)
162 rebasing 8:904590360559 "H"
163 rebasing 9:59c2e59309fe "dev-two named branch"
164 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/bc8139ee757c-f11c1080-backup.hg (glob)
159
165
160 $ hg tglog
166 $ hg tglog
161 o 9: 'dev-two named branch' dev-two
167 o 9: 'dev-two named branch' dev-two
@@ -180,21 +186,22 b' Branch name containing a dash (issue3181'
180
186
181 $ hg rebase -s 'max(branch("dev-one"))' -d 0 --keepbranches
187 $ hg rebase -s 'max(branch("dev-one"))' -d 0 --keepbranches
182 rebasing 5:643fc9128048 "dev-one named branch"
188 rebasing 5:643fc9128048 "dev-one named branch"
183 note: rebase of 5:643fc9128048 created no changes to commit
189 rebasing 6:679f28760620 "F"
184 rebasing 6:05584c618d45 "F"
190 rebasing 7:549f007a9f5f "G"
185 rebasing 7:471695f5257d "G"
191 rebasing 8:12b2bc666e20 "H"
186 rebasing 8:8382a539a2df "H"
192 rebasing 9:71325f8bc082 "dev-two named branch" (tip)
187 rebasing 9:11f718458b32 "dev-two named branch" (tip)
193 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/643fc9128048-6cdd1a52-backup.hg (glob)
188 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/643fc9128048-177f3c5c-backup.hg (glob)
189
194
190 $ hg tglog
195 $ hg tglog
191 o 8: 'dev-two named branch' dev-two
196 o 9: 'dev-two named branch' dev-two
192 |
197 |
193 o 7: 'H'
198 o 8: 'H'
194 |
199 |
195 | o 6: 'G'
200 | o 7: 'G'
196 |/|
201 |/|
197 o | 5: 'F'
202 o | 6: 'F'
203 | |
204 @ | 5: 'dev-one named branch' dev-one
198 | |
205 | |
199 | o 4: 'E'
206 | o 4: 'E'
200 |/
207 |/
@@ -204,61 +211,66 b' Branch name containing a dash (issue3181'
204 | |
211 | |
205 | o 1: 'B'
212 | o 1: 'B'
206 |/
213 |/
207 @ 0: 'A'
214 o 0: 'A'
208
215
216 $ hg up -r 0 > /dev/null
209
217
210 Rebasing descendant onto ancestor across different named branches
218 Rebasing descendant onto ancestor across different named branches
211
219
212 $ hg rebase -s 1 -d 8 --keepbranches
220 $ hg rebase -s 1 -d 9 --keepbranches
213 rebasing 1:42ccdea3bb16 "B"
221 rebasing 1:42ccdea3bb16 "B"
214 rebasing 2:5fddd98957c8 "C"
222 rebasing 2:5fddd98957c8 "C"
215 rebasing 3:32af7686d403 "D"
223 rebasing 3:32af7686d403 "D"
216 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/42ccdea3bb16-3cb021d3-backup.hg (glob)
224 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/42ccdea3bb16-3cb021d3-backup.hg (glob)
217
225
218 $ hg tglog
226 $ hg tglog
219 o 8: 'D'
227 o 9: 'D'
228 |
229 o 8: 'C'
220 |
230 |
221 o 7: 'C'
231 o 7: 'B'
222 |
232 |
223 o 6: 'B'
233 o 6: 'dev-two named branch' dev-two
224 |
234 |
225 o 5: 'dev-two named branch' dev-two
235 o 5: 'H'
226 |
227 o 4: 'H'
228 |
236 |
229 | o 3: 'G'
237 | o 4: 'G'
230 |/|
238 |/|
231 o | 2: 'F'
239 o | 3: 'F'
240 | |
241 o | 2: 'dev-one named branch' dev-one
232 | |
242 | |
233 | o 1: 'E'
243 | o 1: 'E'
234 |/
244 |/
235 @ 0: 'A'
245 @ 0: 'A'
236
246
237 $ hg rebase -s 4 -d 5
247 $ hg rebase -s 5 -d 6
238 abort: source is ancestor of destination
248 abort: source is ancestor of destination
239 [255]
249 [255]
240
250
241 $ hg rebase -s 5 -d 4
251 $ hg rebase -s 6 -d 5
242 rebasing 5:32d3b0de7f37 "dev-two named branch"
252 rebasing 6:3944801ae4ea "dev-two named branch"
243 rebasing 6:580fcd9fd48f "B"
253 rebasing 7:3bdb949809d9 "B"
244 rebasing 7:32aba0402ed2 "C"
254 rebasing 8:a0d543090fa4 "C"
245 rebasing 8:e4787b575338 "D" (tip)
255 rebasing 9:e9f862ce8bad "D" (tip)
246 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/32d3b0de7f37-c37815ca-backup.hg (glob)
256 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/3944801ae4ea-fb46ed74-backup.hg (glob)
247
257
248 $ hg tglog
258 $ hg tglog
249 o 8: 'D'
259 o 9: 'D'
260 |
261 o 8: 'C'
250 |
262 |
251 o 7: 'C'
263 o 7: 'B'
252 |
264 |
253 o 6: 'B'
265 o 6: 'dev-two named branch'
254 |
266 |
255 o 5: 'dev-two named branch'
267 o 5: 'H'
256 |
257 o 4: 'H'
258 |
268 |
259 | o 3: 'G'
269 | o 4: 'G'
260 |/|
270 |/|
261 o | 2: 'F'
271 o | 3: 'F'
272 | |
273 o | 2: 'dev-one named branch' dev-one
262 | |
274 | |
263 | o 1: 'E'
275 | o 1: 'E'
264 |/
276 |/
@@ -272,13 +284,13 b' Reopen branch by rebase'
272 $ hg ci -m 'create b'
284 $ hg ci -m 'create b'
273 $ hg ci -m 'close b' --close
285 $ hg ci -m 'close b' --close
274 $ hg rebase -b 8 -d b
286 $ hg rebase -b 8 -d b
275 reopening closed branch head ea9de14a36c6
287 reopening closed branch head 2b586e70108d
276 rebasing 4:86693275b2ef "H"
288 rebasing 5:8e279d293175 "H"
277 rebasing 5:2149726d0970 "dev-two named branch"
289 rebasing 6:c57724c84928 "dev-two named branch"
278 rebasing 6:81e55225e95d "B"
290 rebasing 7:160b0930ccc6 "B"
279 rebasing 7:09eda3dc3195 "C"
291 rebasing 8:810110211f50 "C"
280 rebasing 8:31298fc9d159 "D"
292 rebasing 9:e522577ccdbd "D"
281 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/86693275b2ef-f9fcf4e2-backup.hg (glob)
293 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/8e279d293175-b023e27c-backup.hg (glob)
282
294
283 $ cd ..
295 $ cd ..
284
296
General Comments 0
You need to be logged in to leave comments. Login now