changeset 50248:2fbc109fd58a

narrow: read pending file when applicable Now that this is part of the transaction, this is necessary to make sure we read the right data in hooks (if any).
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 02 Mar 2023 04:16:47 +0100
parents 57133107ab4d
children a6b8b1ab9116
files mercurial/narrowspec.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/narrowspec.py	Tue Feb 28 11:44:52 2023 -0500
+++ b/mercurial/narrowspec.py	Thu Mar 02 04:16:47 2023 +0100
@@ -16,6 +16,7 @@
     mergestate as mergestatemod,
     scmutil,
     sparse,
+    txnutil,
     util,
 )
 
@@ -169,7 +170,13 @@
 def load(repo):
     # Treat "narrowspec does not exist" the same as "narrowspec file exists
     # and is empty".
-    spec = repo.svfs.tryread(FILENAME)
+    spec = None
+    if txnutil.mayhavepending(repo.root):
+        pending_path = b"%s.pending" % FILENAME
+        if repo.svfs.exists(pending_path):
+            spec = repo.svfs.tryread(FILENAME)
+    if spec is None:
+        spec = repo.svfs.tryread(FILENAME)
     return parseconfig(repo.ui, spec)