##// END OF EJS Templates
changegroup: extract cgpacker.group() to standalone function...
Gregory Szorc -
r39045:9e8eb2b4 default
parent child Browse files
Show More
@@ -681,77 +681,7 b' def _revisiondeltanarrow(cl, store, isch'
681 681 deltachunks=(diffheader, data),
682 682 )
683 683
684 class cgpacker(object):
685 def __init__(self, repo, filematcher, version, allowreorder,
686 deltaparentfn, builddeltaheader, manifestsend,
687 bundlecaps=None, ellipses=False,
688 shallow=False, ellipsisroots=None, fullnodes=None):
689 """Given a source repo, construct a bundler.
690
691 filematcher is a matcher that matches on files to include in the
692 changegroup. Used to facilitate sparse changegroups.
693
694 allowreorder controls whether reordering of revisions is allowed.
695 This value is used when ``bundle.reorder`` is ``auto`` or isn't
696 set.
697
698 deltaparentfn is a callable that resolves the delta parent for
699 a specific revision.
700
701 builddeltaheader is a callable that constructs the header for a group
702 delta.
703
704 manifestsend is a chunk to send after manifests have been fully emitted.
705
706 ellipses indicates whether ellipsis serving mode is enabled.
707
708 bundlecaps is optional and can be used to specify the set of
709 capabilities which can be used to build the bundle. While bundlecaps is
710 unused in core Mercurial, extensions rely on this feature to communicate
711 capabilities to customize the changegroup packer.
712
713 shallow indicates whether shallow data might be sent. The packer may
714 need to pack file contents not introduced by the changes being packed.
715
716 fullnodes is the set of changelog nodes which should not be ellipsis
717 nodes. We store this rather than the set of nodes that should be
718 ellipsis because for very large histories we expect this to be
719 significantly smaller.
720 """
721 assert filematcher
722 self._filematcher = filematcher
723
724 self.version = version
725 self._deltaparentfn = deltaparentfn
726 self._builddeltaheader = builddeltaheader
727 self._manifestsend = manifestsend
728 self._ellipses = ellipses
729
730 # Set of capabilities we can use to build the bundle.
731 if bundlecaps is None:
732 bundlecaps = set()
733 self._bundlecaps = bundlecaps
734 self._isshallow = shallow
735 self._fullclnodes = fullnodes
736
737 # Maps ellipsis revs to their roots at the changelog level.
738 self._precomputedellipsis = ellipsisroots
739
740 # experimental config: bundle.reorder
741 reorder = repo.ui.config('bundle', 'reorder')
742 if reorder == 'auto':
743 self._reorder = allowreorder
744 else:
745 self._reorder = stringutil.parsebool(reorder)
746
747 self._repo = repo
748
749 if self._repo.ui.verbose and not self._repo.ui.debugflag:
750 self._verbosenote = self._repo.ui.note
751 else:
752 self._verbosenote = lambda s: None
753
754 def group(self, repo, revs, store, ischangelog, lookup, deltaparentfn,
684 def deltagroup(repo, revs, store, ischangelog, lookup, deltaparentfn,
755 685 deltaheaderfn, units=None,
756 686 ellipses=False, clrevtolocalrev=None, fullclnodes=None,
757 687 precomputedellipsis=None):
@@ -825,6 +755,76 b' class cgpacker(object):'
825 755
826 756 yield closechunk()
827 757
758 class cgpacker(object):
759 def __init__(self, repo, filematcher, version, allowreorder,
760 deltaparentfn, builddeltaheader, manifestsend,
761 bundlecaps=None, ellipses=False,
762 shallow=False, ellipsisroots=None, fullnodes=None):
763 """Given a source repo, construct a bundler.
764
765 filematcher is a matcher that matches on files to include in the
766 changegroup. Used to facilitate sparse changegroups.
767
768 allowreorder controls whether reordering of revisions is allowed.
769 This value is used when ``bundle.reorder`` is ``auto`` or isn't
770 set.
771
772 deltaparentfn is a callable that resolves the delta parent for
773 a specific revision.
774
775 builddeltaheader is a callable that constructs the header for a group
776 delta.
777
778 manifestsend is a chunk to send after manifests have been fully emitted.
779
780 ellipses indicates whether ellipsis serving mode is enabled.
781
782 bundlecaps is optional and can be used to specify the set of
783 capabilities which can be used to build the bundle. While bundlecaps is
784 unused in core Mercurial, extensions rely on this feature to communicate
785 capabilities to customize the changegroup packer.
786
787 shallow indicates whether shallow data might be sent. The packer may
788 need to pack file contents not introduced by the changes being packed.
789
790 fullnodes is the set of changelog nodes which should not be ellipsis
791 nodes. We store this rather than the set of nodes that should be
792 ellipsis because for very large histories we expect this to be
793 significantly smaller.
794 """
795 assert filematcher
796 self._filematcher = filematcher
797
798 self.version = version
799 self._deltaparentfn = deltaparentfn
800 self._builddeltaheader = builddeltaheader
801 self._manifestsend = manifestsend
802 self._ellipses = ellipses
803
804 # Set of capabilities we can use to build the bundle.
805 if bundlecaps is None:
806 bundlecaps = set()
807 self._bundlecaps = bundlecaps
808 self._isshallow = shallow
809 self._fullclnodes = fullnodes
810
811 # Maps ellipsis revs to their roots at the changelog level.
812 self._precomputedellipsis = ellipsisroots
813
814 # experimental config: bundle.reorder
815 reorder = repo.ui.config('bundle', 'reorder')
816 if reorder == 'auto':
817 self._reorder = allowreorder
818 else:
819 self._reorder = stringutil.parsebool(reorder)
820
821 self._repo = repo
822
823 if self._repo.ui.verbose and not self._repo.ui.debugflag:
824 self._verbosenote = self._repo.ui.note
825 else:
826 self._verbosenote = lambda s: None
827
828 828 def generate(self, commonrevs, clnodes, fastpathlinkrev, source):
829 829 """Yield a sequence of changegroup byte chunks."""
830 830
@@ -958,7 +958,8 b' class cgpacker(object):'
958 958 'clrevtomanifestrev': clrevtomanifestrev,
959 959 }
960 960
961 gen = self.group(self._repo, revs, cl, True, lookupcl,
961 gen = deltagroup(
962 self._repo, revs, cl, True, lookupcl,
962 963 self._deltaparentfn, self._builddeltaheader,
963 964 ellipses=self._ellipses,
964 965 units=_('changesets'),
@@ -1053,7 +1054,7 b' class cgpacker(object):'
1053 1054 size += len(chunk)
1054 1055 yield chunk
1055 1056
1056 it = self.group(
1057 it = deltagroup(
1057 1058 self._repo, revs, store, False, lookupfn,
1058 1059 self._deltaparentfn, self._builddeltaheader,
1059 1060 ellipses=self._ellipses,
@@ -1153,7 +1154,7 b' class cgpacker(object):'
1153 1154 size = len(h)
1154 1155 yield h
1155 1156
1156 it = self.group(
1157 it = deltagroup(
1157 1158 self._repo, revs, filerevlog, False, lookupfilelog,
1158 1159 self._deltaparentfn, self._builddeltaheader,
1159 1160 ellipses=self._ellipses,
General Comments 0
You need to be logged in to leave comments. Login now