[Request] [+ ] D12523: rust: add `Debug` trait to a bunch of structs
Alphare (Raphaël Gomès)
phabricator at mercurial-scm.org
Tue Apr 12 16:04:45 UTC 2022
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This is useful when... debugging. Right now the output is not in the most
readable state it could be, but this is very low effort and is good enough
for now. We may want to write a nicer custom debug formatter for some of those
structs in the future.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D12523
AFFECTED FILES
rust/hg-core/src/dirstate_tree/dirstate_map.rs
rust/hg-core/src/dirstate_tree/on_disk.rs
CHANGE DETAILS
diff --git a/rust/hg-core/src/dirstate_tree/on_disk.rs b/rust/hg-core/src/dirstate_tree/on_disk.rs
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs
@@ -84,7 +84,7 @@
/// Fields are documented in the *The data file format*
/// section of `mercurial/helptext/internals/dirstate-v2.txt`
-#[derive(BytesCast)]
+#[derive(BytesCast, Debug)]
#[repr(C)]
pub(super) struct Node {
full_path: PathSlice,
@@ -124,7 +124,7 @@
}
/// Duration since the Unix epoch
-#[derive(BytesCast, Copy, Clone)]
+#[derive(BytesCast, Copy, Clone, Debug)]
#[repr(C)]
struct PackedTruncatedTimestamp {
truncated_seconds: U32Be,
@@ -152,7 +152,7 @@
/// Always sorted by ascending `full_path`, to allow binary search.
/// Since nodes with the same parent nodes also have the same parent path,
/// only the `base_name`s need to be compared during binary search.
-#[derive(BytesCast, Copy, Clone)]
+#[derive(BytesCast, Copy, Clone, Debug)]
#[repr(C)]
struct ChildNodes {
start: Offset,
@@ -160,7 +160,7 @@
}
/// A `HgPath` of `len` bytes
-#[derive(BytesCast, Copy, Clone)]
+#[derive(BytesCast, Copy, Clone, Debug)]
#[repr(C)]
struct PathSlice {
start: Offset,
diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -32,6 +32,7 @@
/// anymore) is less than this fraction of the total amount of existing data.
const ACCEPTABLE_UNREACHABLE_BYTES_RATIO: f32 = 0.5;
+#[derive(Debug)]
pub struct DirstateMap<'on_disk> {
/// Contents of the `.hg/dirstate` file
pub(super) on_disk: &'on_disk [u8],
@@ -61,21 +62,25 @@
/// Similar to `&'tree Cow<'on_disk, HgPath>`, but can also be returned
/// for on-disk nodes that donât actually have a `Cow` to borrow.
+#[derive(Debug)]
pub(super) enum BorrowedPath<'tree, 'on_disk> {
InMemory(&'tree HgPathBuf),
OnDisk(&'on_disk HgPath),
}
+#[derive(Debug)]
pub(super) enum ChildNodes<'on_disk> {
InMemory(FastHashMap<NodeKey<'on_disk>, Node<'on_disk>>),
OnDisk(&'on_disk [on_disk::Node]),
}
+#[derive(Debug)]
pub(super) enum ChildNodesRef<'tree, 'on_disk> {
InMemory(&'tree FastHashMap<NodeKey<'on_disk>, Node<'on_disk>>),
OnDisk(&'on_disk [on_disk::Node]),
}
+#[derive(Debug)]
pub(super) enum NodeRef<'tree, 'on_disk> {
InMemory(&'tree NodeKey<'on_disk>, &'tree Node<'on_disk>),
OnDisk(&'on_disk on_disk::Node),
@@ -383,7 +388,7 @@
}
/// Represents a file or a directory
-#[derive(Default)]
+#[derive(Default, Debug)]
pub(super) struct Node<'on_disk> {
pub(super) data: NodeData,
@@ -399,6 +404,7 @@
pub(super) tracked_descendants_count: u32,
}
+#[derive(Debug)]
pub(super) enum NodeData {
Entry(DirstateEntry),
CachedDirectory { mtime: TruncatedTimestamp },
To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20220412/e31fb088/attachment-0001.html>
More information about the Mercurial-patches
mailing list