Stop using indexes on uploadtrees

Summary:
Read the summary of D31935606 (82bc644036)

This is also about not using indexes anymore in requests. This is about the type `UploadTreeResponse`, which is very similar to `LookupResponse`, but not the same, as `token` is not optional.

We also don't actually use the returned index on client side, so the transition is easier.

Steps:
1. Remove client code that depends on `UploadTreeResponse.index` **(this diff)**
2. Remove `index` from `UploadTreeResponse`, to prevent bad usage in the future. (next diff) (needs to wait for (1) to push)

Reviewed By: StanislavGlebik

Differential Revision: D32001742

fbshipit-source-id: 72b3e25ea8cad6c55189b1f58a56c85cf7df2b90
This commit is contained in:
Yan Soares Couto 2021-11-02 11:50:29 -07:00 committed by Facebook GitHub Bot
parent bdfc8d5d91
commit 0bf79b7ca0
3 changed files with 6 additions and 8 deletions

View File

@ -120,14 +120,14 @@ def _uploadtrees(repo, treesbase):
try:
with repo.ui.timesection("http.edenapi.upload_trees"):
stream, _stats = repo.edenapi.uploadtrees(getreponame(repo), trees)
foundindices = {item[INDEX_KEY] for item in stream if item[TOKEN_KEY]}
trees = list(stream)
repo.ui.status(
_n(
"uploaded %d tree\n",
"uploaded %d trees\n",
len(foundindices),
len(trees),
)
% len(foundindices),
% len(trees),
component="edenapi",
)
except (error.RustError, error.HttpError) as e:

View File

@ -41,7 +41,6 @@ use edenapi_types::TreeEntry;
use edenapi_types::UploadSnapshotResponse;
use edenapi_types::UploadToken;
use edenapi_types::UploadTokensResponse;
use edenapi_types::UploadTreeResponse;
use futures::TryStreamExt;
use minibytes::Bytes;
use progress::NullProgressFactory;
@ -345,7 +344,7 @@ py_class!(pub class client |py| {
Serde<HgId>, /* p2 */
PyBytes, /* data */
)>,
) -> PyResult<(TStream<anyhow::Result<Serde<UploadTreeResponse>>>, PyFuture)> {
) -> PyResult<(TStream<anyhow::Result<Serde<UploadToken>>>, PyFuture)> {
self.inner(py).clone().uploadtrees_py(py, repo, items)
}

View File

@ -56,7 +56,6 @@ use edenapi_types::UploadHgChangeset;
use edenapi_types::UploadSnapshotResponse;
use edenapi_types::UploadToken;
use edenapi_types::UploadTokensResponse;
use edenapi_types::UploadTreeResponse;
use futures::prelude::*;
use futures::stream;
use progress::ProgressBar;
@ -679,7 +678,7 @@ pub trait EdenApiPyExt: EdenApi {
Serde<HgId>, /* p2 */
PyBytes, /* data */
)>,
) -> PyResult<(TStream<anyhow::Result<Serde<UploadTreeResponse>>>, PyFuture)> {
) -> PyResult<(TStream<anyhow::Result<Serde<UploadToken>>>, PyFuture)> {
let items = to_trees_upload_items(py, &items)?;
let (responses, stats) = py
.allow_threads(|| {
@ -691,7 +690,7 @@ pub trait EdenApiPyExt: EdenApi {
.map_pyerr(py)?
.map_pyerr(py)?;
let responses_py = responses.map_ok(Serde).map_err(Into::into);
let responses_py = responses.map_ok(|r| Serde(r.token)).map_err(Into::into);
let stats_py = PyFuture::new(py, stats.map_ok(PyStats))?;
Ok((responses_py.into(), stats_py))
}