Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 19625:6a411a06cb1f
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. In particular this change is necessary to implement manifest
compression.
author | Wojciech Lopata <lopek@fb.com> |
---|---|
date | Mon, 19 Aug 2013 11:25:23 -0700 |
parents | 55749cb14d24 |
children | c2e27e57d250 |
comparison
equal
deleted
inserted
replaced
19624:55749cb14d24 | 19625:6a411a06cb1f |
---|---|
991 fp.close() | 991 fp.close() |
992 | 992 |
993 tr.replace(self.indexfile, trindex * self._io.size) | 993 tr.replace(self.indexfile, trindex * self._io.size) |
994 self._chunkclear() | 994 self._chunkclear() |
995 | 995 |
996 def addrevision(self, text, transaction, link, p1, p2, cachedelta=None): | 996 def addrevision(self, text, transaction, link, p1, p2, cachedelta=None, |
997 node=None): | |
997 """add a revision to the log | 998 """add a revision to the log |
998 | 999 |
999 text - the revision data to add | 1000 text - the revision data to add |
1000 transaction - the transaction object used for rollback | 1001 transaction - the transaction object used for rollback |
1001 link - the linkrev data to add | 1002 link - the linkrev data to add |
1002 p1, p2 - the parent nodeids of the revision | 1003 p1, p2 - the parent nodeids of the revision |
1003 cachedelta - an optional precomputed delta | 1004 cachedelta - an optional precomputed delta |
1005 node - nodeid of revision; typically node is not specified, and it is | |
1006 computed by default as hash(text, p1, p2), however subclasses might | |
1007 use different hashing method (and override checkhash() in such case) | |
1004 """ | 1008 """ |
1005 if link == nullrev: | 1009 if link == nullrev: |
1006 raise RevlogError(_("attempted to add linkrev -1 to %s") | 1010 raise RevlogError(_("attempted to add linkrev -1 to %s") |
1007 % self.indexfile) | 1011 % self.indexfile) |
1008 node = hash(text, p1, p2) | 1012 node = node or hash(text, p1, p2) |
1009 if node in self.nodemap: | 1013 if node in self.nodemap: |
1010 return node | 1014 return node |
1011 | 1015 |
1012 dfh = None | 1016 dfh = None |
1013 if not self._inline: | 1017 if not self._inline: |