diff rust/hg-core/src/operations/debugdata.rs @ 45832:57dc78861196

rhg: add full node id support for `debugdata` command Unlike other later implemented commands `debugdata` only supported revision number. This changeset add full node id support for consistency with other commands. Differential Revision: https://phab.mercurial-scm.org/D9230
author Antoine cezar<acezar@chwitlabs.fr>
date Tue, 20 Oct 2020 15:09:08 +0200
parents 7252f5237352
children 8d6164098782
line wrap: on
line diff
--- a/rust/hg-core/src/operations/debugdata.rs	Thu Oct 29 13:54:25 2020 +0100
+++ b/rust/hg-core/src/operations/debugdata.rs	Tue Oct 20 15:09:08 2020 +0200
@@ -92,18 +92,22 @@
     }
 
     pub fn run(&mut self) -> Result<Vec<u8>, DebugDataError> {
-        let rev = self
-            .rev
-            .parse::<Revision>()
-            .or(Err(DebugDataErrorKind::InvalidRevision))?;
-
         let root = find_root::FindRoot::new().run()?;
         let index_file = match self.kind {
             DebugDataKind::Changelog => root.join(".hg/store/00changelog.i"),
             DebugDataKind::Manifest => root.join(".hg/store/00manifest.i"),
         };
         let revlog = Revlog::open(&index_file, None)?;
-        let data = revlog.get_rev_data(rev)?;
+
+        let data = match self.rev.parse::<Revision>() {
+            Ok(rev) => revlog.get_rev_data(rev)?,
+            _ => {
+                let node = hex::decode(&self.rev)
+                    .map_err(|_| DebugDataErrorKind::InvalidRevision)?;
+                let rev = revlog.get_node_rev(&node)?;
+                revlog.get_rev_data(rev)?
+            }
+        };
 
         Ok(data)
     }