151 self.keepf = opts.get('keep', False) |
151 self.keepf = opts.get('keep', False) |
152 self.keepbranchesf = opts.get('keepbranches', False) |
152 self.keepbranchesf = opts.get('keepbranches', False) |
153 # keepopen is not meant for use on the command line, but by |
153 # keepopen is not meant for use on the command line, but by |
154 # other extensions |
154 # other extensions |
155 self.keepopen = opts.get('keepopen', False) |
155 self.keepopen = opts.get('keepopen', False) |
|
156 self.obsoletenotrebased = {} |
156 |
157 |
157 def restorestatus(self): |
158 def restorestatus(self): |
158 """Restore a previously stored status""" |
159 """Restore a previously stored status""" |
159 repo = self.repo |
160 repo = self.repo |
160 keepbranches = None |
161 keepbranches = None |
397 if abortf: |
398 if abortf: |
398 return abort(repo, rbsrt.originalwd, rbsrt.target, |
399 return abort(repo, rbsrt.originalwd, rbsrt.target, |
399 rbsrt.state, |
400 rbsrt.state, |
400 activebookmark=rbsrt.activebookmark) |
401 activebookmark=rbsrt.activebookmark) |
401 |
402 |
402 obsoletenotrebased = {} |
403 rbsrt.obsoletenotrebased = {} |
403 if ui.configbool('experimental', 'rebaseskipobsolete', |
404 if ui.configbool('experimental', 'rebaseskipobsolete', |
404 default=True): |
405 default=True): |
405 rebaseobsrevs = set([r for r, st in rbsrt.state.items() |
406 rebaseobsrevs = set([r for r, st in rbsrt.state.items() |
406 if st == revprecursor]) |
407 if st == revprecursor]) |
407 rebasesetrevs = set(rbsrt.state.keys()) |
408 rebasesetrevs = set(rbsrt.state.keys()) |
408 obsoletenotrebased = _computeobsoletenotrebased(repo, |
409 rbsrt.obsoletenotrebased = _computeobsoletenotrebased(repo, |
409 rebaseobsrevs, rbsrt.target) |
410 rebaseobsrevs, rbsrt.target) |
410 rebaseobsskipped = set(obsoletenotrebased) |
411 rebaseobsskipped = set(rbsrt.obsoletenotrebased) |
411 _checkobsrebase(repo, ui, rebaseobsrevs, rebasesetrevs, |
412 _checkobsrebase(repo, ui, rebaseobsrevs, rebasesetrevs, |
412 rebaseobsskipped) |
413 rebaseobsskipped) |
413 else: |
414 else: |
414 dest, rebaseset = _definesets(ui, repo, destf, srcf, basef, revf, |
415 dest, rebaseset = _definesets(ui, repo, destf, srcf, basef, revf, |
415 destspace=destspace) |
416 destspace=destspace) |
423 raise error.Abort( |
424 raise error.Abort( |
424 _("can't remove original changesets with" |
425 _("can't remove original changesets with" |
425 " unrebased descendants"), |
426 " unrebased descendants"), |
426 hint=_('use --keep to keep original changesets')) |
427 hint=_('use --keep to keep original changesets')) |
427 |
428 |
428 obsoletenotrebased = {} |
429 rbsrt.obsoletenotrebased = {} |
429 if ui.configbool('experimental', 'rebaseskipobsolete', |
430 if ui.configbool('experimental', 'rebaseskipobsolete', |
430 default=True): |
431 default=True): |
431 rebasesetrevs = set(rebaseset) |
432 rebasesetrevs = set(rebaseset) |
432 rebaseobsrevs = _filterobsoleterevs(repo, rebasesetrevs) |
433 rebaseobsrevs = _filterobsoleterevs(repo, rebasesetrevs) |
433 obsoletenotrebased = _computeobsoletenotrebased(repo, |
434 rbsrt.obsoletenotrebased = _computeobsoletenotrebased(repo, |
434 rebaseobsrevs, |
435 rebaseobsrevs, |
435 dest) |
436 dest) |
436 rebaseobsskipped = set(obsoletenotrebased) |
437 rebaseobsskipped = set(rbsrt.obsoletenotrebased) |
437 _checkobsrebase(repo, ui, rebaseobsrevs, |
438 _checkobsrebase(repo, ui, rebaseobsrevs, |
438 rebasesetrevs, |
439 rebasesetrevs, |
439 rebaseobsskipped) |
440 rebaseobsskipped) |
440 |
441 |
441 result = buildstate(repo, dest, rebaseset, rbsrt.collapsef, |
442 result = buildstate(repo, dest, rebaseset, rbsrt.collapsef, |
442 obsoletenotrebased) |
443 rbsrt.obsoletenotrebased) |
443 |
444 |
444 if not result: |
445 if not result: |
445 # Empty state built, nothing to rebase |
446 # Empty state built, nothing to rebase |
446 ui.status(_('nothing to rebase\n')) |
447 ui.status(_('nothing to rebase\n')) |
447 return _nothingtorebase() |
448 return _nothingtorebase() |
504 ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, ctx)), |
505 ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, ctx)), |
505 _('changesets'), total) |
506 _('changesets'), total) |
506 p1, p2, base = defineparents(repo, rev, rbsrt.target, |
507 p1, p2, base = defineparents(repo, rev, rbsrt.target, |
507 rbsrt.state, |
508 rbsrt.state, |
508 rbsrt.targetancestors, |
509 rbsrt.targetancestors, |
509 obsoletenotrebased) |
510 rbsrt.obsoletenotrebased) |
510 storestatus(repo, rbsrt.originalwd, rbsrt.target, |
511 storestatus(repo, rbsrt.originalwd, rbsrt.target, |
511 rbsrt.state, rbsrt.collapsef, rbsrt.keepf, |
512 rbsrt.state, rbsrt.collapsef, rbsrt.keepf, |
512 rbsrt.keepbranchesf, rbsrt.external, |
513 rbsrt.keepbranchesf, rbsrt.external, |
513 rbsrt.activebookmark) |
514 rbsrt.activebookmark) |
514 storecollapsemsg(repo, rbsrt.collapsemsg) |
515 storecollapsemsg(repo, rbsrt.collapsemsg) |
554 elif rbsrt.state[rev] == nullmerge: |
555 elif rbsrt.state[rev] == nullmerge: |
555 ui.debug('ignoring null merge rebase of %s\n' % rev) |
556 ui.debug('ignoring null merge rebase of %s\n' % rev) |
556 elif rbsrt.state[rev] == revignored: |
557 elif rbsrt.state[rev] == revignored: |
557 ui.status(_('not rebasing ignored %s\n') % desc) |
558 ui.status(_('not rebasing ignored %s\n') % desc) |
558 elif rbsrt.state[rev] == revprecursor: |
559 elif rbsrt.state[rev] == revprecursor: |
559 targetctx = repo[obsoletenotrebased[rev]] |
560 targetctx = repo[rbsrt.obsoletenotrebased[rev]] |
560 desctarget = '%d:%s "%s"' % (targetctx.rev(), targetctx, |
561 desctarget = '%d:%s "%s"' % (targetctx.rev(), targetctx, |
561 targetctx.description().split('\n', 1)[0]) |
562 targetctx.description().split('\n', 1)[0]) |
562 msg = _('note: not rebasing %s, already in destination as %s\n') |
563 msg = _('note: not rebasing %s, already in destination as %s\n') |
563 ui.status(msg % (desc, desctarget)) |
564 ui.status(msg % (desc, desctarget)) |
564 elif rbsrt.state[rev] == revpruned: |
565 elif rbsrt.state[rev] == revpruned: |
573 |
574 |
574 if rbsrt.collapsef and not rbsrt.keepopen: |
575 if rbsrt.collapsef and not rbsrt.keepopen: |
575 p1, p2, _base = defineparents(repo, min(rbsrt.state), |
576 p1, p2, _base = defineparents(repo, min(rbsrt.state), |
576 rbsrt.target, rbsrt.state, |
577 rbsrt.target, rbsrt.state, |
577 rbsrt.targetancestors, |
578 rbsrt.targetancestors, |
578 obsoletenotrebased) |
579 rbsrt.obsoletenotrebased) |
579 editopt = opts.get('edit') |
580 editopt = opts.get('edit') |
580 editform = 'rebase.collapse' |
581 editform = 'rebase.collapse' |
581 if rbsrt.collapsemsg: |
582 if rbsrt.collapsemsg: |
582 commitmsg = rbsrt.collapsemsg |
583 commitmsg = rbsrt.collapsemsg |
583 else: |
584 else: |
609 nstate = {} |
610 nstate = {} |
610 for k, v in rbsrt.state.iteritems(): |
611 for k, v in rbsrt.state.iteritems(): |
611 if v > nullmerge: |
612 if v > nullmerge: |
612 nstate[repo[k].node()] = repo[v].node() |
613 nstate[repo[k].node()] = repo[v].node() |
613 elif v == revprecursor: |
614 elif v == revprecursor: |
614 succ = obsoletenotrebased[k] |
615 succ = rbsrt.obsoletenotrebased[k] |
615 nstate[repo[k].node()] = repo[succ].node() |
616 nstate[repo[k].node()] = repo[succ].node() |
616 # XXX this is the same as dest.node() for the non-continue path -- |
617 # XXX this is the same as dest.node() for the non-continue path -- |
617 # this should probably be cleaned up |
618 # this should probably be cleaned up |
618 targetnode = repo[rbsrt.target].node() |
619 targetnode = repo[rbsrt.target].node() |
619 |
620 |
620 # restore original working directory |
621 # restore original working directory |
621 # (we do this before stripping) |
622 # (we do this before stripping) |
622 newwd = rbsrt.state.get(rbsrt.originalwd, rbsrt.originalwd) |
623 newwd = rbsrt.state.get(rbsrt.originalwd, rbsrt.originalwd) |
623 if newwd == revprecursor: |
624 if newwd == revprecursor: |
624 newwd = obsoletenotrebased[rbsrt.originalwd] |
625 newwd = rbsrt.obsoletenotrebased[rbsrt.originalwd] |
625 elif newwd < 0: |
626 elif newwd < 0: |
626 # original directory is a parent of rebase set root or ignored |
627 # original directory is a parent of rebase set root or ignored |
627 newwd = rbsrt.originalwd |
628 newwd = rbsrt.originalwd |
628 if newwd not in [c.rev() for c in repo[None].parents()]: |
629 if newwd not in [c.rev() for c in repo[None].parents()]: |
629 ui.note(_("update back to initial working directory parent\n")) |
630 ui.note(_("update back to initial working directory parent\n")) |