changeset 38998:40374b4a780f

changegroup: track changelog to manifest revision map explicitly Previously, self._nextclrevtolocalrev was only populated as part of the changelog lookup callback. But cgpacker._close() was looking at self._nextclrevtolocalrev on every invocation. Since self._nextclrevtolocalrev is for communicating the mapping of changelog revisions to manifest revisions, this commit refactors the code to make that explicit. The changelog state now stores this mapping. And after the changelog group is emitted, we update self._clrevtolocalrev with that dict. self._nextclrevtolocalrev is unused and has been deleted. Differential Revision: https://phab.mercurial-scm.org/D4190
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 07 Aug 2018 10:55:32 -0700
parents 812eec3f89cb
children b83e9c503f2f
files mercurial/changegroup.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changegroup.py	Tue Aug 07 10:49:41 2018 -0700
+++ b/mercurial/changegroup.py	Tue Aug 07 10:55:32 2018 -0700
@@ -661,14 +661,10 @@
         # Maps CL revs to per-revlog revisions. Cleared in close() at
         # the end of each group.
         self._clrevtolocalrev = {}
-        self._nextclrevtolocalrev = {}
 
     def _close(self):
         # Ellipses serving mode.
         self._clrevtolocalrev.clear()
-        if self._nextclrevtolocalrev is not None:
-            self._clrevtolocalrev = self._nextclrevtolocalrev
-            self._nextclrevtolocalrev = None
 
         return closechunk()
 
@@ -784,6 +780,9 @@
         mfs = clstate['mfs']
         changedfiles = clstate['changedfiles']
 
+        if self._ellipses:
+            self._clrevtolocalrev = clstate['clrevtomanifestrev']
+
         # We need to make sure that the linkrev in the changegroup refers to
         # the first changeset that introduced the manifest or file revision.
         # The fastpath is usually safer than the slowpath, because the filelogs
@@ -853,6 +852,7 @@
         # TODO violates storage abstraction.
         mfrevlog = mfl._revlog
         changedfiles = set()
+        clrevtomanifestrev = {}
 
         # Callback for the changelog, used to collect changed files and
         # manifest nodes.
@@ -876,8 +876,7 @@
                     # manifest revnum to look up for this cl revnum. (Part of
                     # mapping changelog ellipsis parents to manifest ellipsis
                     # parents)
-                    self._nextclrevtolocalrev.setdefault(cl.rev(x),
-                                                         mfrevlog.rev(n))
+                    clrevtomanifestrev.setdefault(cl.rev(x), mfrevlog.rev(n))
                 # We can't trust the changed files list in the changeset if the
                 # client requested a shallow clone.
                 if self._isshallow:
@@ -903,6 +902,7 @@
             'clrevorder': clrevorder,
             'mfs': mfs,
             'changedfiles': changedfiles,
+            'clrevtomanifestrev': clrevtomanifestrev,
         }
 
         gen = self.group(revs, cl, True, lookupcl, units=_('changesets'))