[PATCH 2 of 7] manifest: remove manifest.find
Durham Goode
durham at fb.com
Tue Nov 8 11:42:56 EST 2016
# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1478621023 28800
# Tue Nov 08 08:03:43 2016 -0800
# Node ID 734fe516a6a23c43bfb56543e8e12b419b715b8d
# Parent b47bc9c8aaa603f0e143f9103dc6985f5678c818
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.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2566,11 +2566,14 @@ def cat(ui, repo, ctx, matcher, prefix,
# 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)
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -259,8 +259,10 @@ class basectx(object):
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'))
diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1389,6 +1389,9 @@ class manifestctx(object):
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
@@ -1481,6 +1484,9 @@ class treemanifestctx(object):
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
@@ -1543,15 +1549,6 @@ class manifest(manifestrevlog):
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()
More information about the Mercurial-devel
mailing list