This instance will be upgraded to Heptapod 0.27.1 on 2021-12-02 at 15:00 UTC+1 (a few minutes of down time)

Commit 48bac72c authored by Pulkit Goyal's avatar Pulkit Goyal
Browse files

rhg: raise wdir specific error for `hg debugdata`

Helps remove the conditional in `test-debugcommands.t` for rhg.

Differential Revision: https://phab.mercurial-scm.org/D10254
parent a86c5de12d22
Pipeline #19775 passed with stages
in 28 minutes and 18 seconds
......@@ -35,6 +35,9 @@ pub const NULL_REVISION: Revision = -1;
#[allow(clippy::unreadable_literal)]
pub const WORKING_DIRECTORY_REVISION: Revision = 0x7fffffff;
pub const WORKING_DIRECTORY_HEX: &str =
"ffffffffffffffffffffffffffffffffffffffff";
/// The simplest expression of what we need of Mercurial DAGs.
pub trait Graph {
/// Return the two parents of the given `Revision`.
......
......@@ -23,6 +23,8 @@ use crate::revlog::Revision;
#[derive(derive_more::From)]
pub enum RevlogError {
InvalidRevision,
/// Working directory is not supported
WDirUnsupported,
/// Found more than one entry whose ID match the requested prefix
AmbiguousPrefix,
#[from]
......
......@@ -7,7 +7,8 @@ use crate::repo::Repo;
use crate::revlog::changelog::Changelog;
use crate::revlog::revlog::{Revlog, RevlogError};
use crate::revlog::NodePrefix;
use crate::revlog::{Revision, NULL_REVISION};
use crate::revlog::{Revision, NULL_REVISION, WORKING_DIRECTORY_HEX};
use crate::Node;
/// Resolve a query string into a single revision.
///
......@@ -51,6 +52,10 @@ pub fn resolve_rev_number_or_hex_prefix(
}
}
if let Ok(prefix) = NodePrefix::from_hex(input) {
if prefix.is_prefix_of(&Node::from_hex(WORKING_DIRECTORY_HEX).unwrap())
{
return Err(RevlogError::WDirUnsupported);
}
return revlog.get_node_rev(prefix);
}
Err(RevlogError::InvalidRevision)
......
......@@ -157,6 +157,9 @@ impl From<ConfigParseError> for CommandError {
impl From<(RevlogError, &str)> for CommandError {
fn from((err, rev): (RevlogError, &str)) -> CommandError {
match err {
RevlogError::WDirUnsupported => CommandError::abort(
"abort: working directory revision cannot be specified",
),
RevlogError::InvalidRevision => CommandError::abort(format!(
"abort: invalid revision identifier: {}",
rev
......
......@@ -531,17 +531,9 @@ amount of time, displays error message and returns 1
Test WdirUnsupported exception
#if no-rhg
$ hg debugdata -c ffffffffffffffffffffffffffffffffffffffff
abort: working directory revision cannot be specified
[255]
#else
TODO: add rhg support for (at least parsing) the working directory pseudo-changeset
$ hg debugdata -c ffffffffffffffffffffffffffffffffffffffff
abort: working directory revision cannot be specified (missing-correct-output !)
abort: invalid revision identifier: ffffffffffffffffffffffffffffffffffffffff (known-bad-output !)
[255]
#endif
Test cache warming command
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment