rust/hg-core/src/dirstate.rs
changeset 46440 776b97179c06
parent 45610 496537c9c1b4
child 46594 f88e8ae0aa8f
equal deleted inserted replaced
46439:68a15b5a7e58 46440:776b97179c06
     3 // Copyright 2019 Raphaël Gomès <rgomes@octobus.net>
     3 // Copyright 2019 Raphaël Gomès <rgomes@octobus.net>
     4 //
     4 //
     5 // This software may be used and distributed according to the terms of the
     5 // This software may be used and distributed according to the terms of the
     6 // GNU General Public License version 2 or any later version.
     6 // GNU General Public License version 2 or any later version.
     7 
     7 
     8 use crate::{utils::hg_path::HgPathBuf, DirstateParseError, FastHashMap};
     8 use crate::errors::HgError;
       
     9 use crate::{utils::hg_path::HgPathBuf, FastHashMap};
     9 use std::collections::hash_map;
    10 use std::collections::hash_map;
    10 use std::convert::TryFrom;
    11 use std::convert::TryFrom;
    11 
    12 
    12 pub mod dirs_multiset;
    13 pub mod dirs_multiset;
    13 pub mod dirstate_map;
    14 pub mod dirstate_map;
    58     Merged,
    59     Merged,
    59     Unknown,
    60     Unknown,
    60 }
    61 }
    61 
    62 
    62 impl TryFrom<u8> for EntryState {
    63 impl TryFrom<u8> for EntryState {
    63     type Error = DirstateParseError;
    64     type Error = HgError;
    64 
    65 
    65     fn try_from(value: u8) -> Result<Self, Self::Error> {
    66     fn try_from(value: u8) -> Result<Self, Self::Error> {
    66         match value {
    67         match value {
    67             b'n' => Ok(EntryState::Normal),
    68             b'n' => Ok(EntryState::Normal),
    68             b'a' => Ok(EntryState::Added),
    69             b'a' => Ok(EntryState::Added),
    69             b'r' => Ok(EntryState::Removed),
    70             b'r' => Ok(EntryState::Removed),
    70             b'm' => Ok(EntryState::Merged),
    71             b'm' => Ok(EntryState::Merged),
    71             b'?' => Ok(EntryState::Unknown),
    72             b'?' => Ok(EntryState::Unknown),
    72             _ => Err(DirstateParseError::CorruptedEntry(format!(
    73             _ => Err(HgError::CorruptedRepository(format!(
    73                 "Incorrect entry state {}",
    74                 "Incorrect dirstate entry state {}",
    74                 value
    75                 value
    75             ))),
    76             ))),
    76         }
    77         }
    77     }
    78     }
    78 }
    79 }