##// END OF EJS Templates
rust: blanket implementation of Graph for Graph references...
rust: blanket implementation of Graph for Graph references The need comes from the fact that `AncestorsIterator` and many Graph-related algorithms take ownership of the `Graph` they work with. This, in turn is due to them needing to accept the `Index` instances that are provided by the Python layers (that neither rhg nor `RHGitaly` use, of course): the fact that nowadays the Python layer holds an object that is itself implemented in Rust does not change the core problem that they cannot be tracked by the borrow checker. Even though it looks like cloning `Changelog` would be cheap, it seems hard to guarantee that on the long run. The object is already too rich for us to be comfortable with it, when using references is the most natural and guaranteed way of proceeding. The added test seems a bit superfleous, but it will act as a reminder that this feature is really useful until something in the Mercurial code base actually uses it.

File last commit:

r50809:58074252 default
r52512:b08c5fbe stable
Show More
debugrhgsparse.rs
49 lines | 1.5 KiB | application/rls-services+xml | RustLexer
use std::{
ffi::{OsStr, OsString},
os::unix::prelude::OsStrExt,
};
use crate::error::CommandError;
use hg::{self, utils::hg_path::HgPath};
pub const HELP_TEXT: &str = "";
pub fn args() -> clap::Command {
clap::command!("debugrhgsparse")
.arg(
clap::Arg::new("files")
.value_name("FILES")
.required(true)
.num_args(1..)
.value_parser(clap::value_parser!(std::ffi::OsString))
.help("Files to check against sparse profile"),
)
.about(HELP_TEXT)
}
pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
let repo = invocation.repo?;
let (matcher, _warnings) = hg::sparse::matcher(repo).unwrap();
let files = invocation.subcommand_args.get_many::<OsString>("files");
if let Some(files) = files {
let files: Vec<&OsStr> = files
.filter(|s| !s.is_empty())
.map(|s| s.as_os_str())
.collect();
for file in files {
invocation.ui.write_stdout(b"matches: ")?;
invocation.ui.write_stdout(
if matcher.matches(HgPath::new(file.as_bytes())) {
b"yes"
} else {
b"no"
},
)?;
invocation.ui.write_stdout(b" | file: ")?;
invocation.ui.write_stdout(file.as_bytes())?;
invocation.ui.write_stdout(b"\n")?;
}
}
Ok(())
}