##// END OF EJS Templates
rust: implement conversion of RevlogError into HgError...
rust: implement conversion of RevlogError into HgError The conversion already exists in rhg, where we need to convert to CommandError. This commit moves it to hg core. This makes it easier to code some middleware where we need to carry around a type that represents any type of hg error (HgError).

File last commit:

r53187:a3fa37bd default
r53241:09a36de5 default
Show More
debugdata.rs
45 lines | 1.3 KiB | application/rls-services+xml | RustLexer
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 // debugdata.rs
//
// Copyright 2020 Antoine Cezar <antoine.cezar@octobus.net>
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
Raphaël Gomès
rust: use new revlog configs in all revlog opening code...
r52760 use crate::errors::HgError;
Raphaël Gomès
rust: don't star export from the `revlog` module...
r53075 use crate::exit_codes;
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 use crate::repo::Repo;
Raphaël Gomès
rust-revlog: introduce an `options` module...
r53053 use crate::revlog::options::default_revlog_options;
Raphaël Gomès
rust: don't star export from the `revlog` module...
r53075 use crate::revlog::{Revlog, RevlogError, RevlogType};
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098
/// Dump the contents data of a revision.
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 pub fn debug_data(
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 repo: &Repo,
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 revset: &str,
Raphaël Gomès
rust: use new revlog configs in all revlog opening code...
r52760 kind: RevlogType,
Simon Sapin
rust: remove three enums that were identical to `RevlogError`...
r47166 ) -> Result<Vec<u8>, RevlogError> {
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 let index_file = match kind {
Raphaël Gomès
rust: use new revlog configs in all revlog opening code...
r52760 RevlogType::Changelog => "00changelog.i",
RevlogType::Manifestlog => "00manifest.i",
_ => {
return Err(RevlogError::Other(HgError::abort(
format!("invalid revlog type {}", kind),
exit_codes::ABORT,
None,
)))
}
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 };
Raphaël Gomès
rust-revlog: teach the revlog opening code to read the repo options...
r52084 let revlog = Revlog::open(
&repo.store_vfs(),
index_file,
None,
Raphaël Gomès
rust-revlog: introduce an `options` module...
r53053 default_revlog_options(
repo.config(),
repo.requirements(),
RevlogType::Changelog,
)?,
Raphaël Gomès
rust-revlog: teach the revlog opening code to read the repo options...
r52084 )?;
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 let rev =
crate::revset::resolve_rev_number_or_hex_prefix(revset, &revlog)?;
Raphaël Gomès
rust: normalize `_for_unchecked_rev` naming among revlogs and the index...
r53187 let data = revlog.get_data(rev)?;
Simon Sapin
rhg: Add RevlogEntry::data that does delta resolution...
r49373 Ok(data.into_owned())
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 }