##// END OF EJS Templates
obsolete: don't use os.stat in repo.obsstore.__nonzero__ if it's static HTTP...
obsolete: don't use os.stat in repo.obsstore.__nonzero__ if it's static HTTP If a repo is accessed via static HTTP, then we obviously can't use os.stat() to just peek at the file size. Let's download the entire file to check its size. Yes, this feels wasteful, but: 1. If we're cloning or pulling a repo from a static HTTP server, we need the contents of the obsstore anyway. 2. Implementing statichttpvfs.stat() that uses HEAD will result in one more request to a static-only HTTP server, which is already slow. Also parsing a response to a HEAD request to construct os.stat_result is pretty hacky. There's also a question of the remote server properly supporting HEAD method and reporting at least file size. 3. Implementing statichttpvfs.stat() that uses GET is pretty much the same thing as we do here, except we can't even cache the response easily, unlike simply accessing obsstore._data, which is @propertycache'd. Importing statichttprepo locally to avoid circular import. See also: 4507bc001365 and commit message of f8f2ecdde4b5. Differential Revision: https://phab.mercurial-scm.org/D12195

File last commit:

r48893:3da7bf75 default
r49640:ef50a62e default
Show More
revset.rs
69 lines | 2.1 KiB | application/rls-services+xml | RustLexer
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 //! The revset query language
//!
//! <https://www.mercurial-scm.org/repo/hg/help/revsets>
Simon Sapin
rhg: Fall back to Python for unsupported revset syntax...
r47459 use crate::errors::HgError;
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 use crate::repo::Repo;
use crate::revlog::revlog::{Revlog, RevlogError};
use crate::revlog::NodePrefix;
Pulkit Goyal
rhg: raise wdir specific error for `hg debugdata`...
r47577 use crate::revlog::{Revision, NULL_REVISION, WORKING_DIRECTORY_HEX};
use crate::Node;
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162
/// Resolve a query string into a single revision.
///
/// Only some of the revset language is implemented yet.
pub fn resolve_single(
input: &str,
repo: &Repo,
) -> Result<Revision, RevlogError> {
Simon Sapin
rust: Keep lazily-initialized Changelog and Manifest log on the Repo object...
r48773 let changelog = repo.changelog()?;
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162
Raphaël Gomès
rust-revset: add separate match logic for shortcuts...
r48892 match input {
Raphaël Gomès
rust-revset: support explicit `.` revision...
r48893 "." => {
let p1 = repo.dirstate_parents()?.p1;
return Ok(changelog.revlog.rev_from_node(p1.into())?);
}
Raphaël Gomès
rust-revset: add separate match logic for shortcuts...
r48892 "null" => return Ok(NULL_REVISION),
_ => {}
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 }
Raphaël Gomès
rust-revset: add separate match logic for shortcuts...
r48892 match resolve_rev_number_or_hex_prefix(input, &changelog.revlog) {
Err(RevlogError::InvalidRevision) => {
// TODO: support for the rest of the language here.
let msg = format!("cannot parse revset '{}'", input);
Err(HgError::unsupported(msg).into())
}
result => return result,
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 }
}
/// Resolve the small subset of the language suitable for revlogs other than
/// the changelog, such as in `hg debugdata --manifest` CLI argument.
///
/// * A non-negative decimal integer for a revision number, or
/// * An hexadecimal string, for the unique node ID that starts with this
/// prefix
pub fn resolve_rev_number_or_hex_prefix(
input: &str,
revlog: &Revlog,
) -> Result<Revision, RevlogError> {
Simon Sapin
rhg: Align with Python on some revset parsing corner cases...
r48776 // The Python equivalent of this is part of `revsymbol` in
// `mercurial/scmutil.py`
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 if let Ok(integer) = input.parse::<i32>() {
Simon Sapin
rhg: Align with Python on some revset parsing corner cases...
r48776 if integer.to_string() == input
&& integer >= 0
&& revlog.has_rev(integer)
{
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 return Ok(integer);
}
}
if let Ok(prefix) = NodePrefix::from_hex(input) {
Pulkit Goyal
rhg: raise wdir specific error for `hg debugdata`...
r47577 if prefix.is_prefix_of(&Node::from_hex(WORKING_DIRECTORY_HEX).unwrap())
{
return Err(RevlogError::WDirUnsupported);
}
Simon Sapin
rust: Rename the `Revlog::get_node_rev` method to `rev_from_node`...
r48782 return revlog.rev_from_node(prefix);
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 }
Err(RevlogError::InvalidRevision)
}