annotate rust/hg-core/src/dirstate.rs @ 47350:04d1f17f49e7

dirstate-v2: Write .hg/dirstate back to disk on directory cache changes Differential Revision: https://phab.mercurial-scm.org/D10827
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 31 May 2021 18:35:44 +0200
parents ed1583a845d2
children bd88b6bfd8da
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42748
7cae6bc29ff9 rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42609
diff changeset
1 // dirstate module
7cae6bc29ff9 rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42609
diff changeset
2 //
7cae6bc29ff9 rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42609
diff changeset
3 // Copyright 2019 Raphaël Gomès <rgomes@octobus.net>
7cae6bc29ff9 rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42609
diff changeset
4 //
7cae6bc29ff9 rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42609
diff changeset
5 // This software may be used and distributed according to the terms of the
7cae6bc29ff9 rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42609
diff changeset
6 // GNU General Public License version 2 or any later version.
7cae6bc29ff9 rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42609
diff changeset
7
47335
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47332
diff changeset
8 use crate::dirstate_tree::on_disk::DirstateV2ParseError;
46440
776b97179c06 rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents: 45610
diff changeset
9 use crate::errors::HgError;
46595
98a455a62699 rust: Make `DirstateParents`?s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents: 46594
diff changeset
10 use crate::revlog::Node;
47124
cd8ca38fccff rust: Use `&HgPath` instead of `&HgPathBuf` in may APIs
Simon Sapin <simon.sapin@octobus.net>
parents: 47113
diff changeset
11 use crate::utils::hg_path::{HgPath, HgPathBuf};
cd8ca38fccff rust: Use `&HgPath` instead of `&HgPathBuf` in may APIs
Simon Sapin <simon.sapin@octobus.net>
parents: 47113
diff changeset
12 use crate::FastHashMap;
46594
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
13 use bytes_cast::{unaligned, BytesCast};
42749
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
14 use std::convert::TryFrom;
42748
7cae6bc29ff9 rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42609
diff changeset
15
42536
2dcee6497b0b rust-dirstate: add "dirs" Rust implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42424
diff changeset
16 pub mod dirs_multiset;
42753
fce6dc93a510 rust-dirstate: rust implementation of dirstatemap
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42749
diff changeset
17 pub mod dirstate_map;
42424
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
18 pub mod parsers;
43271
99394e6c5d12 rust-dirstate-status: add first Rust implementation of `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42957
diff changeset
19 pub mod status;
42424
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
20
46594
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
21 #[derive(Debug, PartialEq, Clone, BytesCast)]
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
22 #[repr(C)]
42748
7cae6bc29ff9 rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42609
diff changeset
23 pub struct DirstateParents {
46595
98a455a62699 rust: Make `DirstateParents`?s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents: 46594
diff changeset
24 pub p1: Node,
98a455a62699 rust: Make `DirstateParents`?s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents: 46594
diff changeset
25 pub p2: Node,
42424
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
26 }
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
27
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
28 /// The C implementation uses all signed types. This will be an issue
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
29 /// either when 4GB+ source files are commonplace or in 2038, whichever
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
30 /// comes first.
42748
7cae6bc29ff9 rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42609
diff changeset
31 #[derive(Debug, PartialEq, Copy, Clone)]
42424
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
32 pub struct DirstateEntry {
42749
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
33 pub state: EntryState,
42424
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
34 pub mode: i32,
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
35 pub mtime: i32,
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
36 pub size: i32,
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
37 }
d3b5cbe311d9 rust-dirstate: create dirstate submodule
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
38
47108
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47106
diff changeset
39 impl DirstateEntry {
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47106
diff changeset
40 pub fn is_non_normal(&self) -> bool {
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47106
diff changeset
41 self.state != EntryState::Normal || self.mtime == MTIME_UNSET
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47106
diff changeset
42 }
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47106
diff changeset
43
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47106
diff changeset
44 pub fn is_from_other_parent(&self) -> bool {
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47106
diff changeset
45 self.state == EntryState::Normal && self.size == SIZE_FROM_OTHER_PARENT
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47106
diff changeset
46 }
47113
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
47
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
48 // TODO: other platforms
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
49 #[cfg(unix)]
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
50 pub fn mode_changed(
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
51 &self,
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
52 filesystem_metadata: &std::fs::Metadata,
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
53 ) -> bool {
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
54 use std::os::unix::fs::MetadataExt;
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
55 const EXEC_BIT_MASK: u32 = 0o100;
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
56 let dirstate_exec_bit = (self.mode as u32) & EXEC_BIT_MASK;
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
57 let fs_exec_bit = filesystem_metadata.mode() & EXEC_BIT_MASK;
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
58 dirstate_exec_bit != fs_exec_bit
be579775c2d9 dirstate-tree: Add the new `status()` algorithm
Simon Sapin <simon.sapin@octobus.net>
parents: 47108
diff changeset
59 }
47108
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47106
diff changeset
60 }
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47106
diff changeset
61
46594
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
62 #[derive(BytesCast)]
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
63 #[repr(C)]
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
64 struct RawEntry {
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
65 state: u8,
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
66 mode: unaligned::I32Be,
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
67 size: unaligned::I32Be,
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
68 mtime: unaligned::I32Be,
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
69 length: unaligned::I32Be,
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
70 }
f88e8ae0aa8f rust: Rewrite dirstate parsing usin the `bytes-cast` crate
Simon Sapin <simon.sapin@octobus.net>
parents: 46440
diff changeset
71
47108
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47106
diff changeset
72 const MTIME_UNSET: i32 = -1;
e3cebe96c0fc dirstate-tree: Add "non normal" and "from other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents: 47106
diff changeset
73
43605
8210c3f46912 rust: introduce SIZE_FROM_OTHER_PARENT constant
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43271
diff changeset
74 /// A `DirstateEntry` with a size of `-2` means that it was merged from the
8210c3f46912 rust: introduce SIZE_FROM_OTHER_PARENT constant
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43271
diff changeset
75 /// other parent. This allows revert to pick the right status back during a
8210c3f46912 rust: introduce SIZE_FROM_OTHER_PARENT constant
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43271
diff changeset
76 /// merge.
8210c3f46912 rust: introduce SIZE_FROM_OTHER_PARENT constant
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43271
diff changeset
77 pub const SIZE_FROM_OTHER_PARENT: i32 = -2;
8210c3f46912 rust: introduce SIZE_FROM_OTHER_PARENT constant
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43271
diff changeset
78
43826
5ac243a92e37 rust-performance: introduce FastHashMap type alias for HashMap
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43605
diff changeset
79 pub type StateMap = FastHashMap<HgPathBuf, DirstateEntry>;
47335
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47332
diff changeset
80 pub type StateMapIter<'a> = Box<
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47332
diff changeset
81 dyn Iterator<
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47332
diff changeset
82 Item = Result<(&'a HgPath, DirstateEntry), DirstateV2ParseError>,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47332
diff changeset
83 > + Send
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47332
diff changeset
84 + 'a,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47332
diff changeset
85 >;
45610
496537c9c1b4 rust: start plugging the dirstate tree behind a feature gate
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45609
diff changeset
86
43826
5ac243a92e37 rust-performance: introduce FastHashMap type alias for HashMap
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43605
diff changeset
87 pub type CopyMap = FastHashMap<HgPathBuf, HgPathBuf>;
47335
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47332
diff changeset
88 pub type CopyMapIter<'a> = Box<
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47332
diff changeset
89 dyn Iterator<Item = Result<(&'a HgPath, &'a HgPath), DirstateV2ParseError>>
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47332
diff changeset
90 + Send
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47332
diff changeset
91 + 'a,
ed1583a845d2 dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents: 47332
diff changeset
92 >;
42536
2dcee6497b0b rust-dirstate: add "dirs" Rust implementation
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42424
diff changeset
93
42749
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
94 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
95 pub enum EntryState {
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
96 Normal,
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
97 Added,
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
98 Removed,
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
99 Merged,
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
100 Unknown,
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
101 }
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
102
47106
52906934b775 dirstate-tree: Add has_dir and has_tracked_dir
Simon Sapin <simon.sapin@octobus.net>
parents: 47093
diff changeset
103 impl EntryState {
52906934b775 dirstate-tree: Add has_dir and has_tracked_dir
Simon Sapin <simon.sapin@octobus.net>
parents: 47093
diff changeset
104 pub fn is_tracked(self) -> bool {
52906934b775 dirstate-tree: Add has_dir and has_tracked_dir
Simon Sapin <simon.sapin@octobus.net>
parents: 47093
diff changeset
105 use EntryState::*;
52906934b775 dirstate-tree: Add has_dir and has_tracked_dir
Simon Sapin <simon.sapin@octobus.net>
parents: 47093
diff changeset
106 match self {
52906934b775 dirstate-tree: Add has_dir and has_tracked_dir
Simon Sapin <simon.sapin@octobus.net>
parents: 47093
diff changeset
107 Normal | Added | Merged => true,
52906934b775 dirstate-tree: Add has_dir and has_tracked_dir
Simon Sapin <simon.sapin@octobus.net>
parents: 47093
diff changeset
108 Removed | Unknown => false,
52906934b775 dirstate-tree: Add has_dir and has_tracked_dir
Simon Sapin <simon.sapin@octobus.net>
parents: 47093
diff changeset
109 }
52906934b775 dirstate-tree: Add has_dir and has_tracked_dir
Simon Sapin <simon.sapin@octobus.net>
parents: 47093
diff changeset
110 }
52906934b775 dirstate-tree: Add has_dir and has_tracked_dir
Simon Sapin <simon.sapin@octobus.net>
parents: 47093
diff changeset
111 }
52906934b775 dirstate-tree: Add has_dir and has_tracked_dir
Simon Sapin <simon.sapin@octobus.net>
parents: 47093
diff changeset
112
42749
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
113 impl TryFrom<u8> for EntryState {
46440
776b97179c06 rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents: 45610
diff changeset
114 type Error = HgError;
42749
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
115
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
116 fn try_from(value: u8) -> Result<Self, Self::Error> {
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
117 match value {
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
118 b'n' => Ok(EntryState::Normal),
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
119 b'a' => Ok(EntryState::Added),
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
120 b'r' => Ok(EntryState::Removed),
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
121 b'm' => Ok(EntryState::Merged),
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
122 b'?' => Ok(EntryState::Unknown),
46440
776b97179c06 rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents: 45610
diff changeset
123 _ => Err(HgError::CorruptedRepository(format!(
776b97179c06 rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents: 45610
diff changeset
124 "Incorrect dirstate entry state {}",
42749
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
125 value
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
126 ))),
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
127 }
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
128 }
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
129 }
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
130
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
131 impl Into<u8> for EntryState {
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
132 fn into(self) -> u8 {
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
133 match self {
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
134 EntryState::Normal => b'n',
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
135 EntryState::Added => b'a',
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
136 EntryState::Removed => b'r',
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
137 EntryState::Merged => b'm',
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
138 EntryState::Unknown => b'?',
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
139 }
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
140 }
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42748
diff changeset
141 }