Mercurial > hg
comparison hgext/rebase.py @ 39093:cc37009e95ca
rebase: add --stop option to stop rebase at any point (issue5206)
Before this patch, during a rebase if you get a point where you can't
figure out what to do next, then either you had to complete your series
or abandon all the work you have done during this rebase.
Now, with this feature you can stop at any point by keeping the rebased
csets and mark original csets as obsolete. And if you don't have evolution
extension enabled then you can use --keep option as an alternative which
will keep original csets too, instead of marking them obsolete.
Differential Revision: https://phab.mercurial-scm.org/D3959
author | Sushil khanchi <sushilkhanchi97@gmail.com> |
---|---|
date | Wed, 18 Jul 2018 00:25:52 +0530 |
parents | 2b728789edfd |
children | 2cf0b8b830ba |
comparison
equal
deleted
inserted
replaced
39092:8943c1352b6c | 39093:cc37009e95ca |
---|---|
671 ('k', 'keep', False, _('keep original changesets')), | 671 ('k', 'keep', False, _('keep original changesets')), |
672 ('', 'keepbranches', False, _('keep original branch names')), | 672 ('', 'keepbranches', False, _('keep original branch names')), |
673 ('D', 'detach', False, _('(DEPRECATED)')), | 673 ('D', 'detach', False, _('(DEPRECATED)')), |
674 ('i', 'interactive', False, _('(DEPRECATED)')), | 674 ('i', 'interactive', False, _('(DEPRECATED)')), |
675 ('t', 'tool', '', _('specify merge tool')), | 675 ('t', 'tool', '', _('specify merge tool')), |
676 ('', 'stop', False, _('stop interrupted rebase')), | |
676 ('c', 'continue', False, _('continue an interrupted rebase')), | 677 ('c', 'continue', False, _('continue an interrupted rebase')), |
677 ('a', 'abort', False, _('abort an interrupted rebase')), | 678 ('a', 'abort', False, _('abort an interrupted rebase')), |
678 ('', 'auto-orphans', '', _('automatically rebase orphan revisions ' | 679 ('', 'auto-orphans', '', _('automatically rebase orphan revisions ' |
679 'in the specified revset (EXPERIMENTAL)')), | 680 'in the specified revset (EXPERIMENTAL)')), |
680 ] + cmdutil.dryrunopts + cmdutil.formatteropts + cmdutil.confirmopts, | 681 ] + cmdutil.dryrunopts + cmdutil.formatteropts + cmdutil.confirmopts, |
801 | 802 |
802 """ | 803 """ |
803 opts = pycompat.byteskwargs(opts) | 804 opts = pycompat.byteskwargs(opts) |
804 inmemory = ui.configbool('rebase', 'experimental.inmemory') | 805 inmemory = ui.configbool('rebase', 'experimental.inmemory') |
805 dryrun = opts.get('dry_run') | 806 dryrun = opts.get('dry_run') |
807 stop = opts.get('stop') | |
806 if dryrun: | 808 if dryrun: |
807 if opts.get('abort'): | 809 if opts.get('abort'): |
808 raise error.Abort(_('cannot specify both --dry-run and --abort')) | 810 raise error.Abort(_('cannot specify both --dry-run and --abort')) |
809 if opts.get('continue'): | 811 if opts.get('continue'): |
810 raise error.Abort(_('cannot specify both --dry-run and --continue')) | 812 raise error.Abort(_('cannot specify both --dry-run and --continue')) |
833 opts['rev'] = [revsetlang.formatspec('%ld and orphan()', userrevs)] | 835 opts['rev'] = [revsetlang.formatspec('%ld and orphan()', userrevs)] |
834 opts['dest'] = '_destautoorphanrebase(SRC)' | 836 opts['dest'] = '_destautoorphanrebase(SRC)' |
835 | 837 |
836 if dryrun: | 838 if dryrun: |
837 return _dryrunrebase(ui, repo, opts) | 839 return _dryrunrebase(ui, repo, opts) |
840 elif stop: | |
841 rbsrt = rebaseruntime(repo, ui) | |
842 rbsrt.restorestatus() | |
843 | |
844 #todo: raise error for conflicting options | |
845 if rbsrt.collapsef: | |
846 raise error.Abort(_("cannot stop in --collapse session")) | |
847 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt) | |
848 if not (rbsrt.keepf or allowunstable): | |
849 raise error.Abort(_("cannot remove original changesets with" | |
850 " unrebased descendants"), | |
851 hint=_('either enable obsmarkers to allow unstable ' | |
852 'revisions or use --keep to keep original ' | |
853 'changesets')) | |
854 with repo.wlock(), repo.lock(): | |
855 if needupdate(repo, rbsrt.state): | |
856 # update to the current working revision | |
857 # to clear interrupted merge | |
858 hg.updaterepo(repo, rbsrt.originalwd, overwrite=True) | |
859 rbsrt._finishrebase() | |
860 return 0 | |
838 elif inmemory: | 861 elif inmemory: |
839 try: | 862 try: |
840 # in-memory merge doesn't support conflicts, so if we hit any, abort | 863 # in-memory merge doesn't support conflicts, so if we hit any, abort |
841 # and re-run as an on-disk merge. | 864 # and re-run as an on-disk merge. |
842 overrides = {('rebase', 'singletransaction'): True} | 865 overrides = {('rebase', 'singletransaction'): True} |