Show More
@@ -423,6 +423,93 b' class rebaseruntime(object):' | |||||
423 | ui.progress(_('rebasing'), None) |
|
423 | ui.progress(_('rebasing'), None) | |
424 | ui.note(_('rebase merging completed\n')) |
|
424 | ui.note(_('rebase merging completed\n')) | |
425 |
|
425 | |||
|
426 | def _finishrebase(self): | |||
|
427 | repo, ui, opts = self.repo, self.ui, self.opts | |||
|
428 | if self.collapsef and not self.keepopen: | |||
|
429 | p1, p2, _base = defineparents(repo, min(self.state), | |||
|
430 | self.target, self.state, | |||
|
431 | self.targetancestors, | |||
|
432 | self.obsoletenotrebased) | |||
|
433 | editopt = opts.get('edit') | |||
|
434 | editform = 'rebase.collapse' | |||
|
435 | if self.collapsemsg: | |||
|
436 | commitmsg = self.collapsemsg | |||
|
437 | else: | |||
|
438 | commitmsg = 'Collapsed revision' | |||
|
439 | for rebased in self.state: | |||
|
440 | if rebased not in self.skipped and\ | |||
|
441 | self.state[rebased] > nullmerge: | |||
|
442 | commitmsg += '\n* %s' % repo[rebased].description() | |||
|
443 | editopt = True | |||
|
444 | editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) | |||
|
445 | revtoreuse = self.sortedstate[-1] | |||
|
446 | newnode = concludenode(repo, revtoreuse, p1, self.external, | |||
|
447 | commitmsg=commitmsg, | |||
|
448 | extrafn=self.extrafn, editor=editor, | |||
|
449 | keepbranches=self.keepbranchesf, | |||
|
450 | date=self.date) | |||
|
451 | if newnode is None: | |||
|
452 | newrev = self.target | |||
|
453 | else: | |||
|
454 | newrev = repo[newnode].rev() | |||
|
455 | for oldrev in self.state.iterkeys(): | |||
|
456 | if self.state[oldrev] > nullmerge: | |||
|
457 | self.state[oldrev] = newrev | |||
|
458 | ||||
|
459 | if 'qtip' in repo.tags(): | |||
|
460 | updatemq(repo, self.state, self.skipped, **opts) | |||
|
461 | ||||
|
462 | if self.currentbookmarks: | |||
|
463 | # Nodeids are needed to reset bookmarks | |||
|
464 | nstate = {} | |||
|
465 | for k, v in self.state.iteritems(): | |||
|
466 | if v > nullmerge: | |||
|
467 | nstate[repo[k].node()] = repo[v].node() | |||
|
468 | elif v == revprecursor: | |||
|
469 | succ = self.obsoletenotrebased[k] | |||
|
470 | nstate[repo[k].node()] = repo[succ].node() | |||
|
471 | # XXX this is the same as dest.node() for the non-continue path -- | |||
|
472 | # this should probably be cleaned up | |||
|
473 | targetnode = repo[self.target].node() | |||
|
474 | ||||
|
475 | # restore original working directory | |||
|
476 | # (we do this before stripping) | |||
|
477 | newwd = self.state.get(self.originalwd, self.originalwd) | |||
|
478 | if newwd == revprecursor: | |||
|
479 | newwd = self.obsoletenotrebased[self.originalwd] | |||
|
480 | elif newwd < 0: | |||
|
481 | # original directory is a parent of rebase set root or ignored | |||
|
482 | newwd = self.originalwd | |||
|
483 | if newwd not in [c.rev() for c in repo[None].parents()]: | |||
|
484 | ui.note(_("update back to initial working directory parent\n")) | |||
|
485 | hg.updaterepo(repo, newwd, False) | |||
|
486 | ||||
|
487 | if not self.keepf: | |||
|
488 | collapsedas = None | |||
|
489 | if self.collapsef: | |||
|
490 | collapsedas = newnode | |||
|
491 | clearrebased(ui, repo, self.state, self.skipped, collapsedas) | |||
|
492 | ||||
|
493 | with repo.transaction('bookmark') as tr: | |||
|
494 | if self.currentbookmarks: | |||
|
495 | updatebookmarks(repo, targetnode, nstate, | |||
|
496 | self.currentbookmarks, tr) | |||
|
497 | if self.activebookmark not in repo._bookmarks: | |||
|
498 | # active bookmark was divergent one and has been deleted | |||
|
499 | self.activebookmark = None | |||
|
500 | clearstatus(repo) | |||
|
501 | clearcollapsemsg(repo) | |||
|
502 | ||||
|
503 | ui.note(_("rebase completed\n")) | |||
|
504 | util.unlinkpath(repo.sjoin('undo'), ignoremissing=True) | |||
|
505 | if self.skipped: | |||
|
506 | skippedlen = len(self.skipped) | |||
|
507 | ui.note(_("%d revisions have been skipped\n") % skippedlen) | |||
|
508 | ||||
|
509 | if (self.activebookmark and | |||
|
510 | repo['.'].node() == repo._bookmarks[self.activebookmark]): | |||
|
511 | bookmarks.activate(repo, self.activebookmark) | |||
|
512 | ||||
426 | @command('rebase', |
|
513 | @command('rebase', | |
427 | [('s', 'source', '', |
|
514 | [('s', 'source', '', | |
428 | _('rebase the specified changeset and descendants'), _('REV')), |
|
515 | _('rebase the specified changeset and descendants'), _('REV')), | |
@@ -588,92 +675,7 b' def rebase(ui, repo, **opts):' | |||||
588 | return retcode |
|
675 | return retcode | |
589 |
|
676 | |||
590 | rbsrt._performrebase() |
|
677 | rbsrt._performrebase() | |
591 |
|
678 | rbsrt._finishrebase() | ||
592 | if rbsrt.collapsef and not rbsrt.keepopen: |
|
|||
593 | p1, p2, _base = defineparents(repo, min(rbsrt.state), |
|
|||
594 | rbsrt.target, rbsrt.state, |
|
|||
595 | rbsrt.targetancestors, |
|
|||
596 | rbsrt.obsoletenotrebased) |
|
|||
597 | editopt = opts.get('edit') |
|
|||
598 | editform = 'rebase.collapse' |
|
|||
599 | if rbsrt.collapsemsg: |
|
|||
600 | commitmsg = rbsrt.collapsemsg |
|
|||
601 | else: |
|
|||
602 | commitmsg = 'Collapsed revision' |
|
|||
603 | for rebased in rbsrt.state: |
|
|||
604 | if rebased not in rbsrt.skipped and\ |
|
|||
605 | rbsrt.state[rebased] > nullmerge: |
|
|||
606 | commitmsg += '\n* %s' % repo[rebased].description() |
|
|||
607 | editopt = True |
|
|||
608 | editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) |
|
|||
609 | revtoreuse = rbsrt.sortedstate[-1] |
|
|||
610 | newnode = concludenode(repo, revtoreuse, p1, rbsrt.external, |
|
|||
611 | commitmsg=commitmsg, |
|
|||
612 | extrafn=rbsrt.extrafn, editor=editor, |
|
|||
613 | keepbranches=rbsrt.keepbranchesf, |
|
|||
614 | date=rbsrt.date) |
|
|||
615 | if newnode is None: |
|
|||
616 | newrev = rbsrt.target |
|
|||
617 | else: |
|
|||
618 | newrev = repo[newnode].rev() |
|
|||
619 | for oldrev in rbsrt.state.iterkeys(): |
|
|||
620 | if rbsrt.state[oldrev] > nullmerge: |
|
|||
621 | rbsrt.state[oldrev] = newrev |
|
|||
622 |
|
||||
623 | if 'qtip' in repo.tags(): |
|
|||
624 | updatemq(repo, rbsrt.state, rbsrt.skipped, **opts) |
|
|||
625 |
|
||||
626 | if rbsrt.currentbookmarks: |
|
|||
627 | # Nodeids are needed to reset bookmarks |
|
|||
628 | nstate = {} |
|
|||
629 | for k, v in rbsrt.state.iteritems(): |
|
|||
630 | if v > nullmerge: |
|
|||
631 | nstate[repo[k].node()] = repo[v].node() |
|
|||
632 | elif v == revprecursor: |
|
|||
633 | succ = rbsrt.obsoletenotrebased[k] |
|
|||
634 | nstate[repo[k].node()] = repo[succ].node() |
|
|||
635 | # XXX this is the same as dest.node() for the non-continue path -- |
|
|||
636 | # this should probably be cleaned up |
|
|||
637 | targetnode = repo[rbsrt.target].node() |
|
|||
638 |
|
||||
639 | # restore original working directory |
|
|||
640 | # (we do this before stripping) |
|
|||
641 | newwd = rbsrt.state.get(rbsrt.originalwd, rbsrt.originalwd) |
|
|||
642 | if newwd == revprecursor: |
|
|||
643 | newwd = rbsrt.obsoletenotrebased[rbsrt.originalwd] |
|
|||
644 | elif newwd < 0: |
|
|||
645 | # original directory is a parent of rebase set root or ignored |
|
|||
646 | newwd = rbsrt.originalwd |
|
|||
647 | if newwd not in [c.rev() for c in repo[None].parents()]: |
|
|||
648 | ui.note(_("update back to initial working directory parent\n")) |
|
|||
649 | hg.updaterepo(repo, newwd, False) |
|
|||
650 |
|
||||
651 | if not rbsrt.keepf: |
|
|||
652 | collapsedas = None |
|
|||
653 | if rbsrt.collapsef: |
|
|||
654 | collapsedas = newnode |
|
|||
655 | clearrebased(ui, repo, rbsrt.state, rbsrt.skipped, collapsedas) |
|
|||
656 |
|
||||
657 | with repo.transaction('bookmark') as tr: |
|
|||
658 | if rbsrt.currentbookmarks: |
|
|||
659 | updatebookmarks(repo, targetnode, nstate, |
|
|||
660 | rbsrt.currentbookmarks, tr) |
|
|||
661 | if rbsrt.activebookmark not in repo._bookmarks: |
|
|||
662 | # active bookmark was divergent one and has been deleted |
|
|||
663 | rbsrt.activebookmark = None |
|
|||
664 | clearstatus(repo) |
|
|||
665 | clearcollapsemsg(repo) |
|
|||
666 |
|
||||
667 | ui.note(_("rebase completed\n")) |
|
|||
668 | util.unlinkpath(repo.sjoin('undo'), ignoremissing=True) |
|
|||
669 | if rbsrt.skipped: |
|
|||
670 | skippedlen = len(rbsrt.skipped) |
|
|||
671 | ui.note(_("%d revisions have been skipped\n") % skippedlen) |
|
|||
672 |
|
||||
673 | if (rbsrt.activebookmark and |
|
|||
674 | repo['.'].node() == repo._bookmarks[rbsrt.activebookmark]): |
|
|||
675 | bookmarks.activate(repo, rbsrt.activebookmark) |
|
|||
676 |
|
||||
677 | finally: |
|
679 | finally: | |
678 | release(lock, wlock) |
|
680 | release(lock, wlock) | |
679 |
|
681 |
General Comments 0
You need to be logged in to leave comments.
Login now