# HG changeset patch # User Pierre-Yves David # Date 1677121358 -3600 # Node ID 99296ca9f29e73b83b4640035160ef6dead604ba # Parent a6ca61fd1fa82a4a21e6761f96fff6799660b63a narrow: get the narrow patterns from the repository object instead of disk Relying on disk data make the transactionally of this change complicated, so let us start reading data from other API instead. diff -r a6ca61fd1fa8 -r 99296ca9f29e mercurial/narrowspec.py --- a/mercurial/narrowspec.py Thu Feb 23 00:12:53 2023 +0100 +++ b/mercurial/narrowspec.py Thu Feb 23 04:02:38 2023 +0100 @@ -181,7 +181,7 @@ def copytoworkingcopy(repo): - spec = repo.svfs.read(FILENAME) + spec = format(*repo.narrowpats) repo.vfs.write(DIRSTATE_FILENAME, spec) @@ -296,8 +296,9 @@ # Avoid infinite recursion when updating the working copy if getattr(repo, '_updatingnarrowspec', False): return - storespec = repo.svfs.tryread(FILENAME) + storespec = repo.narrowpats wcspec = repo.vfs.tryread(DIRSTATE_FILENAME) + wcspec = parseconfig(repo.ui, wcspec) if wcspec != storespec: raise error.StateError( _(b"working copy's narrowspec is stale"), @@ -312,11 +313,10 @@ be deleted. It is then up to the caller to make sure they are clean. """ oldspec = repo.vfs.tryread(DIRSTATE_FILENAME) - newspec = repo.svfs.tryread(FILENAME) + newincludes, newexcludes = repo.narrowpats repo._updatingnarrowspec = True oldincludes, oldexcludes = parseconfig(repo.ui, oldspec) - newincludes, newexcludes = parseconfig(repo.ui, newspec) oldmatch = match(repo.root, include=oldincludes, exclude=oldexcludes) newmatch = match(repo.root, include=newincludes, exclude=newexcludes) addedmatch = matchmod.differencematcher(newmatch, oldmatch)