From patchwork Thu Sep 27 16:49:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,4] revlog: add a callback "tracking" duplicate node addition From: Boris Feld X-Patchwork-Id: 35136 Message-Id: <1bed338fee8612ca502b.1538066989@localhost.localdomain> To: mercurial-devel@mercurial-scm.org Date: Thu, 27 Sep 2018 18:49:49 +0200 # HG changeset patch # User Boris Feld # Date 1537383767 -7200 # Wed Sep 19 21:02:47 2018 +0200 # Node ID 1bed338fee8612ca502b2ef462c8cd7a59efe0aa # Parent ddca38941b2b80124220646554bbc2a0af1aff21 # EXP-Topic revlog-duplicates # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1bed338fee86 revlog: add a callback "tracking" duplicate node addition If a changegroup contains node already added to the repository, they will be skipped. Skipping them is the right behavior (we don't need to store things twice), but it can hide some information to the code doing the unbundle (eg: shelve looking for the tip of the bundle). The first step to improve this situation is to add a low level callback. We do not need this tracking on all revlog, so actual tracking will be added in the next changeset. diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -1797,6 +1797,10 @@ class revlog(object): tr.replace(self.indexfile, trindex * self._io.size) self._chunkclear() + def _nodeduplicatecallback(self, transaction, node): + """called when trying to add a node already stored. + """ + def addrevision(self, text, transaction, link, p1, p2, cachedelta=None, node=None, flags=REVIDX_DEFAULT_FLAGS, deltacomputer=None): """add a revision to the log @@ -2078,6 +2082,7 @@ class revlog(object): nodes.append(node) if node in self.nodemap: + self._nodeduplicatecallback(transaction, node) # this can happen if two branches make the same change continue