Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG2d5dfc8fed55: hg-core: impl TryFrom<PathBuff> for HgPathBuf
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
hg-reviewers |
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | rust/hg-core/src/utils/hg_path.rs (8 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
bebc93623bb5 | 3786e468941f | Antoine Cezar | Sep 15 2020, 4:52 AM |
Status | Author | Revision | |
---|---|---|---|
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | D9049 hg-core: add path_encode | |
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | D8962 rhg: Add debug timing | |
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar | ||
Closed | acezar |
// hg_path.rs | // hg_path.rs | ||||
// | // | ||||
// Copyright 2019 Raphaël Gomès <rgomes@octobus.net> | // Copyright 2019 Raphaël Gomès <rgomes@octobus.net> | ||||
// | // | ||||
// This software may be used and distributed according to the terms of the | // This software may be used and distributed according to the terms of the | ||||
// GNU General Public License version 2 or any later version. | // GNU General Public License version 2 or any later version. | ||||
use std::borrow::Borrow; | use std::borrow::Borrow; | ||||
use std::convert::TryFrom; | |||||
use std::ffi::{OsStr, OsString}; | use std::ffi::{OsStr, OsString}; | ||||
use std::fmt; | use std::fmt; | ||||
use std::ops::Deref; | use std::ops::Deref; | ||||
use std::path::{Path, PathBuf}; | use std::path::{Path, PathBuf}; | ||||
#[derive(Debug, Eq, PartialEq)] | #[derive(Debug, Eq, PartialEq)] | ||||
pub enum HgPathError { | pub enum HgPathError { | ||||
/// Bytes from the invalid `HgPath` | /// Bytes from the invalid `HgPath` | ||||
} | } | ||||
// TODO Handle other platforms | // TODO Handle other platforms | ||||
// TODO: convert from WTF8 to Windows MBCS (ANSI encoding). | // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). | ||||
buf.check_state()?; | buf.check_state()?; | ||||
Ok(buf) | Ok(buf) | ||||
} | } | ||||
impl TryFrom<PathBuf> for HgPathBuf { | |||||
type Error = HgPathError; | |||||
fn try_from(path: PathBuf) -> Result<Self, Self::Error> { | |||||
path_to_hg_path_buf(path) | |||||
} | |||||
} | |||||
#[cfg(test)] | #[cfg(test)] | ||||
mod tests { | mod tests { | ||||
use super::*; | use super::*; | ||||
use pretty_assertions::assert_eq; | use pretty_assertions::assert_eq; | ||||
#[test] | #[test] | ||||
fn test_path_states() { | fn test_path_states() { | ||||
assert_eq!( | assert_eq!( |