Mercurial > hg
comparison hgext/rebase.py @ 38816:2b728789edfd
rebase: move "backup" flag to rebaseruntime
It was getting messy to populate "backup" flag to calls
of `_finishrebase()` and `_prepareabortorcontinue`, so
made some changes to move "backup" flag to rbsrt.
Differential Revision: https://phab.mercurial-scm.org/D4055
author | Sushil khanchi <sushilkhanchi97@gmail.com> |
---|---|
date | Fri, 03 Aug 2018 00:10:52 +0530 |
parents | 2002c193f2bc |
children | cc37009e95ca |
comparison
equal
deleted
inserted
replaced
38815:617ae7e33a65 | 38816:2b728789edfd |
---|---|
175 e = opts.get('extrafn') # internal, used by e.g. hgsubversion | 175 e = opts.get('extrafn') # internal, used by e.g. hgsubversion |
176 self.extrafns = [_savegraft] | 176 self.extrafns = [_savegraft] |
177 if e: | 177 if e: |
178 self.extrafns = [e] | 178 self.extrafns = [e] |
179 | 179 |
180 self.backupf = ui.configbool('ui', 'history-editing-backup') | |
180 self.keepf = opts.get('keep', False) | 181 self.keepf = opts.get('keep', False) |
181 self.keepbranchesf = opts.get('keepbranches', False) | 182 self.keepbranchesf = opts.get('keepbranches', False) |
182 self.obsoletenotrebased = {} | 183 self.obsoletenotrebased = {} |
183 self.obsoletewithoutsuccessorindestination = set() | 184 self.obsoletewithoutsuccessorindestination = set() |
184 self.inmemory = inmemory | 185 self.inmemory = inmemory |
341 return 0 | 342 return 0 |
342 else: | 343 else: |
343 msg = _('cannot continue inconsistent rebase') | 344 msg = _('cannot continue inconsistent rebase') |
344 hint = _('use "hg rebase --abort" to clear broken state') | 345 hint = _('use "hg rebase --abort" to clear broken state') |
345 raise error.Abort(msg, hint=hint) | 346 raise error.Abort(msg, hint=hint) |
347 | |
346 if isabort: | 348 if isabort: |
349 backup = backup and self.backupf | |
347 return abort(self.repo, self.originalwd, self.destmap, self.state, | 350 return abort(self.repo, self.originalwd, self.destmap, self.state, |
348 activebookmark=self.activebookmark, backup=backup, | 351 activebookmark=self.activebookmark, backup=backup, |
349 suppwarns=suppwarns) | 352 suppwarns=suppwarns) |
350 | 353 |
351 def _preparenewrebase(self, destmap): | 354 def _preparenewrebase(self, destmap): |
583 # commit is completely done. On InterventionRequired, we thus | 586 # commit is completely done. On InterventionRequired, we thus |
584 # won't store the status. Instead, we'll hit the "len(parents) == 2" | 587 # won't store the status. Instead, we'll hit the "len(parents) == 2" |
585 # case and realize that the commit was in progress. | 588 # case and realize that the commit was in progress. |
586 self.storestatus() | 589 self.storestatus() |
587 | 590 |
588 def _finishrebase(self, backup=True): | 591 def _finishrebase(self): |
589 """ | |
590 backup: if False, no backup will be stored when stripping rebased | |
591 revisions | |
592 """ | |
593 repo, ui, opts = self.repo, self.ui, self.opts | 592 repo, ui, opts = self.repo, self.ui, self.opts |
594 fm = ui.formatter('rebase', opts) | 593 fm = ui.formatter('rebase', opts) |
595 fm.startitem() | 594 fm.startitem() |
596 if self.collapsef: | 595 if self.collapsef: |
597 p1, p2, _base = defineparents(repo, min(self.state), self.destmap, | 596 p1, p2, _base = defineparents(repo, min(self.state), self.destmap, |
634 | 633 |
635 collapsedas = None | 634 collapsedas = None |
636 if self.collapsef and not self.keepf: | 635 if self.collapsef and not self.keepf: |
637 collapsedas = newnode | 636 collapsedas = newnode |
638 clearrebased(ui, repo, self.destmap, self.state, self.skipped, | 637 clearrebased(ui, repo, self.destmap, self.state, self.skipped, |
639 collapsedas, self.keepf, fm=fm, backup=backup) | 638 collapsedas, self.keepf, fm=fm, backup=self.backupf) |
640 | 639 |
641 clearstatus(repo) | 640 clearstatus(repo) |
642 clearcollapsemsg(repo) | 641 clearcollapsemsg(repo) |
643 | 642 |
644 ui.note(_("rebase completed\n")) | 643 ui.note(_("rebase completed\n")) |
831 raise error.Abort(_('--auto-orphans is incompatible with %s') % | 830 raise error.Abort(_('--auto-orphans is incompatible with %s') % |
832 ('--' + key)) | 831 ('--' + key)) |
833 userrevs = list(repo.revs(opts.get('auto_orphans'))) | 832 userrevs = list(repo.revs(opts.get('auto_orphans'))) |
834 opts['rev'] = [revsetlang.formatspec('%ld and orphan()', userrevs)] | 833 opts['rev'] = [revsetlang.formatspec('%ld and orphan()', userrevs)] |
835 opts['dest'] = '_destautoorphanrebase(SRC)' | 834 opts['dest'] = '_destautoorphanrebase(SRC)' |
836 backup = ui.configbool('ui', 'history-editing-backup') | |
837 opts['backup'] = backup | |
838 | 835 |
839 if dryrun: | 836 if dryrun: |
840 return _dryrunrebase(ui, repo, opts) | 837 return _dryrunrebase(ui, repo, opts) |
841 elif inmemory: | 838 elif inmemory: |
842 try: | 839 try: |
854 return _dorebase(ui, repo, opts) | 851 return _dorebase(ui, repo, opts) |
855 | 852 |
856 def _dryrunrebase(ui, repo, opts): | 853 def _dryrunrebase(ui, repo, opts): |
857 rbsrt = rebaseruntime(repo, ui, inmemory=True, opts=opts) | 854 rbsrt = rebaseruntime(repo, ui, inmemory=True, opts=opts) |
858 confirm = opts.get('confirm') | 855 confirm = opts.get('confirm') |
859 backup = opts.get('backup') | |
860 if confirm: | 856 if confirm: |
861 ui.status(_('starting in-memory rebase\n')) | 857 ui.status(_('starting in-memory rebase\n')) |
862 else: | 858 else: |
863 ui.status(_('starting dry-run rebase; repository will not be ' | 859 ui.status(_('starting dry-run rebase; repository will not be ' |
864 'changed\n')) | 860 'changed\n')) |
876 if confirm: | 872 if confirm: |
877 ui.status(_('rebase completed successfully\n')) | 873 ui.status(_('rebase completed successfully\n')) |
878 if not ui.promptchoice(_(b'apply changes (yn)?' | 874 if not ui.promptchoice(_(b'apply changes (yn)?' |
879 b'$$ &Yes $$ &No')): | 875 b'$$ &Yes $$ &No')): |
880 # finish unfinished rebase | 876 # finish unfinished rebase |
881 rbsrt._finishrebase(backup=backup) | 877 rbsrt._finishrebase() |
882 else: | 878 else: |
883 rbsrt._prepareabortorcontinue(isabort=True, backup=False, | 879 rbsrt._prepareabortorcontinue(isabort=True, backup=False, |
884 suppwarns=True) | 880 suppwarns=True) |
885 needsabort = False | 881 needsabort = False |
886 else: | 882 else: |
907 # search default destination in this space | 903 # search default destination in this space |
908 # used in the 'hg pull --rebase' case, see issue 5214. | 904 # used in the 'hg pull --rebase' case, see issue 5214. |
909 destspace = opts.get('_destspace') | 905 destspace = opts.get('_destspace') |
910 contf = opts.get('continue') | 906 contf = opts.get('continue') |
911 abortf = opts.get('abort') | 907 abortf = opts.get('abort') |
912 backup = opts.get('backup') | |
913 if opts.get('interactive'): | 908 if opts.get('interactive'): |
914 try: | 909 try: |
915 if extensions.find('histedit'): | 910 if extensions.find('histedit'): |
916 enablehistedit = '' | 911 enablehistedit = '' |
917 except KeyError: | 912 except KeyError: |
938 ui.warn(_('tool option will be ignored\n')) | 933 ui.warn(_('tool option will be ignored\n')) |
939 if contf: | 934 if contf: |
940 ms = mergemod.mergestate.read(repo) | 935 ms = mergemod.mergestate.read(repo) |
941 mergeutil.checkunresolved(ms) | 936 mergeutil.checkunresolved(ms) |
942 | 937 |
943 retcode = rbsrt._prepareabortorcontinue(abortf, backup=backup) | 938 retcode = rbsrt._prepareabortorcontinue(abortf) |
944 if retcode is not None: | 939 if retcode is not None: |
945 return retcode | 940 return retcode |
946 else: | 941 else: |
947 destmap = _definedestmap(ui, repo, inmemory, destf, srcf, basef, | 942 destmap = _definedestmap(ui, repo, inmemory, destf, srcf, basef, |
948 revf, destspace=destspace) | 943 revf, destspace=destspace) |
967 if singletr and not inmemory: | 962 if singletr and not inmemory: |
968 dsguard = dirstateguard.dirstateguard(repo, 'rebase') | 963 dsguard = dirstateguard.dirstateguard(repo, 'rebase') |
969 with util.acceptintervention(dsguard): | 964 with util.acceptintervention(dsguard): |
970 rbsrt._performrebase(tr) | 965 rbsrt._performrebase(tr) |
971 if not leaveunfinished: | 966 if not leaveunfinished: |
972 rbsrt._finishrebase(backup=backup) | 967 rbsrt._finishrebase() |
973 | 968 |
974 def _definedestmap(ui, repo, inmemory, destf=None, srcf=None, basef=None, | 969 def _definedestmap(ui, repo, inmemory, destf=None, srcf=None, basef=None, |
975 revf=None, destspace=None): | 970 revf=None, destspace=None): |
976 """use revisions argument to define destmap {srcrev: destrev}""" | 971 """use revisions argument to define destmap {srcrev: destrev}""" |
977 if revf is None: | 972 if revf is None: |