Skip to content
Snippets Groups Projects
Commit 6b54aa74 authored by Georges Racinet's avatar Georges Racinet
Browse files

RHGitaly: message::commit_for_node_prefix

This method is fairly simple, but it has the tremendous advantage
to flatten three possible `RevlogError` into one, considerably
simplifying error treatment for the caller.
parent 8b6fdf35
No related branches found
No related tags found
2 merge requests!169Protocol v15.9 and stable branch merge",!164RHGitaly CommitService.FindCommit implementation
//! Adaptators for common Gitaly / HGitaly messages
use hg::changelog::Changelog;
use hg::changelog::{ChangelogEntry, ChangelogRevisionData};
use hg::errors::HgError;
......@@ -2,6 +3,6 @@
use hg::changelog::{ChangelogEntry, ChangelogRevisionData};
use hg::errors::HgError;
use hg::revlog::RevlogError;
use hg::revlog::{NodePrefix, RevlogError, NULL_REVISION};
use std::fmt;
use crate::gitaly::{CommitAuthor, GitCommit};
......@@ -230,6 +231,21 @@
})
}
/// Return the [`GitCommit`] message for a changeset given by Node prefix.
///
/// If the Node prefix resolves to [`NULL_REVISION`], the return value is `Ok(None)`.
pub fn commit_for_node_prefix(
cl: &Changelog,
node_prefix: NodePrefix,
) -> Result<Option<GitCommit>, RevlogError> {
let rev = cl.rev_from_node(node_prefix)?;
if rev == NULL_REVISION {
return Ok(None);
}
Ok(Some(commit(cl.entry_for_rev(rev)?)?))
}
#[cfg(test)]
mod tests {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment