D4681: narrow: extract wdir cleanup function to make it extensible
spectral (Kyle Lippincott)
phabricator at mercurial-scm.org
Thu Sep 20 19:20:09 UTC 2018
spectral created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
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).
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4681
AFFECTED FILES
hgext/narrow/narrowcommands.py
CHANGE DETAILS
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -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()
To: spectral, durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list