Patchwork [9,of,9,V4] manifest: remove manifest.readshallowdelta

login
register
mail settings
Submitter Durham Goode
Date Sept. 20, 2016, 11:47 p.m.
Message ID <f24ed91bde0ea4307546.1474415276@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/16703/
State Accepted
Headers show

Comments

Durham Goode - Sept. 20, 2016, 11:47 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1474399441 25200
#      Tue Sep 20 12:24:01 2016 -0700
# Node ID f24ed91bde0ea4307546848e1100735d13879372
# Parent  b16ce237ed47ef8c6f0f72bbc511b29ea9289ef3
manifest: remove manifest.readshallowdelta

This removes manifest.readshallowdelta and converts its one consumer to use
manifestlog instead.
Durham Goode - Oct. 25, 2016, 8:19 p.m.
On 9/21/16 1:33 PM, Martin von Zweigbergk wrote:
> On Tue, Sep 20, 2016 at 4:47 PM, Durham Goode <durham@fb.com> wrote:
>> # HG changeset patch
>> # User Durham Goode <durham@fb.com>
>> # Date 1474399441 25200
>> #      Tue Sep 20 12:24:01 2016 -0700
>> # Node ID f24ed91bde0ea4307546848e1100735d13879372
>> # Parent  b16ce237ed47ef8c6f0f72bbc511b29ea9289ef3
>> manifest: remove manifest.readshallowdelta
>>
>> This removes manifest.readshallowdelta and converts its one consumer to use
>> manifestlog instead.
>>
>> diff --git a/mercurial/manifest.py b/mercurial/manifest.py
>> --- a/mercurial/manifest.py
>> +++ b/mercurial/manifest.py
>> @@ -1246,41 +1246,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.'''
> I thought this comment might be useful. Could you add it to the new
> method, thanks. Same thing applies to readshallow() in the previous
> patch.
Will do.
>
>> -        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)
>> +        mf = self.repo.manifestlog._revlog.dirlog(dir)
>> +        mfl = self.repo.manifestlog
> nit: write mf in terms of mfl instead, but feel free to leave as is if
> this is changing again before the end of the series (feel free to
> ignore otherwise too :-))
I'm not sure I understand what you mean by "in terms of mfl"?
>
>>           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
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=DQIBaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=nuarHzhP1wi1T9iURRCj1A&m=g23kxRa7I_WePzUCgsxSI92ed8zsD4GVzkhJgLrw8eg&s=-N_dUrq34DPROF4fJwAyTK6oFG8nFVVMUaUVPCRskfY&e=
via Mercurial-devel - Oct. 25, 2016, 8:22 p.m.
On Tue, Oct 25, 2016 at 1:19 PM, Durham Goode <durham@fb.com> wrote:
>
>
> On 9/21/16 1:33 PM, Martin von Zweigbergk wrote:
>>
>> On Tue, Sep 20, 2016 at 4:47 PM, Durham Goode <durham@fb.com> wrote:
>>>
>>> # HG changeset patch
>>> # User Durham Goode <durham@fb.com>
>>> # Date 1474399441 25200
>>> #      Tue Sep 20 12:24:01 2016 -0700
>>> # Node ID f24ed91bde0ea4307546848e1100735d13879372
>>> # Parent  b16ce237ed47ef8c6f0f72bbc511b29ea9289ef3
>>> manifest: remove manifest.readshallowdelta
>>>
>>> This removes manifest.readshallowdelta and converts its one consumer to
>>> use
>>> manifestlog instead.
>>>
>>> diff --git a/mercurial/manifest.py b/mercurial/manifest.py
>>> --- a/mercurial/manifest.py
>>> +++ b/mercurial/manifest.py
>>> @@ -1246,41 +1246,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.'''
>>
>> I thought this comment might be useful. Could you add it to the new
>> method, thanks. Same thing applies to readshallow() in the previous
>> patch.
>
> Will do.
>
>>
>>> -        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)
>>> +        mf = self.repo.manifestlog._revlog.dirlog(dir)
>>> +        mfl = self.repo.manifestlog
>>
>> nit: write mf in terms of mfl instead, but feel free to leave as is if
>> this is changing again before the end of the series (feel free to
>> ignore otherwise too :-))
>
> I'm not sure I understand what you mean by "in terms of mfl"?

I just mean to replace

  mf = self.repo.manifestlog._revlog.dirlog(dir)
  mfl = self.repo.manifestlog

by

  mfl = self.repo.manifestlog
  mf = mfl._revlog.dirlog(dir)

But it's definitely nitpicking.

>>
>>
>>>           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
>>> _______________________________________________
>>> Mercurial-devel mailing list
>>> Mercurial-devel@mercurial-scm.org
>>>
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=DQIBaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=nuarHzhP1wi1T9iURRCj1A&m=g23kxRa7I_WePzUCgsxSI92ed8zsD4GVzkhJgLrw8eg&s=-N_dUrq34DPROF4fJwAyTK6oFG8nFVVMUaUVPCRskfY&e=
>
>

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1246,41 +1246,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)
+        mf = self.repo.manifestlog._revlog.dirlog(dir)
+        mfl = self.repo.manifestlog
 
         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