annotate rust/hg-core/src/revlog/mod.rs @ 52298:645d247d4c75

rust-vfs: rename `open` to `open_write` and `open_read` to `open` `open` being read *and* write is surprising because it differs from the Rust stdlib where `std::fs::File::open` is read-only by default. More importantly, writing is more dangerous than reading, so let's make it more explicit.
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 29 Oct 2024 12:03:55 +0100
parents a3fa37bdb7ec
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
1 // Copyright 2018-2023 Georges Racinet <georges.racinet@octobus.net>
44005
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
2 // and Mercurial contributors
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
3 //
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
4 // This software may be used and distributed according to the terms of the
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
5 // GNU General Public License version 2 or any later version.
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
6 //! Mercurial concepts for handling revision history
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
7
44143
7f86426fdd2c rust-node: binary Node ID and conversion utilities
Georges Racinet <georges.racinet@octobus.net>
parents: 44142
diff changeset
8 pub mod node;
44142
63db6657d280 rust-nodemap: building blocks for nodetree structures
Georges Racinet <georges.racinet@octobus.net>
parents: 44088
diff changeset
9 pub mod nodemap;
46090
9eb07ab3f2d4 rhg: use persistent nodemap when available
Simon Sapin <simon-commits@exyr.org>
parents: 45539
diff changeset
10 mod nodemap_docket;
45539
aebc976fd7d5 hg-core: add path_encode
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45533
diff changeset
11 pub mod path_encode;
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
12 use inner_revlog::CoreRevisionBuffer;
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
13 use inner_revlog::InnerRevlog;
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
14 use inner_revlog::RevisionBuffer;
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
15 use memmap2::MmapOptions;
52182
bd8081e9fd62 rust: don't star export from the `revlog` module
Raphaël Gomès <rgomes@octobus.net>
parents: 52181
diff changeset
16 pub use node::{FromHexError, Node, NodePrefix, NULL_NODE, NULL_NODE_ID};
52160
039b7caeb4d9 rust-revlog: introduce an `options` module
Raphaël Gomès <rgomes@octobus.net>
parents: 52159
diff changeset
17 use options::RevlogOpenOptions;
45532
c2317b7624fd hg-core: add `Changlog` a specialized `Revlog`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45526
diff changeset
18 pub mod changelog;
52158
0744248cc541 rust-revlog: add compression helpers
Raphaël Gomès <rgomes@octobus.net>
parents: 52060
diff changeset
19 pub mod compression;
52159
426696af24d3 rust-revlog: add file IO helpers
Raphaël Gomès <rgomes@octobus.net>
parents: 52158
diff changeset
20 pub mod file_io;
47961
4d2a5ca060e3 rust: Add a Filelog struct that wraps Revlog
Simon Sapin <simon.sapin@octobus.net>
parents: 46821
diff changeset
21 pub mod filelog;
45526
26c53ee51c68 hg-core: Add a limited read only `revlog` implementation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44973
diff changeset
22 pub mod index;
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
23 pub mod inner_revlog;
45533
89ac95bd4993 hg-core: add `Manifest` a specialized `Revlog`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45532
diff changeset
24 pub mod manifest;
52160
039b7caeb4d9 rust-revlog: introduce an `options` module
Raphaël Gomès <rgomes@octobus.net>
parents: 52159
diff changeset
25 pub mod options;
45526
26c53ee51c68 hg-core: Add a limited read only `revlog` implementation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 44973
diff changeset
26 pub mod patch;
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
27
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
28 use std::borrow::Cow;
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
29 use std::io::ErrorKind;
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
30 use std::io::Read;
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
31 use std::ops::Deref;
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
32 use std::path::Path;
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
33
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
34 use self::nodemap_docket::NodeMapDocket;
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
35 use crate::errors::HgError;
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
36 use crate::errors::IoResultExt;
51865
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
37 use crate::exit_codes;
52182
bd8081e9fd62 rust: don't star export from the `revlog` module
Raphaël Gomès <rgomes@octobus.net>
parents: 52181
diff changeset
38 use crate::revlog::index::Index;
bd8081e9fd62 rust: don't star export from the `revlog` module
Raphaël Gomès <rgomes@octobus.net>
parents: 52181
diff changeset
39 use crate::revlog::nodemap::{NodeMap, NodeMapError};
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
40 use crate::vfs::Vfs;
51868
db7dbe6f7bb2 rust: add Vfs trait
Raphaël Gomès <rgomes@octobus.net>
parents: 51867
diff changeset
41 use crate::vfs::VfsImpl;
44142
63db6657d280 rust-nodemap: building blocks for nodetree structures
Georges Racinet <georges.racinet@octobus.net>
parents: 44088
diff changeset
42
44005
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
43 /// As noted in revlog.c, revision numbers are actually encoded in
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
44 /// 4 bytes, and are liberally converted to ints, whence the i32
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
45 pub type BaseRevision = i32;
44005
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
46
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
47 /// Mercurial revision numbers
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
48 /// In contrast to the more general [`UncheckedRevision`], these are "checked"
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
49 /// in the sense that they should only be used for revisions that are
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
50 /// valid for a given index (i.e. in bounds).
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
51 #[derive(
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
52 Debug,
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
53 derive_more::Display,
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
54 Clone,
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
55 Copy,
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
56 Hash,
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
57 PartialEq,
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
58 Eq,
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
59 PartialOrd,
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
60 Ord,
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
61 )]
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
62 pub struct Revision(pub BaseRevision);
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
63
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
64 impl format_bytes::DisplayBytes for Revision {
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
65 fn display_bytes(
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
66 &self,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
67 output: &mut dyn std::io::Write,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
68 ) -> std::io::Result<()> {
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
69 self.0.display_bytes(output)
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
70 }
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
71 }
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
72
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
73 /// Unchecked Mercurial revision numbers.
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
74 ///
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
75 /// Values of this type have no guarantee of being a valid revision number
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
76 /// in any context. Use method `check_revision` to get a valid revision within
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
77 /// the appropriate index object.
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
78 #[derive(
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
79 Debug,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
80 derive_more::Display,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
81 Clone,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
82 Copy,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
83 Hash,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
84 PartialEq,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
85 Eq,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
86 PartialOrd,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
87 Ord,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
88 )]
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
89 pub struct UncheckedRevision(pub BaseRevision);
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
90
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
91 impl format_bytes::DisplayBytes for UncheckedRevision {
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
92 fn display_bytes(
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
93 &self,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
94 output: &mut dyn std::io::Write,
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
95 ) -> std::io::Result<()> {
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
96 self.0.display_bytes(output)
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
97 }
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
98 }
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
99
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
100 impl From<Revision> for UncheckedRevision {
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
101 fn from(value: Revision) -> Self {
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
102 Self(value.0)
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
103 }
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
104 }
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
105
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
106 impl From<BaseRevision> for UncheckedRevision {
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
107 fn from(value: BaseRevision) -> Self {
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
108 Self(value)
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
109 }
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
110 }
44005
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
111
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
112 /// Marker expressing the absence of a parent
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
113 ///
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
114 /// Independently of the actual representation, `NULL_REVISION` is guaranteed
44088
b3ec1ea95ee6 rust-core: fix typo in comment
Aay Jay Chan <aayjaychan@itopia.com.hk>
parents: 44005
diff changeset
115 /// to be smaller than all existing revisions.
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
116 pub const NULL_REVISION: Revision = Revision(-1);
44005
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
117
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
118 /// Same as `mercurial.node.wdirrev`
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
119 ///
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
120 /// This is also equal to `i32::max_value()`, but it's better to spell
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
121 /// it out explicitely, same as in `mercurial.node`
44973
26114bd6ec60 rust: do a clippy pass
Raphaël Gomès <rgomes@octobus.net>
parents: 44182
diff changeset
122 #[allow(clippy::unreadable_literal)]
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
123 pub const WORKING_DIRECTORY_REVISION: UncheckedRevision =
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
124 UncheckedRevision(0x7fffffff);
44005
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
125
46821
e8ae91b1a63d rhg: raise wdir specific error for `hg debugdata`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46431
diff changeset
126 pub const WORKING_DIRECTORY_HEX: &str =
e8ae91b1a63d rhg: raise wdir specific error for `hg debugdata`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46431
diff changeset
127 "ffffffffffffffffffffffffffffffffffffffff";
e8ae91b1a63d rhg: raise wdir specific error for `hg debugdata`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46431
diff changeset
128
44005
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
129 /// The simplest expression of what we need of Mercurial DAGs.
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
130 pub trait Graph {
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
131 /// Return the two parents of the given `Revision`.
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
132 ///
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
133 /// Each of the parents can be independently `NULL_REVISION`
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
134 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError>;
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
135 }
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
136
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
137 #[derive(Clone, Debug, PartialEq)]
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
138 pub enum GraphError {
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
139 ParentOutOfRange(Revision),
6b332c1fc7fe rust-core: extracted a revlog submodule
Georges Racinet <georges.racinet@octobus.net>
parents:
diff changeset
140 }
44181
3fb39dc2e356 rust-revlog: a trait for the revlog index
Georges Racinet <georges.racinet@octobus.net>
parents: 44143
diff changeset
141
52045
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
142 impl std::fmt::Display for GraphError {
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
143 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
144 match self {
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
145 GraphError::ParentOutOfRange(revision) => {
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
146 write!(f, "parent out of range ({})", revision)
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
147 }
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
148 }
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
149 }
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
150 }
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
151
51619
b08c5fbe0e70 rust: blanket implementation of Graph for Graph references
Georges Racinet <georges.racinet@octobus.net>
parents: 51256
diff changeset
152 impl<T: Graph> Graph for &T {
b08c5fbe0e70 rust: blanket implementation of Graph for Graph references
Georges Racinet <georges.racinet@octobus.net>
parents: 51256
diff changeset
153 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> {
b08c5fbe0e70 rust: blanket implementation of Graph for Graph references
Georges Racinet <georges.racinet@octobus.net>
parents: 51256
diff changeset
154 (*self).parents(rev)
b08c5fbe0e70 rust: blanket implementation of Graph for Graph references
Georges Racinet <georges.racinet@octobus.net>
parents: 51256
diff changeset
155 }
b08c5fbe0e70 rust: blanket implementation of Graph for Graph references
Georges Racinet <georges.racinet@octobus.net>
parents: 51256
diff changeset
156 }
b08c5fbe0e70 rust: blanket implementation of Graph for Graph references
Georges Racinet <georges.racinet@octobus.net>
parents: 51256
diff changeset
157
44181
3fb39dc2e356 rust-revlog: a trait for the revlog index
Georges Racinet <georges.racinet@octobus.net>
parents: 44143
diff changeset
158 /// The Mercurial Revlog Index
3fb39dc2e356 rust-revlog: a trait for the revlog index
Georges Racinet <georges.racinet@octobus.net>
parents: 44143
diff changeset
159 ///
3fb39dc2e356 rust-revlog: a trait for the revlog index
Georges Racinet <georges.racinet@octobus.net>
parents: 44143
diff changeset
160 /// This is currently limited to the minimal interface that is needed for
3fb39dc2e356 rust-revlog: a trait for the revlog index
Georges Racinet <georges.racinet@octobus.net>
parents: 44143
diff changeset
161 /// the [`nodemap`](nodemap/index.html) module
3fb39dc2e356 rust-revlog: a trait for the revlog index
Georges Racinet <georges.racinet@octobus.net>
parents: 44143
diff changeset
162 pub trait RevlogIndex {
3fb39dc2e356 rust-revlog: a trait for the revlog index
Georges Racinet <georges.racinet@octobus.net>
parents: 44143
diff changeset
163 /// Total number of Revisions referenced in this index
3fb39dc2e356 rust-revlog: a trait for the revlog index
Georges Racinet <georges.racinet@octobus.net>
parents: 44143
diff changeset
164 fn len(&self) -> usize;
3fb39dc2e356 rust-revlog: a trait for the revlog index
Georges Racinet <georges.racinet@octobus.net>
parents: 44143
diff changeset
165
44973
26114bd6ec60 rust: do a clippy pass
Raphaël Gomès <rgomes@octobus.net>
parents: 44182
diff changeset
166 fn is_empty(&self) -> bool {
26114bd6ec60 rust: do a clippy pass
Raphaël Gomès <rgomes@octobus.net>
parents: 44182
diff changeset
167 self.len() == 0
26114bd6ec60 rust: do a clippy pass
Raphaël Gomès <rgomes@octobus.net>
parents: 44182
diff changeset
168 }
26114bd6ec60 rust: do a clippy pass
Raphaël Gomès <rgomes@octobus.net>
parents: 44182
diff changeset
169
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
170 /// Return a reference to the Node or `None` for `NULL_REVISION`
44181
3fb39dc2e356 rust-revlog: a trait for the revlog index
Georges Racinet <georges.racinet@octobus.net>
parents: 44143
diff changeset
171 fn node(&self, rev: Revision) -> Option<&Node>;
50974
c950fdba7472 rust: add `UncheckedRevision` type
Raphaël Gomès <rgomes@octobus.net>
parents: 50746
diff changeset
172
c950fdba7472 rust: add `UncheckedRevision` type
Raphaël Gomès <rgomes@octobus.net>
parents: 50746
diff changeset
173 /// Return a [`Revision`] if `rev` is a valid revision number for this
51203
7434747343ab rust-index: check that the entry bytes are the same in both indexes
Raphaël Gomès <rgomes@octobus.net>
parents: 51191
diff changeset
174 /// index.
7434747343ab rust-index: check that the entry bytes are the same in both indexes
Raphaël Gomès <rgomes@octobus.net>
parents: 51191
diff changeset
175 ///
7434747343ab rust-index: check that the entry bytes are the same in both indexes
Raphaël Gomès <rgomes@octobus.net>
parents: 51191
diff changeset
176 /// [`NULL_REVISION`] is considered to be valid.
51256
83de5a06f6eb rust-index: allow inlining `check_revision` across crates
Raphaël Gomès <rgomes@octobus.net>
parents: 51203
diff changeset
177 #[inline(always)]
50974
c950fdba7472 rust: add `UncheckedRevision` type
Raphaël Gomès <rgomes@octobus.net>
parents: 50746
diff changeset
178 fn check_revision(&self, rev: UncheckedRevision) -> Option<Revision> {
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
179 let rev = rev.0;
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
180
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
181 if rev == NULL_REVISION.0 || (rev >= 0 && (rev as usize) < self.len())
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
182 {
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
183 Some(Revision(rev))
50974
c950fdba7472 rust: add `UncheckedRevision` type
Raphaël Gomès <rgomes@octobus.net>
parents: 50746
diff changeset
184 } else {
c950fdba7472 rust: add `UncheckedRevision` type
Raphaël Gomès <rgomes@octobus.net>
parents: 50746
diff changeset
185 None
c950fdba7472 rust: add `UncheckedRevision` type
Raphaël Gomès <rgomes@octobus.net>
parents: 50746
diff changeset
186 }
c950fdba7472 rust: add `UncheckedRevision` type
Raphaël Gomès <rgomes@octobus.net>
parents: 50746
diff changeset
187 }
44181
3fb39dc2e356 rust-revlog: a trait for the revlog index
Georges Racinet <georges.racinet@octobus.net>
parents: 44143
diff changeset
188 }
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
189
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
190 const REVISION_FLAG_CENSORED: u16 = 1 << 15;
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
191 const REVISION_FLAG_ELLIPSIS: u16 = 1 << 14;
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
192 const REVISION_FLAG_EXTSTORED: u16 = 1 << 13;
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
193 const REVISION_FLAG_HASCOPIESINFO: u16 = 1 << 12;
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
194
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
195 // Keep this in sync with REVIDX_KNOWN_FLAGS in
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
196 // mercurial/revlogutils/flagutil.py
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
197 const REVIDX_KNOWN_FLAGS: u16 = REVISION_FLAG_CENSORED
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
198 | REVISION_FLAG_ELLIPSIS
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
199 | REVISION_FLAG_EXTSTORED
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
200 | REVISION_FLAG_HASCOPIESINFO;
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
201
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
202 const NULL_REVLOG_ENTRY_FLAGS: u16 = 0;
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
203
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
204 #[derive(Debug, derive_more::From, derive_more::Display)]
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
205 pub enum RevlogError {
52045
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
206 #[display(fmt = "invalid revision identifier: {}", "_0")]
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
207 InvalidRevision(String),
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
208 /// Working directory is not supported
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
209 WDirUnsupported,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
210 /// Found more than one entry whose ID match the requested prefix
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
211 AmbiguousPrefix,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
212 #[from]
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
213 Other(HgError),
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
214 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
215
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
216 impl From<NodeMapError> for RevlogError {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
217 fn from(error: NodeMapError) -> Self {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
218 match error {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
219 NodeMapError::MultipleResults => RevlogError::AmbiguousPrefix,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
220 NodeMapError::RevisionNotInIndex(rev) => RevlogError::corrupted(
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
221 format!("nodemap point to revision {} not in index", rev),
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
222 ),
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
223 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
224 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
225 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
226
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
227 fn corrupted<S: AsRef<str>>(context: S) -> HgError {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
228 HgError::corrupted(format!("corrupted revlog, {}", context.as_ref()))
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
229 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
230
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
231 impl RevlogError {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
232 fn corrupted<S: AsRef<str>>(context: S) -> Self {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
233 RevlogError::Other(corrupted(context))
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
234 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
235 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
236
51867
69b804c8e09e rust: use new revlog configs in all revlog opening code
Raphaël Gomès <rgomes@octobus.net>
parents: 51866
diff changeset
237 #[derive(derive_more::Display, Debug, Copy, Clone, PartialEq, Eq)]
51865
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
238 pub enum RevlogType {
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
239 Changelog,
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
240 Manifestlog,
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
241 Filelog,
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
242 }
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
243
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
244 impl TryFrom<usize> for RevlogType {
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
245 type Error = HgError;
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
246
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
247 fn try_from(value: usize) -> Result<Self, Self::Error> {
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
248 match value {
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
249 1001 => Ok(Self::Changelog),
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
250 1002 => Ok(Self::Manifestlog),
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
251 1003 => Ok(Self::Filelog),
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
252 t => Err(HgError::abort(
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
253 format!("Unknown revlog type {}", t),
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
254 exit_codes::ABORT,
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
255 None,
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
256 )),
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
257 }
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
258 }
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
259 }
0604673428b7 rust-revlog: add revlog-specific config objects
Raphaël Gomès <rgomes@octobus.net>
parents: 51623
diff changeset
260
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
261 pub struct Revlog {
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
262 inner: InnerRevlog,
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
263 /// When present on disk: the persistent nodemap for this revlog
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
264 nodemap: Option<nodemap::NodeTree>,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
265 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
266
50978
27e773aa607d rust: implement the `Graph` trait for all revlogs
Raphaël Gomès <rgomes@octobus.net>
parents: 50977
diff changeset
267 impl Graph for Revlog {
27e773aa607d rust: implement the `Graph` trait for all revlogs
Raphaël Gomès <rgomes@octobus.net>
parents: 50977
diff changeset
268 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> {
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
269 self.index().parents(rev)
50978
27e773aa607d rust: implement the `Graph` trait for all revlogs
Raphaël Gomès <rgomes@octobus.net>
parents: 50977
diff changeset
270 }
27e773aa607d rust: implement the `Graph` trait for all revlogs
Raphaël Gomès <rgomes@octobus.net>
parents: 50977
diff changeset
271 }
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
272 impl Revlog {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
273 /// Open a revlog index file.
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
274 ///
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
275 /// It will also open the associated data file if index and data are not
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
276 /// interleaved.
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
277 pub fn open(
51868
db7dbe6f7bb2 rust: add Vfs trait
Raphaël Gomès <rgomes@octobus.net>
parents: 51867
diff changeset
278 // Todo use the `Vfs` trait here once we create a function for mmap
db7dbe6f7bb2 rust: add Vfs trait
Raphaël Gomès <rgomes@octobus.net>
parents: 51867
diff changeset
279 store_vfs: &VfsImpl,
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
280 index_path: impl AsRef<Path>,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
281 data_path: Option<&Path>,
51191
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
282 options: RevlogOpenOptions,
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
283 ) -> Result<Self, HgError> {
51191
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
284 Self::open_gen(store_vfs, index_path, data_path, options, None)
50986
eccf7dc7c91e revlog: make the rust test for node hex prefix resolution exercise the nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50985
diff changeset
285 }
eccf7dc7c91e revlog: make the rust test for node hex prefix resolution exercise the nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50985
diff changeset
286
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
287 fn index(&self) -> &Index {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
288 &self.inner.index
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
289 }
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
290
50986
eccf7dc7c91e revlog: make the rust test for node hex prefix resolution exercise the nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50985
diff changeset
291 fn open_gen(
51868
db7dbe6f7bb2 rust: add Vfs trait
Raphaël Gomès <rgomes@octobus.net>
parents: 51867
diff changeset
292 // Todo use the `Vfs` trait here once we create a function for mmap
db7dbe6f7bb2 rust: add Vfs trait
Raphaël Gomès <rgomes@octobus.net>
parents: 51867
diff changeset
293 store_vfs: &VfsImpl,
50986
eccf7dc7c91e revlog: make the rust test for node hex prefix resolution exercise the nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50985
diff changeset
294 index_path: impl AsRef<Path>,
eccf7dc7c91e revlog: make the rust test for node hex prefix resolution exercise the nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50985
diff changeset
295 data_path: Option<&Path>,
51191
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
296 options: RevlogOpenOptions,
50986
eccf7dc7c91e revlog: make the rust test for node hex prefix resolution exercise the nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50985
diff changeset
297 nodemap_for_test: Option<nodemap::NodeTree>,
eccf7dc7c91e revlog: make the rust test for node hex prefix resolution exercise the nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50985
diff changeset
298 ) -> Result<Self, HgError> {
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
299 let index_path = index_path.as_ref();
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
300 let index = open_index(store_vfs, index_path, options)?;
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
301
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
302 let default_data_path = index_path.with_extension("d");
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
303 let data_path = data_path.unwrap_or(&default_data_path);
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
304
51191
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
305 let nodemap = if index.is_inline() || !options.use_nodemap {
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
306 None
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
307 } else {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
308 NodeMapDocket::read_from_file(store_vfs, index_path)?.map(
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
309 |(docket, data)| {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
310 nodemap::NodeTree::load_bytes(
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
311 Box::new(data),
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
312 docket.data_length,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
313 )
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
314 },
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
315 )
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
316 };
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
317
50986
eccf7dc7c91e revlog: make the rust test for node hex prefix resolution exercise the nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50985
diff changeset
318 let nodemap = nodemap_for_test.or(nodemap);
eccf7dc7c91e revlog: make the rust test for node hex prefix resolution exercise the nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50985
diff changeset
319
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
320 Ok(Revlog {
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
321 inner: InnerRevlog::new(
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
322 Box::new(store_vfs.clone()),
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
323 index,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
324 index_path.to_path_buf(),
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
325 data_path.to_path_buf(),
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
326 options.data_config,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
327 options.delta_config,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
328 options.feature_config,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
329 ),
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
330 nodemap,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
331 })
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
332 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
333
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
334 /// Return number of entries of the `Revlog`.
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
335 pub fn len(&self) -> usize {
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
336 self.index().len()
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
337 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
338
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
339 /// Returns `true` if the `Revlog` has zero `entries`.
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
340 pub fn is_empty(&self) -> bool {
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
341 self.index().is_empty()
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
342 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
343
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
344 /// Returns the node ID for the given revision number, if it exists in this
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
345 /// revlog
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
346 pub fn node_from_rev(&self, rev: UncheckedRevision) -> Option<&Node> {
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
347 if rev == NULL_REVISION.into() {
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
348 return Some(&NULL_NODE);
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
349 }
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
350 let rev = self.index().check_revision(rev)?;
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
351 Some(self.index().get_entry(rev)?.hash())
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
352 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
353
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
354 /// Return the revision number for the given node ID, if it exists in this
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
355 /// revlog
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
356 pub fn rev_from_node(
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
357 &self,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
358 node: NodePrefix,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
359 ) -> Result<Revision, RevlogError> {
50985
363620b934aa revlog: fix a bug where NULL_NODE failed to be resolved to NULL_REV
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50746
diff changeset
360 if let Some(nodemap) = &self.nodemap {
50744
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
361 nodemap
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
362 .find_bin(self.index(), node)?
52045
652149ed64f0 rust: improve `InvalidRevision` error message
Raphaël Gomès <rgomes@octobus.net>
parents: 51868
diff changeset
363 .ok_or(RevlogError::InvalidRevision(format!("{:x}", node)))
50744
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
364 } else {
52177
1da6995835b4 rust-revlog: move non-persistent-nodemap rev lookup to the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52171
diff changeset
365 self.index().rev_from_node_no_persistent_nodemap(node)
50985
363620b934aa revlog: fix a bug where NULL_NODE failed to be resolved to NULL_REV
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50746
diff changeset
366 }
50743
0159b014f3ab rust-revlog: split out method for `rev_from_node` without persistent nodemap
Georges Racinet <georges.racinet@octobus.net>
parents: 50508
diff changeset
367 }
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
368
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
369 /// Returns whether the given revision exists in this revlog.
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
370 pub fn has_rev(&self, rev: UncheckedRevision) -> bool {
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
371 self.index().check_revision(rev).is_some()
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
372 }
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
373
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
374 pub fn get_entry(
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
375 &self,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
376 rev: Revision,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
377 ) -> Result<RevlogEntry, RevlogError> {
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
378 self.inner.get_entry(rev)
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
379 }
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
380
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
381 pub fn get_entry_for_unchecked_rev(
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
382 &self,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
383 rev: UncheckedRevision,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
384 ) -> Result<RevlogEntry, RevlogError> {
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
385 self.inner.get_entry_for_unchecked_rev(rev)
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
386 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
387
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
388 /// Return the full data associated to a revision.
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
389 ///
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
390 /// All entries required to build the final data out of deltas will be
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
391 /// retrieved as needed, and the deltas will be applied to the initial
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
392 /// snapshot to rebuild the final data.
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
393 pub fn get_data_for_unchecked_rev(
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
394 &self,
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
395 rev: UncheckedRevision,
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
396 ) -> Result<Cow<[u8]>, RevlogError> {
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
397 if rev == NULL_REVISION.into() {
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
398 return Ok(Cow::Borrowed(&[]));
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
399 };
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
400 self.get_entry_for_unchecked_rev(rev)?.data()
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
401 }
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
402
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
403 /// [`Self::get_data_for_unchecked_rev`] for a checked [`Revision`].
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
404 pub fn get_data(&self, rev: Revision) -> Result<Cow<[u8]>, RevlogError> {
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
405 if rev == NULL_REVISION {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
406 return Ok(Cow::Borrowed(&[]));
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
407 };
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
408 self.get_entry(rev)?.data()
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
409 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
410
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
411 /// Check the hash of some given data against the recorded hash.
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
412 pub fn check_hash(
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
413 &self,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
414 p1: Revision,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
415 p2: Revision,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
416 expected: &[u8],
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
417 data: &[u8],
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
418 ) -> bool {
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
419 self.inner.check_hash(p1, p2, expected, data)
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
420 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
421
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
422 /// Build the full data of a revision out its snapshot
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
423 /// and its deltas.
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
424 fn build_data_from_deltas<T>(
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
425 buffer: &mut dyn RevisionBuffer<Target = T>,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
426 snapshot: &[u8],
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
427 deltas: &[impl AsRef<[u8]>],
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
428 ) -> Result<(), RevlogError> {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
429 if deltas.is_empty() {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
430 buffer.extend_from_slice(snapshot);
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
431 return Ok(());
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
432 }
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
433 let patches: Result<Vec<_>, _> = deltas
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
434 .iter()
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
435 .map(|d| patch::PatchList::new(d.as_ref()))
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
436 .collect();
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
437 let patch = patch::fold_patch_lists(&patches?);
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
438 patch.apply(buffer, snapshot);
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
439 Ok(())
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
440 }
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
441 }
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
442
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
443 type IndexData = Box<dyn Deref<Target = [u8]> + Send + Sync>;
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
444
52181
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
445 /// TODO We should check for version 5.14+ at runtime, but we either should
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
446 /// add the `nix` dependency to get it efficiently, or vendor the code to read
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
447 /// both of which are overkill for such a feature. If we need this dependency
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
448 /// for more things later, we'll use it here too.
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
449 #[cfg(target_os = "linux")]
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
450 fn can_advise_populate_read() -> bool {
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
451 true
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
452 }
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
453
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
454 #[cfg(not(target_os = "linux"))]
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
455 fn can_advise_populate_read() -> bool {
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
456 false
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
457 }
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
458
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
459 /// Call `madvise` on the mmap with `MADV_POPULATE_READ` in a separate thread
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
460 /// to populate the mmap in the background for a small perf improvement.
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
461 #[cfg(target_os = "linux")]
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
462 fn advise_populate_read_mmap(mmap: &memmap2::Mmap) {
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
463 const MADV_POPULATE_READ: i32 = 22;
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
464
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
465 // This is fine because the mmap is still referenced for at least
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
466 // the duration of this function, and the kernel will reject any wrong
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
467 // address.
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
468 let ptr = mmap.as_ptr() as u64;
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
469 let len = mmap.len();
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
470
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
471 // Fire and forget. The `JoinHandle` returned by `spawn` is dropped right
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
472 // after the call, the thread is thus detached. We don't care about success
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
473 // or failure here.
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
474 std::thread::spawn(move || unsafe {
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
475 // mmap's pointer is always page-aligned on Linux. In the case of
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
476 // file-based mmap (which is our use-case), the length should be
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
477 // correct. If not, it's not a safety concern as the kernel will just
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
478 // ignore unmapped pages and return ENOMEM, which we will promptly
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
479 // ignore, because we don't care about any errors.
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
480 libc::madvise(ptr as *mut libc::c_void, len, MADV_POPULATE_READ);
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
481 });
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
482 }
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
483
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
484 #[cfg(not(target_os = "linux"))]
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
485 fn advise_populate_read_mmap(mmap: &memmap2::Mmap) {}
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
486
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
487 /// Open the revlog [`Index`] at `index_path`, through the `store_vfs` and the
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
488 /// given `options`. This controls whether (and how) we `mmap` the index file,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
489 /// and returns an empty buffer if the index does not exist on disk.
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
490 /// This is only used when doing pure-Rust work, in Python contexts this is
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
491 /// unused at the time of writing.
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
492 pub fn open_index(
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
493 store_vfs: &impl Vfs,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
494 index_path: &Path,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
495 options: RevlogOpenOptions,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
496 ) -> Result<Index, HgError> {
52298
645d247d4c75 rust-vfs: rename `open` to `open_write` and `open_read` to `open`
Raphaël Gomès <rgomes@octobus.net>
parents: 52294
diff changeset
497 let buf: IndexData = match store_vfs.open(index_path) {
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
498 Ok(mut file) => {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
499 let mut buf = if let Some(threshold) =
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
500 options.data_config.mmap_index_threshold
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
501 {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
502 let size = store_vfs.file_size(&file)?;
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
503 if size >= threshold {
52169
84b5802ba7d3 rust: populate mmap by default if available
Raphaël Gomès <rgomes@octobus.net>
parents: 52164
diff changeset
504 // TODO madvise populate read in a background thread
84b5802ba7d3 rust: populate mmap by default if available
Raphaël Gomès <rgomes@octobus.net>
parents: 52164
diff changeset
505 let mut mmap_options = MmapOptions::new();
52181
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
506 if !can_advise_populate_read() {
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
507 // Fall back to populating in the main thread if
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
508 // post-creation advice is not supported.
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
509 // Does nothing on platforms where it's not defined.
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
510 mmap_options.populate();
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
511 }
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
512 // Safety is "enforced" by locks and assuming other
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
513 // processes are well-behaved. If any misbehaving or
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
514 // malicious process does touch the index, it could lead
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
515 // to corruption. This is somewhat inherent to file-based
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
516 // `mmap`, though some platforms have some ways of
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
517 // mitigating.
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
518 // TODO linux: set the immutable flag with `chattr(1)`?
52169
84b5802ba7d3 rust: populate mmap by default if available
Raphaël Gomès <rgomes@octobus.net>
parents: 52164
diff changeset
519 let mmap = unsafe { mmap_options.map(&file) }
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
520 .when_reading_file(index_path)?;
52181
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
521
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
522 if can_advise_populate_read() {
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
523 advise_populate_read_mmap(&mmap);
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
524 }
3d797007905d rust: populate mmaps in a separate thread if possible
Raphaël Gomès <rgomes@octobus.net>
parents: 52177
diff changeset
525
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
526 Some(Box::new(mmap) as IndexData)
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
527 } else {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
528 None
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
529 }
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
530 } else {
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
531 None
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
532 };
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
533
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
534 if buf.is_none() {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
535 let mut data = vec![];
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
536 file.read_to_end(&mut data).when_reading_file(index_path)?;
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
537 buf = Some(Box::new(data) as IndexData);
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
538 }
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
539 buf.unwrap()
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
540 }
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
541 Err(err) => match err {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
542 HgError::IoError { error, context } => match error.kind() {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
543 ErrorKind::NotFound => Box::<Vec<u8>>::default(),
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
544 _ => return Err(HgError::IoError { error, context }),
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
545 },
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
546 e => return Err(e),
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
547 },
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
548 };
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
549
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
550 let index = Index::new(buf, options.index_header())?;
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
551 Ok(index)
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
552 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
553
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
554 /// The revlog entry's bytes and the necessary informations to extract
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
555 /// the entry's data.
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
556 #[derive(Clone)]
50412
7ef51fff2c4f rust-revlog: explicit naming for `RevlogEntry` lifetime
Georges Racinet <georges.racinet@octobus.net>
parents: 49937
diff changeset
557 pub struct RevlogEntry<'revlog> {
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
558 revlog: &'revlog InnerRevlog,
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
559 rev: Revision,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
560 uncompressed_len: i32,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
561 p1: Revision,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
562 p2: Revision,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
563 flags: u16,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
564 hash: Node,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
565 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
566
50412
7ef51fff2c4f rust-revlog: explicit naming for `RevlogEntry` lifetime
Georges Racinet <georges.racinet@octobus.net>
parents: 49937
diff changeset
567 impl<'revlog> RevlogEntry<'revlog> {
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
568 pub fn revision(&self) -> Revision {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
569 self.rev
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
570 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
571
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
572 pub fn node(&self) -> &Node {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
573 &self.hash
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
574 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
575
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
576 pub fn uncompressed_len(&self) -> Option<u32> {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
577 u32::try_from(self.uncompressed_len).ok()
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
578 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
579
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
580 pub fn has_p1(&self) -> bool {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
581 self.p1 != NULL_REVISION
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
582 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
583
50413
c101e7757ed7 rust-revlog: fix lifetime problem for RevlogEntry parent entries accessors
Georges Racinet <georges.racinet@octobus.net>
parents: 50412
diff changeset
584 pub fn p1_entry(
c101e7757ed7 rust-revlog: fix lifetime problem for RevlogEntry parent entries accessors
Georges Racinet <georges.racinet@octobus.net>
parents: 50412
diff changeset
585 &self,
c101e7757ed7 rust-revlog: fix lifetime problem for RevlogEntry parent entries accessors
Georges Racinet <georges.racinet@octobus.net>
parents: 50412
diff changeset
586 ) -> Result<Option<RevlogEntry<'revlog>>, RevlogError> {
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
587 if self.p1 == NULL_REVISION {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
588 Ok(None)
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
589 } else {
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
590 Ok(Some(self.revlog.get_entry(self.p1)?))
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
591 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
592 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
593
50413
c101e7757ed7 rust-revlog: fix lifetime problem for RevlogEntry parent entries accessors
Georges Racinet <georges.racinet@octobus.net>
parents: 50412
diff changeset
594 pub fn p2_entry(
c101e7757ed7 rust-revlog: fix lifetime problem for RevlogEntry parent entries accessors
Georges Racinet <georges.racinet@octobus.net>
parents: 50412
diff changeset
595 &self,
c101e7757ed7 rust-revlog: fix lifetime problem for RevlogEntry parent entries accessors
Georges Racinet <georges.racinet@octobus.net>
parents: 50412
diff changeset
596 ) -> Result<Option<RevlogEntry<'revlog>>, RevlogError> {
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
597 if self.p2 == NULL_REVISION {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
598 Ok(None)
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
599 } else {
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
600 Ok(Some(self.revlog.get_entry(self.p2)?))
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
601 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
602 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
603
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
604 pub fn p1(&self) -> Option<Revision> {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
605 if self.p1 == NULL_REVISION {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
606 None
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
607 } else {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
608 Some(self.p1)
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
609 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
610 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
611
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
612 pub fn p2(&self) -> Option<Revision> {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
613 if self.p2 == NULL_REVISION {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
614 None
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
615 } else {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
616 Some(self.p2)
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
617 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
618 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
619
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
620 pub fn is_censored(&self) -> bool {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
621 (self.flags & REVISION_FLAG_CENSORED) != 0
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
622 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
623
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
624 pub fn has_length_affecting_flag_processor(&self) -> bool {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
625 // Relevant Python code: revlog.size()
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
626 // note: ELLIPSIS is known to not change the content
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
627 (self.flags & (REVIDX_KNOWN_FLAGS ^ REVISION_FLAG_ELLIPSIS)) != 0
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
628 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
629
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
630 /// The data for this entry, after resolving deltas if any.
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
631 /// Non-Python callers should probably call [`Self::data`] instead.
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
632 fn rawdata<G, T>(
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
633 &self,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
634 stop_rev: Option<(Revision, &[u8])>,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
635 with_buffer: G,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
636 ) -> Result<(), RevlogError>
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
637 where
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
638 G: FnOnce(
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
639 usize,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
640 &mut dyn FnMut(
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
641 &mut dyn RevisionBuffer<Target = T>,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
642 ) -> Result<(), RevlogError>,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
643 ) -> Result<(), RevlogError>,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
644 {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
645 let (delta_chain, stopped) = self
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
646 .revlog
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
647 .delta_chain(self.revision(), stop_rev.map(|(r, _)| r))?;
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
648 let target_size =
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
649 self.uncompressed_len().map(|raw_size| 4 * raw_size as u64);
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
650
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
651 let deltas = self.revlog.chunks(delta_chain, target_size)?;
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
652
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
653 let (base_text, deltas) = if stopped {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
654 (
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
655 stop_rev.as_ref().expect("last revision should be cached").1,
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
656 &deltas[..],
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
657 )
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
658 } else {
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
659 let (buf, deltas) = deltas.split_at(1);
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
660 (buf[0].as_ref(), deltas)
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
661 };
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
662
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
663 let size = self
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
664 .uncompressed_len()
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
665 .map(|l| l as usize)
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
666 .unwrap_or(base_text.len());
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
667 with_buffer(size, &mut |buf| {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
668 Revlog::build_data_from_deltas(buf, base_text, deltas)?;
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
669 Ok(())
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
670 })?;
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
671 Ok(())
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
672 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
673
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
674 fn check_data(
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
675 &self,
50412
7ef51fff2c4f rust-revlog: explicit naming for `RevlogEntry` lifetime
Georges Racinet <georges.racinet@octobus.net>
parents: 49937
diff changeset
676 data: Cow<'revlog, [u8]>,
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
677 ) -> Result<Cow<'revlog, [u8]>, RevlogError> {
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
678 if self.revlog.check_hash(
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
679 self.p1,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
680 self.p2,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
681 self.hash.as_bytes(),
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
682 &data,
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
683 ) {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
684 Ok(data)
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
685 } else {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
686 if (self.flags & REVISION_FLAG_ELLIPSIS) != 0 {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
687 return Err(HgError::unsupported(
52060
8b7123c8947b update: add a Rust fast-path when updating from null (and clean)
Raphaël Gomès <rgomes@octobus.net>
parents: 52045
diff changeset
688 "support for ellipsis nodes is missing",
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
689 )
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
690 .into());
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
691 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
692 Err(corrupted(format!(
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
693 "hash check failed for revision {}",
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
694 self.rev
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
695 ))
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
696 .into())
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
697 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
698 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
699
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
700 pub fn data(&self) -> Result<Cow<'revlog, [u8]>, RevlogError> {
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
701 // TODO figure out if there is ever a need for `Cow` here anymore.
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
702 let mut data = CoreRevisionBuffer::new();
50746
124c44b5cfad rust-revlog: fix RevlogEntry.data() for NULL_REVISION
Georges Racinet <georges.racinet@octobus.net>
parents: 50745
diff changeset
703 if self.rev == NULL_REVISION {
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
704 return Ok(data.finish().into());
50746
124c44b5cfad rust-revlog: fix RevlogEntry.data() for NULL_REVISION
Georges Racinet <georges.racinet@octobus.net>
parents: 50745
diff changeset
705 }
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
706 self.rawdata(None, |size, f| {
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
707 // Pre-allocate the expected size (received from the index)
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
708 data.resize(size);
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
709 // Actually fill the buffer
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
710 f(&mut data)?;
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
711 Ok(())
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
712 })?;
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
713 if self.is_censored() {
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
714 return Err(HgError::CensoredNodeError.into());
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
715 }
52164
e01e84e5e426 rust-revlog: add a Rust-only `InnerRevlog`
Raphaël Gomès <rgomes@octobus.net>
parents: 52160
diff changeset
716 self.check_data(data.finish().into())
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
717 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
718 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
719
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
720 #[cfg(test)]
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
721 mod tests {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
722 use super::*;
52182
bd8081e9fd62 rust: don't star export from the `revlog` module
Raphaël Gomès <rgomes@octobus.net>
parents: 52181
diff changeset
723 use crate::revlog::index::IndexEntryBuilder;
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
724 use itertools::Itertools;
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
725
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
726 #[test]
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
727 fn test_empty() {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
728 let temp = tempfile::tempdir().unwrap();
52171
7be39c5110c9 hg-core: add a complete VFS
Raphaël Gomès <rgomes@octobus.net>
parents: 52169
diff changeset
729 let vfs = VfsImpl::new(temp.path().to_owned(), false);
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
730 std::fs::write(temp.path().join("foo.i"), b"").unwrap();
51867
69b804c8e09e rust: use new revlog configs in all revlog opening code
Raphaël Gomès <rgomes@octobus.net>
parents: 51866
diff changeset
731 std::fs::write(temp.path().join("foo.d"), b"").unwrap();
51191
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
732 let revlog =
51867
69b804c8e09e rust: use new revlog configs in all revlog opening code
Raphaël Gomès <rgomes@octobus.net>
parents: 51866
diff changeset
733 Revlog::open(&vfs, "foo.i", None, RevlogOpenOptions::default())
51191
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
734 .unwrap();
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
735 assert!(revlog.is_empty());
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
736 assert_eq!(revlog.len(), 0);
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
737 assert!(revlog.get_entry_for_unchecked_rev(0.into()).is_err());
50977
1928b770e3e7 rust: use the new `UncheckedRevision` everywhere applicable
Raphaël Gomès <rgomes@octobus.net>
parents: 50976
diff changeset
738 assert!(!revlog.has_rev(0.into()));
50745
3338c6ffdaa3 rust-revlog: using constant in test
Georges Racinet <georges.racinet@octobus.net>
parents: 50744
diff changeset
739 assert_eq!(
3338c6ffdaa3 rust-revlog: using constant in test
Georges Racinet <georges.racinet@octobus.net>
parents: 50744
diff changeset
740 revlog.rev_from_node(NULL_NODE.into()).unwrap(),
3338c6ffdaa3 rust-revlog: using constant in test
Georges Racinet <georges.racinet@octobus.net>
parents: 50744
diff changeset
741 NULL_REVISION
3338c6ffdaa3 rust-revlog: using constant in test
Georges Racinet <georges.racinet@octobus.net>
parents: 50744
diff changeset
742 );
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
743 let null_entry = revlog
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
744 .get_entry_for_unchecked_rev(NULL_REVISION.into())
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
745 .ok()
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
746 .unwrap();
50746
124c44b5cfad rust-revlog: fix RevlogEntry.data() for NULL_REVISION
Georges Racinet <georges.racinet@octobus.net>
parents: 50745
diff changeset
747 assert_eq!(null_entry.revision(), NULL_REVISION);
124c44b5cfad rust-revlog: fix RevlogEntry.data() for NULL_REVISION
Georges Racinet <georges.racinet@octobus.net>
parents: 50745
diff changeset
748 assert!(null_entry.data().unwrap().is_empty());
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
749 }
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
750
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
751 #[test]
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
752 fn test_inline() {
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
753 let temp = tempfile::tempdir().unwrap();
52171
7be39c5110c9 hg-core: add a complete VFS
Raphaël Gomès <rgomes@octobus.net>
parents: 52169
diff changeset
754 let vfs = VfsImpl::new(temp.path().to_owned(), false);
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
755 let node0 = Node::from_hex("2ed2a3912a0b24502043eae84ee4b279c18b90dd")
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
756 .unwrap();
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
757 let node1 = Node::from_hex("b004912a8510032a0350a74daa2803dadfb00e12")
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
758 .unwrap();
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
759 let node2 = Node::from_hex("dd6ad206e907be60927b5a3117b97dffb2590582")
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
760 .unwrap();
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
761 let entry0_bytes = IndexEntryBuilder::new()
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
762 .is_first(true)
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
763 .with_version(1)
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
764 .with_inline(true)
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
765 .with_node(node0)
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
766 .build();
51444
c3f2a9b55f59 rust-index: stop calling `with_offset` in the tests
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51256
diff changeset
767 let entry1_bytes = IndexEntryBuilder::new().with_node(node1).build();
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
768 let entry2_bytes = IndexEntryBuilder::new()
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
769 .with_p1(Revision(0))
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
770 .with_p2(Revision(1))
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
771 .with_node(node2)
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
772 .build();
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
773 let contents = vec![entry0_bytes, entry1_bytes, entry2_bytes]
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
774 .into_iter()
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
775 .flatten()
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
776 .collect_vec();
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
777 std::fs::write(temp.path().join("foo.i"), contents).unwrap();
51191
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
778 let revlog =
51867
69b804c8e09e rust: use new revlog configs in all revlog opening code
Raphaël Gomès <rgomes@octobus.net>
parents: 51866
diff changeset
779 Revlog::open(&vfs, "foo.i", None, RevlogOpenOptions::default())
51191
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
780 .unwrap();
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
781
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
782 let entry0 =
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
783 revlog.get_entry_for_unchecked_rev(0.into()).ok().unwrap();
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
784 assert_eq!(entry0.revision(), Revision(0));
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
785 assert_eq!(*entry0.node(), node0);
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
786 assert!(!entry0.has_p1());
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
787 assert_eq!(entry0.p1(), None);
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
788 assert_eq!(entry0.p2(), None);
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
789 let p1_entry = entry0.p1_entry().unwrap();
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
790 assert!(p1_entry.is_none());
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
791 let p2_entry = entry0.p2_entry().unwrap();
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
792 assert!(p2_entry.is_none());
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
793
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
794 let entry1 =
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
795 revlog.get_entry_for_unchecked_rev(1.into()).ok().unwrap();
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
796 assert_eq!(entry1.revision(), Revision(1));
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
797 assert_eq!(*entry1.node(), node1);
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
798 assert!(!entry1.has_p1());
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
799 assert_eq!(entry1.p1(), None);
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
800 assert_eq!(entry1.p2(), None);
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
801 let p1_entry = entry1.p1_entry().unwrap();
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
802 assert!(p1_entry.is_none());
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
803 let p2_entry = entry1.p2_entry().unwrap();
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
804 assert!(p2_entry.is_none());
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
805
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
806 let entry2 =
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
807 revlog.get_entry_for_unchecked_rev(2.into()).ok().unwrap();
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
808 assert_eq!(entry2.revision(), Revision(2));
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
809 assert_eq!(*entry2.node(), node2);
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
810 assert!(entry2.has_p1());
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
811 assert_eq!(entry2.p1(), Some(Revision(0)));
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
812 assert_eq!(entry2.p2(), Some(Revision(1)));
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
813 let p1_entry = entry2.p1_entry().unwrap();
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
814 assert!(p1_entry.is_some());
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
815 assert_eq!(p1_entry.unwrap().revision(), Revision(0));
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
816 let p2_entry = entry2.p2_entry().unwrap();
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
817 assert!(p2_entry.is_some());
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
818 assert_eq!(p2_entry.unwrap().revision(), Revision(1));
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
819 }
50744
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
820
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
821 #[test]
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
822 fn test_nodemap() {
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
823 let temp = tempfile::tempdir().unwrap();
52171
7be39c5110c9 hg-core: add a complete VFS
Raphaël Gomès <rgomes@octobus.net>
parents: 52169
diff changeset
824 let vfs = VfsImpl::new(temp.path().to_owned(), false);
50744
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
825
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
826 // building a revlog with a forced Node starting with zeros
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
827 // This is a corruption, but it does not preclude using the nodemap
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
828 // if we don't try and access the data
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
829 let node0 = Node::from_hex("00d2a3912a0b24502043eae84ee4b279c18b90dd")
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
830 .unwrap();
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
831 let node1 = Node::from_hex("b004912a8510032a0350a74daa2803dadfb00e12")
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
832 .unwrap();
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
833 let entry0_bytes = IndexEntryBuilder::new()
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
834 .is_first(true)
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
835 .with_version(1)
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
836 .with_inline(true)
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
837 .with_node(node0)
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
838 .build();
51444
c3f2a9b55f59 rust-index: stop calling `with_offset` in the tests
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51256
diff changeset
839 let entry1_bytes = IndexEntryBuilder::new().with_node(node1).build();
50744
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
840 let contents = vec![entry0_bytes, entry1_bytes]
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
841 .into_iter()
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
842 .flatten()
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
843 .collect_vec();
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
844 std::fs::write(temp.path().join("foo.i"), contents).unwrap();
50986
eccf7dc7c91e revlog: make the rust test for node hex prefix resolution exercise the nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50985
diff changeset
845
eccf7dc7c91e revlog: make the rust test for node hex prefix resolution exercise the nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50985
diff changeset
846 let mut idx = nodemap::tests::TestNtIndex::new();
50993
12c308c55e53 branching: merge stable into default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50979 50986
diff changeset
847 idx.insert_node(Revision(0), node0).unwrap();
12c308c55e53 branching: merge stable into default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50979 50986
diff changeset
848 idx.insert_node(Revision(1), node1).unwrap();
50986
eccf7dc7c91e revlog: make the rust test for node hex prefix resolution exercise the nodemap
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50985
diff changeset
849
51191
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
850 let revlog = Revlog::open_gen(
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
851 &vfs,
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
852 "foo.i",
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
853 None,
51867
69b804c8e09e rust: use new revlog configs in all revlog opening code
Raphaël Gomès <rgomes@octobus.net>
parents: 51866
diff changeset
854 RevlogOpenOptions::default(),
51191
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
855 Some(idx.nt),
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
856 )
13f58ce70299 rust-revlog: teach the revlog opening code to read the repo options
Raphaël Gomès <rgomes@octobus.net>
parents: 51120
diff changeset
857 .unwrap();
50744
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
858
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
859 // accessing the data shows the corruption
52294
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
860 revlog
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
861 .get_entry_for_unchecked_rev(0.into())
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
862 .unwrap()
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
863 .data()
a3fa37bdb7ec rust: normalize `_for_unchecked_rev` naming among revlogs and the index
Raphaël Gomès <rgomes@octobus.net>
parents: 52182
diff changeset
864 .unwrap_err();
50744
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
865
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
866 assert_eq!(
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
867 revlog.rev_from_node(NULL_NODE.into()).unwrap(),
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
868 Revision(-1)
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
869 );
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
870 assert_eq!(revlog.rev_from_node(node0.into()).unwrap(), Revision(0));
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
871 assert_eq!(revlog.rev_from_node(node1.into()).unwrap(), Revision(1));
50744
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
872 assert_eq!(
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
873 revlog
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
874 .rev_from_node(NodePrefix::from_hex("000").unwrap())
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
875 .unwrap(),
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
876 Revision(-1)
50744
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
877 );
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
878 assert_eq!(
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
879 revlog
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
880 .rev_from_node(NodePrefix::from_hex("b00").unwrap())
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
881 .unwrap(),
50979
4c5f6e95df84 rust: make `Revision` a newtype
Raphaël Gomès <rgomes@octobus.net>
parents: 50978
diff changeset
882 Revision(1)
50744
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
883 );
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
884 // RevlogError does not implement PartialEq
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
885 // (ultimately because io::Error does not)
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
886 match revlog
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
887 .rev_from_node(NodePrefix::from_hex("00").unwrap())
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
888 .expect_err("Expected to give AmbiguousPrefix error")
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
889 {
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
890 RevlogError::AmbiguousPrefix => (),
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
891 e => {
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
892 panic!("Got another error than AmbiguousPrefix: {:?}", e);
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
893 }
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
894 };
bca4037306da rust-revlog: fix incorrect results with NULL_NODE prefixes
Georges Racinet <georges.racinet@octobus.net>
parents: 50743
diff changeset
895 }
49937
750409505286 rust-clippy: merge "revlog" module definition and struct implementation
Raphaël Gomès <rgomes@octobus.net>
parents: 47961
diff changeset
896 }