Mercurial > hg
comparison mercurial/changegroup.py @ 39233:8b9b93bf70b1
changegroup: rename dir to tree to avoid shadowing a built-in
Differential Revision: https://phab.mercurial-scm.org/D4235
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 09 Aug 2018 19:30:36 -0700 |
parents | b41d023a412a |
children | a79279a21b0a |
comparison
equal
deleted
inserted
replaced
39232:0a5b20c107a6 | 39233:8b9b93bf70b1 |
---|---|
880 size = 0 | 880 size = 0 |
881 it = self.generatemanifests( | 881 it = self.generatemanifests( |
882 commonrevs, clrevorder, fastpathlinkrev, mfs, fnodes, source, | 882 commonrevs, clrevorder, fastpathlinkrev, mfs, fnodes, source, |
883 clstate['clrevtomanifestrev']) | 883 clstate['clrevtomanifestrev']) |
884 | 884 |
885 for dir, deltas in it: | 885 for tree, deltas in it: |
886 if dir: | 886 if tree: |
887 assert self.version == b'03' | 887 assert self.version == b'03' |
888 chunk = _fileheader(dir) | 888 chunk = _fileheader(tree) |
889 size += len(chunk) | 889 size += len(chunk) |
890 yield chunk | 890 yield chunk |
891 | 891 |
892 for delta in deltas: | 892 for delta in deltas: |
893 chunks = _revisiondeltatochunks(delta, self._builddeltaheader) | 893 chunks = _revisiondeltatochunks(delta, self._builddeltaheader) |
1024 tmfnodes = {'': mfs} | 1024 tmfnodes = {'': mfs} |
1025 | 1025 |
1026 # Callback for the manifest, used to collect linkrevs for filelog | 1026 # Callback for the manifest, used to collect linkrevs for filelog |
1027 # revisions. | 1027 # revisions. |
1028 # Returns the linkrev node (collected in lookupcl). | 1028 # Returns the linkrev node (collected in lookupcl). |
1029 def makelookupmflinknode(dir, nodes): | 1029 def makelookupmflinknode(tree, nodes): |
1030 if fastpathlinkrev: | 1030 if fastpathlinkrev: |
1031 assert not dir | 1031 assert not tree |
1032 return mfs.__getitem__ | 1032 return mfs.__getitem__ |
1033 | 1033 |
1034 def lookupmflinknode(x): | 1034 def lookupmflinknode(x): |
1035 """Callback for looking up the linknode for manifests. | 1035 """Callback for looking up the linknode for manifests. |
1036 | 1036 |
1046 Note that this means manifests must be completely sent to | 1046 Note that this means manifests must be completely sent to |
1047 the client before you can trust the list of files and | 1047 the client before you can trust the list of files and |
1048 treemanifests to send. | 1048 treemanifests to send. |
1049 """ | 1049 """ |
1050 clnode = nodes[x] | 1050 clnode = nodes[x] |
1051 mdata = mfl.get(dir, x).readfast(shallow=True) | 1051 mdata = mfl.get(tree, x).readfast(shallow=True) |
1052 for p, n, fl in mdata.iterentries(): | 1052 for p, n, fl in mdata.iterentries(): |
1053 if fl == 't': # subdirectory manifest | 1053 if fl == 't': # subdirectory manifest |
1054 subdir = dir + p + '/' | 1054 subtree = tree + p + '/' |
1055 tmfclnodes = tmfnodes.setdefault(subdir, {}) | 1055 tmfclnodes = tmfnodes.setdefault(subtree, {}) |
1056 tmfclnode = tmfclnodes.setdefault(n, clnode) | 1056 tmfclnode = tmfclnodes.setdefault(n, clnode) |
1057 if clrevorder[clnode] < clrevorder[tmfclnode]: | 1057 if clrevorder[clnode] < clrevorder[tmfclnode]: |
1058 tmfclnodes[n] = clnode | 1058 tmfclnodes[n] = clnode |
1059 else: | 1059 else: |
1060 f = dir + p | 1060 f = tree + p |
1061 fclnodes = fnodes.setdefault(f, {}) | 1061 fclnodes = fnodes.setdefault(f, {}) |
1062 fclnode = fclnodes.setdefault(n, clnode) | 1062 fclnode = fclnodes.setdefault(n, clnode) |
1063 if clrevorder[clnode] < clrevorder[fclnode]: | 1063 if clrevorder[clnode] < clrevorder[fclnode]: |
1064 fclnodes[n] = clnode | 1064 fclnodes[n] = clnode |
1065 return clnode | 1065 return clnode |
1066 return lookupmflinknode | 1066 return lookupmflinknode |
1067 | 1067 |
1068 while tmfnodes: | 1068 while tmfnodes: |
1069 dir, nodes = tmfnodes.popitem() | 1069 tree, nodes = tmfnodes.popitem() |
1070 store = dirlog(dir) | 1070 store = dirlog(tree) |
1071 | 1071 |
1072 if not self._filematcher.visitdir(store._dir[:-1] or '.'): | 1072 if not self._filematcher.visitdir(store._dir[:-1] or '.'): |
1073 prunednodes = [] | 1073 prunednodes = [] |
1074 else: | 1074 else: |
1075 frev, flr = store.rev, store.linkrev | 1075 frev, flr = store.rev, store.linkrev |
1076 prunednodes = [n for n in nodes | 1076 prunednodes = [n for n in nodes |
1077 if flr(frev(n)) not in commonrevs] | 1077 if flr(frev(n)) not in commonrevs] |
1078 | 1078 |
1079 if dir and not prunednodes: | 1079 if tree and not prunednodes: |
1080 continue | 1080 continue |
1081 | 1081 |
1082 lookupfn = makelookupmflinknode(dir, nodes) | 1082 lookupfn = makelookupmflinknode(tree, nodes) |
1083 | 1083 |
1084 deltas = deltagroup( | 1084 deltas = deltagroup( |
1085 self._repo, store, prunednodes, False, lookupfn, | 1085 self._repo, store, prunednodes, False, lookupfn, |
1086 self._forcedeltaparentprev, self._reorder, | 1086 self._forcedeltaparentprev, self._reorder, |
1087 ellipses=self._ellipses, | 1087 ellipses=self._ellipses, |
1088 units=_('manifests'), | 1088 units=_('manifests'), |
1089 clrevtolocalrev=clrevtolocalrev, | 1089 clrevtolocalrev=clrevtolocalrev, |
1090 fullclnodes=self._fullclnodes, | 1090 fullclnodes=self._fullclnodes, |
1091 precomputedellipsis=self._precomputedellipsis) | 1091 precomputedellipsis=self._precomputedellipsis) |
1092 | 1092 |
1093 yield dir, deltas | 1093 yield tree, deltas |
1094 | 1094 |
1095 # The 'source' parameter is useful for extensions | 1095 # The 'source' parameter is useful for extensions |
1096 def generatefiles(self, changedfiles, commonrevs, source, | 1096 def generatefiles(self, changedfiles, commonrevs, source, |
1097 mfdicts, fastpathlinkrev, fnodes, clrevs): | 1097 mfdicts, fastpathlinkrev, fnodes, clrevs): |
1098 changedfiles = list(filter(self._filematcher, changedfiles)) | 1098 changedfiles = list(filter(self._filematcher, changedfiles)) |