Show More
@@ -984,9 +984,7 b' def getfilestore(repo, proto, path):' | |||||
984 |
|
984 | |||
985 | return fl |
|
985 | return fl | |
986 |
|
986 | |||
987 | def emitfilerevisions(repo, path, revisions, fields): |
|
987 | def emitfilerevisions(repo, path, revisions, linknodes, fields): | |
988 | clnode = repo.changelog.node |
|
|||
989 |
|
||||
990 | for revision in revisions: |
|
988 | for revision in revisions: | |
991 | d = { |
|
989 | d = { | |
992 | b'node': revision.node, |
|
990 | b'node': revision.node, | |
@@ -996,13 +994,7 b' def emitfilerevisions(repo, path, revisi' | |||||
996 | d[b'parents'] = [revision.p1node, revision.p2node] |
|
994 | d[b'parents'] = [revision.p1node, revision.p2node] | |
997 |
|
995 | |||
998 | if b'linknode' in fields: |
|
996 | if b'linknode' in fields: | |
999 | # TODO by creating the filectx against a specific file revision |
|
997 | d[b'linknode'] = linknodes[revision.node] | |
1000 | # instead of changeset, linkrev() is always used. This is wrong for |
|
|||
1001 | # cases where linkrev() may refer to a hidden changeset. We need an |
|
|||
1002 | # API for performing linkrev adjustment that takes this into |
|
|||
1003 | # account. |
|
|||
1004 | fctx = repo.filectx(path, fileid=revision.node) |
|
|||
1005 | d[b'linknode'] = clnode(fctx.introrev()) |
|
|||
1006 |
|
998 | |||
1007 | followingmeta = [] |
|
999 | followingmeta = [] | |
1008 | followingdata = [] |
|
1000 | followingdata = [] | |
@@ -1086,6 +1078,9 b' def filedata(repo, proto, haveparents, n' | |||||
1086 | except FileAccessError as e: |
|
1078 | except FileAccessError as e: | |
1087 | raise error.WireprotoCommandError(e.msg, e.args) |
|
1079 | raise error.WireprotoCommandError(e.msg, e.args) | |
1088 |
|
1080 | |||
|
1081 | clnode = repo.changelog.node | |||
|
1082 | linknodes = {} | |||
|
1083 | ||||
1089 | # Validate requested nodes. |
|
1084 | # Validate requested nodes. | |
1090 | for node in nodes: |
|
1085 | for node in nodes: | |
1091 | try: |
|
1086 | try: | |
@@ -1094,6 +1089,14 b' def filedata(repo, proto, haveparents, n' | |||||
1094 | raise error.WireprotoCommandError('unknown file node: %s', |
|
1089 | raise error.WireprotoCommandError('unknown file node: %s', | |
1095 | (hex(node),)) |
|
1090 | (hex(node),)) | |
1096 |
|
1091 | |||
|
1092 | # TODO by creating the filectx against a specific file revision | |||
|
1093 | # instead of changeset, linkrev() is always used. This is wrong for | |||
|
1094 | # cases where linkrev() may refer to a hidden changeset. But since this | |||
|
1095 | # API doesn't know anything about changesets, we're not sure how to | |||
|
1096 | # disambiguate the linknode. Perhaps we should delete this API? | |||
|
1097 | fctx = repo.filectx(path, fileid=node) | |||
|
1098 | linknodes[node] = clnode(fctx.introrev()) | |||
|
1099 | ||||
1097 | revisions = store.emitrevisions(nodes, |
|
1100 | revisions = store.emitrevisions(nodes, | |
1098 | revisiondata=b'revision' in fields, |
|
1101 | revisiondata=b'revision' in fields, | |
1099 | assumehaveparentrevisions=haveparents) |
|
1102 | assumehaveparentrevisions=haveparents) | |
@@ -1102,7 +1105,7 b' def filedata(repo, proto, haveparents, n' | |||||
1102 | b'totalitems': len(nodes), |
|
1105 | b'totalitems': len(nodes), | |
1103 | } |
|
1106 | } | |
1104 |
|
1107 | |||
1105 | for o in emitfilerevisions(repo, path, revisions, fields): |
|
1108 | for o in emitfilerevisions(repo, path, revisions, linknodes, fields): | |
1106 | yield o |
|
1109 | yield o | |
1107 |
|
1110 | |||
1108 | def filesdatacapabilities(repo, proto): |
|
1111 | def filesdatacapabilities(repo, proto): | |
@@ -1154,12 +1157,14 b' def filesdata(repo, proto, haveparents, ' | |||||
1154 | # changeset. |
|
1157 | # changeset. | |
1155 |
|
1158 | |||
1156 | cl = repo.changelog |
|
1159 | cl = repo.changelog | |
|
1160 | clnode = cl.node | |||
1157 | outgoing = resolvenodes(repo, revisions) |
|
1161 | outgoing = resolvenodes(repo, revisions) | |
1158 | filematcher = makefilematcher(repo, pathfilter) |
|
1162 | filematcher = makefilematcher(repo, pathfilter) | |
1159 |
|
1163 | |||
1160 | # Figure out what needs to be emitted. |
|
1164 | # Figure out what needs to be emitted. | |
1161 | changedpaths = set() |
|
1165 | changedpaths = set() | |
1162 | fnodes = collections.defaultdict(set) |
|
1166 | # path -> {fnode: linknode} | |
|
1167 | fnodes = collections.defaultdict(dict) | |||
1163 |
|
1168 | |||
1164 | for node in outgoing: |
|
1169 | for node in outgoing: | |
1165 | ctx = repo[node] |
|
1170 | ctx = repo[node] | |
@@ -1182,7 +1187,7 b' def filesdata(repo, proto, haveparents, ' | |||||
1182 | linkrev = store.linkrev(rev) |
|
1187 | linkrev = store.linkrev(rev) | |
1183 |
|
1188 | |||
1184 | if linkrev in outgoingclrevs: |
|
1189 | if linkrev in outgoingclrevs: | |
1185 |
fnodes[path]. |
|
1190 | fnodes[path].setdefault(store.node(rev), clnode(linkrev)) | |
1186 |
|
1191 | |||
1187 | # If ancestors aren't known, we walk the manifests and send all |
|
1192 | # If ancestors aren't known, we walk the manifests and send all | |
1188 | # encountered file revisions. |
|
1193 | # encountered file revisions. | |
@@ -1192,7 +1197,7 b' def filesdata(repo, proto, haveparents, ' | |||||
1192 |
|
1197 | |||
1193 | for path, fnode in mctx.read().items(): |
|
1198 | for path, fnode in mctx.read().items(): | |
1194 | if filematcher(path): |
|
1199 | if filematcher(path): | |
1195 |
fnodes[path]. |
|
1200 | fnodes[path].setdefault(fnode, node) | |
1196 |
|
1201 | |||
1197 | yield { |
|
1202 | yield { | |
1198 | b'totalpaths': len(fnodes), |
|
1203 | b'totalpaths': len(fnodes), | |
@@ -1210,11 +1215,11 b' def filesdata(repo, proto, haveparents, ' | |||||
1210 | b'totalitems': len(filenodes), |
|
1215 | b'totalitems': len(filenodes), | |
1211 | } |
|
1216 | } | |
1212 |
|
1217 | |||
1213 | revisions = store.emitrevisions(filenodes, |
|
1218 | revisions = store.emitrevisions(filenodes.keys(), | |
1214 | revisiondata=b'revision' in fields, |
|
1219 | revisiondata=b'revision' in fields, | |
1215 | assumehaveparentrevisions=haveparents) |
|
1220 | assumehaveparentrevisions=haveparents) | |
1216 |
|
1221 | |||
1217 | for o in emitfilerevisions(repo, path, revisions, fields): |
|
1222 | for o in emitfilerevisions(repo, path, revisions, filenodes, fields): | |
1218 | yield o |
|
1223 | yield o | |
1219 |
|
1224 | |||
1220 | @wireprotocommand( |
|
1225 | @wireprotocommand( |
@@ -1239,7 +1239,6 b' Request for changeset introducing fileno' | |||||
1239 |
|
1239 | |||
1240 | Request for changeset where recorded linknode isn't in DAG ancestry will get |
|
1240 | Request for changeset where recorded linknode isn't in DAG ancestry will get | |
1241 | rewritten accordingly |
|
1241 | rewritten accordingly | |
1242 | TODO this is buggy |
|
|||
1243 |
|
1242 | |||
1244 | $ sendhttpv2peer << EOF |
|
1243 | $ sendhttpv2peer << EOF | |
1245 | > command filesdata |
|
1244 | > command filesdata | |
@@ -1263,7 +1262,7 b' TODO this is buggy' | |||||
1263 | b'totalitems': 1 |
|
1262 | b'totalitems': 1 | |
1264 | }, |
|
1263 | }, | |
1265 | { |
|
1264 | { | |
1266 | b'linknode': b'\xb1l\xce)g\xc1t\x9e\xf4\xf4\xe3\x08j\x80l\xfb\xad\x8a:\xf7', |
|
1265 | b'linknode': b'G\xfc0X\t\x11#,\xb2dg[@(\x19\xde\xdd\xf6\xc6\xf0', | |
1267 | b'node': b'.\xd2\xa3\x91*\x0b$P C\xea\xe8N\xe4\xb2y\xc1\x8b\x90\xdd' |
|
1266 | b'node': b'.\xd2\xa3\x91*\x0b$P C\xea\xe8N\xe4\xb2y\xc1\x8b\x90\xdd' | |
1268 | } |
|
1267 | } | |
1269 | ] |
|
1268 | ] |
@@ -196,7 +196,7 b' Shallow clone pulls down latest revision' | |||||
196 | node = I\x1d\xa1\xbb\x89\xeax\xc0\xc0\xa2s[\x16\xce}\x93\x1d\xc8\xe2\r (esc) |
|
196 | node = I\x1d\xa1\xbb\x89\xeax\xc0\xc0\xa2s[\x16\xce}\x93\x1d\xc8\xe2\r (esc) | |
197 | p1rev = -1 |
|
197 | p1rev = -1 | |
198 | p2rev = -1 |
|
198 | p2rev = -1 | |
199 |
linkrev = |
|
199 | linkrev = 5 | |
200 | flags = 2 |
|
200 | flags = 2 | |
201 |
|
201 | |||
202 | id = 4 |
|
202 | id = 4 | |
@@ -205,7 +205,7 b' Shallow clone pulls down latest revision' | |||||
205 | node = S\x82\x06\xdc\x97\x1eR\x15@\xd6\x84:\xbf\xe6\xd1`2\xf6\xd4& (esc) |
|
205 | node = S\x82\x06\xdc\x97\x1eR\x15@\xd6\x84:\xbf\xe6\xd1`2\xf6\xd4& (esc) | |
206 | p1rev = -1 |
|
206 | p1rev = -1 | |
207 | p2rev = -1 |
|
207 | p2rev = -1 | |
208 |
linkrev = |
|
208 | linkrev = 5 | |
209 | flags = 0 |
|
209 | flags = 0 | |
210 |
|
210 | |||
211 | id = 5 |
|
211 | id = 5 | |
@@ -214,7 +214,7 b' Shallow clone pulls down latest revision' | |||||
214 | node = ]\xf3\xac\xd8\xd0\xc7\xfaP\x98\xd0'\x9a\x044\xc3\x02\x9e+x\xe1 (esc) |
|
214 | node = ]\xf3\xac\xd8\xd0\xc7\xfaP\x98\xd0'\x9a\x044\xc3\x02\x9e+x\xe1 (esc) | |
215 | p1rev = -1 |
|
215 | p1rev = -1 | |
216 | p2rev = -1 |
|
216 | p2rev = -1 | |
217 |
linkrev = |
|
217 | linkrev = 5 | |
218 | flags = 2 |
|
218 | flags = 2 | |
219 |
|
219 | |||
220 | id = 6 |
|
220 | id = 6 | |
@@ -223,7 +223,7 b' Shallow clone pulls down latest revision' | |||||
223 | node = (\xc7v\xae\x08\xd0\xd5^\xb4\x06H\xb4\x01\xb9\x0f\xf5DH4\x8e (esc) |
|
223 | node = (\xc7v\xae\x08\xd0\xd5^\xb4\x06H\xb4\x01\xb9\x0f\xf5DH4\x8e (esc) | |
224 | p1rev = -1 |
|
224 | p1rev = -1 | |
225 | p2rev = -1 |
|
225 | p2rev = -1 | |
226 |
linkrev = |
|
226 | linkrev = 5 | |
227 | flags = 2 |
|
227 | flags = 2 | |
228 |
|
228 | |||
229 | Test a shallow clone with only some files |
|
229 | Test a shallow clone with only some files | |
@@ -342,7 +342,7 b' Test a shallow clone with only some file' | |||||
342 | node = I\x1d\xa1\xbb\x89\xeax\xc0\xc0\xa2s[\x16\xce}\x93\x1d\xc8\xe2\r (esc) |
|
342 | node = I\x1d\xa1\xbb\x89\xeax\xc0\xc0\xa2s[\x16\xce}\x93\x1d\xc8\xe2\r (esc) | |
343 | p1rev = -1 |
|
343 | p1rev = -1 | |
344 | p2rev = -1 |
|
344 | p2rev = -1 | |
345 |
linkrev = |
|
345 | linkrev = 5 | |
346 | flags = 2 |
|
346 | flags = 2 | |
347 |
|
347 | |||
348 | id = 2 |
|
348 | id = 2 | |
@@ -351,7 +351,7 b' Test a shallow clone with only some file' | |||||
351 | node = S\x82\x06\xdc\x97\x1eR\x15@\xd6\x84:\xbf\xe6\xd1`2\xf6\xd4& (esc) |
|
351 | node = S\x82\x06\xdc\x97\x1eR\x15@\xd6\x84:\xbf\xe6\xd1`2\xf6\xd4& (esc) | |
352 | p1rev = -1 |
|
352 | p1rev = -1 | |
353 | p2rev = -1 |
|
353 | p2rev = -1 | |
354 |
linkrev = |
|
354 | linkrev = 5 | |
355 | flags = 0 |
|
355 | flags = 0 | |
356 |
|
356 | |||
357 | Cloning an old revision with depth=1 works |
|
357 | Cloning an old revision with depth=1 works |
General Comments 0
You need to be logged in to leave comments.
Login now