Skip to content

Commit

Permalink
edenapi: add copy info to BonsaiFileChanges
Browse files Browse the repository at this point in the history
Summary: When testing the `IdenticalChangesets` endpoint I was getting an error that the bonsai I sent didn't have the same hash as the bonsai it was being generated from the data structure. When I looked, copy info was responsible since we don't pipe it through edenapi, fixing that.

Reviewed By: markbt

Differential Revision: D67379172

fbshipit-source-id: 88da24c0dcccd28172b083e21bc696ff9ecd1d04
  • Loading branch information
lmvasquezg authored and facebook-github-bot committed Dec 19, 2024
1 parent 925e427 commit 1e3142f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions eden/mononoke/edenapi_service/src/handlers/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ impl SaplingRemoteApiHandler for FetchSnapshotHandler {
Some(bubble_id.into()),
),
file_type: tc.file_type().try_into()?,
copy_info: None, // TODO: Add copy info on tracked changes
},
FileChange::UntrackedChange(uc) => BonsaiFileChange::UntrackedChange {
upload_token: UploadToken::new_fake_token(
Expand Down
9 changes: 7 additions & 2 deletions eden/mononoke/edenapi_service/src/utils/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use mercurial_types::HgNodeHash;
use mononoke_api::CreateChange;
use mononoke_api::CreateChangeFile;
use mononoke_api::CreateChangeFileContents;
use mononoke_api::CreateCopyInfo;
use mononoke_types::path::MPath;
use mononoke_types::DateTime;
use mononoke_types::NonRootMPath;
Expand Down Expand Up @@ -102,6 +103,7 @@ pub fn to_create_change(fc: BonsaiFileChange, bubble_id: Option<BubbleId>) -> Re
BonsaiFileChange::Change {
file_type,
upload_token,
copy_info,
} => {
verify(&upload_token)?;
if let UploadTokenData {
Expand All @@ -119,8 +121,11 @@ pub fn to_create_change(fc: BonsaiFileChange, bubble_id: Option<BubbleId>) -> Re
file_type: file_type.into(),
git_lfs: None,
},
// TODO(yancouto): Add copy info on tracked changes
None,
copy_info
.map(|(path, index)| {
anyhow::Ok(CreateCopyInfo::new(to_mpath(path)?, index))
})
.transpose()?,
))
} else {
bail!("Invalid upload token format, missing content id")
Expand Down
1 change: 1 addition & 0 deletions eden/scm/lib/edenapi/ext/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ pub async fn upload_snapshot(
BonsaiFileChange::Change {
file_type,
upload_token,
copy_info: None, // TODO(yancouto): Add copy info on tracked changes
}
} else {
BonsaiFileChange::UntrackedChange {
Expand Down
2 changes: 2 additions & 0 deletions eden/scm/lib/edenapi/types/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ pub enum BonsaiFileChange {
/// Token proving the file was uploaded, and containing its content id and size
upload_token: UploadToken,
file_type: FileType,
copy_info: Option<(RepoPathBuf, usize)>,
},
Deletion,
UntrackedChange {
Expand Down Expand Up @@ -449,6 +450,7 @@ impl Arbitrary for BonsaiFileChange {
0..=49 => Self::Change {
upload_token: Arbitrary::arbitrary(g),
file_type: Arbitrary::arbitrary(g),
copy_info: Arbitrary::arbitrary(g),
},
50..=79 => Self::Deletion,
80..=94 => Self::UntrackedChange {
Expand Down
21 changes: 20 additions & 1 deletion eden/scm/lib/edenapi/types/src/wire/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ pub enum WireBonsaiFileChange {
#[serde(rename = "4")]
Deletion,

#[serde(rename = "5")]
ChangeWithCopyInfo(WireUploadToken, WireFileType, (WireRepoPathBuf, usize)),

#[serde(other, rename = "0")]
Unknown,
}
Expand Down Expand Up @@ -339,7 +342,15 @@ impl ToWire for BonsaiFileChange {
Self::Change {
upload_token,
file_type,
} => WireBonsaiFileChange::Change(upload_token.to_wire(), file_type.to_wire()),
copy_info,
} => match copy_info {
Some((path, index)) => WireBonsaiFileChange::ChangeWithCopyInfo(
upload_token.to_wire(),
file_type.to_wire(),
(path.to_wire(), index.to_wire()),
),
None => WireBonsaiFileChange::Change(upload_token.to_wire(), file_type.to_wire()),
},
Self::UntrackedChange {
upload_token,
file_type,
Expand Down Expand Up @@ -380,7 +391,15 @@ impl ToApi for WireBonsaiFileChange {
Self::Change(upload_token, file_type) => Ok(BonsaiFileChange::Change {
upload_token: upload_token.to_api()?,
file_type: file_type.to_api()?,
copy_info: None,
}),
Self::ChangeWithCopyInfo(upload_token, file_type, (path, index)) => {
Ok(BonsaiFileChange::Change {
upload_token: upload_token.to_api()?,
file_type: file_type.to_api()?,
copy_info: Some((path.to_api()?, index)),
})
}
Self::UntrackedChange(upload_token, file_type) => {
Ok(BonsaiFileChange::UntrackedChange {
upload_token: upload_token.to_api()?,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: commit.rs
expression: "WireFetchSnapshotResponse::arbitrary(&mut g)"

expression: "WireFetchSnapshotResponse :: arbitrary(& mut g)"
---
{"2":[["aiffeu/uatbfkh/jkleav",{"1":[{"1":{"1":{"4":[96,254,202,4,46,38,85,25,36,58,55,101,239,1,100,81,21,29,1,4]},"3":6325243916544195815}},"3"]}]],"3":";","4":-6078798801950842190,"5":1781715560,"6":11404059536174006203}
{"2":[["aiffeu/uatbfkh/jkleav",{"5":[{"1":{"1":{"4":[96,254,202,4,46,38,85,25,36,58,55,101,239,1,100,81,21,29,1,4]},"3":6325243916544195815}},"3",["gdqp/nhxnr/ixfpat/mw",18446744073709551615]]}]],"4":5294005526868283990,"5":-1808809550,"6":14415315640882124868,"7":[""]}

0 comments on commit 1e3142f

Please sign in to comment.