Patchwork D10254: rhg: raise wdir specific error for `hg debugdata`

login
register
mail settings
Submitter phabricator
Date March 23, 2021, 8:39 p.m.
Message ID <differential-rev-PHID-DREV-5n4zgmmumrq2qfdfnmjl-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48570/
State Superseded
Headers show

Comments

phabricator - March 23, 2021, 8:39 p.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10254

AFFECTED FILES
  rust/hg-core/src/revlog.rs
  rust/hg-core/src/revlog/revlog.rs
  rust/hg-core/src/revset.rs
  rust/rhg/src/error.rs
  tests/test-debugcommands.t

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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
 
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/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/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/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`.