Mercurial > hg
comparison mercurial/changegroup.py @ 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 |
comparison
equal
deleted
inserted
replaced
38997:812eec3f89cb | 38998:40374b4a780f |
---|---|
659 self._verbosenote = lambda s: None | 659 self._verbosenote = lambda s: None |
660 | 660 |
661 # Maps CL revs to per-revlog revisions. Cleared in close() at | 661 # Maps CL revs to per-revlog revisions. Cleared in close() at |
662 # the end of each group. | 662 # the end of each group. |
663 self._clrevtolocalrev = {} | 663 self._clrevtolocalrev = {} |
664 self._nextclrevtolocalrev = {} | |
665 | 664 |
666 def _close(self): | 665 def _close(self): |
667 # Ellipses serving mode. | 666 # Ellipses serving mode. |
668 self._clrevtolocalrev.clear() | 667 self._clrevtolocalrev.clear() |
669 if self._nextclrevtolocalrev is not None: | |
670 self._clrevtolocalrev = self._nextclrevtolocalrev | |
671 self._nextclrevtolocalrev = None | |
672 | 668 |
673 return closechunk() | 669 return closechunk() |
674 | 670 |
675 def group(self, revs, store, ischangelog, lookup, units=None): | 671 def group(self, revs, store, ischangelog, lookup, units=None): |
676 """Calculate a delta group, yielding a sequence of changegroup chunks | 672 """Calculate a delta group, yielding a sequence of changegroup chunks |
781 self._verbosenote(_('%8.i (changelog)\n') % size) | 777 self._verbosenote(_('%8.i (changelog)\n') % size) |
782 | 778 |
783 clrevorder = clstate['clrevorder'] | 779 clrevorder = clstate['clrevorder'] |
784 mfs = clstate['mfs'] | 780 mfs = clstate['mfs'] |
785 changedfiles = clstate['changedfiles'] | 781 changedfiles = clstate['changedfiles'] |
782 | |
783 if self._ellipses: | |
784 self._clrevtolocalrev = clstate['clrevtomanifestrev'] | |
786 | 785 |
787 # We need to make sure that the linkrev in the changegroup refers to | 786 # We need to make sure that the linkrev in the changegroup refers to |
788 # the first changeset that introduced the manifest or file revision. | 787 # the first changeset that introduced the manifest or file revision. |
789 # The fastpath is usually safer than the slowpath, because the filelogs | 788 # The fastpath is usually safer than the slowpath, because the filelogs |
790 # are walked in revlog order. | 789 # are walked in revlog order. |
851 mfs = {} # needed manifests | 850 mfs = {} # needed manifests |
852 mfl = self._repo.manifestlog | 851 mfl = self._repo.manifestlog |
853 # TODO violates storage abstraction. | 852 # TODO violates storage abstraction. |
854 mfrevlog = mfl._revlog | 853 mfrevlog = mfl._revlog |
855 changedfiles = set() | 854 changedfiles = set() |
855 clrevtomanifestrev = {} | |
856 | 856 |
857 # Callback for the changelog, used to collect changed files and | 857 # Callback for the changelog, used to collect changed files and |
858 # manifest nodes. | 858 # manifest nodes. |
859 # Returns the linkrev node (identity in the changelog case). | 859 # Returns the linkrev node (identity in the changelog case). |
860 def lookupcl(x): | 860 def lookupcl(x): |
874 mfs.setdefault(n, x) | 874 mfs.setdefault(n, x) |
875 # Set this narrow-specific dict so we have the lowest | 875 # Set this narrow-specific dict so we have the lowest |
876 # manifest revnum to look up for this cl revnum. (Part of | 876 # manifest revnum to look up for this cl revnum. (Part of |
877 # mapping changelog ellipsis parents to manifest ellipsis | 877 # mapping changelog ellipsis parents to manifest ellipsis |
878 # parents) | 878 # parents) |
879 self._nextclrevtolocalrev.setdefault(cl.rev(x), | 879 clrevtomanifestrev.setdefault(cl.rev(x), mfrevlog.rev(n)) |
880 mfrevlog.rev(n)) | |
881 # We can't trust the changed files list in the changeset if the | 880 # We can't trust the changed files list in the changeset if the |
882 # client requested a shallow clone. | 881 # client requested a shallow clone. |
883 if self._isshallow: | 882 if self._isshallow: |
884 changedfiles.update(mfl[c[0]].read().keys()) | 883 changedfiles.update(mfl[c[0]].read().keys()) |
885 else: | 884 else: |
901 | 900 |
902 state = { | 901 state = { |
903 'clrevorder': clrevorder, | 902 'clrevorder': clrevorder, |
904 'mfs': mfs, | 903 'mfs': mfs, |
905 'changedfiles': changedfiles, | 904 'changedfiles': changedfiles, |
905 'clrevtomanifestrev': clrevtomanifestrev, | |
906 } | 906 } |
907 | 907 |
908 gen = self.group(revs, cl, True, lookupcl, units=_('changesets')) | 908 gen = self.group(revs, cl, True, lookupcl, units=_('changesets')) |
909 | 909 |
910 return state, gen | 910 return state, gen |