changeset 50224:99296ca9f29e

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 23 Feb 2023 04:02:38 +0100
parents a6ca61fd1fa8
children 8bc14ac53a41
files mercurial/narrowspec.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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)