##// END OF EJS Templates
rust-core: extracted a revlog submodule...
Georges Racinet -
r44457:6b332c1f default
parent child Browse files
Show More
@@ -0,0 +1,38 b''
1 // Copyright 2018-2020 Georges Racinet <georges.racinet@octobus.net>
2 // and Mercurial contributors
3 //
4 // This software may be used and distributed according to the terms of the
5 // GNU General Public License version 2 or any later version.
6 //! Mercurial concepts for handling revision history
7
8 /// Mercurial revision numbers
9 ///
10 /// As noted in revlog.c, revision numbers are actually encoded in
11 /// 4 bytes, and are liberally converted to ints, whence the i32
12 pub type Revision = i32;
13
14 /// Marker expressing the absence of a parent
15 ///
16 /// Independently of the actual representation, `NULL_REVISION` is guaranteed
17 /// to be smaller that all existing revisions.
18 pub const NULL_REVISION: Revision = -1;
19
20 /// Same as `mercurial.node.wdirrev`
21 ///
22 /// This is also equal to `i32::max_value()`, but it's better to spell
23 /// it out explicitely, same as in `mercurial.node`
24 pub const WORKING_DIRECTORY_REVISION: Revision = 0x7fffffff;
25
26 /// The simplest expression of what we need of Mercurial DAGs.
27 pub trait Graph {
28 /// Return the two parents of the given `Revision`.
29 ///
30 /// Each of the parents can be independently `NULL_REVISION`
31 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError>;
32 }
33
34 #[derive(Clone, Debug, PartialEq)]
35 pub enum GraphError {
36 ParentOutOfRange(Revision),
37 WorkingDirectoryUnsupported,
38 }
@@ -19,6 +19,8 b' pub use dirstate::{'
19 };
19 };
20 mod filepatterns;
20 mod filepatterns;
21 pub mod matchers;
21 pub mod matchers;
22 pub mod revlog;
23 pub use revlog::*;
22 pub mod utils;
24 pub mod utils;
23
25
24 use crate::utils::hg_path::HgPathBuf;
26 use crate::utils::hg_path::HgPathBuf;
@@ -28,32 +30,6 b' pub use filepatterns::{'
28 use std::collections::HashMap;
30 use std::collections::HashMap;
29 use twox_hash::RandomXxHashBuilder64;
31 use twox_hash::RandomXxHashBuilder64;
30
32
31 /// Mercurial revision numbers
32 ///
33 /// As noted in revlog.c, revision numbers are actually encoded in
34 /// 4 bytes, and are liberally converted to ints, whence the i32
35 pub type Revision = i32;
36
37 /// Marker expressing the absence of a parent
38 ///
39 /// Independently of the actual representation, `NULL_REVISION` is guaranteed
40 /// to be smaller that all existing revisions.
41 pub const NULL_REVISION: Revision = -1;
42
43 /// Same as `mercurial.node.wdirrev`
44 ///
45 /// This is also equal to `i32::max_value()`, but it's better to spell
46 /// it out explicitely, same as in `mercurial.node`
47 pub const WORKING_DIRECTORY_REVISION: Revision = 0x7fffffff;
48
49 /// The simplest expression of what we need of Mercurial DAGs.
50 pub trait Graph {
51 /// Return the two parents of the given `Revision`.
52 ///
53 /// Each of the parents can be independently `NULL_REVISION`
54 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError>;
55 }
56
57 pub type LineNumber = usize;
33 pub type LineNumber = usize;
58
34
59 /// Rust's default hasher is too slow because it tries to prevent collision
35 /// Rust's default hasher is too slow because it tries to prevent collision
@@ -62,12 +38,6 b' pub type LineNumber = usize;'
62 pub type FastHashMap<K, V> = HashMap<K, V, RandomXxHashBuilder64>;
38 pub type FastHashMap<K, V> = HashMap<K, V, RandomXxHashBuilder64>;
63
39
64 #[derive(Clone, Debug, PartialEq)]
40 #[derive(Clone, Debug, PartialEq)]
65 pub enum GraphError {
66 ParentOutOfRange(Revision),
67 WorkingDirectoryUnsupported,
68 }
69
70 #[derive(Clone, Debug, PartialEq)]
71 pub enum DirstateParseError {
41 pub enum DirstateParseError {
72 TooLittleData,
42 TooLittleData,
73 Overflow,
43 Overflow,
General Comments 0
You need to be logged in to leave comments. Login now