[PATCH] revlog: allow custom nodeids in subclasses

Matt Mackall mpm at selenic.com
Sun Aug 18 20:08:59 CDT 2013


On Thu, 2013-08-15 at 23:29 +0000, Wojciech Lopata wrote:
> > From: Matt Mackall [mailto:mpm at selenic.com]
> > Sent: Thursday, August 15, 2013 1:29 PM
> > To: Wojciech Lopata
> > Cc: mercurial-devel at selenic.com
> > Subject: Re: [PATCH] revlog: allow custom nodeids in subclasses
> > 
> > On Wed, 2013-08-14 at 09:53 -0700, Wojciech Lopata wrote:
> > > # HG changeset patch
> > > # User Wojciech Lopata <lopek at fb.com>
> > > # Date 1376497815 25200
> > > #      Wed Aug 14 09:30:15 2013 -0700
> > > # Node ID 1e1e57b10f2a1927781408b8c01ab84dc84e8d3f
> > > # Parent  df54cc67b91bea97c4fc299241a67aeecf099d00
> > > revlog: allow custom nodeids in subclasses
> > >
> > > Modify revlog class to allow its subclasses to use custom method of
> > computing
> > > nodeids. In particular this change is necesary to implement manifest
> > > compression.
> > >
> > > diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> > > old mode 100644
> > > new mode 100755
> > > --- a/mercurial/revlog.py
> > > +++ b/mercurial/revlog.py
> > > @@ -943,11 +943,15 @@
> > >
> > >      def _checkhash(self, text, node, rev):
> > >          p1, p2 = self.parents(node)
> > > -        if node != hash(text, p1, p2):
> > > +        if not self._ishashcorrect(text, p1, p2, node):
> > >              raise RevlogError(_("integrity check failed on %s:%d")
> > >                                % (self.indexfile, rev))
> > 
> > Let's move the raise inside the method. Then the method can be renamed
> > to checkhash, with no return code.
> > 
> > > -    def addrevision(self, text, transaction, link, p1, p2, cachedelta=None):
> > > +    def addrevision(self, text, transaction, link, p1, p2, cachedelta=None,
> > > +                    node=None):
> > 
> > Separate patch, please.
> > 
> > > +            if not self._ishashcorrect(btext[0], p1, p2, node):
> > >                  raise RevlogError(_("consistency error in delta"))
> > 
> > You'll note this message is less informative than the earlier one.
> 
> Earlier message, that contains filename and rev, doesn't fit this
> situation - here we assert that nodeid and delta passed to
> _addrevision match (there is no concept of indexfile or rev yet).

There definitely is an indexfile, it's given to revlog at init time. And
we don't really care about rev if we have a node.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list