Patchwork D6468: narrowspec: replace one recursion-avoidance hack with another

login
register
mail settings
Submitter phabricator
Date May 31, 2019, 11:34 p.m.
Message ID <differential-rev-PHID-DREV-p4q2wc6wqievjmc3fxck-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/40292/
State Superseded
Headers show

Comments

phabricator - May 31, 2019, 11:34 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When updating the working copy narrowspec, we call context.walk() in
  order to find which files to update the working copy
  with. context.walk() calls repo.narrowmatch(). In order to avoid
  infinite recursion in this case, we have a hack that assigns the new
  values for repo.narrowpats and repo._narrowmatch. However, doing that
  of course breaks future invalidation of those properties (they're
  @storecache'd). Let's instead avoid the infinite recursion by setting
  a flag on the repo instance when we're updating the working copy.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/narrowspec.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -270,6 +270,9 @@ 
                        mctx=repo['.'], overwrite=False)
 
 def checkworkingcopynarrowspec(repo):
+    # Avoid infinite recursion when updating the working copy
+    if getattr(repo, '_updatingnarrowspec', False):
+        return
     storespec = repo.svfs.tryread(FILENAME)
     wcspec = repo.vfs.tryread(DIRSTATE_FILENAME)
     if wcspec != storespec:
@@ -284,6 +287,7 @@ 
     """
     oldspec = repo.vfs.tryread(DIRSTATE_FILENAME)
     newspec = repo.svfs.tryread(FILENAME)
+    repo._updatingnarrowspec = True
 
     oldincludes, oldexcludes = parseconfig(repo.ui, oldspec)
     newincludes, newexcludes = parseconfig(repo.ui, newspec)
@@ -313,10 +317,9 @@ 
     for f in clean + trackeddirty:
         ds.drop(f)
 
-    repo.narrowpats = newincludes, newexcludes
-    repo._narrowmatch = newmatch
     pctx = repo['.']
     newfiles = [f for f in pctx.manifest().walk(addedmatch) if f not in ds]
     for f in newfiles:
         ds.normallookup(f)
     _writeaddedfiles(repo, pctx, newfiles)
+    repo._updatingnarrowspec = False