changeset 42411:4738c292a520

narrowspec: replace one recursion-avoidance hack with another 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. Differential Revision: https://phab.mercurial-scm.org/D6468
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 31 May 2019 15:28:31 -0700
parents a5b5ecff5f37
children 127937874395
files mercurial/narrowspec.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/narrowspec.py	Sat Mar 09 22:13:06 2019 -0800
+++ b/mercurial/narrowspec.py	Fri May 31 15:28:31 2019 -0700
@@ -262,6 +262,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:
@@ -276,6 +279,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)
@@ -305,10 +309,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