##// END OF EJS Templates
changegroup: emit revisiondelta instances from deltagroup()...
Gregory Szorc -
r39050:d662959d default
parent child Browse files
Show More
@@ -522,6 +522,15 class revisiondelta(object):
522 522 # Iterable of chunks holding raw delta data.
523 523 deltachunks = attr.ib()
524 524
525 def _revisiondeltatochunks(delta, headerfn):
526 """Serialize a revisiondelta to changegroup chunks."""
527 meta = headerfn(delta)
528 l = len(meta) + sum(len(x) for x in delta.deltachunks)
529 yield chunkheader(l)
530 yield meta
531 for x in delta.deltachunks:
532 yield x
533
525 534 def _sortnodesnormal(store, nodes, reorder):
526 535 """Sort nodes for changegroup generation and turn into revnums."""
527 536 # for generaldelta revlogs, we linearize the revs; this will both be
@@ -682,18 +691,12 def _revisiondeltanarrow(cl, store, isch
682 691 )
683 692
684 693 def deltagroup(repo, revs, store, ischangelog, lookup, deltaparentfn,
685 deltaheaderfn, units=None,
694 units=None,
686 695 ellipses=False, clrevtolocalrev=None, fullclnodes=None,
687 696 precomputedellipsis=None):
688 """Calculate a delta group, yielding a sequence of changegroup chunks
689 (strings).
697 """Calculate deltas for a set of revisions.
690 698
691 Given a list of changeset revs, return a set of deltas and
692 metadata corresponding to nodes. The first delta is
693 first parent(nodelist[0]) -> nodelist[0], the receiver is
694 guaranteed to have this parent as it has all history before
695 these changesets. In the case firstparent is nullrev the
696 changegroup starts with a full revision.
699 Is a generator of ``revisiondelta`` instances.
697 700
698 701 If units is not None, progress detail will be generated, units specifies
699 702 the type of revlog that is touched (changelog, manifest, etc.).
@@ -739,15 +742,8 def deltagroup(repo, revs, store, ischan
739 742 delta = _revisiondeltanormal(store, curr, prev, linknode,
740 743 deltaparentfn)
741 744
742 if not delta:
743 continue
744
745 meta = deltaheaderfn(delta)
746 l = len(meta) + sum(len(x) for x in delta.deltachunks)
747 yield chunkheader(l)
748 yield meta
749 for x in delta.deltachunks:
750 yield x
745 if delta:
746 yield delta
751 747
752 748 if progress:
753 749 progress.complete()
@@ -831,8 +827,9 class cgpacker(object):
831 827 self._verbosenote(_('uncompressed size of bundle content:\n'))
832 828 size = 0
833 829
834 clstate, chunks = self._generatechangelog(cl, clnodes)
835 for chunk in chunks:
830 clstate, deltas = self._generatechangelog(cl, clnodes)
831 for delta in deltas:
832 for chunk in _revisiondeltatochunks(delta, self._builddeltaheader):
836 833 size += len(chunk)
837 834 yield chunk
838 835
@@ -875,13 +872,15 class cgpacker(object):
875 872 commonrevs, clrevorder, fastpathlinkrev, mfs, fnodes, source,
876 873 clstate['clrevtomanifestrev'])
877 874
878 for dir, chunks in it:
875 for dir, deltas in it:
879 876 if dir:
880 877 assert self.version == b'03'
881 878 chunk = _fileheader(dir)
882 879 size += len(chunk)
883 880 yield chunk
884 881
882 for delta in deltas:
883 chunks = _revisiondeltatochunks(delta, self._builddeltaheader)
885 884 for chunk in chunks:
886 885 size += len(chunk)
887 886 yield chunk
@@ -905,11 +904,13 class cgpacker(object):
905 904 source, mfdicts, fastpathlinkrev,
906 905 fnodes, clrevs)
907 906
908 for path, chunks in it:
907 for path, deltas in it:
909 908 h = _fileheader(path)
910 909 size = len(h)
911 910 yield h
912 911
912 for delta in deltas:
913 chunks = _revisiondeltatochunks(delta, self._builddeltaheader)
913 914 for chunk in chunks:
914 915 size += len(chunk)
915 916 yield chunk
@@ -993,7 +994,7 class cgpacker(object):
993 994
994 995 gen = deltagroup(
995 996 self._repo, revs, cl, True, lookupcl,
996 self._deltaparentfn, self._builddeltaheader,
997 self._deltaparentfn,
997 998 ellipses=self._ellipses,
998 999 units=_('changesets'),
999 1000 clrevtolocalrev={},
@@ -1080,16 +1081,16 class cgpacker(object):
1080 1081 revs = _sortnodesnormal(store, prunednodes,
1081 1082 self._reorder)
1082 1083
1083 it = deltagroup(
1084 deltas = deltagroup(
1084 1085 self._repo, revs, store, False, lookupfn,
1085 self._deltaparentfn, self._builddeltaheader,
1086 self._deltaparentfn,
1086 1087 ellipses=self._ellipses,
1087 1088 units=_('manifests'),
1088 1089 clrevtolocalrev=clrevtolocalrev,
1089 1090 fullclnodes=self._fullclnodes,
1090 1091 precomputedellipsis=self._precomputedellipsis)
1091 1092
1092 yield dir, it
1093 yield dir, deltas
1093 1094
1094 1095 # The 'source' parameter is useful for extensions
1095 1096 def generatefiles(self, changedfiles, commonrevs, source,
@@ -1172,15 +1173,15 class cgpacker(object):
1172 1173
1173 1174 progress.update(i + 1, item=fname)
1174 1175
1175 it = deltagroup(
1176 deltas = deltagroup(
1176 1177 self._repo, revs, filerevlog, False, lookupfilelog,
1177 self._deltaparentfn, self._builddeltaheader,
1178 self._deltaparentfn,
1178 1179 ellipses=self._ellipses,
1179 1180 clrevtolocalrev=clrevtolocalrev,
1180 1181 fullclnodes=self._fullclnodes,
1181 1182 precomputedellipsis=self._precomputedellipsis)
1182 1183
1183 yield fname, it
1184 yield fname, deltas
1184 1185
1185 1186 progress.complete()
1186 1187
General Comments 0
You need to be logged in to leave comments. Login now