From patchwork Tue May 2 23:43:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2,of,8] transaction: track newly introduced revisions From: Pierre-Yves David X-Patchwork-Id: 20364 Message-Id: <76a035851a620dcf36a6.1493768619@nodosa.octopoid.net> To: mercurial-devel@mercurial-scm.org Date: Wed, 03 May 2017 01:43:39 +0200 # HG changeset patch # User Pierre-Yves David # Date 1493743551 -7200 # Tue May 02 18:45:51 2017 +0200 # Branch stable # Node ID 76a035851a620dcf36a6dd18a37409dff43c6d42 # Parent 6697da7c4eab3fbe3588a2f91fa3f99b16f808ac # EXP-Topic obscache # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ # hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 76a035851a62 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. diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -535,3 +535,14 @@ class changelog(revlog.revlog): 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 diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1100,6 +1100,7 @@ class localrepository(object): 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