Show More
@@ -39,6 +39,16 b' use crate::vfs::Vfs;' | |||||
39 | /// 4 bytes, and are liberally converted to ints, whence the i32 |
|
39 | /// 4 bytes, and are liberally converted to ints, whence the i32 | |
40 | pub type Revision = i32; |
|
40 | pub type Revision = i32; | |
41 |
|
41 | |||
|
42 | /// Unchecked Mercurial revision numbers. | |||
|
43 | /// | |||
|
44 | /// Values of this type have no guarantee of being a valid revision number | |||
|
45 | /// in any context. Use method `check_revision` to get a valid revision within | |||
|
46 | /// the appropriate index object. | |||
|
47 | /// | |||
|
48 | /// As noted in revlog.c, revision numbers are actually encoded in | |||
|
49 | /// 4 bytes, and are liberally converted to ints, whence the i32 | |||
|
50 | pub type UncheckedRevision = i32; | |||
|
51 | ||||
42 | /// Marker expressing the absence of a parent |
|
52 | /// Marker expressing the absence of a parent | |
43 | /// |
|
53 | /// | |
44 | /// Independently of the actual representation, `NULL_REVISION` is guaranteed |
|
54 | /// Independently of the actual representation, `NULL_REVISION` is guaranteed | |
@@ -85,6 +95,16 b' pub trait RevlogIndex {' | |||||
85 | /// |
|
95 | /// | |
86 | /// `NULL_REVISION` is not considered to be out of bounds. |
|
96 | /// `NULL_REVISION` is not considered to be out of bounds. | |
87 | fn node(&self, rev: Revision) -> Option<&Node>; |
|
97 | fn node(&self, rev: Revision) -> Option<&Node>; | |
|
98 | ||||
|
99 | /// Return a [`Revision`] if `rev` is a valid revision number for this | |||
|
100 | /// index | |||
|
101 | fn check_revision(&self, rev: UncheckedRevision) -> Option<Revision> { | |||
|
102 | if rev == NULL_REVISION || (rev >= 0 && (rev as usize) < self.len()) { | |||
|
103 | Some(rev) | |||
|
104 | } else { | |||
|
105 | None | |||
|
106 | } | |||
|
107 | } | |||
88 | } |
|
108 | } | |
89 |
|
109 | |||
90 | const REVISION_FLAG_CENSORED: u16 = 1 << 15; |
|
110 | const REVISION_FLAG_CENSORED: u16 = 1 << 15; |
General Comments 0
You need to be logged in to leave comments.
Login now