Mercurial > hg
comparison rust/hg-core/src/dirstate/entry.rs @ 48026:1b2ee68e85f9
rust: Remove EntryState::Unknown
This enum variant represented the `state == '?'` case, which was used
to represent the absence of a dirstate entry/item (and therefore of that
entry’s state).
Now that previous refactors have removed this use in the Python/Rust
FFI APIs, the remaining uses can be removed by replacing `EntryState`
by `Option<EntryState>` where appropriate, using `None` to represent
the absence of an entry.
Differential Revision: https://phab.mercurial-scm.org/D11465
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 20 Sep 2021 20:55:38 +0200 |
parents | f2a9db29cb2d |
children | 008959fcbfb2 |
comparison
equal
deleted
inserted
replaced
48025:631f6b445a77 | 48026:1b2ee68e85f9 |
---|---|
5 pub enum EntryState { | 5 pub enum EntryState { |
6 Normal, | 6 Normal, |
7 Added, | 7 Added, |
8 Removed, | 8 Removed, |
9 Merged, | 9 Merged, |
10 Unknown, | |
11 } | 10 } |
12 | 11 |
13 /// The C implementation uses all signed types. This will be an issue | 12 /// The C implementation uses all signed types. This will be an issue |
14 /// either when 4GB+ source files are commonplace or in 2038, whichever | 13 /// either when 4GB+ source files are commonplace or in 2038, whichever |
15 /// comes first. | 14 /// comes first. |
155 impl EntryState { | 154 impl EntryState { |
156 pub fn is_tracked(self) -> bool { | 155 pub fn is_tracked(self) -> bool { |
157 use EntryState::*; | 156 use EntryState::*; |
158 match self { | 157 match self { |
159 Normal | Added | Merged => true, | 158 Normal | Added | Merged => true, |
160 Removed | Unknown => false, | 159 Removed => false, |
161 } | 160 } |
162 } | 161 } |
163 } | 162 } |
164 | 163 |
165 impl TryFrom<u8> for EntryState { | 164 impl TryFrom<u8> for EntryState { |
169 match value { | 168 match value { |
170 b'n' => Ok(EntryState::Normal), | 169 b'n' => Ok(EntryState::Normal), |
171 b'a' => Ok(EntryState::Added), | 170 b'a' => Ok(EntryState::Added), |
172 b'r' => Ok(EntryState::Removed), | 171 b'r' => Ok(EntryState::Removed), |
173 b'm' => Ok(EntryState::Merged), | 172 b'm' => Ok(EntryState::Merged), |
174 b'?' => Ok(EntryState::Unknown), | |
175 _ => Err(HgError::CorruptedRepository(format!( | 173 _ => Err(HgError::CorruptedRepository(format!( |
176 "Incorrect dirstate entry state {}", | 174 "Incorrect dirstate entry state {}", |
177 value | 175 value |
178 ))), | 176 ))), |
179 } | 177 } |
185 match self { | 183 match self { |
186 EntryState::Normal => b'n', | 184 EntryState::Normal => b'n', |
187 EntryState::Added => b'a', | 185 EntryState::Added => b'a', |
188 EntryState::Removed => b'r', | 186 EntryState::Removed => b'r', |
189 EntryState::Merged => b'm', | 187 EntryState::Merged => b'm', |
190 EntryState::Unknown => b'?', | |
191 } | 188 } |
192 } | 189 } |
193 } | 190 } |