Patchwork D11610: largefiles: pass current transaction to `lfdirstate.write()`

login
register
mail settings
Submitter phabricator
Date Oct. 5, 2021, 11:44 a.m.
Message ID <differential-rev-PHID-DREV-acstun6y5edillea7aqz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49936/
State Superseded
Headers show

Comments

phabricator - Oct. 5, 2021, 11:44 a.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11610

AFFECTED FILES
  hgext/largefiles/lfcommands.py
  hgext/largefiles/lfutil.py
  hgext/largefiles/overrides.py
  hgext/largefiles/reposetup.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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 @@ 
                     ]
 
                 if gotlock:
-                    lfdirstate.write()
+                    lfdirstate.write(self.currenttransaction())
 
             self.lfstatus = True
             return scmutil.status(*result)
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 @@ 
                 )
                 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 @@ 
         for f in remove:
             lfdirstate.set_untracked(lfutil.splitstandin(f))
 
-        lfdirstate.write()
+        lfdirstate.write(repo.currenttransaction())
 
     return result
 
@@ -659,7 +659,7 @@ 
                 )
                 # 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 @@ 
                     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 @@ 
     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 @@ 
         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 @@ 
         # 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 @@ 
             # 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/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -191,7 +191,7 @@ 
     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 @@ 
             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/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -569,7 +569,7 @@ 
                         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 @@ 
 
                 lfutil.synclfdirstate(repo, lfdirstate, lfile, normallookup)
 
-        lfdirstate.write()
+        lfdirstate.write(repo.currenttransaction())
         if lfiles:
             statuswriter(
                 _(b'%d largefiles updated, %d removed\n') % (updated, removed)