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

Martin von Zweigbergk martinvonz at google.com
Wed Mar 11 11:21:53 CDT 2015


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at 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.

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
 


More information about the Mercurial-devel mailing list