Patchwork [5,of,5,V2] treemanifest: make hasdir() faster

login
register
mail settings
Submitter Martin von Zweigbergk
Date March 16, 2015, 11:27 p.m.
Message ID <fa7e71d04732596a5f6c.1426548431@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8104/
State Superseded
Headers show

Comments

Martin von Zweigbergk - March 16, 2015, 11:27 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1426546876 25200
#      Mon Mar 16 16:01:16 2015 -0700
# Node ID fa7e71d04732596a5f6c0714e6c8918a611914dd
# Parent  cee77fda8c7108824307f1750aafcdd76f3409a2
treemanifest: make hasdir() faster

Same rationale as the previous change.
Matt Mackall - March 18, 2015, 10:30 p.m.
On Mon, 2015-03-16 at 16:27 -0700, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1426546876 25200
> #      Mon Mar 16 16:01:16 2015 -0700
> # Node ID fa7e71d04732596a5f6c0714e6c8918a611914dd
> # Parent  cee77fda8c7108824307f1750aafcdd76f3409a2
> treemanifest: make hasdir() faster
> 
> Same rationale as the previous change.

These look good, except for the aforementioned requires file thing.

Patch

diff -r cee77fda8c71 -r fa7e71d04732 mercurial/manifest.py
--- a/mercurial/manifest.py	Tue Mar 03 13:50:06 2015 -0800
+++ b/mercurial/manifest.py	Mon Mar 16 16:01:16 2015 -0700
@@ -506,7 +506,12 @@ 
         return self._alldirs
 
     def hasdir(self, dir):
-        return dir in self._alldirs
+        topdir, subdir = _splittopdir(dir)
+        if topdir:
+            if topdir in self._dirs:
+                return self._dirs[topdir].hasdir(subdir)
+            return False
+        return (dir + '/') in self._dirs
 
     def matches(self, match):
         '''generate a new manifest filtered by the match argument'''