Mercurial > hg
comparison mercurial/changegroup.py @ 39006:5959ef78d834
changegroup: inline _packmanifests() into generatemanifests()
It is relatively small. Every other generate*() calls group()
directly. So the new code is consistent.
Differential Revision: https://phab.mercurial-scm.org/D4198
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 07 Aug 2018 15:31:03 -0700 |
parents | d56a6b78de3b |
children | 39f5c7afdc25 |
comparison
equal
deleted
inserted
replaced
39005:d56a6b78de3b | 39006:5959ef78d834 |
---|---|
832 return [] | 832 return [] |
833 | 833 |
834 rr, rl = store.rev, store.linkrev | 834 rr, rl = store.rev, store.linkrev |
835 return [n for n in missing if rl(rr(n)) not in commonrevs] | 835 return [n for n in missing if rl(rr(n)) not in commonrevs] |
836 | 836 |
837 def _packmanifests(self, dir, dirlog, revs, lookuplinknode, | |
838 clrevtolocalrev): | |
839 """Pack manifests into a changegroup stream. | |
840 | |
841 Encodes the directory name in the output so multiple manifests | |
842 can be sent. Multiple manifests is not supported by cg1 and cg2. | |
843 """ | |
844 if dir: | |
845 assert self.version == b'03' | |
846 yield _fileheader(dir) | |
847 | |
848 for chunk in self.group(revs, dirlog, False, lookuplinknode, | |
849 units=_('manifests'), | |
850 clrevtolocalrev=clrevtolocalrev): | |
851 yield chunk | |
852 | |
853 def generate(self, commonrevs, clnodes, fastpathlinkrev, source): | 837 def generate(self, commonrevs, clnodes, fastpathlinkrev, source): |
854 """Yield a sequence of changegroup byte chunks.""" | 838 """Yield a sequence of changegroup byte chunks.""" |
855 | 839 |
856 repo = self._repo | 840 repo = self._repo |
857 cl = repo.changelog | 841 cl = repo.changelog |
1059 lookupfn) | 1043 lookupfn) |
1060 else: | 1044 else: |
1061 revs = _sortnodesnormal(store, prunednodes, | 1045 revs = _sortnodesnormal(store, prunednodes, |
1062 self._reorder) | 1046 self._reorder) |
1063 | 1047 |
1064 for x in self._packmanifests(dir, store, revs, lookupfn, | 1048 if dir: |
1065 clrevtolocalrev): | 1049 assert self.version == b'03' |
1066 size += len(x) | 1050 chunk = _fileheader(dir) |
1067 yield x | 1051 size += len(chunk) |
1052 yield chunk | |
1053 | |
1054 for chunk in self.group(revs, store, False, lookupfn, | |
1055 units=_('manifests'), | |
1056 clrevtolocalrev=clrevtolocalrev): | |
1057 size += len(chunk) | |
1058 yield chunk | |
1068 | 1059 |
1069 self._verbosenote(_('%8.i (manifests)\n') % size) | 1060 self._verbosenote(_('%8.i (manifests)\n') % size) |
1070 yield self._manifestsend | 1061 yield self._manifestsend |
1071 | 1062 |
1072 # The 'source' parameter is useful for extensions | 1063 # The 'source' parameter is useful for extensions |