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