diff --git a/hgext/sqlitestore.py b/hgext/sqlitestore.py --- a/hgext/sqlitestore.py +++ b/hgext/sqlitestore.py @@ -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): diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -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 diff --git a/mercurial/filelog.py b/mercurial/filelog.py --- a/mercurial/filelog.py +++ b/mercurial/filelog.py @@ -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) diff --git a/mercurial/interfaces/repository.py b/mercurial/interfaces/repository.py --- a/mercurial/interfaces/repository.py +++ b/mercurial/interfaces/repository.py @@ -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. diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -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) diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -2111,13 +2111,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, @@ -2128,7 +2129,6 @@ cachedelta=cachedelta, deltacomputer=deltacomputer, ) - return node def addrawrevision( self,