##// END OF EJS Templates
commands: correct documentation of hg serve’s --ipv6 option...
commands: correct documentation of hg serve’s --ipv6 option When the --ipv6 option is given, the server doesn’t listen to a IPv4 socket. This can be verified by running two servers, one with and one without the option, which works fine. I think that listening to both a IPv4 and a IPv6 socket would be better, but given that the Python standard library class underlying the HTTP server supports only one socket, this is not trivial.

File last commit:

r51147:a6b8b1ab merge default
r51265:80784ac0 stable
Show More
owning.rs
104 lines | 2.5 KiB | application/rls-services+xml | RustLexer
use crate::{DirstateError, DirstateParents};
use super::dirstate_map::DirstateMap;
use std::ops::Deref;
use ouroboros::self_referencing;
/// Keep a `DirstateMap<'on_disk>` next to the `on_disk` buffer that it
/// borrows.
#[self_referencing]
pub struct OwningDirstateMap {
on_disk: Box<dyn Deref<Target = [u8]> + Send>,
#[borrows(on_disk)]
#[covariant]
map: DirstateMap<'this>,
}
impl OwningDirstateMap {
pub fn new_empty<OnDisk>(on_disk: OnDisk) -> Self
where
OnDisk: Deref<Target = [u8]> + Send + 'static,
{
let on_disk = Box::new(on_disk);
OwningDirstateMapBuilder {
on_disk,
map_builder: |bytes| DirstateMap::empty(bytes),
}
.build()
}
pub fn new_v1<OnDisk>(
on_disk: OnDisk,
identity: Option<u64>,
) -> Result<(Self, DirstateParents), DirstateError>
where
OnDisk: Deref<Target = [u8]> + Send + 'static,
{
let on_disk = Box::new(on_disk);
let mut parents = DirstateParents::NULL;
Ok((
OwningDirstateMapTryBuilder {
on_disk,
map_builder: |bytes| {
DirstateMap::new_v1(bytes, identity).map(|(dmap, p)| {
parents = p.unwrap_or(DirstateParents::NULL);
dmap
})
},
}
.try_build()?,
parents,
))
}
pub fn new_v2<OnDisk>(
on_disk: OnDisk,
data_size: usize,
metadata: &[u8],
uuid: Vec<u8>,
identity: Option<u64>,
) -> 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, uuid, identity)
},
}
.try_build()
}
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()
}
pub fn old_uuid(&self) -> Option<&[u8]> {
self.get_map().old_uuid.as_deref()
}
pub fn old_identity(&self) -> Option<u64> {
self.get_map().identity
}
pub fn old_data_size(&self) -> usize {
self.get_map().old_data_size
}
}