commit: rewrite check for `hg ci <path>` being a directory
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 15 Nov 2019 14:41:00 -0800
changeset 43711 7f443cce2972
parent 43709 039fbd14d4e2
child 43712 f965b1027fb0
commit: rewrite check for `hg ci <path>` being a directory The matcher API is complicated by match.bad, match.explicitdir, and match.traversedir. We already have very few users of match.explicitdir. By rewriting this check we get close to being able to remove match.explicitdir. This may make the check slower, but I think that will be very marginal. Disclosure: I actually wrote this patch to solve a bug we've seen with an internal extension. The internal extension overrides the dirstate walk to only walk the files that our FUSE tells us are modified. That led to "vdirs" not getting populated as this code expected. I have wanted to get rid of match.explicitdir for a very long time, though. Differential Revision: https://phab.mercurial-scm.org/D7437
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Mon Nov 18 20:10:38 2019 -0800
+++ b/mercurial/localrepo.py	Fri Nov 15 14:41:00 2019 -0800
@@ -2800,7 +2800,8 @@
                     continue
                 if f in status.deleted:
                     fail(f, _(b'file not found!'))
-                if f in vdirs:  # visited directory
+                # Is it a directory that exists or used to exist?
+                if self.wvfs.isdir(f) or wctx.p1().hasdir(f):
                     d = f + b'/'
                     for mf in matched:
                         if mf.startswith(d):