Show More
@@ -1,38 +1,38 b'' | |||||
1 | // Copyright 2018-2020 Georges Racinet <georges.racinet@octobus.net> |
|
1 | // Copyright 2018-2020 Georges Racinet <georges.racinet@octobus.net> | |
2 | // and Mercurial contributors |
|
2 | // and Mercurial contributors | |
3 | // |
|
3 | // | |
4 | // This software may be used and distributed according to the terms of the |
|
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. |
|
5 | // GNU General Public License version 2 or any later version. | |
6 | //! Mercurial concepts for handling revision history |
|
6 | //! Mercurial concepts for handling revision history | |
7 |
|
7 | |||
8 | /// Mercurial revision numbers |
|
8 | /// Mercurial revision numbers | |
9 | /// |
|
9 | /// | |
10 | /// As noted in revlog.c, revision numbers are actually encoded in |
|
10 | /// As noted in revlog.c, revision numbers are actually encoded in | |
11 | /// 4 bytes, and are liberally converted to ints, whence the i32 |
|
11 | /// 4 bytes, and are liberally converted to ints, whence the i32 | |
12 | pub type Revision = i32; |
|
12 | pub type Revision = i32; | |
13 |
|
13 | |||
14 | /// Marker expressing the absence of a parent |
|
14 | /// Marker expressing the absence of a parent | |
15 | /// |
|
15 | /// | |
16 | /// Independently of the actual representation, `NULL_REVISION` is guaranteed |
|
16 | /// Independently of the actual representation, `NULL_REVISION` is guaranteed | |
17 |
/// to be smaller tha |
|
17 | /// to be smaller than all existing revisions. | |
18 | pub const NULL_REVISION: Revision = -1; |
|
18 | pub const NULL_REVISION: Revision = -1; | |
19 |
|
19 | |||
20 | /// Same as `mercurial.node.wdirrev` |
|
20 | /// Same as `mercurial.node.wdirrev` | |
21 | /// |
|
21 | /// | |
22 | /// This is also equal to `i32::max_value()`, but it's better to spell |
|
22 | /// This is also equal to `i32::max_value()`, but it's better to spell | |
23 | /// it out explicitely, same as in `mercurial.node` |
|
23 | /// it out explicitely, same as in `mercurial.node` | |
24 | pub const WORKING_DIRECTORY_REVISION: Revision = 0x7fffffff; |
|
24 | pub const WORKING_DIRECTORY_REVISION: Revision = 0x7fffffff; | |
25 |
|
25 | |||
26 | /// The simplest expression of what we need of Mercurial DAGs. |
|
26 | /// The simplest expression of what we need of Mercurial DAGs. | |
27 | pub trait Graph { |
|
27 | pub trait Graph { | |
28 | /// Return the two parents of the given `Revision`. |
|
28 | /// Return the two parents of the given `Revision`. | |
29 | /// |
|
29 | /// | |
30 | /// Each of the parents can be independently `NULL_REVISION` |
|
30 | /// Each of the parents can be independently `NULL_REVISION` | |
31 | fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError>; |
|
31 | fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError>; | |
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | #[derive(Clone, Debug, PartialEq)] |
|
34 | #[derive(Clone, Debug, PartialEq)] | |
35 | pub enum GraphError { |
|
35 | pub enum GraphError { | |
36 | ParentOutOfRange(Revision), |
|
36 | ParentOutOfRange(Revision), | |
37 | WorkingDirectoryUnsupported, |
|
37 | WorkingDirectoryUnsupported, | |
38 | } |
|
38 | } |
General Comments 0
You need to be logged in to leave comments.
Login now