comparison hgext/largefiles/overrides.py @ 48168:df3021c1f093

largefiles: pass current transaction to `lfdirstate.write()` Right now, the largefile dirstate is not included in transaction which makes things complex. Next patch will add code to do so, so let's make it mandatory to pass current transaction and pass from all existing callers. Differential Revision: https://phab.mercurial-scm.org/D11610
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 19 Jul 2021 04:11:08 +0530
parents 5105a9975407
children 941fbaab5aff
comparison
equal deleted inserted replaced
48167:1b0f8aafedea 48168:df3021c1f093
149 hash=b'', 149 hash=b'',
150 executable=lfutil.getexecutable(repo.wjoin(f)), 150 executable=lfutil.getexecutable(repo.wjoin(f)),
151 ) 151 )
152 standins.append(standinname) 152 standins.append(standinname)
153 lfdirstate.set_tracked(f) 153 lfdirstate.set_tracked(f)
154 lfdirstate.write() 154 lfdirstate.write(repo.currenttransaction())
155 bad += [ 155 bad += [
156 lfutil.splitstandin(f) 156 lfutil.splitstandin(f)
157 for f in repo[None].add(standins) 157 for f in repo[None].add(standins)
158 if f in m.files() 158 if f in m.files()
159 ] 159 ]
227 repo[None].forget(remove) 227 repo[None].forget(remove)
228 228
229 for f in remove: 229 for f in remove:
230 lfdirstate.set_untracked(lfutil.splitstandin(f)) 230 lfdirstate.set_untracked(lfutil.splitstandin(f))
231 231
232 lfdirstate.write() 232 lfdirstate.write(repo.currenttransaction())
233 233
234 return result 234 return result
235 235
236 236
237 # For overriding mercurial.hgweb.webcommands so that largefiles will 237 # For overriding mercurial.hgweb.webcommands so that largefiles will
657 repo.dirstate.update_file( 657 repo.dirstate.update_file(
658 lfile, p1_tracked=True, wc_tracked=False 658 lfile, p1_tracked=True, wc_tracked=False
659 ) 659 )
660 # make sure lfile doesn't get synclfdirstate'd as normal 660 # make sure lfile doesn't get synclfdirstate'd as normal
661 lfdirstate.update_file(lfile, p1_tracked=False, wc_tracked=True) 661 lfdirstate.update_file(lfile, p1_tracked=False, wc_tracked=True)
662 lfdirstate.write() 662 lfdirstate.write(repo.currenttransaction())
663 663
664 return orig(repo, actions, branchmerge, getfiledata) 664 return orig(repo, actions, branchmerge, getfiledata)
665 665
666 666
667 # Override filemerge to prompt the user about how they wish to merge 667 # Override filemerge to prompt the user about how they wish to merge
862 lfdirstate.set_untracked(srclfile) 862 lfdirstate.set_untracked(srclfile)
863 else: 863 else:
864 util.copyfile(repo.wjoin(srclfile), repo.wjoin(destlfile)) 864 util.copyfile(repo.wjoin(srclfile), repo.wjoin(destlfile))
865 865
866 lfdirstate.set_tracked(destlfile) 866 lfdirstate.set_tracked(destlfile)
867 lfdirstate.write() 867 lfdirstate.write(repo.currenttransaction())
868 except error.Abort as e: 868 except error.Abort as e:
869 if e.message != _(b'no files to copy'): 869 if e.message != _(b'no files to copy'):
870 raise e 870 raise e
871 else: 871 else:
872 nolfiles = True 872 nolfiles = True
894 # and then return them to a correct state we need to lock to 894 # and then return them to a correct state we need to lock to
895 # prevent others from changing them in their incorrect state. 895 # prevent others from changing them in their incorrect state.
896 with repo.wlock(): 896 with repo.wlock():
897 lfdirstate = lfutil.openlfdirstate(ui, repo) 897 lfdirstate = lfutil.openlfdirstate(ui, repo)
898 s = lfutil.lfdirstatestatus(lfdirstate, repo) 898 s = lfutil.lfdirstatestatus(lfdirstate, repo)
899 lfdirstate.write() 899 lfdirstate.write(repo.currenttransaction())
900 for lfile in s.modified: 900 for lfile in s.modified:
901 lfutil.updatestandin(repo, lfile, lfutil.standin(lfile)) 901 lfutil.updatestandin(repo, lfile, lfutil.standin(lfile))
902 for lfile in s.deleted: 902 for lfile in s.deleted:
903 fstandin = lfutil.standin(lfile) 903 fstandin = lfutil.standin(lfile)
904 if repo.wvfs.exists(fstandin): 904 if repo.wvfs.exists(fstandin):
1381 # repository and we could race in-between. 1381 # repository and we could race in-between.
1382 with repo.wlock(): 1382 with repo.wlock():
1383 lfdirstate = lfutil.openlfdirstate(ui, repo) 1383 lfdirstate = lfutil.openlfdirstate(ui, repo)
1384 for f in forget: 1384 for f in forget:
1385 lfdirstate.set_untracked(f) 1385 lfdirstate.set_untracked(f)
1386 lfdirstate.write() 1386 lfdirstate.write(repo.currenttransaction())
1387 standins = [lfutil.standin(f) for f in forget] 1387 standins = [lfutil.standin(f) for f in forget]
1388 for f in standins: 1388 for f in standins:
1389 repo.wvfs.unlinkpath(f, ignoremissing=True) 1389 repo.wvfs.unlinkpath(f, ignoremissing=True)
1390 rejected = repo[None].forget(standins) 1390 rejected = repo[None].forget(standins)
1391 1391
1790 lfutil.updatestandin(repo, lfile, fstandin) 1790 lfutil.updatestandin(repo, lfile, fstandin)
1791 # mark all clean largefiles as dirty, just in case the update gets 1791 # mark all clean largefiles as dirty, just in case the update gets
1792 # interrupted before largefiles and lfdirstate are synchronized 1792 # interrupted before largefiles and lfdirstate are synchronized
1793 for lfile in oldclean: 1793 for lfile in oldclean:
1794 lfdirstate.set_possibly_dirty(lfile) 1794 lfdirstate.set_possibly_dirty(lfile)
1795 lfdirstate.write() 1795 lfdirstate.write(repo.currenttransaction())
1796 1796
1797 oldstandins = lfutil.getstandinsstate(repo) 1797 oldstandins = lfutil.getstandinsstate(repo)
1798 wc = kwargs.get('wc') 1798 wc = kwargs.get('wc')
1799 if wc and wc.isinmemory(): 1799 if wc and wc.isinmemory():
1800 # largefiles is not a good candidate for in-memory merge (large 1800 # largefiles is not a good candidate for in-memory merge (large
1810 1810
1811 # to avoid leaving all largefiles as dirty and thus rehash them, mark 1811 # to avoid leaving all largefiles as dirty and thus rehash them, mark
1812 # all the ones that didn't change as clean 1812 # all the ones that didn't change as clean
1813 for lfile in oldclean.difference(filelist): 1813 for lfile in oldclean.difference(filelist):
1814 lfdirstate.update_file(lfile, p1_tracked=True, wc_tracked=True) 1814 lfdirstate.update_file(lfile, p1_tracked=True, wc_tracked=True)
1815 lfdirstate.write() 1815 lfdirstate.write(repo.currenttransaction())
1816 1816
1817 if branchmerge or force or partial: 1817 if branchmerge or force or partial:
1818 filelist.extend(s.deleted + s.removed) 1818 filelist.extend(s.deleted + s.removed)
1819 1819
1820 lfcommands.updatelfiles( 1820 lfcommands.updatelfiles(