joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The new callback is called whenever a changeset is added to the repository
  (commit, unbundle or exchange). Since the bulk operations already parse
  the changeset (readfiles or full changesetrevision), always use the
  latter to avoid redundant lookups. The first consumer of the new
  interface needs to look at extra.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9780

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/commit.py
  mercurial/exchangev2.py
  mercurial/interfaces/repository.py
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1989,6 +1989,9 @@
             self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
         return self._revbranchcache
 
+    def register_changeset(self, node, changelogrevision):
+        pass
+
     def branchtip(self, branch, ignoremissing=False):
         """return the tip node for a given branch
 
diff --git a/mercurial/interfaces/repository.py 
b/mercurial/interfaces/repository.py
--- a/mercurial/interfaces/repository.py
+++ b/mercurial/interfaces/repository.py
@@ -1641,6 +1641,13 @@
     def revbranchcache():
         pass
 
+    def register_changeset(node, changelogrevision):
+        """Extension point for caches for new nodes.
+
+        The changelogrevision object is provided as optimisation to
+        avoid duplicate lookups."""
+        pass
+
     def branchtip(branchtip, ignoremissing=False):
         """Return the tip node for a given branch."""
 
diff --git a/mercurial/exchangev2.py b/mercurial/exchangev2.py
--- a/mercurial/exchangev2.py
+++ b/mercurial/exchangev2.py
@@ -371,6 +371,8 @@
         # so we can set the linkrev accordingly when manifests are added.
         manifestnodes[cl.rev(node)] = revision.manifest
 
+        repo.register_changeset(node, revision)
+
     nodesbyphase = {phase: set() for phase in phases.phasenames.values()}
     remotebookmarks = {}
 
diff --git a/mercurial/commit.py b/mercurial/commit.py
--- a/mercurial/commit.py
+++ b/mercurial/commit.py
@@ -96,6 +96,8 @@
             ctx.date(),
             extra,
         )
+        repo.register_changeset(n, repo.changelog.changelogrevision(n))
+
         xp1, xp2 = p1.hex(), p2 and p2.hex() or b''
         repo.hook(
             b'pretxncommit',
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -323,7 +323,9 @@
                     cgnodes.append(node)
 
             def onchangelog(cl, node):
-                efilesset.update(cl.readfiles(node))
+                ctx = cl.changelogrevision(node)
+                efilesset.update(ctx.files)
+                repo.register_changeset(node, ctx)
 
             self.changelogheader()
             deltas = self.deltaiter()



To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to