Patchwork [1,of,5] manifest: rewrite find(node, f) in terms of read(node)

login
register
mail settings
Submitter Martin von Zweigbergk
Date March 11, 2015, 11:14 p.m.
Message ID <0709db5b7ee275833b41.1426115663@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8013/
State Accepted
Commit b7add2ebef9e41b91a1cd16a0cf149f517527cf0
Headers show

Comments

Martin von Zweigbergk - March 11, 2015, 11:14 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1426087736 25200
#      Wed Mar 11 08:28:56 2015 -0700
# Node ID 0709db5b7ee275833b41b89feab59625dca28c7a
# Parent  7cf9a9e0cf893e7ae82dc576a03c843fd6640438
manifest: rewrite find(node, f) in terms of read(node)

Since find() now always works with a full manifest, we can simplify by
calling read() to give us that manifest. That way, we also populate
the manifest cache. However, now that we no longer parse the manifest
text into a Python type (thanks, lazymanifest/Augie), the cost of
parsing (scanning for newlines, really) is small enough that it seems
generally drowned by revlog reading.

Patch

diff -r 7cf9a9e0cf89 -r 0709db5b7ee2 mercurial/manifest.py
--- a/mercurial/manifest.py	Wed Mar 11 15:22:34 2015 -0700
+++ b/mercurial/manifest.py	Wed Mar 11 08:28:56 2015 -0700
@@ -350,12 +350,9 @@ 
     def find(self, node, f):
         '''look up entry for a single file efficiently.
         return (node, flags) pair if found, (None, None) if not.'''
-        if node in self._mancache:
-            m = self._mancache[node][0]
-            return m.get(f), m.flags(f)
-        text = self.revision(node)
+        m = self.read(node)
         try:
-            return manifestdict(text).find(f)
+            return m.find(f)
         except KeyError:
             return None, None