changeset 41040:92fde28860bb

tests: update narrowspec when narrowspec, not dirstate, is accessed test-narrow-expanddirstate.t mimics a Google-internal extension that updates the narrowspec whenever the dirstate is accessed. Since 1d09ba0d2ed3 (narrow: move remaining narrow-limited dirstate walks to core, 2018-10-01) and a few commits before it, we no longer restrict repo.dirstate.walk() to the narrowspec. It is instead done at a higher level (e.g. context.status()). We were running into problems with the Google-internal extension when importing those commits. The issue was that the narrowspec was read before the first dirstate access. I believe the right fix is to instead update the narrowspec when trying to read it (not when reading the dirstate), so that's what this patch does. Differential Revision: https://phab.mercurial-scm.org/D5275
author Martin von Zweigbergk <martinvonz@google.com>
date Sat, 27 Oct 2018 22:56:31 -0700
parents 54c3b4bd01f2
children 1e8d9f472ea1
files tests/test-narrow-expanddirstate.t
diffstat 1 files changed, 8 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-narrow-expanddirstate.t	Fri Dec 21 09:48:30 2018 -0800
+++ b/tests/test-narrow-expanddirstate.t	Sat Oct 27 22:56:31 2018 -0700
@@ -56,9 +56,13 @@
   > from mercurial import patch
   > from mercurial import util as hgutil
   > 
+  > narrowspecexpanded = False
   > def expandnarrowspec(ui, repo, newincludes=None):
   >   if not newincludes:
   >     return
+  >   if getattr(repo, '_narrowspecexpanded', False):
+  >     return
+  >   repo._narrowspecexpanded = True
   >   import sys
   >   newincludes = set([newincludes])
   >   includes, excludes = repo.narrowpats
@@ -72,24 +76,14 @@
   >   for f in repo[b'.'].manifest().walk(added):
   >     repo.dirstate.normallookup(f)
   > 
-  > def wrapds(ui, repo, ds):
-  >   class expandingdirstate(ds.__class__):
-  >     @hgutil.propertycache
-  >     def _map(self):
-  >       ret = super(expandingdirstate, self)._map
+  > def reposetup(ui, repo):
+  >   class expandingrepo(repo.__class__):
+  >     def narrowmatch(self, *args, **kwargs):
   >       with repo.wlock(), repo.lock(), repo.transaction(
   >           b'expandnarrowspec'):
   >         expandnarrowspec(ui, repo,
   >                          encoding.environ.get(b'DIRSTATEINCLUDES'))
-  >       return ret
-  >   ds.__class__ = expandingdirstate
-  >   return ds
-  > 
-  > def reposetup(ui, repo):
-  >   class expandingrepo(repo.__class__):
-  >     def _makedirstate(self):
-  >       dirstate = super(expandingrepo, self)._makedirstate()
-  >       return wrapds(ui, repo, dirstate)
+  >       return super(expandingrepo, self).narrowmatch(*args, **kwargs)
   >   repo.__class__ = expandingrepo
   > 
   > def extsetup(unused_ui):