Patchwork D11103: largefile: synchronise the dirstate within a `parentchange` context

login
register
mail settings
Submitter phabricator
Date July 18, 2021, 9:52 p.m.
Message ID <differential-rev-PHID-DREV-shgdjjvuh2djdwtxagdy-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49417/
State Superseded
Headers show

Comments

phabricator - July 18, 2021, 9:52 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Semantically these changes are made to adjust the dirstate after a commit, so it
  should be in a `parentchange` context.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/largefiles/lfutil.py

CHANGE DETAILS




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

Patch

diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -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.