# HG changeset patch # User Pierre-Yves David # Date 2023-03-02 03:16:47 # Node ID 2fbc109fd58a44475ad5fa5fea66a6ae74e93e4b # Parent 57133107ab4da43888160548e29437a13c246239 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). diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py --- a/mercurial/narrowspec.py +++ b/mercurial/narrowspec.py @@ -16,6 +16,7 @@ from . import ( mergestate as mergestatemod, scmutil, sparse, + txnutil, util, ) @@ -169,7 +170,13 @@ def parseconfig(ui, spec): 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)