comparison hgext/rebase.py @ 35332:03bec089e105

rebase: disable `inmemory` if the rebaseset contains the working copy As described in the comment, rebasing the working copy parent with in-memory merge, and then updating to the new commit, isn't much faster because of the extra overhead of uppdating. Best to leave it off in that case. This commit makes deploying in-memory merge via an extension easier, because you can just set `inmemory=True` based on some config or probability, and this will turn off the cases where it's not desired. Differential Revision: https://phab.mercurial-scm.org/D1616
author Phil Cohen <phillco@fb.com>
date Fri, 08 Dec 2017 15:27:58 -0800
parents d901a88891fe
children 8dba17546016
comparison
equal deleted inserted replaced
35331:773a9a06047c 35332:03bec089e105
828 if retcode is not None: 828 if retcode is not None:
829 return retcode 829 return retcode
830 else: 830 else:
831 destmap = _definedestmap(ui, repo, destf, srcf, basef, revf, 831 destmap = _definedestmap(ui, repo, destf, srcf, basef, revf,
832 destspace=destspace, 832 destspace=destspace,
833 inmemory=opts['inmemory']) 833 opts=opts)
834 rbsrt.inmemory = opts['inmemory']
834 retcode = rbsrt._preparenewrebase(destmap) 835 retcode = rbsrt._preparenewrebase(destmap)
835 if retcode is not None: 836 if retcode is not None:
836 return retcode 837 return retcode
837 838
838 tr = None 839 tr = None
848 rbsrt._performrebase(tr) 849 rbsrt._performrebase(tr)
849 850
850 rbsrt._finishrebase() 851 rbsrt._finishrebase()
851 852
852 def _definedestmap(ui, repo, destf=None, srcf=None, basef=None, revf=None, 853 def _definedestmap(ui, repo, destf=None, srcf=None, basef=None, revf=None,
853 destspace=None, inmemory=False): 854 destspace=None, opts=None):
854 """use revisions argument to define destmap {srcrev: destrev}""" 855 """use revisions argument to define destmap {srcrev: destrev}"""
855 if revf is None: 856 if revf is None:
856 revf = [] 857 revf = []
857 858
858 # destspace is here to work around issues with `hg pull --rebase` see 859 # destspace is here to work around issues with `hg pull --rebase` see
862 if revf and basef: 863 if revf and basef:
863 raise error.Abort(_('cannot specify both a revision and a base')) 864 raise error.Abort(_('cannot specify both a revision and a base'))
864 if revf and srcf: 865 if revf and srcf:
865 raise error.Abort(_('cannot specify both a revision and a source')) 866 raise error.Abort(_('cannot specify both a revision and a source'))
866 867
867 if not inmemory: 868 if not opts['inmemory']:
868 cmdutil.checkunfinished(repo) 869 cmdutil.checkunfinished(repo)
869 cmdutil.bailifchanged(repo) 870 cmdutil.bailifchanged(repo)
870 871
871 if ui.configbool('commands', 'rebase.requiredest') and not destf: 872 if ui.configbool('commands', 'rebase.requiredest') and not destf:
872 raise error.Abort(_('you must specify a destination'), 873 raise error.Abort(_('you must specify a destination'),
937 'ancestor of destination %s\n') % dest) 938 'ancestor of destination %s\n') % dest)
938 else: # can it happen? 939 else: # can it happen?
939 ui.status(_('nothing to rebase from %s to %s\n') % 940 ui.status(_('nothing to rebase from %s to %s\n') %
940 ('+'.join(str(repo[r]) for r in base), dest)) 941 ('+'.join(str(repo[r]) for r in base), dest))
941 return None 942 return None
943 # If rebasing the working copy parent, force in-memory merge to be off.
944 #
945 # This is because the extra work of checking out the newly rebased commit
946 # outweights the benefits of rebasing in-memory, and executing an extra
947 # update command adds a bit of overhead, so better to just do it on disk. In
948 # all other cases leave it on.
949 #
950 # Note that there are cases where this isn't true -- e.g., rebasing large
951 # stacks that include the WCP. However, I'm not yet sure where the cutoff
952 # is.
953 rebasingwcp = repo['.'].rev() in rebaseset
954 if opts['inmemory'] and rebasingwcp:
955 opts['inmemory'] = False
956 # Check these since we did not before.
957 cmdutil.checkunfinished(repo)
958 cmdutil.bailifchanged(repo)
942 959
943 if not destf: 960 if not destf:
944 dest = repo[_destrebase(repo, rebaseset, destspace=destspace)] 961 dest = repo[_destrebase(repo, rebaseset, destspace=destspace)]
945 destf = str(dest) 962 destf = str(dest)
946 963