##// END OF EJS Templates
rebase: use action variable to select things to do
Yuya Nishihara -
r39136:e9e742bd default
parent child Browse files
Show More
@@ -806,7 +806,6 b' def rebase(ui, repo, **opts):'
806 806 inmemory = ui.configbool('rebase', 'experimental.inmemory')
807 807 dryrun = opts.get('dry_run')
808 808 confirm = opts.get('confirm')
809 stop = opts.get('stop')
810 809 selactions = [k for k in ['abort', 'stop', 'continue'] if opts.get(k)]
811 810 if len(selactions) > 1:
812 811 raise error.Abort(_('cannot use --%s with --%s')
@@ -819,8 +818,7 b' def rebase(ui, repo, **opts):'
819 818 if dryrun and confirm:
820 819 raise error.Abort(_('cannot specify both --confirm and --dry-run'))
821 820
822 if (opts.get('continue') or opts.get('abort') or
823 repo.currenttransaction() is not None):
821 if action in {'abort', 'continue'} or repo.currenttransaction() is not None:
824 822 # in-memory rebase is not compatible with resuming rebases.
825 823 # (Or if it is run within a transaction, since the restart logic can
826 824 # fail the entire transaction.)
@@ -836,8 +834,8 b' def rebase(ui, repo, **opts):'
836 834 opts['dest'] = '_destautoorphanrebase(SRC)'
837 835
838 836 if dryrun or confirm:
839 return _dryrunrebase(ui, repo, opts)
840 elif stop:
837 return _dryrunrebase(ui, repo, action, opts)
838 elif action == 'stop':
841 839 rbsrt = rebaseruntime(repo, ui)
842 840 rbsrt.restorestatus()
843 841
@@ -863,16 +861,16 b' def rebase(ui, repo, **opts):'
863 861 # and re-run as an on-disk merge.
864 862 overrides = {('rebase', 'singletransaction'): True}
865 863 with ui.configoverride(overrides, 'rebase'):
866 return _dorebase(ui, repo, opts, inmemory=inmemory)
864 return _dorebase(ui, repo, action, opts, inmemory=inmemory)
867 865 except error.InMemoryMergeConflictsError:
868 866 ui.warn(_('hit merge conflicts; re-running rebase without in-memory'
869 867 ' merge\n'))
870 _dorebase(ui, repo, {'abort': True})
871 return _dorebase(ui, repo, opts, inmemory=False)
868 _dorebase(ui, repo, action='abort')
869 return _dorebase(ui, repo, action, opts, inmemory=False)
872 870 else:
873 return _dorebase(ui, repo, opts)
871 return _dorebase(ui, repo, action, opts)
874 872
875 def _dryrunrebase(ui, repo, opts):
873 def _dryrunrebase(ui, repo, action, opts):
876 874 rbsrt = rebaseruntime(repo, ui, inmemory=True, opts=opts)
877 875 confirm = opts.get('confirm')
878 876 if confirm:
@@ -885,7 +883,7 b' def _dryrunrebase(ui, repo, opts):'
885 883 try:
886 884 overrides = {('rebase', 'singletransaction'): True}
887 885 with ui.configoverride(overrides, 'rebase'):
888 _origrebase(ui, repo, opts, rbsrt, inmemory=True,
886 _origrebase(ui, repo, action, opts, rbsrt, inmemory=True,
889 887 leaveunfinished=True)
890 888 except error.InMemoryMergeConflictsError:
891 889 ui.status(_('hit a merge conflict\n'))
@@ -911,11 +909,13 b' def _dryrunrebase(ui, repo, opts):'
911 909 rbsrt._prepareabortorcontinue(isabort=True, backup=False,
912 910 suppwarns=True)
913 911
914 def _dorebase(ui, repo, opts, inmemory=False):
912 def _dorebase(ui, repo, action, opts, inmemory=False):
915 913 rbsrt = rebaseruntime(repo, ui, inmemory, opts)
916 return _origrebase(ui, repo, opts, rbsrt, inmemory=inmemory)
914 return _origrebase(ui, repo, action, opts, rbsrt, inmemory=inmemory)
917 915
918 def _origrebase(ui, repo, opts, rbsrt, inmemory=False, leaveunfinished=False):
916 def _origrebase(ui, repo, action, opts, rbsrt, inmemory=False,
917 leaveunfinished=False):
918 assert action != 'stop'
919 919 with repo.wlock(), repo.lock():
920 920 # Validate input and define rebasing points
921 921 destf = opts.get('dest', None)
@@ -925,8 +925,6 b' def _origrebase(ui, repo, opts, rbsrt, i'
925 925 # search default destination in this space
926 926 # used in the 'hg pull --rebase' case, see issue 5214.
927 927 destspace = opts.get('_destspace')
928 contf = opts.get('continue')
929 abortf = opts.get('abort')
930 928 if opts.get('interactive'):
931 929 try:
932 930 if extensions.find('histedit'):
@@ -942,20 +940,20 b' def _origrebase(ui, repo, opts, rbsrt, i'
942 940 raise error.Abort(
943 941 _('message can only be specified with collapse'))
944 942
945 if contf or abortf:
943 if action:
946 944 if rbsrt.collapsef:
947 945 raise error.Abort(
948 946 _('cannot use collapse with continue or abort'))
949 947 if srcf or basef or destf:
950 948 raise error.Abort(
951 949 _('abort and continue do not allow specifying revisions'))
952 if abortf and opts.get('tool', False):
950 if action == 'abort' and opts.get('tool', False):
953 951 ui.warn(_('tool option will be ignored\n'))
954 if contf:
952 if action == 'continue':
955 953 ms = mergemod.mergestate.read(repo)
956 954 mergeutil.checkunresolved(ms)
957 955
958 retcode = rbsrt._prepareabortorcontinue(abortf)
956 retcode = rbsrt._prepareabortorcontinue(isabort=(action == 'abort'))
959 957 if retcode is not None:
960 958 return retcode
961 959 else:
General Comments 0
You need to be logged in to leave comments. Login now