Submitter | Wojciech Lopata |
---|---|
Date | Aug. 19, 2013, 6:55 p.m. |
Message ID | <568a119612c68959ac44.1376938538@dev1179.prn1.facebook.com> |
Download | mbox | patch |
Permalink | /patch/2227/ |
State | Superseded |
Commit | 6a411a06cb1feef5776127b08ca1a6b7284e0238 |
Headers | show |
Comments
series LGTM On Mon, Aug 19, 2013 at 2:55 PM, Wojciech Lopata <lopek@fb.com> wrote: > # HG changeset patch > # User Wojciech Lopata <lopek@fb.com> > # Date 1376936723 25200 > # Mon Aug 19 11:25:23 2013 -0700 > # Node ID 568a119612c68959ac44c9ec73c7b50f71c10810 > # Parent ace27c00a18646ce022b5b75448246c1423bde6a > revlog: pass node as an argument of addrevision > > This change will allow revlog subclasses that override 'checkhash' method > to use custom strategy of computing nodeids without overriding 'addrevision' > method. > > diff --git a/mercurial/revlog.py b/mercurial/revlog.py > --- a/mercurial/revlog.py > +++ b/mercurial/revlog.py > @@ -990,7 +990,8 @@ > tr.replace(self.indexfile, trindex * self._io.size) > self._chunkclear() > > - def addrevision(self, text, transaction, link, p1, p2, cachedelta=None): > + def addrevision(self, text, transaction, link, p1, p2, cachedelta=None, > + node=None): > """add a revision to the log > > text - the revision data to add > @@ -998,11 +999,14 @@ > link - the linkrev data to add > p1, p2 - the parent nodeids of the revision > cachedelta - an optional precomputed delta > + node - nodeid of revision; typically node is not specified, and it is > + computed by default as hash(text, p1, p2), however subclasses might > + use different hashing method (and override checkhash() in such case) > """ > if link == nullrev: > raise RevlogError(_("attempted to add linkrev -1 to %s") > % self.indexfile) > - node = hash(text, p1, p2) > + node = node or hash(text, p1, p2) > if node in self.nodemap: > return node > > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
Actually this one had small bug in displaying error message that I noticed too late ('12345678901234567890' nodeid is not a good choice for testing). This was also sent from wrong bookmark and has wrong parent (although I don't know if it matters). Sorry for spamming :( I've just resent correct (hopefully) patch. > -----Original Message----- > From: Augie Fackler [mailto:lists@durin42.com] > Sent: Monday, August 19, 2013 12:08 PM > To: Wojciech Lopata > Cc: Mercurial-devel > Subject: Re: [PATCH 2 of 2] revlog: pass node as an argument of addrevision > > series LGTM > > On Mon, Aug 19, 2013 at 2:55 PM, Wojciech Lopata <lopek@fb.com> wrote: > > # HG changeset patch > > # User Wojciech Lopata <lopek@fb.com> > > # Date 1376936723 25200 > > # Mon Aug 19 11:25:23 2013 -0700 > > # Node ID 568a119612c68959ac44c9ec73c7b50f71c10810 > > # Parent ace27c00a18646ce022b5b75448246c1423bde6a > > revlog: pass node as an argument of addrevision > > > > This change will allow revlog subclasses that override 'checkhash' > > method to use custom strategy of computing nodeids without overriding > 'addrevision' > > method. > > > > diff --git a/mercurial/revlog.py b/mercurial/revlog.py > > --- a/mercurial/revlog.py > > +++ b/mercurial/revlog.py > > @@ -990,7 +990,8 @@ > > tr.replace(self.indexfile, trindex * self._io.size) > > self._chunkclear() > > > > - def addrevision(self, text, transaction, link, p1, p2, cachedelta=None): > > + def addrevision(self, text, transaction, link, p1, p2, cachedelta=None, > > + node=None): > > """add a revision to the log > > > > text - the revision data to add @@ -998,11 +999,14 @@ > > link - the linkrev data to add > > p1, p2 - the parent nodeids of the revision > > cachedelta - an optional precomputed delta > > + node - nodeid of revision; typically node is not specified, and it is > > + computed by default as hash(text, p1, p2), however subclasses > might > > + use different hashing method (and override checkhash() in > > + such case) > > """ > > if link == nullrev: > > raise RevlogError(_("attempted to add linkrev -1 to %s") > > % self.indexfile) > > - node = hash(text, p1, p2) > > + node = node or hash(text, p1, p2) > > if node in self.nodemap: > > return node > > > > _______________________________________________ > > Mercurial-devel mailing list > > Mercurial-devel@selenic.com > > http://selenic.com/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -990,7 +990,8 @@ tr.replace(self.indexfile, trindex * self._io.size) self._chunkclear() - def addrevision(self, text, transaction, link, p1, p2, cachedelta=None): + def addrevision(self, text, transaction, link, p1, p2, cachedelta=None, + node=None): """add a revision to the log text - the revision data to add @@ -998,11 +999,14 @@ link - the linkrev data to add p1, p2 - the parent nodeids of the revision cachedelta - an optional precomputed delta + node - nodeid of revision; typically node is not specified, and it is + computed by default as hash(text, p1, p2), however subclasses might + use different hashing method (and override checkhash() in such case) """ if link == nullrev: raise RevlogError(_("attempted to add linkrev -1 to %s") % self.indexfile) - node = hash(text, p1, p2) + node = node or hash(text, p1, p2) if node in self.nodemap: return node