changeset 32262:85ef5a073114

transaction: track newly introduced revisions Tracking revisions is not the data that will unlock the most new capability. However, they are the simplest thing to track and still unlock some nice improvements in regard with caching. We plug ourself at the changelog level to make sure we do not miss any revision additions. The 'revs' set is configured at the repository level because the transaction itself does not needs to know that much about the business logic.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 02 May 2017 18:45:51 +0200
parents 976681123416
children 604d65e2c0b2
files mercurial/changelog.py mercurial/localrepo.py
diffstat 2 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changelog.py	Tue May 02 18:31:18 2017 +0200
+++ b/mercurial/changelog.py	Tue May 02 18:45:51 2017 +0200
@@ -535,3 +535,14 @@
         just to access this is costly."""
         extra = self.read(rev)[5]
         return encoding.tolocal(extra.get("branch")), 'close' in extra
+
+    def _addrevision(self, node, rawtext, transaction, *args, **kwargs):
+        # overlay over the standard revlog._addrevision to track the new
+        # revision on the transaction.
+        rev = len(self)
+        node = super(changelog, self)._addrevision(node, rawtext, transaction,
+                                                   *args, **kwargs)
+        revs = transaction.changes.get('revs')
+        if revs is not None:
+            revs.add(rev)
+        return node
--- a/mercurial/localrepo.py	Tue May 02 18:31:18 2017 +0200
+++ b/mercurial/localrepo.py	Tue May 02 18:45:51 2017 +0200
@@ -1072,6 +1072,7 @@
                                      self.store.createmode,
                                      validator=validate,
                                      releasefn=releasefn)
+        tr.changes['revs'] = set()
 
         tr.hookargs['txnid'] = txnid
         # note: writing the fncache only during finalize mean that the file is