Patchwork [6,of,6,V5] manifest: remove manifest.readshallowdelta

login
register
mail settings
Submitter Durham Goode
Date Nov. 3, 2016, 1:30 a.m.
Message ID <5a8fa7811314ee6cc08c.1478136601@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/17308/
State Accepted
Headers show

Comments

Durham Goode - Nov. 3, 2016, 1:30 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1478131847 25200
#      Wed Nov 02 17:10:47 2016 -0700
# Branch stable
# Node ID 5a8fa7811314ee6cc08c43e06b4ff0a9c38f5041
# Parent  42cbc5a35d816cf9e5c0ab31791ab90df8004dab
manifest: remove manifest.readshallowdelta

This removes manifest.readshallowdelta and converts its one consumer to use
manifestlog instead.

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1365,6 +1365,12 @@  class manifestctx(object):
         return self.read()
 
     def readdelta(self, shallow=False):
+        '''Returns a manifest containing just the entries that are present
+        in this manifest, but not in its p1 manifest. This is efficient to read
+        if the revlog delta is already p1.
+
+        Changing the value of `shallow` has no effect on flat manifests.
+        '''
         revlog = self._repo.manifestlog._revlog
         if revlog._usemanifestv2:
             # Need to perform a slow delta
@@ -1427,6 +1433,16 @@  class treemanifestctx(object):
         return self._node
 
     def readdelta(self, shallow=False):
+        '''Returns a manifest containing just the entries that are present
+        in this manifest, but not in its p1 manifest. This is efficient to read
+        if the revlog delta is already p1.
+
+        If `shallow` is True, this will read the delta for this directory,
+        without recursively reading subdirectory manifests. Instead, any
+        subdirectory entry will be reported as it appears in the manifest, i.e.
+        the subdirectory will be reported among files and distinguished only by
+        its 't' flag.
+        '''
         revlog = self._revlog()
         if shallow and revlog._treeondisk and not revlog._usemanifestv2:
             r = revlog.rev(self._node)
@@ -1500,41 +1516,6 @@  class manifest(manifestrevlog):
                                               self._dirlogcache)
         return self._dirlogcache[dir]
 
-    def _slowreaddelta(self, node):
-        r0 = self.deltaparent(self.rev(node))
-        m0 = self.read(self.node(r0))
-        m1 = self.read(node)
-        md = self._newmanifest()
-        for f, ((n0, fl0), (n1, fl1)) in m0.diff(m1).iteritems():
-            if n1:
-                md[f] = n1
-                if fl1:
-                    md.setflag(f, fl1)
-        return md
-
-    def readdelta(self, node):
-        if self._usemanifestv2 or self._treeondisk:
-            return self._slowreaddelta(node)
-        r = self.rev(node)
-        d = mdiff.patchtext(self.revdiff(self.deltaparent(r), r))
-        return self._newmanifest(d)
-
-    def readshallowdelta(self, node):
-        '''For flat manifests, this is the same as readdelta(). For
-        treemanifests, this will read the delta for this revlog's directory,
-        without recursively reading subdirectory manifests. Instead, any
-        subdirectory entry will be reported as it appears in the manifests, i.e.
-        the subdirectory will be reported among files and distinguished only by
-        its 't' flag.'''
-        if not self._treeondisk:
-            return self.readdelta(node)
-        if self._usemanifestv2:
-            raise error.Abort(
-                _("readshallowdelta() not implemented for manifestv2"))
-        r = self.rev(node)
-        d = mdiff.patchtext(self.revdiff(self.deltaparent(r), r))
-        return manifestdict(d)
-
     def read(self, node):
         if node == revlog.nullid:
             return self._newmanifest() # don't upset local cache
diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -201,7 +201,8 @@  class verifier(object):
                         progress=None):
         repo = self.repo
         ui = self.ui
-        mf = self.repo.manifest.dirlog(dir)
+        mfl = self.repo.manifestlog
+        mf = mfl._revlog.dirlog(dir)
 
         if not dir:
             self.ui.status(_("checking manifests\n"))
@@ -235,7 +236,8 @@  class verifier(object):
                 self.err(lr, _("%s not in changesets") % short(n), label)
 
             try:
-                for f, fn, fl in mf.readshallowdelta(n).iterentries():
+                mfdelta = mfl.get(dir, n).readdelta(shallow=True)
+                for f, fn, fl in mfdelta.iterentries():
                     if not f:
                         self.err(lr, _("entry without name in manifest"))
                     elif f == "/dev/null":  # ignore this in very old repos