Skip to content

Commit

Permalink
commits: support git commit text in more places
Browse files Browse the repository at this point in the history
Summary:
By searching `::len` I found a few other places that need change to support the
Git format.

Reviewed By: zzl0

Differential Revision: D64948069

fbshipit-source-id: 8bd632438a8bd64c72affc9a567a75f63545555f
  • Loading branch information
quark-zju authored and facebook-github-bot committed Oct 29, 2024
1 parent f40b3a5 commit 41e0562
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 5 additions & 1 deletion eden/scm/lib/commits/src/hybrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use edenapi::types::CommitLocationToHashRequest;
use edenapi::SaplingRemoteApi;
use format_util::git_sha1_serialize;
use format_util::hg_sha1_deserialize;
use format_util::strip_sha1_header;
use futures::stream;
use futures::stream::BoxStream;
use futures::stream::StreamExt;
Expand Down Expand Up @@ -476,7 +477,10 @@ impl HybridResolver<Vertex, Bytes, anyhow::Error> for Resolver {
return Ok(Some(Bytes::new()));
}
match self.zstore.read().get(id)? {
Some(bytes) => Ok(Some(bytes.slice(Id20::len() * 2..))),
Some(bytes) => {
let text = strip_sha1_header(&bytes, self.format)?;
Ok(Some(text))
}
None => Ok(crate::revlog::get_hard_coded_commit_text(vertex)),
}
}
Expand Down
13 changes: 5 additions & 8 deletions eden/scm/lib/commits/src/on_disk_commits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ use dag::Group;
use dag::Set;
use dag::Vertex;
use dag::VertexListWithOptions;
use format_util::git_sha1_deserialize;
use format_util::git_sha1_serialize;
use format_util::hg_sha1_deserialize;
use format_util::hg_sha1_serialize;
use format_util::strip_sha1_header;
use futures::stream::BoxStream;
use futures::stream::StreamExt;
use minibytes::Bytes;
Expand Down Expand Up @@ -207,11 +206,8 @@ fn get_commit_raw_text(
let id = Id20::from_slice(vertex.as_ref())?;
match store.get(id)? {
Some(bytes) => {
let raw_text = match format {
SerializationFormat::Hg => hg_sha1_deserialize(bytes.as_ref())?.0,
SerializationFormat::Git => git_sha1_deserialize(bytes.as_ref())?.0,
};
Ok(Some(bytes.slice_to_bytes(raw_text)))
let raw_text = strip_sha1_header(&bytes, format)?;
Ok(Some(raw_text))
}
None => Ok(crate::revlog::get_hard_coded_commit_text(vertex)),
}
Expand All @@ -223,6 +219,7 @@ impl StreamCommitText for OnDiskCommits {
stream: BoxStream<'static, anyhow::Result<Vertex>>,
) -> Result<BoxStream<'static, anyhow::Result<ParentlessHgCommit>>> {
let zstore = Zstore::open(&self.commits_path)?;
let format = self.format;
let stream = stream.map(move |item| {
let vertex = item?;
let id = Id20::from_slice(vertex.as_ref())?;
Expand All @@ -231,7 +228,7 @@ impl StreamCommitText for OnDiskCommits {
Default::default()
} else {
match zstore.get(id)? {
Some(raw_data) => raw_data.slice(Id20::len() * 2..),
Some(raw_data) => strip_sha1_header(&raw_data, format)?,
None => return vertex.not_found().map_err(Into::into),
}
};
Expand Down

0 comments on commit 41e0562

Please sign in to comment.