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

login
register
mail settings
Submitter Martin von Zweigbergk
Date March 11, 2015, 4:21 p.m.
Message ID <2598d47afb032b232898.1426090913@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8005/
State Superseded
Commit b7add2ebef9e41b91a1cd16a0cf149f517527cf0
Headers show

Comments

Martin von Zweigbergk - March 11, 2015, 4:21 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 2598d47afb032b232898275a77d5f830c9c89eec
# Parent  4ebfeb027ce588a72347788c8c23b2318d8fb6d3
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 4ebfeb027ce5 -r 2598d47afb03 mercurial/manifest.py
--- a/mercurial/manifest.py	Tue Mar 03 13:50:06 2015 -0800
+++ b/mercurial/manifest.py	Wed Mar 11 08:28:56 2015 -0700
@@ -595,12 +595,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 self._newmanifest(text).find(f)
+            return m.find(f)
         except KeyError:
             return None, None