##// END OF EJS Templates
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command...
debugshell: allow TortoiseHg builds to exit with the usual `quit()` command I've long been annoyed that `quit()` only randomly worked to exit the interpreter. When that happens, Ctrl+C doesn't work either (it simply prints "KeyboardInterrupt"), so then you have to `import sys` and `sys.exit()`. But it turns out that the behavior isn't random and it depended on which `hg.exe` was picked up on PATH first, because py2exe disables site initialization. I wasn't able to persuade the maintainer to allow an opt-in to initialization[1], but this works around it so that the behavior is now consistent however `hg.exe` is built. TortoiseHg 6.3.3 will be the first build that includes the site package, so handle the ImportError. [1] https://github.com/py2exe/py2exe/issues/154

File last commit:

r49857:c9f44fc9 stable
r50791:88b81dc2 default
Show More
owning.rs
89 lines | 2.1 KiB | application/rls-services+xml | RustLexer
Raphaël Gomès
rust: fix unsound `OwningDirstateMap`...
r49864 use crate::{DirstateError, DirstateParents};
Simon Sapin
rust: Make OwningDirstateMap generic and move it into hg-core...
r48766 use super::dirstate_map::DirstateMap;
use std::ops::Deref;
Raphaël Gomès
rust: fix unsound `OwningDirstateMap`...
r49864 use ouroboros::self_referencing;
Raphaël Gomès
rust: explain why the current `OwningDirstateMap` is unsound...
r49863
Simon Sapin
rust: Make OwningDirstateMap generic and move it into hg-core...
r48766 /// Keep a `DirstateMap<'on_disk>` next to the `on_disk` buffer that it
/// borrows.
Raphaël Gomès
rust: fix unsound `OwningDirstateMap`...
r49864 #[self_referencing]
Simon Sapin
rust: Make OwningDirstateMap generic and move it into hg-core...
r48766 pub struct OwningDirstateMap {
on_disk: Box<dyn Deref<Target = [u8]> + Send>,
Raphaël Gomès
rust: fix unsound `OwningDirstateMap`...
r49864 #[borrows(on_disk)]
#[covariant]
map: DirstateMap<'this>,
Simon Sapin
rust: Make OwningDirstateMap generic and move it into hg-core...
r48766 }
impl OwningDirstateMap {
pub fn new_empty<OnDisk>(on_disk: OnDisk) -> Self
where
Raphaël Gomès
rust: fix unsound `OwningDirstateMap`...
r49864 OnDisk: Deref<Target = [u8]> + Send + 'static,
Simon Sapin
rust: Make OwningDirstateMap generic and move it into hg-core...
r48766 {
let on_disk = Box::new(on_disk);
Raphaël Gomès
rust: fix unsound `OwningDirstateMap`...
r49864 OwningDirstateMapBuilder {
on_disk,
map_builder: |bytes| DirstateMap::empty(&bytes),
}
.build()
Simon Sapin
rust: Make OwningDirstateMap generic and move it into hg-core...
r48766 }
Raphaël Gomès
rust: fix unsound `OwningDirstateMap`...
r49864 pub fn new_v1<OnDisk>(
on_disk: OnDisk,
) -> Result<(Self, DirstateParents), DirstateError>
where
OnDisk: Deref<Target = [u8]> + Send + 'static,
{
let on_disk = Box::new(on_disk);
let mut parents = DirstateParents::NULL;
Simon Sapin
rust: Make OwningDirstateMap generic and move it into hg-core...
r48766
Raphaël Gomès
rust: fix unsound `OwningDirstateMap`...
r49864 Ok((
OwningDirstateMapTryBuilder {
on_disk,
map_builder: |bytes| {
DirstateMap::new_v1(&bytes).map(|(dmap, p)| {
parents = p.unwrap_or(DirstateParents::NULL);
dmap
})
},
}
.try_build()?,
parents,
))
Simon Sapin
rust: Make OwningDirstateMap generic and move it into hg-core...
r48766 }
Raphaël Gomès
rust: fix unsound `OwningDirstateMap`...
r49864 pub fn new_v2<OnDisk>(
on_disk: OnDisk,
data_size: usize,
metadata: &[u8],
) -> Result<Self, DirstateError>
where
OnDisk: Deref<Target = [u8]> + Send + 'static,
{
let on_disk = Box::new(on_disk);
OwningDirstateMapTryBuilder {
on_disk,
map_builder: |bytes| {
DirstateMap::new_v2(&bytes, data_size, metadata)
},
}
.try_build()
Simon Sapin
rust: Make OwningDirstateMap generic and move it into hg-core...
r48766 }
Raphaël Gomès
rust: fix unsound `OwningDirstateMap`...
r49864 pub fn with_dmap_mut<R>(
&mut self,
f: impl FnOnce(&mut DirstateMap) -> R,
) -> R {
self.with_map_mut(f)
}
pub fn get_map(&self) -> &DirstateMap {
self.borrow_map()
}
pub fn on_disk(&self) -> &[u8] {
self.borrow_on_disk()
Simon Sapin
rust: Make OwningDirstateMap generic and move it into hg-core...
r48766 }
}