diff --git a/rust/hg-core/src/revlog.rs b/rust/hg-core/src/revlog.rs --- a/rust/hg-core/src/revlog.rs +++ b/rust/hg-core/src/revlog.rs @@ -35,6 +35,9 @@ #[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`. diff --git a/rust/hg-core/src/revlog/revlog.rs b/rust/hg-core/src/revlog/revlog.rs --- a/rust/hg-core/src/revlog/revlog.rs +++ b/rust/hg-core/src/revlog/revlog.rs @@ -23,6 +23,8 @@ #[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] diff --git a/rust/hg-core/src/revset.rs b/rust/hg-core/src/revset.rs --- a/rust/hg-core/src/revset.rs +++ b/rust/hg-core/src/revset.rs @@ -7,7 +7,7 @@ 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}; /// Resolve a query string into a single revision. /// @@ -50,6 +50,9 @@ return Ok(integer); } } + if input == WORKING_DIRECTORY_HEX { + return Err(RevlogError::WDirUnsupported); + } if let Ok(prefix) = NodePrefix::from_hex(input) { return revlog.get_node_rev(prefix); } diff --git a/rust/rhg/src/error.rs b/rust/rhg/src/error.rs --- a/rust/rhg/src/error.rs +++ b/rust/rhg/src/error.rs @@ -157,6 +157,9 @@ 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 diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t --- a/tests/test-debugcommands.t +++ b/tests/test-debugcommands.t @@ -531,17 +531,9 @@ 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