# HG changeset patch # User Kyle Lippincott # Date 1537470780 25200 # Node ID 9d5c919b6dc35bbc820738f4a83ae9955f55d70d # Parent 5adc5fe41a7daa292272f43493a23e4aa7a3d9b6 narrow: extract wdir cleanup function to make it extensible We have an overlay filesystem which shows the entire repository, and unlinking a file that's in the underlying data store will create "tombstone" entries, which are going to cause our automatic tracking to re-add these directories. We need to use a different (non-posix) interface to clean up items in the working directory that are no longer relevant. Extracting this to a function lets us use extensions.wrappedfunction and perform this cleanup work, even if the paths aren't in the dirstate (they may have been removed in the past and thus entirely "tombstone" entries already, part of hgignore, exclusively directories (possibly empty), or other edge cases). Differential Revision: https://phab.mercurial-scm.org/D4681 diff -r 5adc5fe41a7d -r 9d5c919b6dc3 hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py Thu Sep 20 09:52:59 2018 -0400 +++ b/hgext/narrow/narrowcommands.py Thu Sep 20 12:13:00 2018 -0700 @@ -160,6 +160,16 @@ extensions.wrapfunction(exchange,'_pullbundle2extraprepare', pullbundle2extraprepare) +# This is an extension point for filesystems that need to do something other +# than just blindly unlink the files. It's not clear what arguments would be +# useful, so we're passing in a fair number of them, some of them redundant. +def _narrowcleanupwdir(repo, oldincludes, oldexcludes, newincludes, newexcludes, + oldmatch, newmatch): + for f in repo.dirstate: + if not newmatch(f): + repo.dirstate.drop(f) + repo.wvfs.unlinkpath(f) + def _narrow(ui, repo, remote, commoninc, oldincludes, oldexcludes, newincludes, newexcludes, force): oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes) @@ -235,10 +245,8 @@ util.unlinkpath(repo.svfs.join(f)) repo.store.markremoved(f) - for f in repo.dirstate: - if not newmatch(f): - repo.dirstate.drop(f) - repo.wvfs.unlinkpath(f) + _narrowcleanupwdir(repo, oldincludes, oldexcludes, newincludes, + newexcludes, oldmatch, newmatch) repo.setnarrowpats(newincludes, newexcludes) repo.destroyed()