# HG changeset patch # User Gregory Szorc # Date 2018-08-07 17:55:32 # Node ID 40374b4a780fb082c1632eba9cb64765d4807887 # Parent 812eec3f89cb7668ca5ec848dbb23a84e1f8f911 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 diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -661,14 +661,10 @@ class cgpacker(object): # 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 @@ class cgpacker(object): 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 @@ class cgpacker(object): # 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 @@ class cgpacker(object): # 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 @@ class cgpacker(object): 'clrevorder': clrevorder, 'mfs': mfs, 'changedfiles': changedfiles, + 'clrevtomanifestrev': clrevtomanifestrev, } gen = self.group(revs, cl, True, lookupcl, units=_('changesets'))