Mercurial > hg
comparison mercurial/changegroup.py @ 38890:d706c77449f9
changegroup: move generate() modifications from narrow
Narrow had a custom version of generate() that was essentially a copy
of generate() with inline additions to facilitate ellipses serving.
This commit inlines those modifications into generate().
Differential Revision: https://phab.mercurial-scm.org/D4067
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 02 Aug 2018 14:15:10 -0700 |
parents | a06aab274aef |
children | 205c98e2f1ba |
comparison
equal
deleted
inserted
replaced
38889:a06aab274aef | 38890:d706c77449f9 |
---|---|
655 cl = repo.changelog | 655 cl = repo.changelog |
656 | 656 |
657 clrevorder = {} | 657 clrevorder = {} |
658 mfs = {} # needed manifests | 658 mfs = {} # needed manifests |
659 fnodes = {} # needed file nodes | 659 fnodes = {} # needed file nodes |
660 mfl = repo.manifestlog | |
661 # TODO violates storage abstraction. | |
662 mfrevlog = mfl._revlog | |
660 changedfiles = set() | 663 changedfiles = set() |
661 | 664 |
662 # Callback for the changelog, used to collect changed files and manifest | 665 ellipsesmode = util.safehasattr(self, 'full_nodes') |
663 # nodes. | 666 |
667 # Callback for the changelog, used to collect changed files and | |
668 # manifest nodes. | |
664 # Returns the linkrev node (identity in the changelog case). | 669 # Returns the linkrev node (identity in the changelog case). |
665 def lookupcl(x): | 670 def lookupcl(x): |
666 c = cl.read(x) | 671 c = cl.read(x) |
667 clrevorder[x] = len(clrevorder) | 672 clrevorder[x] = len(clrevorder) |
668 n = c[0] | 673 |
669 # record the first changeset introducing this manifest version | 674 if ellipsesmode: |
670 mfs.setdefault(n, x) | 675 # Only update mfs if x is going to be sent. Otherwise we |
671 # Record a complete list of potentially-changed files in | 676 # end up with bogus linkrevs specified for manifests and |
672 # this manifest. | 677 # we skip some manifest nodes that we should otherwise |
673 changedfiles.update(c[3]) | 678 # have sent. |
679 if (x in self.full_nodes | |
680 or cl.rev(x) in self.precomputed_ellipsis): | |
681 n = c[0] | |
682 # Record the first changeset introducing this manifest | |
683 # version. | |
684 mfs.setdefault(n, x) | |
685 # Set this narrow-specific dict so we have the lowest | |
686 # manifest revnum to look up for this cl revnum. (Part of | |
687 # mapping changelog ellipsis parents to manifest ellipsis | |
688 # parents) | |
689 self.next_clrev_to_localrev.setdefault(cl.rev(x), | |
690 mfrevlog.rev(n)) | |
691 # We can't trust the changed files list in the changeset if the | |
692 # client requested a shallow clone. | |
693 if self.is_shallow: | |
694 changedfiles.update(mfl[c[0]].read().keys()) | |
695 else: | |
696 changedfiles.update(c[3]) | |
697 else: | |
698 | |
699 n = c[0] | |
700 # record the first changeset introducing this manifest version | |
701 mfs.setdefault(n, x) | |
702 # Record a complete list of potentially-changed files in | |
703 # this manifest. | |
704 changedfiles.update(c[3]) | |
705 | |
674 return x | 706 return x |
675 | 707 |
676 self._verbosenote(_('uncompressed size of bundle content:\n')) | 708 self._verbosenote(_('uncompressed size of bundle content:\n')) |
677 size = 0 | 709 size = 0 |
678 for chunk in self.group(clnodes, cl, lookupcl, units=_('changesets')): | 710 for chunk in self.group(clnodes, cl, lookupcl, units=_('changesets')): |
703 'treemanifest' not in repo.requirements) | 735 'treemanifest' not in repo.requirements) |
704 | 736 |
705 for chunk in self.generatemanifests(commonrevs, clrevorder, | 737 for chunk in self.generatemanifests(commonrevs, clrevorder, |
706 fastpathlinkrev, mfs, fnodes, source): | 738 fastpathlinkrev, mfs, fnodes, source): |
707 yield chunk | 739 yield chunk |
740 | |
741 if ellipsesmode: | |
742 mfdicts = None | |
743 if self.is_shallow: | |
744 mfdicts = [(self._repo.manifestlog[n].read(), lr) | |
745 for (n, lr) in mfs.iteritems()] | |
746 | |
708 mfs.clear() | 747 mfs.clear() |
709 clrevs = set(cl.rev(x) for x in clnodes) | 748 clrevs = set(cl.rev(x) for x in clnodes) |
710 | 749 |
711 if not fastpathlinkrev: | 750 if not fastpathlinkrev: |
712 def linknodes(unused, fname): | 751 def linknodes(unused, fname): |
716 def linknodes(filerevlog, fname): | 755 def linknodes(filerevlog, fname): |
717 llr = filerevlog.linkrev | 756 llr = filerevlog.linkrev |
718 fln = filerevlog.node | 757 fln = filerevlog.node |
719 revs = ((r, llr(r)) for r in filerevlog) | 758 revs = ((r, llr(r)) for r in filerevlog) |
720 return dict((fln(r), cln(lr)) for r, lr in revs if lr in clrevs) | 759 return dict((fln(r), cln(lr)) for r, lr in revs if lr in clrevs) |
760 | |
761 if ellipsesmode: | |
762 # We need to pass the mfdicts variable down into | |
763 # generatefiles(), but more than one command might have | |
764 # wrapped generatefiles so we can't modify the function | |
765 # signature. Instead, we pass the data to ourselves using an | |
766 # instance attribute. I'm sorry. | |
767 self._mfdicts = mfdicts | |
721 | 768 |
722 for chunk in self.generatefiles(changedfiles, linknodes, commonrevs, | 769 for chunk in self.generatefiles(changedfiles, linknodes, commonrevs, |
723 source): | 770 source): |
724 yield chunk | 771 yield chunk |
725 | 772 |