changeset 30340:608ba935e041

manifest: remove manifest.find As part of removing dependencies on manifest, this drops the find function and fixes up the two existing callers to use the equivalent apis on manifestctx.
author Durham Goode <durham@fb.com>
date Tue, 08 Nov 2016 08:03:43 -0800
parents 6cdfb7e15a35
children 3dfb5a0171c9
files mercurial/cmdutil.py mercurial/context.py mercurial/manifest.py
diffstat 3 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Tue Nov 08 08:03:43 2016 -0800
+++ b/mercurial/cmdutil.py	Tue Nov 08 08:03:43 2016 -0800
@@ -2566,11 +2566,14 @@
     # for performance to avoid the cost of parsing the manifest.
     if len(matcher.files()) == 1 and not matcher.anypats():
         file = matcher.files()[0]
-        mf = repo.manifest
+        mfl = repo.manifestlog
         mfnode = ctx.manifestnode()
-        if mfnode and mf.find(mfnode, file)[0]:
-            write(file)
-            return 0
+        try:
+            if mfnode and mfl[mfnode].find(file)[0]:
+                write(file)
+                return 0
+        except KeyError:
+            pass
 
     for abs in ctx.walk(matcher):
         write(abs)
--- a/mercurial/context.py	Tue Nov 08 08:03:43 2016 -0800
+++ b/mercurial/context.py	Tue Nov 08 08:03:43 2016 -0800
@@ -259,8 +259,10 @@
             if path in self._manifestdelta:
                 return (self._manifestdelta[path],
                         self._manifestdelta.flags(path))
-        node, flag = self._repo.manifest.find(self._changeset.manifest, path)
-        if not node:
+        mfl = self._repo.manifestlog
+        try:
+            node, flag = mfl[self._changeset.manifest].find(path)
+        except KeyError:
             raise error.ManifestLookupError(self._node, path,
                                             _('not found in manifest'))
 
--- a/mercurial/manifest.py	Tue Nov 08 08:03:43 2016 -0800
+++ b/mercurial/manifest.py	Tue Nov 08 08:03:43 2016 -0800
@@ -1394,6 +1394,9 @@
         d = mdiff.patchtext(revlog.revdiff(revlog.deltaparent(r), r))
         return manifestdict(d)
 
+    def find(self, key):
+        return self.read().find(key)
+
 class treemanifestctx(object):
     def __init__(self, repo, dir, node):
         self._repo = repo
@@ -1486,6 +1489,9 @@
         else:
             return self.read()
 
+    def find(self, key):
+        return self.read().find(key)
+
 class manifest(manifestrevlog):
     def __init__(self, opener, dir='', dirlogcache=None):
         '''The 'dir' and 'dirlogcache' arguments are for internal use by
@@ -1548,15 +1554,6 @@
             self.fulltextcache[node] = arraytext
         return m
 
-    def find(self, node, f):
-        '''look up entry for a single file efficiently.
-        return (node, flags) pair if found, (None, None) if not.'''
-        m = self.read(node)
-        try:
-            return m.find(f)
-        except KeyError:
-            return None, None
-
     def clearcaches(self):
         super(manifest, self).clearcaches()
         self._mancache.clear()