From patchwork Mon Aug 19 19:46:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2,of,2] revlog: pass node as an argument of addrevision From: Wojciech Lopata X-Patchwork-Id: 2229 Message-Id: <9c0faa02950e30cb7b28.1376941572@dev1179.prn1.facebook.com> To: mercurial-devel@selenic.com Date: Mon, 19 Aug 2013 12:46:12 -0700 # HG changeset patch # User Wojciech Lopata # Date 1376936723 25200 # Mon Aug 19 11:25:23 2013 -0700 # Node ID 9c0faa02950e30cb7b288019368e458a6f5e310a # Parent 89b4d30ddd5c1d09c61d4578b1ad4875b7780418 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 @@ -991,7 +991,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 @@ -999,11 +1000,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