Skip to content

Commit d93fb54

Browse files
yancoutofacebook-github-bot
authored andcommitted
Fix upload of trees that are not available locally but are on server
Reviewed By: markbt Differential Revision: D31759482 fbshipit-source-id: f1c1f79a761b5d9a69910b8e75ccbf08b3791949
1 parent 2328811 commit d93fb54

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

Diff for: eden/scm/edenscm/mercurial/edenapi_upload.py

+27-20
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ def _filtercommits(repo, nodes):
4040
raise error.Abort(e)
4141

4242

43-
def _filteruploaded(repo, blobs, trees):
43+
def _filteruploaded(repo, files, trees):
4444
"""Returns list of missing blobs and trees"""
4545
try:
4646
with repo.ui.timesection("http.edenapi.upload_lookup"):
4747
stream = repo.edenapi.lookup_filenodes_and_trees(
4848
getreponame(repo),
49-
[blob[1] for blob in blobs],
49+
[fctx.filenode() for fctx in files],
5050
[tree[0] for tree in trees],
5151
)
5252

5353
results = list(stream)
54-
blobslen = len(blobs)
54+
blobslen = len(files)
5555

5656
foundindicesblobs = {
5757
item[INDEX_KEY]
@@ -64,9 +64,9 @@ def _filteruploaded(repo, blobs, trees):
6464
if item[TOKEN_KEY] and "HgTreeId" in item[TOKEN_KEY]["data"]["id"]
6565
}
6666

67-
missingblobs = [
68-
blob
69-
for index, blob in enumerate(blobs)
67+
missingfiles = [
68+
fctx
69+
for index, fctx in enumerate(files)
7070
if index not in foundindicesblobs
7171
]
7272
missingtrees = [
@@ -75,15 +75,19 @@ def _filteruploaded(repo, blobs, trees):
7575
if index not in foundindicestrees
7676
]
7777

78-
return missingblobs, missingtrees
78+
return missingfiles, missingtrees
7979
except (error.RustError, error.HttpError) as e:
8080
raise error.Abort(e)
8181

8282

83-
def _uploadfilenodes(repo, keys):
83+
def _uploadfilenodes(repo, fctxs):
8484
"""Upload file content and filenodes"""
85-
if not keys:
85+
if not fctxs:
8686
return
87+
keys = []
88+
for fctx in fctxs:
89+
p1, p2 = fctx.filelog().parents(fctx.filenode())
90+
keys.append((fctx.path(), fctx.filenode(), p1, p2))
8791
dpack, _hpack = repo.fileslog.getmutablelocalpacks()
8892
try:
8993
with repo.ui.timesection("http.edenapi.upload_files"):
@@ -104,10 +108,17 @@ def _uploadfilenodes(repo, keys):
104108
raise error.Abort(e)
105109

106110

107-
def _uploadtrees(repo, trees):
111+
def _uploadtrees(repo, treesbase):
108112
"""Upload trees"""
109-
if not trees:
113+
if not treesbase:
110114
return
115+
trees = []
116+
for treenode, subdir, treetext in treesbase:
117+
p1, p2, _link, _copy = repo.manifestlog.historystore.getnodeinfo(
118+
subdir, treenode
119+
)
120+
trees.append((treenode, p1, p2, treetext))
121+
111122
try:
112123
with repo.ui.timesection("http.edenapi.upload_trees"):
113124
stream, _stats = repo.edenapi.uploadtrees(getreponame(repo), trees)
@@ -155,7 +166,7 @@ def _uploadchangesets(repo, changesets, mutations):
155166
raise error.Abort(e)
156167

157168

158-
def _getblobs(repo, nodes):
169+
def _getfiles(repo, nodes):
159170
"""Get changed files"""
160171
toupload = set()
161172
for node in nodes.iterrev():
@@ -164,8 +175,7 @@ def _getblobs(repo, nodes):
164175
if f not in ctx:
165176
continue
166177
fctx = ctx[f]
167-
p1, p2 = fctx.filelog().parents(fctx.filenode())
168-
toupload.add((fctx.path(), fctx.filenode(), p1, p2))
178+
toupload.add(fctx)
169179
return toupload
170180

171181

@@ -182,10 +192,7 @@ def _gettrees(repo, nodes):
182192
repo.manifestlog.datastore, "", mfnode, basemfnodes, treedepth
183193
)
184194
for subdir, treenode, treetext, _x, _x, _x in difftrees:
185-
p1, p2, _link, _copy = repo.manifestlog.historystore.getnodeinfo(
186-
subdir, treenode
187-
)
188-
yield treenode, p1, p2, treetext
195+
yield treenode, subdir, treetext
189196

190197

191198
def _torevs(repo, uploadednodes, failednodes):
@@ -272,13 +279,13 @@ def uploadhgchangesets(repo, revs, force=False, skipknowncheck=False):
272279
uploadcommitqueue = repo.changelog.dag.sort(uploadcommitqueue)
273280

274281
# Build a queue of missing filenodes to upload
275-
blobs = list(_getblobs(repo, uploadcommitqueue))
282+
files = list(_getfiles(repo, uploadcommitqueue))
276283

277284
# Build a queue of missing trees to upload
278285
trees = list(_gettrees(repo, uploadcommitqueue))
279286

280287
uploadblobqueue, uploadtreesqueue = (
281-
(blobs, trees) if force else _filteruploaded(repo, blobs, trees)
288+
(files, trees) if force else _filteruploaded(repo, files, trees)
282289
)
283290

284291
repo.ui.status(

0 commit comments

Comments
 (0)