comparison rust/hg-core/src/revlog.rs @ 44005:6b332c1fc7fe

rust-core: extracted a revlog submodule This moves fundamental definitions from the top of the crate to the newly created `revlog` submodule and reexports them for easy compatibility. As we are about to add new features to this crate, we felt it will improve clarity, and moreso if `ancestors` and `dagops` would become submodules of `revlog`. Differential Revision: https://phab.mercurial-scm.org/D7782
author Georges Racinet <georges.racinet@octobus.net>
date Wed, 25 Dec 2019 15:17:55 +0100
parents
children b3ec1ea95ee6
comparison
equal deleted inserted replaced
44004:9c1fd975e9ac 44005:6b332c1fc7fe
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 }