[PATCH 5 of 5] manifest: have context use self.hasdir()

Drew Gottlieb drgott at google.com
Fri Mar 13 18:35:37 CDT 2015


# HG changeset patch
# User Drew Gottlieb <drgott at google.com>
# Date 1426286171 25200
#      Fri Mar 13 15:36:11 2015 -0700
# Node ID 4c9d2b99b7517bf30737d1ec7b1b5f33e738afa2
# Parent  e6322f7d1ebdd7f67d0656bad2eacbd7d76547e5
manifest: have context use self.hasdir()

A couple places in context currently use "x in self._dirs" to check for the
existence of the directory, but this requires that all directories be loaded
into a dict. Calling hasdir() instead puts the work on the the manifest to
check for the existence of a directory in the most efficient manner.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -607,10 +607,8 @@
             if match(fn):
                 yield fn
         for fn in sorted(fset):
-            if fn in self._dirs:
-                # specified pattern is a directory
-                continue
-            match.bad(fn, _('no such file in rev %s') % self)
+            if not self.hasdir(fn):
+                match.bad(fn, _('no such file in rev %s') % self)
 
     def matches(self, match):
         return self.walk(match)
@@ -1560,7 +1558,7 @@
             def bad(f, msg):
                 # 'f' may be a directory pattern from 'match.files()',
                 # so 'f not in ctx1' is not enough
-                if f not in other and f not in other.dirs():
+                if f not in other and not other.hasdir(f):
                     self._repo.ui.warn('%s: %s\n' %
                                        (self._repo.dirstate.pathto(f), msg))
             match.bad = bad


More information about the Mercurial-devel mailing list