Mercurial > hg
comparison mercurial/changegroup.py @ 38984:a3105433ecc4
changegroup: inline _revchunk() into group()
_revchunk() was pretty minimal. I think having all the code for
generating data composing the changegroup in one function makes
things easier to understand.
As part of the refactor, we now call the _revisiondelta* functions
explicitly. This paves the road to refactor their argument
signatures.
Differential Revision: https://phab.mercurial-scm.org/D4141
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 06 Aug 2018 11:13:25 -0700 |
parents | fbbda9ff3deb |
children | d85b0d81112b |
comparison
equal
deleted
inserted
replaced
38983:fbbda9ff3deb | 38984:a3105433ecc4 |
---|---|
672 for r in pycompat.xrange(len(revs) - 1): | 672 for r in pycompat.xrange(len(revs) - 1): |
673 if progress: | 673 if progress: |
674 progress.update(r + 1) | 674 progress.update(r + 1) |
675 prev, curr = revs[r], revs[r + 1] | 675 prev, curr = revs[r], revs[r + 1] |
676 linknode = lookup(store.node(curr)) | 676 linknode = lookup(store.node(curr)) |
677 for c in self._revchunk(store, ischangelog, curr, prev, linknode): | 677 |
678 yield c | 678 if self._ellipses: |
679 delta = self._revisiondeltanarrow(store, ischangelog, | |
680 curr, prev, linknode) | |
681 else: | |
682 delta = self._revisiondeltanormal(store, ischangelog, | |
683 curr, prev, linknode) | |
684 | |
685 if not delta: | |
686 continue | |
687 | |
688 meta = self._builddeltaheader(delta) | |
689 l = len(meta) + sum(len(x) for x in delta.deltachunks) | |
690 yield chunkheader(l) | |
691 yield meta | |
692 for x in delta.deltachunks: | |
693 yield x | |
679 | 694 |
680 if progress: | 695 if progress: |
681 progress.complete() | 696 progress.complete() |
682 yield self._close() | 697 yield self._close() |
683 | 698 |
992 for chunk in self.group(revs, filerevlog, False, lookupfilelog): | 1007 for chunk in self.group(revs, filerevlog, False, lookupfilelog): |
993 size += len(chunk) | 1008 size += len(chunk) |
994 yield chunk | 1009 yield chunk |
995 self._verbosenote(_('%8.i %s\n') % (size, fname)) | 1010 self._verbosenote(_('%8.i %s\n') % (size, fname)) |
996 progress.complete() | 1011 progress.complete() |
997 | |
998 def _revchunk(self, store, ischangelog, rev, prev, linknode): | |
999 if self._ellipses: | |
1000 fn = self._revisiondeltanarrow | |
1001 else: | |
1002 fn = self._revisiondeltanormal | |
1003 | |
1004 delta = fn(store, ischangelog, rev, prev, linknode) | |
1005 if not delta: | |
1006 return | |
1007 | |
1008 meta = self._builddeltaheader(delta) | |
1009 l = len(meta) + sum(len(x) for x in delta.deltachunks) | |
1010 | |
1011 yield chunkheader(l) | |
1012 yield meta | |
1013 for x in delta.deltachunks: | |
1014 yield x | |
1015 | 1012 |
1016 def _revisiondeltanormal(self, store, ischangelog, rev, prev, linknode): | 1013 def _revisiondeltanormal(self, store, ischangelog, rev, prev, linknode): |
1017 node = store.node(rev) | 1014 node = store.node(rev) |
1018 p1, p2 = store.parentrevs(rev) | 1015 p1, p2 = store.parentrevs(rev) |
1019 base = self._deltaparentfn(store, rev, p1, p2, prev) | 1016 base = self._deltaparentfn(store, rev, p1, p2, prev) |