# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2021-07-18 22:41:08 # Node ID df3021c1f09338d2df0e4175cabb258936ab811a # Parent 1b0f8aafedea15712c0ebc4c95e1ca20cb026598 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 diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py --- a/hgext/largefiles/lfcommands.py +++ b/hgext/largefiles/lfcommands.py @@ -569,7 +569,7 @@ def updatelfiles( removed += 1 # largefile processing might be slow and be interrupted - be prepared - lfdirstate.write() + lfdirstate.write(repo.currenttransaction()) if lfiles: lfiles = [f for f in lfiles if f not in dropped] @@ -619,7 +619,7 @@ def updatelfiles( lfutil.synclfdirstate(repo, lfdirstate, lfile, normallookup) - lfdirstate.write() + lfdirstate.write(repo.currenttransaction()) if lfiles: statuswriter( _(b'%d largefiles updated, %d removed\n') % (updated, removed) diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -191,7 +191,7 @@ class largefilesdirstate(dirstate.dirsta def _ignore(self, f): return False - def write(self, tr=False): + def write(self, tr): # (1) disable PENDING mode always # (lfdirstate isn't yet managed as a part of the transaction) # (2) avoid develwarn 'use dirstate.write with ....' @@ -588,7 +588,7 @@ def markcommitted(orig, ctx, node): lfile = splitstandin(f) if lfile is not None: synclfdirstate(repo, lfdirstate, lfile, False) - lfdirstate.write() + lfdirstate.write(repo.currenttransaction()) # As part of committing, copy all of the largefiles into the cache. # diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -151,7 +151,7 @@ def addlargefiles(ui, repo, isaddremove, ) standins.append(standinname) lfdirstate.set_tracked(f) - lfdirstate.write() + lfdirstate.write(repo.currenttransaction()) bad += [ lfutil.splitstandin(f) for f in repo[None].add(standins) @@ -229,7 +229,7 @@ def removelargefiles(ui, repo, isaddremo for f in remove: lfdirstate.set_untracked(lfutil.splitstandin(f)) - lfdirstate.write() + lfdirstate.write(repo.currenttransaction()) return result @@ -659,7 +659,7 @@ def mergerecordupdates(orig, repo, actio ) # make sure lfile doesn't get synclfdirstate'd as normal lfdirstate.update_file(lfile, p1_tracked=False, wc_tracked=True) - lfdirstate.write() + lfdirstate.write(repo.currenttransaction()) return orig(repo, actions, branchmerge, getfiledata) @@ -864,7 +864,7 @@ def overridecopy(orig, ui, repo, pats, o util.copyfile(repo.wjoin(srclfile), repo.wjoin(destlfile)) lfdirstate.set_tracked(destlfile) - lfdirstate.write() + lfdirstate.write(repo.currenttransaction()) except error.Abort as e: if e.message != _(b'no files to copy'): raise e @@ -896,7 +896,7 @@ def overriderevert(orig, ui, repo, ctx, with repo.wlock(): lfdirstate = lfutil.openlfdirstate(ui, repo) s = lfutil.lfdirstatestatus(lfdirstate, repo) - lfdirstate.write() + lfdirstate.write(repo.currenttransaction()) for lfile in s.modified: lfutil.updatestandin(repo, lfile, lfutil.standin(lfile)) for lfile in s.deleted: @@ -1383,7 +1383,7 @@ def cmdutilforget( lfdirstate = lfutil.openlfdirstate(ui, repo) for f in forget: lfdirstate.set_untracked(f) - lfdirstate.write() + lfdirstate.write(repo.currenttransaction()) standins = [lfutil.standin(f) for f in forget] for f in standins: repo.wvfs.unlinkpath(f, ignoremissing=True) @@ -1792,7 +1792,7 @@ def mergeupdate(orig, repo, node, branch # interrupted before largefiles and lfdirstate are synchronized for lfile in oldclean: lfdirstate.set_possibly_dirty(lfile) - lfdirstate.write() + lfdirstate.write(repo.currenttransaction()) oldstandins = lfutil.getstandinsstate(repo) wc = kwargs.get('wc') @@ -1812,7 +1812,7 @@ def mergeupdate(orig, repo, node, branch # all the ones that didn't change as clean for lfile in oldclean.difference(filelist): lfdirstate.update_file(lfile, p1_tracked=True, wc_tracked=True) - lfdirstate.write() + lfdirstate.write(repo.currenttransaction()) if branchmerge or force or partial: filelist.extend(s.deleted + s.removed) diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py --- a/hgext/largefiles/reposetup.py +++ b/hgext/largefiles/reposetup.py @@ -310,7 +310,7 @@ def reposetup(ui, repo): ] if gotlock: - lfdirstate.write() + lfdirstate.write(self.currenttransaction()) self.lfstatus = True return scmutil.status(*result)