Mercurial > public > mercurial-scm > hg
comparison mercurial/changegroup.py @ 39007:39f5c7afdc25
changegroup: inline _prune() into call sites
The functionality is pretty simple. As a bonus, _prune() had special
code for the manifest case. We can now exclude this check from the
file call site.
Differential Revision: https://phab.mercurial-scm.org/D4199
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 08 Aug 2018 13:50:54 -0700 |
parents | 5959ef78d834 |
children | 8c84f1ef949e |
comparison
equal
deleted
inserted
replaced
39006:5959ef78d834 | 39007:39f5c7afdc25 |
---|---|
24 ) | 24 ) |
25 | 25 |
26 from . import ( | 26 from . import ( |
27 dagutil, | 27 dagutil, |
28 error, | 28 error, |
29 manifest, | |
30 match as matchmod, | 29 match as matchmod, |
31 mdiff, | 30 mdiff, |
32 phases, | 31 phases, |
33 pycompat, | 32 pycompat, |
34 repository, | 33 repository, |
822 if progress: | 821 if progress: |
823 progress.complete() | 822 progress.complete() |
824 | 823 |
825 yield closechunk() | 824 yield closechunk() |
826 | 825 |
827 # filter any nodes that claim to be part of the known set | |
828 def _prune(self, store, missing, commonrevs): | |
829 # TODO this violates storage abstraction for manifests. | |
830 if isinstance(store, manifest.manifestrevlog): | |
831 if not self._filematcher.visitdir(store._dir[:-1] or '.'): | |
832 return [] | |
833 | |
834 rr, rl = store.rev, store.linkrev | |
835 return [n for n in missing if rl(rr(n)) not in commonrevs] | |
836 | |
837 def generate(self, commonrevs, clnodes, fastpathlinkrev, source): | 826 def generate(self, commonrevs, clnodes, fastpathlinkrev, source): |
838 """Yield a sequence of changegroup byte chunks.""" | 827 """Yield a sequence of changegroup byte chunks.""" |
839 | 828 |
840 repo = self._repo | 829 repo = self._repo |
841 cl = repo.changelog | 830 cl = repo.changelog |
1029 | 1018 |
1030 size = 0 | 1019 size = 0 |
1031 while tmfnodes: | 1020 while tmfnodes: |
1032 dir, nodes = tmfnodes.popitem() | 1021 dir, nodes = tmfnodes.popitem() |
1033 store = dirlog(dir) | 1022 store = dirlog(dir) |
1034 prunednodes = self._prune(store, nodes, commonrevs) | 1023 |
1024 if not self._filematcher.visitdir(store._dir[:-1] or '.'): | |
1025 prunednodes = [] | |
1026 else: | |
1027 frev, flr = store.rev, store.linkrev | |
1028 prunednodes = [n for n in nodes | |
1029 if flr(frev(n)) not in commonrevs] | |
1035 | 1030 |
1036 if dir and not prunednodes: | 1031 if dir and not prunednodes: |
1037 continue | 1032 continue |
1038 | 1033 |
1039 lookupfn = makelookupmflinknode(dir, nodes) | 1034 lookupfn = makelookupmflinknode(dir, nodes) |
1125 # Lookup for filenodes, we collected the linkrev nodes above in the | 1120 # Lookup for filenodes, we collected the linkrev nodes above in the |
1126 # fastpath case and with lookupmf in the slowpath case. | 1121 # fastpath case and with lookupmf in the slowpath case. |
1127 def lookupfilelog(x): | 1122 def lookupfilelog(x): |
1128 return linkrevnodes[x] | 1123 return linkrevnodes[x] |
1129 | 1124 |
1130 filenodes = self._prune(filerevlog, linkrevnodes, commonrevs) | 1125 frev, flr = filerevlog.rev, filerevlog.linkrev |
1126 filenodes = [n for n in linkrevnodes | |
1127 if flr(frev(n)) not in commonrevs] | |
1128 | |
1131 if filenodes: | 1129 if filenodes: |
1132 if self._ellipses: | 1130 if self._ellipses: |
1133 revs = _sortnodesellipsis(filerevlog, filenodes, | 1131 revs = _sortnodesellipsis(filerevlog, filenodes, |
1134 cl, lookupfilelog) | 1132 cl, lookupfilelog) |
1135 else: | 1133 else: |