comparison hgext/largefiles/overrides.py @ 45545:e5e1285b6f6f

largefiles: prevent in-memory merge instead of switching to on-disk I enabled in-memory merge by default while testing some changes. I spent quite some time troubleshooting why largefiles was still creating an on-disk mergestate. Then I found out that it ignores the callers `wc` argument to `mergemod._update()` and always uses on-disk merge. This patch changes that so we raise an error if largefiles is used with in-memory merge. That way we'll notice if in-memory merge is used with largefiles instead of silently replacing ignoring the `overlayworkingctx` instance and updating the working copy instead. I felt a little bad that this would break things more for users with both largefiles and in-memory rebase enabled. So I also added a higher-level override to make sure that largefiles disables in-memory rebase. It turns out that that fixes `run-tests.py -k largefiles --extra-config-opt rebase.experimental.inmemory=1`. Differential Revision: https://phab.mercurial-scm.org/D9069
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 22 Sep 2020 23:18:37 -0700
parents 39ddb1121c4e
children 2c86b9587740
comparison
equal deleted inserted replaced
45544:2b339c6c6e99 45545:e5e1285b6f6f
1101 1101
1102 return result 1102 return result
1103 1103
1104 1104
1105 @eh.wrapcommand(b'rebase', extension=b'rebase') 1105 @eh.wrapcommand(b'rebase', extension=b'rebase')
1106 def overriderebase(orig, ui, repo, **opts): 1106 def overriderebasecmd(orig, ui, repo, **opts):
1107 if not util.safehasattr(repo, b'_largefilesenabled'): 1107 if not util.safehasattr(repo, b'_largefilesenabled'):
1108 return orig(ui, repo, **opts) 1108 return orig(ui, repo, **opts)
1109 1109
1110 resuming = opts.get('continue') 1110 resuming = opts.get('continue')
1111 repo._lfcommithooks.append(lfutil.automatedcommithook(resuming)) 1111 repo._lfcommithooks.append(lfutil.automatedcommithook(resuming))
1112 repo._lfstatuswriters.append(lambda *msg, **opts: None) 1112 repo._lfstatuswriters.append(lambda *msg, **opts: None)
1113 try: 1113 try:
1114 return orig(ui, repo, **opts) 1114 with ui.configoverride(
1115 {(b'rebase', b'experimental.inmemory'): False}, b"largefiles"
1116 ):
1117 return orig(ui, repo, **opts)
1115 finally: 1118 finally:
1116 repo._lfstatuswriters.pop() 1119 repo._lfstatuswriters.pop()
1117 repo._lfcommithooks.pop() 1120 repo._lfcommithooks.pop()
1121
1122
1123 @eh.extsetup
1124 def overriderebase(ui):
1125 try:
1126 rebase = extensions.find(b'rebase')
1127 except KeyError:
1128 pass
1129 else:
1130
1131 def _dorebase(orig, *args, **kwargs):
1132 kwargs['inmemory'] = False
1133 return orig(*args, **kwargs)
1134
1135 extensions.wrapfunction(rebase, b'_dorebase', _dorebase)
1118 1136
1119 1137
1120 @eh.wrapcommand(b'archive') 1138 @eh.wrapcommand(b'archive')
1121 def overridearchivecmd(orig, ui, repo, dest, **opts): 1139 def overridearchivecmd(orig, ui, repo, dest, **opts):
1122 with lfstatus(repo.unfiltered()): 1140 with lfstatus(repo.unfiltered()):
1756 for lfile in oldclean: 1774 for lfile in oldclean:
1757 lfdirstate.normallookup(lfile) 1775 lfdirstate.normallookup(lfile)
1758 lfdirstate.write() 1776 lfdirstate.write()
1759 1777
1760 oldstandins = lfutil.getstandinsstate(repo) 1778 oldstandins = lfutil.getstandinsstate(repo)
1761 # Make sure the merge runs on disk, not in-memory. largefiles is not a 1779 wc = kwargs.get('wc')
1762 # good candidate for in-memory merge (large files, custom dirstate, 1780 if wc and wc.isinmemory():
1763 # matcher usage). 1781 # largefiles is not a good candidate for in-memory merge (large
1764 kwargs['wc'] = repo[None] 1782 # files, custom dirstate, matcher usage).
1783 raise error.ProgrammingError(
1784 b'largefiles is not compatible with in-memory merge'
1785 )
1765 result = orig(repo, node, branchmerge, force, *args, **kwargs) 1786 result = orig(repo, node, branchmerge, force, *args, **kwargs)
1766 1787
1767 newstandins = lfutil.getstandinsstate(repo) 1788 newstandins = lfutil.getstandinsstate(repo)
1768 filelist = lfutil.getlfilestoupdate(oldstandins, newstandins) 1789 filelist = lfutil.getlfilestoupdate(oldstandins, newstandins)
1769 1790