comparison rust/hg-core/src/repo.rs @ 48463:5734b03ecf3e

rhg: Initial repository locking Initial Rust implementation of locking based on the `.hg/wlock` symlink (or file), with lock breaking when the recorded pid and hostname show that a lock was left by a local process that is not running anymore (as it might have been killed). Differential Revision: https://phab.mercurial-scm.org/D11835
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 22 Mar 2021 09:07:10 +0100
parents 005ae1a343f8
children c8659e61073d
comparison
equal deleted inserted replaced
48462:c1b633db67fc 48463:5734b03ecf3e
4 use crate::dirstate_tree::dirstate_map::DirstateMap; 4 use crate::dirstate_tree::dirstate_map::DirstateMap;
5 use crate::dirstate_tree::owning::OwningDirstateMap; 5 use crate::dirstate_tree::owning::OwningDirstateMap;
6 use crate::errors::HgError; 6 use crate::errors::HgError;
7 use crate::errors::HgResultExt; 7 use crate::errors::HgResultExt;
8 use crate::exit_codes; 8 use crate::exit_codes;
9 use crate::lock::{try_with_lock_no_wait, LockError};
9 use crate::manifest::{Manifest, Manifestlog}; 10 use crate::manifest::{Manifest, Manifestlog};
10 use crate::revlog::filelog::Filelog; 11 use crate::revlog::filelog::Filelog;
11 use crate::revlog::revlog::RevlogError; 12 use crate::revlog::revlog::RevlogError;
12 use crate::utils::files::get_path_from_bytes; 13 use crate::utils::files::get_path_from_bytes;
13 use crate::utils::hg_path::HgPath; 14 use crate::utils::hg_path::HgPath;
239 /// For accessing the working copy 240 /// For accessing the working copy
240 pub fn working_directory_vfs(&self) -> Vfs<'_> { 241 pub fn working_directory_vfs(&self) -> Vfs<'_> {
241 Vfs { 242 Vfs {
242 base: &self.working_directory, 243 base: &self.working_directory,
243 } 244 }
245 }
246
247 pub fn try_with_wlock_no_wait<R>(
248 &self,
249 f: impl FnOnce() -> R,
250 ) -> Result<R, LockError> {
251 try_with_lock_no_wait(self.hg_vfs(), "wlock", f)
244 } 252 }
245 253
246 pub fn has_dirstate_v2(&self) -> bool { 254 pub fn has_dirstate_v2(&self) -> bool {
247 self.requirements 255 self.requirements
248 .contains(requirements::DIRSTATE_V2_REQUIREMENT) 256 .contains(requirements::DIRSTATE_V2_REQUIREMENT)