Mercurial > hg
changeset 46508:f7b61ad3c64a
revlog: change addrevision to return the new revision, not node
Differential Revision: https://phab.mercurial-scm.org/D9882
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Wed, 27 Jan 2021 01:43:17 +0100 |
parents | 9ee4e988e2be |
children | 7a93b7b3dc2d |
files | hgext/sqlitestore.py mercurial/changelog.py mercurial/filelog.py mercurial/interfaces/repository.py mercurial/manifest.py mercurial/revlog.py |
diffstat | 6 files changed, 23 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/sqlitestore.py Wed Jan 27 00:55:20 2021 +0100 +++ b/hgext/sqlitestore.py Wed Jan 27 01:43:17 2021 +0100 @@ -636,7 +636,8 @@ if meta or filedata.startswith(b'\x01\n'): filedata = storageutil.packmeta(meta, filedata) - return self.addrevision(filedata, transaction, linkrev, p1, p2) + rev = self.addrevision(filedata, transaction, linkrev, p1, p2) + return self.node(rev) def addrevision( self, @@ -658,15 +659,16 @@ if validatehash: self._checkhash(revisiondata, node, p1, p2) - if node in self._nodetorev: - return node + rev = self._nodetorev.get(node) + if rev is not None: + return rev - node = self._addrawrevision( + rev = self._addrawrevision( node, revisiondata, transaction, linkrev, p1, p2 ) self._revisioncache[node] = revisiondata - return node + return rev def addgroup( self, @@ -1079,7 +1081,7 @@ self._revtonode[rev] = node self._revisions[node] = entry - return node + return rev class sqliterepository(localrepo.localrepository):
--- a/mercurial/changelog.py Wed Jan 27 00:55:20 2021 +0100 +++ b/mercurial/changelog.py Wed Jan 27 01:43:17 2021 +0100 @@ -598,9 +598,10 @@ parseddate = b"%s %s" % (parseddate, extra) l = [hex(manifest), user, parseddate] + sortedfiles + [b"", desc] text = b"\n".join(l) - return self.addrevision( + rev = self.addrevision( text, transaction, len(self), p1, p2, sidedata=sidedata, flags=flags ) + return self.node(rev) def branchinfo(self, rev): """return the branch name and open/close state of a revision
--- a/mercurial/filelog.py Wed Jan 27 00:55:20 2021 +0100 +++ b/mercurial/filelog.py Wed Jan 27 01:43:17 2021 +0100 @@ -176,7 +176,8 @@ def add(self, text, meta, transaction, link, p1=None, p2=None): if meta or text.startswith(b'\1\n'): text = storageutil.packmeta(meta, text) - return self.addrevision(text, transaction, link, p1, p2) + rev = self.addrevision(text, transaction, link, p1, p2) + return self.node(rev) def renamed(self, node): return storageutil.filerevisioncopied(self, node)
--- a/mercurial/interfaces/repository.py Wed Jan 27 00:55:20 2021 +0100 +++ b/mercurial/interfaces/repository.py Wed Jan 27 01:43:17 2021 +0100 @@ -734,7 +734,7 @@ flags=0, cachedelta=None, ): - """Add a new revision to the store. + """Add a new revision to the store and return its number. This is similar to ``add()`` except it operates at a lower level.
--- a/mercurial/manifest.py Wed Jan 27 00:55:20 2021 +0100 +++ b/mercurial/manifest.py Wed Jan 27 01:43:17 2021 +0100 @@ -1704,9 +1704,10 @@ arraytext, deltatext = m.fastdelta(self.fulltextcache[p1], work) cachedelta = self._revlog.rev(p1), deltatext text = util.buffer(arraytext) - n = self._revlog.addrevision( + rev = self._revlog.addrevision( text, transaction, link, p1, p2, cachedelta ) + n = self._revlog.node(rev) except FastdeltaUnavailable: # The first parent manifest isn't already loaded or the # manifest implementation doesn't support fastdelta, so @@ -1724,7 +1725,8 @@ arraytext = None else: text = m.text() - n = self._revlog.addrevision(text, transaction, link, p1, p2) + rev = self._revlog.addrevision(text, transaction, link, p1, p2) + n = self._revlog.node(rev) arraytext = bytearray(text) if arraytext is not None: @@ -1765,9 +1767,10 @@ n = m2.node() if not n: - n = self._revlog.addrevision( + rev = self._revlog.addrevision( text, transaction, link, m1.node(), m2.node() ) + n = self._revlog.node(rev) # Save nodeid so parent manifest can calculate its nodeid m.setnode(n)
--- a/mercurial/revlog.py Wed Jan 27 00:55:20 2021 +0100 +++ b/mercurial/revlog.py Wed Jan 27 01:43:17 2021 +0100 @@ -2106,13 +2106,14 @@ ) node = node or self.hash(rawtext, p1, p2) - if self.index.has_node(node): - return node + rev = self.index.get_rev(node) + if rev is not None: + return rev if validatehash: self.checkhash(rawtext, node, p1=p1, p2=p2) - rev = self.addrawrevision( + return self.addrawrevision( rawtext, transaction, link, @@ -2123,7 +2124,6 @@ cachedelta=cachedelta, deltacomputer=deltacomputer, ) - return node def addrawrevision( self,