Patchwork D11150: sparse: apply update with in a `parentchange` context

login
register
mail settings
Submitter phabricator
Date July 19, 2021, 10:44 a.m.
Message ID <differential-rev-PHID-DREV-rsbrzx7mkkaajnmhcgcg-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49462/
State Superseded
Headers show

Comments

phabricator - July 19, 2021, 10:44 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We are changing the reference so we should be within such context manager.
  
  This seems make the actual dirstate content a bit flaky with content being
  sometime ambigous (but maybe it was flaky before?)
  
  So I increased the matching.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/sparse.py
  tests/test-sparse.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-sparse.t b/tests/test-sparse.t
--- a/tests/test-sparse.t
+++ b/tests/test-sparse.t
@@ -420,12 +420,12 @@ 
 We have files in the dirstate that are included and excluded. Some are in the
 manifest and some are not.
   $ hg debugdirstate --no-dates
-  n 644          0 * excluded (glob)
-  a   0         -1 * excludednomanifest (glob)
-  n 644          0 * included (glob)
-  a   0         -1 * includedadded (glob)
+  n * excluded (glob)
+  a * excludednomanifest (glob)
+  n * included (glob)
+  a * includedadded (glob)
   $ hg debugrebuilddirstate --minimal
   $ hg debugdirstate --no-dates
-  n 644          0 * included (glob)
-  a   0         -1 * includedadded (glob)
+  n * included (glob)
+  a * includedadded (glob)
 
diff --git a/mercurial/sparse.py b/mercurial/sparse.py
--- a/mercurial/sparse.py
+++ b/mercurial/sparse.py
@@ -439,13 +439,21 @@ 
                     message,
                 )
 
-        mergemod.applyupdates(
-            repo, tmresult, repo[None], repo[b'.'], False, wantfiledata=False
-        )
+        with repo.dirstate.parentchange():
+            mergemod.applyupdates(
+                repo,
+                tmresult,
+                repo[None],
+                repo[b'.'],
+                False,
+                wantfiledata=False,
+            )
 
-        dirstate = repo.dirstate
-        for file, flags, msg in tmresult.getactions([mergestatemod.ACTION_GET]):
-            dirstate.normal(file)
+            dirstate = repo.dirstate
+            for file, flags, msg in tmresult.getactions(
+                [mergestatemod.ACTION_GET]
+            ):
+                dirstate.normal(file)
 
     profiles = activeconfig(repo)[2]
     changedprofiles = profiles & files