revlog: add a callback "tracking" duplicate node addition
authorBoris Feld <boris.feld@octobus.net>
Wed, 19 Sep 2018 21:02:47 +0200
changeset 39886 debc4ee597e7
parent 39885 566cc633e637
child 39887 a3095bc47217
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.
mercurial/revlog.py
--- a/mercurial/revlog.py	Wed Sep 26 18:30:19 2018 -0400
+++ b/mercurial/revlog.py	Wed Sep 19 21:02:47 2018 +0200
@@ -1745,6 +1745,10 @@
         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
@@ -2026,6 +2030,7 @@
                 nodes.append(node)
 
                 if node in self.nodemap:
+                    self._nodeduplicatecallback(transaction, node)
                     # this can happen if two branches make the same change
                     continue