Mercurial > public > mercurial-scm > hg
comparison hgext/rebase.py @ 38799:2002c193f2bc
rebase: support "history-editing-backup" config option
If you don't want to store any backup while rebasing, you can
use `history-editing-backup` config option.
[ui]
history-editing-backup = # True or False
Current status of list of commands which supports this config:
1. histedit
2. rebase
Differential Revision: https://phab.mercurial-scm.org/D3887
author | Sushil khanchi <sushilkhanchi97@gmail.com> |
---|---|
date | Thu, 05 Jul 2018 10:42:48 +0530 |
parents | 8eeed92475d5 |
children | 2b728789edfd |
comparison
equal
deleted
inserted
replaced
38798:d58958676b3c | 38799:2002c193f2bc |
---|---|
583 # commit is completely done. On InterventionRequired, we thus | 583 # commit is completely done. On InterventionRequired, we thus |
584 # won't store the status. Instead, we'll hit the "len(parents) == 2" | 584 # won't store the status. Instead, we'll hit the "len(parents) == 2" |
585 # case and realize that the commit was in progress. | 585 # case and realize that the commit was in progress. |
586 self.storestatus() | 586 self.storestatus() |
587 | 587 |
588 def _finishrebase(self): | 588 def _finishrebase(self, backup=True): |
589 """ | |
590 backup: if False, no backup will be stored when stripping rebased | |
591 revisions | |
592 """ | |
589 repo, ui, opts = self.repo, self.ui, self.opts | 593 repo, ui, opts = self.repo, self.ui, self.opts |
590 fm = ui.formatter('rebase', opts) | 594 fm = ui.formatter('rebase', opts) |
591 fm.startitem() | 595 fm.startitem() |
592 if self.collapsef: | 596 if self.collapsef: |
593 p1, p2, _base = defineparents(repo, min(self.state), self.destmap, | 597 p1, p2, _base = defineparents(repo, min(self.state), self.destmap, |
630 | 634 |
631 collapsedas = None | 635 collapsedas = None |
632 if self.collapsef and not self.keepf: | 636 if self.collapsef and not self.keepf: |
633 collapsedas = newnode | 637 collapsedas = newnode |
634 clearrebased(ui, repo, self.destmap, self.state, self.skipped, | 638 clearrebased(ui, repo, self.destmap, self.state, self.skipped, |
635 collapsedas, self.keepf, fm=fm) | 639 collapsedas, self.keepf, fm=fm, backup=backup) |
636 | 640 |
637 clearstatus(repo) | 641 clearstatus(repo) |
638 clearcollapsemsg(repo) | 642 clearcollapsemsg(repo) |
639 | 643 |
640 ui.note(_("rebase completed\n")) | 644 ui.note(_("rebase completed\n")) |
827 raise error.Abort(_('--auto-orphans is incompatible with %s') % | 831 raise error.Abort(_('--auto-orphans is incompatible with %s') % |
828 ('--' + key)) | 832 ('--' + key)) |
829 userrevs = list(repo.revs(opts.get('auto_orphans'))) | 833 userrevs = list(repo.revs(opts.get('auto_orphans'))) |
830 opts['rev'] = [revsetlang.formatspec('%ld and orphan()', userrevs)] | 834 opts['rev'] = [revsetlang.formatspec('%ld and orphan()', userrevs)] |
831 opts['dest'] = '_destautoorphanrebase(SRC)' | 835 opts['dest'] = '_destautoorphanrebase(SRC)' |
836 backup = ui.configbool('ui', 'history-editing-backup') | |
837 opts['backup'] = backup | |
832 | 838 |
833 if dryrun: | 839 if dryrun: |
834 return _dryrunrebase(ui, repo, opts) | 840 return _dryrunrebase(ui, repo, opts) |
835 elif inmemory: | 841 elif inmemory: |
836 try: | 842 try: |
848 return _dorebase(ui, repo, opts) | 854 return _dorebase(ui, repo, opts) |
849 | 855 |
850 def _dryrunrebase(ui, repo, opts): | 856 def _dryrunrebase(ui, repo, opts): |
851 rbsrt = rebaseruntime(repo, ui, inmemory=True, opts=opts) | 857 rbsrt = rebaseruntime(repo, ui, inmemory=True, opts=opts) |
852 confirm = opts.get('confirm') | 858 confirm = opts.get('confirm') |
859 backup = opts.get('backup') | |
853 if confirm: | 860 if confirm: |
854 ui.status(_('starting in-memory rebase\n')) | 861 ui.status(_('starting in-memory rebase\n')) |
855 else: | 862 else: |
856 ui.status(_('starting dry-run rebase; repository will not be ' | 863 ui.status(_('starting dry-run rebase; repository will not be ' |
857 'changed\n')) | 864 'changed\n')) |
869 if confirm: | 876 if confirm: |
870 ui.status(_('rebase completed successfully\n')) | 877 ui.status(_('rebase completed successfully\n')) |
871 if not ui.promptchoice(_(b'apply changes (yn)?' | 878 if not ui.promptchoice(_(b'apply changes (yn)?' |
872 b'$$ &Yes $$ &No')): | 879 b'$$ &Yes $$ &No')): |
873 # finish unfinished rebase | 880 # finish unfinished rebase |
874 rbsrt._finishrebase() | 881 rbsrt._finishrebase(backup=backup) |
875 else: | 882 else: |
876 rbsrt._prepareabortorcontinue(isabort=True, backup=False, | 883 rbsrt._prepareabortorcontinue(isabort=True, backup=False, |
877 suppwarns=True) | 884 suppwarns=True) |
878 needsabort = False | 885 needsabort = False |
879 else: | 886 else: |
900 # search default destination in this space | 907 # search default destination in this space |
901 # used in the 'hg pull --rebase' case, see issue 5214. | 908 # used in the 'hg pull --rebase' case, see issue 5214. |
902 destspace = opts.get('_destspace') | 909 destspace = opts.get('_destspace') |
903 contf = opts.get('continue') | 910 contf = opts.get('continue') |
904 abortf = opts.get('abort') | 911 abortf = opts.get('abort') |
912 backup = opts.get('backup') | |
905 if opts.get('interactive'): | 913 if opts.get('interactive'): |
906 try: | 914 try: |
907 if extensions.find('histedit'): | 915 if extensions.find('histedit'): |
908 enablehistedit = '' | 916 enablehistedit = '' |
909 except KeyError: | 917 except KeyError: |
930 ui.warn(_('tool option will be ignored\n')) | 938 ui.warn(_('tool option will be ignored\n')) |
931 if contf: | 939 if contf: |
932 ms = mergemod.mergestate.read(repo) | 940 ms = mergemod.mergestate.read(repo) |
933 mergeutil.checkunresolved(ms) | 941 mergeutil.checkunresolved(ms) |
934 | 942 |
935 retcode = rbsrt._prepareabortorcontinue(abortf) | 943 retcode = rbsrt._prepareabortorcontinue(abortf, backup=backup) |
936 if retcode is not None: | 944 if retcode is not None: |
937 return retcode | 945 return retcode |
938 else: | 946 else: |
939 destmap = _definedestmap(ui, repo, inmemory, destf, srcf, basef, | 947 destmap = _definedestmap(ui, repo, inmemory, destf, srcf, basef, |
940 revf, destspace=destspace) | 948 revf, destspace=destspace) |
959 if singletr and not inmemory: | 967 if singletr and not inmemory: |
960 dsguard = dirstateguard.dirstateguard(repo, 'rebase') | 968 dsguard = dirstateguard.dirstateguard(repo, 'rebase') |
961 with util.acceptintervention(dsguard): | 969 with util.acceptintervention(dsguard): |
962 rbsrt._performrebase(tr) | 970 rbsrt._performrebase(tr) |
963 if not leaveunfinished: | 971 if not leaveunfinished: |
964 rbsrt._finishrebase() | 972 rbsrt._finishrebase(backup=backup) |
965 | 973 |
966 def _definedestmap(ui, repo, inmemory, destf=None, srcf=None, basef=None, | 974 def _definedestmap(ui, repo, inmemory, destf=None, srcf=None, basef=None, |
967 revf=None, destspace=None): | 975 revf=None, destspace=None): |
968 """use revisions argument to define destmap {srcrev: destrev}""" | 976 """use revisions argument to define destmap {srcrev: destrev}""" |
969 if revf is None: | 977 if revf is None: |
1726 if parents and all((state.get(p) == p for p in parents)): | 1734 if parents and all((state.get(p) == p for p in parents)): |
1727 state[rev] = rev | 1735 state[rev] = rev |
1728 return originalwd, destmap, state | 1736 return originalwd, destmap, state |
1729 | 1737 |
1730 def clearrebased(ui, repo, destmap, state, skipped, collapsedas=None, | 1738 def clearrebased(ui, repo, destmap, state, skipped, collapsedas=None, |
1731 keepf=False, fm=None): | 1739 keepf=False, fm=None, backup=True): |
1732 """dispose of rebased revision at the end of the rebase | 1740 """dispose of rebased revision at the end of the rebase |
1733 | 1741 |
1734 If `collapsedas` is not None, the rebase was a collapse whose result if the | 1742 If `collapsedas` is not None, the rebase was a collapse whose result if the |
1735 `collapsedas` node. | 1743 `collapsedas` node. |
1736 | 1744 |
1737 If `keepf` is not True, the rebase has --keep set and no nodes should be | 1745 If `keepf` is not True, the rebase has --keep set and no nodes should be |
1738 removed (but bookmarks still need to be moved). | 1746 removed (but bookmarks still need to be moved). |
1747 | |
1748 If `backup` is False, no backup will be stored when stripping rebased | |
1749 revisions. | |
1739 """ | 1750 """ |
1740 tonode = repo.changelog.node | 1751 tonode = repo.changelog.node |
1741 replacements = {} | 1752 replacements = {} |
1742 moves = {} | 1753 moves = {} |
1743 for rev, newrev in sorted(state.items()): | 1754 for rev, newrev in sorted(state.items()): |
1749 if rev in skipped: | 1760 if rev in skipped: |
1750 succs = () | 1761 succs = () |
1751 else: | 1762 else: |
1752 succs = (newnode,) | 1763 succs = (newnode,) |
1753 replacements[oldnode] = succs | 1764 replacements[oldnode] = succs |
1754 scmutil.cleanupnodes(repo, replacements, 'rebase', moves) | 1765 scmutil.cleanupnodes(repo, replacements, 'rebase', moves, backup=backup) |
1755 if fm: | 1766 if fm: |
1756 hf = fm.hexfunc | 1767 hf = fm.hexfunc |
1757 fl = fm.formatlist | 1768 fl = fm.formatlist |
1758 fd = fm.formatdict | 1769 fd = fm.formatdict |
1759 nodechanges = fd({hf(oldn): fl([hf(n) for n in newn], name='node') | 1770 nodechanges = fd({hf(oldn): fl([hf(n) for n in newn], name='node') |