Show More
@@ -119,6 +119,17 b' def _revsetdestrebase(repo, subset, x):' | |||
|
119 | 119 | sourceset = revset.getset(repo, revset.fullreposet(repo), x) |
|
120 | 120 | return subset & revset.baseset([_destrebase(repo, sourceset)]) |
|
121 | 121 | |
|
122 | class rebaseruntime(object): | |
|
123 | """This class is a container for rebase runtime state""" | |
|
124 | def __init__(self): | |
|
125 | self.originalwd = None | |
|
126 | self.external = nullrev | |
|
127 | # Mapping between the old revision id and either what is the new rebased | |
|
128 | # revision or what needs to be done with the old revision. The state | |
|
129 | # dict will be what contains most of the rebase progress state. | |
|
130 | self.state = {} | |
|
131 | self.activebookmark = None | |
|
132 | ||
|
122 | 133 | @command('rebase', |
|
123 | 134 | [('s', 'source', '', |
|
124 | 135 | _('rebase the specified changeset and descendants'), _('REV')), |
@@ -229,13 +240,8 b' def rebase(ui, repo, **opts):' | |||
|
229 | 240 | unresolved conflicts. |
|
230 | 241 | |
|
231 | 242 | """ |
|
232 | originalwd = target = None | |
|
233 |
|
|
|
234 | external = nullrev | |
|
235 | # Mapping between the old revision id and either what is the new rebased | |
|
236 | # revision or what needs to be done with the old revision. The state dict | |
|
237 | # will be what contains most of the rebase progress state. | |
|
238 | state = {} | |
|
243 | rbsrt = rebaseruntime() | |
|
244 | target = None | |
|
239 | 245 | skipped = set() |
|
240 | 246 | targetancestors = set() |
|
241 | 247 | |
@@ -296,8 +302,9 b' def rebase(ui, repo, **opts):' | |||
|
296 | 302 | ui.warn(_('tool option will be ignored\n')) |
|
297 | 303 | |
|
298 | 304 | try: |
|
299 |
(originalwd, target, state, skipped, |
|
|
300 | keepbranchesf, external, activebookmark) = restorestatus(repo) | |
|
305 | (rbsrt.originalwd, target, rbsrt.state, skipped, | |
|
306 | collapsef, keepf, keepbranchesf, rbsrt.external, | |
|
307 | rbsrt.activebookmark) = restorestatus(repo) | |
|
301 | 308 | collapsemsg = restorecollapsemsg(repo) |
|
302 | 309 | except error.RepoLookupError: |
|
303 | 310 | if abortf: |
@@ -311,18 +318,17 b' def rebase(ui, repo, **opts):' | |||
|
311 | 318 | hint = _('use "hg rebase --abort" to clear broken state') |
|
312 | 319 | raise error.Abort(msg, hint=hint) |
|
313 | 320 | if abortf: |
|
314 | return abort(repo, originalwd, target, state, | |
|
315 | activebookmark=activebookmark) | |
|
321 | return abort(repo, rbsrt.originalwd, target, rbsrt.state, | |
|
322 | activebookmark=rbsrt.activebookmark) | |
|
316 | 323 | |
|
317 | 324 | obsoletenotrebased = {} |
|
318 | 325 | if ui.configbool('experimental', 'rebaseskipobsolete', |
|
319 | 326 | default=True): |
|
320 |
rebaseobsrevs = set([r for r, st |
|
|
321 |
if st |
|
|
322 | rebasesetrevs = set(state.keys()) | |
|
327 | rebaseobsrevs = set([r for r, st in rbsrt.state.items() | |
|
328 | if st == revprecursor]) | |
|
329 | rebasesetrevs = set(rbsrt.state.keys()) | |
|
323 | 330 | obsoletenotrebased = _computeobsoletenotrebased(repo, |
|
324 |
|
|
|
325 | target) | |
|
331 | rebaseobsrevs, target) | |
|
326 | 332 | rebaseobsskipped = set(obsoletenotrebased) |
|
327 | 333 | _checkobsrebase(repo, ui, rebaseobsrevs, rebasesetrevs, |
|
328 | 334 | rebaseobsskipped) |
@@ -368,11 +374,12 b' def rebase(ui, repo, **opts):' | |||
|
368 | 374 | % repo[root], |
|
369 | 375 | hint=_('see "hg help phases" for details')) |
|
370 | 376 | |
|
371 | originalwd, target, state = result | |
|
377 | (rbsrt.originalwd, target, rbsrt.state) = result | |
|
372 | 378 | if collapsef: |
|
373 | 379 | targetancestors = repo.changelog.ancestors([target], |
|
374 | 380 | inclusive=True) |
|
375 |
external = externalparent(repo, state, |
|
|
381 | rbsrt.external = externalparent(repo, rbsrt.state, | |
|
382 | targetancestors) | |
|
376 | 383 | |
|
377 | 384 | if dest.closesbranch() and not keepbranchesf: |
|
378 | 385 | ui.status(_('reopening closed branch head %s\n') % dest) |
@@ -384,7 +391,7 b' def rebase(ui, repo, **opts):' | |||
|
384 | 391 | extrafns.insert(0, _savebranch) |
|
385 | 392 | if collapsef: |
|
386 | 393 | branches = set() |
|
387 | for rev in state: | |
|
394 | for rev in rbsrt.state: | |
|
388 | 395 | branches.add(repo[rev].branch()) |
|
389 | 396 | if len(branches) > 1: |
|
390 | 397 | raise error.Abort(_('cannot collapse multiple named ' |
@@ -396,13 +403,13 b' def rebase(ui, repo, **opts):' | |||
|
396 | 403 | |
|
397 | 404 | # Keep track of the current bookmarks in order to reset them later |
|
398 | 405 | currentbookmarks = repo._bookmarks.copy() |
|
399 | activebookmark = activebookmark or repo._activebookmark | |
|
400 | if activebookmark: | |
|
406 | rbsrt.activebookmark = rbsrt.activebookmark or repo._activebookmark | |
|
407 | if rbsrt.activebookmark: | |
|
401 | 408 | bookmarks.deactivate(repo) |
|
402 | 409 | |
|
403 | 410 | extrafn = _makeextrafn(extrafns) |
|
404 | 411 | |
|
405 | sortedstate = sorted(state) | |
|
412 | sortedstate = sorted(rbsrt.state) | |
|
406 | 413 | total = len(sortedstate) |
|
407 | 414 | pos = 0 |
|
408 | 415 | for rev in sortedstate: |
@@ -413,15 +420,16 b' def rebase(ui, repo, **opts):' | |||
|
413 | 420 | if names: |
|
414 | 421 | desc += ' (%s)' % ' '.join(names) |
|
415 | 422 | pos += 1 |
|
416 | if state[rev] == revtodo: | |
|
423 | if rbsrt.state[rev] == revtodo: | |
|
417 | 424 | ui.status(_('rebasing %s\n') % desc) |
|
418 | 425 | ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, ctx)), |
|
419 | 426 | _('changesets'), total) |
|
420 | p1, p2, base = defineparents(repo, rev, target, state, | |
|
427 | p1, p2, base = defineparents(repo, rev, target, rbsrt.state, | |
|
421 | 428 | targetancestors, |
|
422 | 429 | obsoletenotrebased) |
|
423 |
storestatus(repo, originalwd, target, state, |
|
|
424 |
keepbranchesf, |
|
|
430 | storestatus(repo, rbsrt.originalwd, target, rbsrt.state, | |
|
431 | collapsef, keepf, keepbranchesf, | |
|
432 | rbsrt.external, rbsrt.activebookmark) | |
|
425 | 433 | storecollapsemsg(repo, collapsemsg) |
|
426 | 434 | if len(repo[None].parents()) == 2: |
|
427 | 435 | repo.ui.debug('resuming interrupted rebase\n') |
@@ -429,7 +437,7 b' def rebase(ui, repo, **opts):' | |||
|
429 | 437 | try: |
|
430 | 438 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
|
431 | 439 | 'rebase') |
|
432 | stats = rebasenode(repo, rev, p1, base, state, | |
|
440 | stats = rebasenode(repo, rev, p1, base, rbsrt.state, | |
|
433 | 441 | collapsef, target) |
|
434 | 442 | if stats and stats[3] > 0: |
|
435 | 443 | raise error.InterventionRequired( |
@@ -453,38 +461,38 b' def rebase(ui, repo, **opts):' | |||
|
453 | 461 | newnode = None |
|
454 | 462 | # Update the state |
|
455 | 463 | if newnode is not None: |
|
456 | state[rev] = repo[newnode].rev() | |
|
464 | rbsrt.state[rev] = repo[newnode].rev() | |
|
457 | 465 | ui.debug('rebased as %s\n' % short(newnode)) |
|
458 | 466 | else: |
|
459 | 467 | if not collapsef: |
|
460 | 468 | ui.warn(_('note: rebase of %d:%s created no changes ' |
|
461 | 469 | 'to commit\n') % (rev, ctx)) |
|
462 | 470 | skipped.add(rev) |
|
463 | state[rev] = p1 | |
|
471 | rbsrt.state[rev] = p1 | |
|
464 | 472 | ui.debug('next revision set to %s\n' % p1) |
|
465 | elif state[rev] == nullmerge: | |
|
473 | elif rbsrt.state[rev] == nullmerge: | |
|
466 | 474 | ui.debug('ignoring null merge rebase of %s\n' % rev) |
|
467 | elif state[rev] == revignored: | |
|
475 | elif rbsrt.state[rev] == revignored: | |
|
468 | 476 | ui.status(_('not rebasing ignored %s\n') % desc) |
|
469 | elif state[rev] == revprecursor: | |
|
477 | elif rbsrt.state[rev] == revprecursor: | |
|
470 | 478 | targetctx = repo[obsoletenotrebased[rev]] |
|
471 | 479 | desctarget = '%d:%s "%s"' % (targetctx.rev(), targetctx, |
|
472 | 480 | targetctx.description().split('\n', 1)[0]) |
|
473 | 481 | msg = _('note: not rebasing %s, already in destination as %s\n') |
|
474 | 482 | ui.status(msg % (desc, desctarget)) |
|
475 | elif state[rev] == revpruned: | |
|
483 | elif rbsrt.state[rev] == revpruned: | |
|
476 | 484 | msg = _('note: not rebasing %s, it has no successor\n') |
|
477 | 485 | ui.status(msg % desc) |
|
478 | 486 | else: |
|
479 | 487 | ui.status(_('already rebased %s as %s\n') % |
|
480 | (desc, repo[state[rev]])) | |
|
488 | (desc, repo[rbsrt.state[rev]])) | |
|
481 | 489 | |
|
482 | 490 | ui.progress(_('rebasing'), None) |
|
483 | 491 | ui.note(_('rebase merging completed\n')) |
|
484 | 492 | |
|
485 | 493 | if collapsef and not keepopen: |
|
486 | p1, p2, _base = defineparents(repo, min(state), target, | |
|
487 | state, targetancestors, | |
|
494 | p1, p2, _base = defineparents(repo, min(rbsrt.state), target, | |
|
495 | rbsrt.state, targetancestors, | |
|
488 | 496 | obsoletenotrebased) |
|
489 | 497 | editopt = opts.get('edit') |
|
490 | 498 | editform = 'rebase.collapse' |
@@ -492,12 +500,14 b' def rebase(ui, repo, **opts):' | |||
|
492 | 500 | commitmsg = collapsemsg |
|
493 | 501 | else: |
|
494 | 502 | commitmsg = 'Collapsed revision' |
|
495 | for rebased in state: | |
|
496 |
if rebased not in skipped and |
|
|
503 | for rebased in rbsrt.state: | |
|
504 | if rebased not in skipped and\ | |
|
505 | rbsrt.state[rebased] > nullmerge: | |
|
497 | 506 | commitmsg += '\n* %s' % repo[rebased].description() |
|
498 | 507 | editopt = True |
|
499 | 508 | editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) |
|
500 |
newnode = concludenode(repo, rev, p1, external, |
|
|
509 | newnode = concludenode(repo, rev, p1, rbsrt.external, | |
|
510 | commitmsg=commitmsg, | |
|
501 | 511 | extrafn=extrafn, editor=editor, |
|
502 | 512 | keepbranches=keepbranchesf, |
|
503 | 513 | date=date) |
@@ -505,17 +515,17 b' def rebase(ui, repo, **opts):' | |||
|
505 | 515 | newrev = target |
|
506 | 516 | else: |
|
507 | 517 | newrev = repo[newnode].rev() |
|
508 | for oldrev in state.iterkeys(): | |
|
509 | if state[oldrev] > nullmerge: | |
|
510 | state[oldrev] = newrev | |
|
518 | for oldrev in rbsrt.state.iterkeys(): | |
|
519 | if rbsrt.state[oldrev] > nullmerge: | |
|
520 | rbsrt.state[oldrev] = newrev | |
|
511 | 521 | |
|
512 | 522 | if 'qtip' in repo.tags(): |
|
513 | updatemq(repo, state, skipped, **opts) | |
|
523 | updatemq(repo, rbsrt.state, skipped, **opts) | |
|
514 | 524 | |
|
515 | 525 | if currentbookmarks: |
|
516 | 526 | # Nodeids are needed to reset bookmarks |
|
517 | 527 | nstate = {} |
|
518 | for k, v in state.iteritems(): | |
|
528 | for k, v in rbsrt.state.iteritems(): | |
|
519 | 529 | if v > nullmerge: |
|
520 | 530 | nstate[repo[k].node()] = repo[v].node() |
|
521 | 531 | # XXX this is the same as dest.node() for the non-continue path -- |
@@ -524,10 +534,10 b' def rebase(ui, repo, **opts):' | |||
|
524 | 534 | |
|
525 | 535 | # restore original working directory |
|
526 | 536 | # (we do this before stripping) |
|
527 | newwd = state.get(originalwd, originalwd) | |
|
537 | newwd = rbsrt.state.get(rbsrt.originalwd, rbsrt.originalwd) | |
|
528 | 538 | if newwd < 0: |
|
529 | 539 | # original directory is a parent of rebase set root or ignored |
|
530 | newwd = originalwd | |
|
540 | newwd = rbsrt.originalwd | |
|
531 | 541 | if newwd not in [c.rev() for c in repo[None].parents()]: |
|
532 | 542 | ui.note(_("update back to initial working directory parent\n")) |
|
533 | 543 | hg.updaterepo(repo, newwd, False) |
@@ -536,14 +546,14 b' def rebase(ui, repo, **opts):' | |||
|
536 | 546 | collapsedas = None |
|
537 | 547 | if collapsef: |
|
538 | 548 | collapsedas = newnode |
|
539 | clearrebased(ui, repo, state, skipped, collapsedas) | |
|
549 | clearrebased(ui, repo, rbsrt.state, skipped, collapsedas) | |
|
540 | 550 | |
|
541 | 551 | with repo.transaction('bookmark') as tr: |
|
542 | 552 | if currentbookmarks: |
|
543 | 553 | updatebookmarks(repo, targetnode, nstate, currentbookmarks, tr) |
|
544 | if activebookmark not in repo._bookmarks: | |
|
554 | if rbsrt.activebookmark not in repo._bookmarks: | |
|
545 | 555 | # active bookmark was divergent one and has been deleted |
|
546 | activebookmark = None | |
|
556 | rbsrt.activebookmark = None | |
|
547 | 557 | clearstatus(repo) |
|
548 | 558 | clearcollapsemsg(repo) |
|
549 | 559 | |
@@ -552,9 +562,9 b' def rebase(ui, repo, **opts):' | |||
|
552 | 562 | if skipped: |
|
553 | 563 | ui.note(_("%d revisions have been skipped\n") % len(skipped)) |
|
554 | 564 | |
|
555 | if (activebookmark and | |
|
556 | repo['.'].node() == repo._bookmarks[activebookmark]): | |
|
557 | bookmarks.activate(repo, activebookmark) | |
|
565 | if (rbsrt.activebookmark and | |
|
566 | repo['.'].node() == repo._bookmarks[rbsrt.activebookmark]): | |
|
567 | bookmarks.activate(repo, rbsrt.activebookmark) | |
|
558 | 568 | |
|
559 | 569 | finally: |
|
560 | 570 | release(lock, wlock) |
General Comments 0
You need to be logged in to leave comments.
Login now