mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
snapshot: Print changeset ID on createremote
Summary: Using changes from D29995429, this returns the upload token of the changeset upload in the uploadsnapshot response. Reviewed By: StanislavGlebik Differential Revision: D30012368 fbshipit-source-id: 5ca54763153a474d1ce3c38ddeaa0efff071b09c
This commit is contained in:
parent
4ed5f8726f
commit
2681fcbf34
@ -1,60 +0,0 @@
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This software may be used and distributed according to the terms of the
|
||||
# GNU General Public License found in the LICENSE file in the root
|
||||
# directory of this source tree.
|
||||
|
||||
$ . "${TEST_FIXTURES}/library.sh"
|
||||
|
||||
setup configuration
|
||||
$ setup_common_config
|
||||
$ cd $TESTTMP
|
||||
|
||||
|
||||
setup common configuration for these tests
|
||||
mononoke local commit cloud backend
|
||||
$ cat >> $HGRCPATH <<EOF
|
||||
> [extensions]
|
||||
> snapshot =
|
||||
> EOF
|
||||
|
||||
setup repo
|
||||
$ hginit_treemanifest repo
|
||||
$ cd repo
|
||||
$ mkcommit "base_commit"
|
||||
$ hg log -T '{short(node)}\n'
|
||||
8b2dca0c8a72
|
||||
$ echo a > a
|
||||
$ hg addremove -q
|
||||
$ hg commit -m "Add a"
|
||||
|
||||
blobimport
|
||||
$ cd $TESTTMP
|
||||
$ blobimport repo/.hg repo
|
||||
|
||||
start mononoke
|
||||
$ mononoke
|
||||
$ wait_for_mononoke
|
||||
|
||||
start edenapi
|
||||
$ setup_configerator_configs
|
||||
$ start_edenapi_server_no_tls
|
||||
|
||||
TEST CASES:
|
||||
|
||||
Make some local changes
|
||||
$ cd repo
|
||||
$ echo b > a
|
||||
$ hgedenapi snapshot
|
||||
abort: you need to specify a subcommand (run with --help to see a list of subcommands)
|
||||
[255]
|
||||
|
||||
Create a snapshot.
|
||||
$ EDENSCM_LOG=edenapi::client=info hgedenapi snapshot createremote
|
||||
INFO edenapi::client: Preparing ephemeral bubble
|
||||
INFO edenapi::client: Created bubble 1
|
||||
INFO edenapi::client: Requesting lookup for 1 item(s)
|
||||
INFO edenapi::client: Received 0 token(s) from the lookup_batch request
|
||||
INFO edenapi::client: Requesting upload for */repo/upload/file/content_id/21c519fe0eb401bc97888f270902935f858d0c5361211f892fd26ed9ce127ff9 (glob)
|
||||
INFO edenapi::client: Received 1 new token(s) from upload requests
|
||||
INFO edenapi::client: Requesting changesets upload for 1 item(s)
|
@ -7,11 +7,14 @@ from edenscm.mercurial.edenapi_upload import getreponame
|
||||
|
||||
|
||||
def createremote(ui, repo, **opts):
|
||||
# TODO(yancouto): Pipe command through and implement logic
|
||||
status = repo.status()
|
||||
|
||||
# Until we get a functional snapshot end to end, let's only consider modifed
|
||||
# files. Later, we'll add all other types of files.
|
||||
_stream, _stats = repo.edenapi.uploadsnapshot(
|
||||
response = repo.edenapi.uploadsnapshot(
|
||||
getreponame(repo), {"files": {"modified": status.modified}}
|
||||
)
|
||||
|
||||
csid = bytes(response["changeset_token"]["data"]["id"]["BonsaiChangesetId"]).hex()
|
||||
|
||||
ui.status(f"Snapshot created with id {csid}\n", component="snapshot")
|
||||
|
@ -342,7 +342,7 @@ py_class!(pub class client |py| {
|
||||
&self,
|
||||
repo: String,
|
||||
data: Serde<SnapshotRawData>,
|
||||
) -> PyResult<(TStream<anyhow::Result<Serde<UploadSnapshotResponse>>>, PyFuture)> {
|
||||
) -> PyResult<Serde<UploadSnapshotResponse>> {
|
||||
self.inner(py).clone().uploadsnapshot_py(py, repo, data)
|
||||
}
|
||||
});
|
||||
|
@ -829,10 +829,7 @@ pub trait EdenApiPyExt: EdenApi {
|
||||
py: Python,
|
||||
repo: String,
|
||||
data: Serde<SnapshotRawData>,
|
||||
) -> PyResult<(
|
||||
TStream<anyhow::Result<Serde<UploadSnapshotResponse>>>,
|
||||
PyFuture,
|
||||
)> {
|
||||
) -> PyResult<Serde<UploadSnapshotResponse>> {
|
||||
let (modified, mut upload_data): (Vec<_>, Vec<_>) = data
|
||||
.0
|
||||
.files
|
||||
@ -856,7 +853,7 @@ pub trait EdenApiPyExt: EdenApi {
|
||||
.map(|(content_id, data)| (AnyFileContentId::ContentId(content_id), data))
|
||||
.collect();
|
||||
|
||||
let (responses, stats) = py
|
||||
let response = py
|
||||
.allow_threads(|| {
|
||||
block_unless_interrupted(async move {
|
||||
let _prepare_response = {
|
||||
@ -885,7 +882,7 @@ pub trait EdenApiPyExt: EdenApi {
|
||||
})
|
||||
.collect::<Result<BTreeMap<_, _>, _>>()?
|
||||
};
|
||||
let response = self.upload_bonsai_changesets(
|
||||
let mut response = self.upload_bonsai_changesets(
|
||||
repo, vec![UploadBonsaiChangeset {
|
||||
// TODO(yancouto): Remove HgId as it doesn't exist and is unnecessary
|
||||
hg_changeset_id: HgId::null_id().clone(),
|
||||
@ -910,20 +907,20 @@ pub trait EdenApiPyExt: EdenApi {
|
||||
},
|
||||
}], vec![]
|
||||
).await?;
|
||||
Ok::<_, EdenApiError>((
|
||||
stream::once(async {
|
||||
Result::<_, EdenApiError>::Ok(UploadSnapshotResponse {})
|
||||
}),
|
||||
response.stats,
|
||||
))
|
||||
let changeset_response = response
|
||||
.entries
|
||||
.next()
|
||||
.await
|
||||
.ok_or_else(|| anyhow!("Failed to create changeset"))??;
|
||||
Ok::<_, EdenApiError>(UploadSnapshotResponse {
|
||||
changeset_token: changeset_response.token,
|
||||
})
|
||||
})
|
||||
})
|
||||
.map_pyerr(py)?
|
||||
.map_pyerr(py)?;
|
||||
|
||||
let responses_py = responses.map_ok(Serde).map_err(Into::into);
|
||||
let stats_py = PyFuture::new(py, stats.map_ok(PyStats))?;
|
||||
Ok((responses_py.into(), stats_py))
|
||||
Ok(Serde(response))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,9 @@ pub struct SnapshotRawData {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
|
||||
pub struct UploadSnapshotResponse {}
|
||||
pub struct UploadSnapshotResponse {
|
||||
pub changeset_token: UploadToken,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Debug, Deserialize, Serialize, Eq, PartialEq)]
|
||||
pub struct EphemeralPrepareRequest {}
|
||||
|
Loading…
Reference in New Issue
Block a user