largefile: synchronise the dirstate within a `parentchange` context
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 08 Jul 2021 01:23:06 +0200
changeset 47647 f16958beb27b
parent 47646 4259a72fe528
child 47648 093b1df410c9
largefile: synchronise the dirstate within a `parentchange` context Semantically these changes are made to adjust the dirstate after a commit, so it should be in a `parentchange` context. Differential Revision: https://phab.mercurial-scm.org/D11103
hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py	Mon Jun 28 12:12:34 2021 +0200
+++ b/hgext/largefiles/lfutil.py	Thu Jul 08 01:23:06 2021 +0200
@@ -574,22 +574,23 @@
 def markcommitted(orig, ctx, node):
     repo = ctx.repo()
 
-    orig(node)
+    with ctx._repo.dirstate.parentchange():
+        orig(node)
 
-    # ATTENTION: "ctx.files()" may differ from "repo[node].files()"
-    # because files coming from the 2nd parent are omitted in the latter.
-    #
-    # The former should be used to get targets of "synclfdirstate",
-    # because such files:
-    # - are marked as "a" by "patch.patch()" (e.g. via transplant), and
-    # - have to be marked as "n" after commit, but
-    # - aren't listed in "repo[node].files()"
+        # ATTENTION: "ctx.files()" may differ from "repo[node].files()"
+        # because files coming from the 2nd parent are omitted in the latter.
+        #
+        # The former should be used to get targets of "synclfdirstate",
+        # because such files:
+        # - are marked as "a" by "patch.patch()" (e.g. via transplant), and
+        # - have to be marked as "n" after commit, but
+        # - aren't listed in "repo[node].files()"
 
-    lfdirstate = openlfdirstate(repo.ui, repo)
-    for f in ctx.files():
-        lfile = splitstandin(f)
-        if lfile is not None:
-            synclfdirstate(repo, lfdirstate, lfile, False)
+        lfdirstate = openlfdirstate(repo.ui, repo)
+        for f in ctx.files():
+            lfile = splitstandin(f)
+            if lfile is not None:
+                synclfdirstate(repo, lfdirstate, lfile, False)
     lfdirstate.write()
 
     # As part of committing, copy all of the largefiles into the cache.