##// END OF EJS Templates
obsolete: don't use os.stat in repo.obsstore.__nonzero__ if it's static HTTP...
obsolete: don't use os.stat in repo.obsstore.__nonzero__ if it's static HTTP If a repo is accessed via static HTTP, then we obviously can't use os.stat() to just peek at the file size. Let's download the entire file to check its size. Yes, this feels wasteful, but: 1. If we're cloning or pulling a repo from a static HTTP server, we need the contents of the obsstore anyway. 2. Implementing statichttpvfs.stat() that uses HEAD will result in one more request to a static-only HTTP server, which is already slow. Also parsing a response to a HEAD request to construct os.stat_result is pretty hacky. There's also a question of the remote server properly supporting HEAD method and reporting at least file size. 3. Implementing statichttpvfs.stat() that uses GET is pretty much the same thing as we do here, except we can't even cache the response easily, unlike simply accessing obsstore._data, which is @propertycache'd. Importing statichttprepo locally to avoid circular import. See also: 4507bc001365 and commit message of f8f2ecdde4b5. Differential Revision: https://phab.mercurial-scm.org/D12195

File last commit:

r48775:4d2a5ca0 default
r49640:ef50a62e default
Show More
revlog.rs
72 lines | 2.2 KiB | application/rls-services+xml | RustLexer
Georges Racinet
rust-core: extracted a revlog submodule...
r44457 // Copyright 2018-2020 Georges Racinet <georges.racinet@octobus.net>
// and Mercurial contributors
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
//! Mercurial concepts for handling revision history
Georges Racinet
rust-node: binary Node ID and conversion utilities...
r44601 pub mod node;
Georges Racinet
rust-nodemap: building blocks for nodetree structures...
r44600 pub mod nodemap;
Simon Sapin
rhg: use persistent nodemap when available...
r46706 mod nodemap_docket;
Antoine Cezar
hg-core: add path_encode...
r46110 pub mod path_encode;
Simon Sapin
rust: Make NodePrefix allocation-free and Copy, remove NodePrefixRef...
r47160 pub use node::{FromHexError, Node, NodePrefix};
Antoine Cezar
hg-core: add `Changlog` a specialized `Revlog`...
r46103 pub mod changelog;
Simon Sapin
rust: Add a Filelog struct that wraps Revlog...
r48775 pub mod filelog;
Antoine Cezar
hg-core: Add a limited read only `revlog` implementation...
r46097 pub mod index;
Antoine Cezar
hg-core: add `Manifest` a specialized `Revlog`...
r46104 pub mod manifest;
Antoine Cezar
hg-core: Add a limited read only `revlog` implementation...
r46097 pub mod patch;
pub mod revlog;
Georges Racinet
rust-nodemap: building blocks for nodetree structures...
r44600
Georges Racinet
rust-core: extracted a revlog submodule...
r44457 /// Mercurial revision numbers
///
/// As noted in revlog.c, revision numbers are actually encoded in
/// 4 bytes, and are liberally converted to ints, whence the i32
pub type Revision = i32;
/// Marker expressing the absence of a parent
///
/// Independently of the actual representation, `NULL_REVISION` is guaranteed
Aay Jay Chan
rust-core: fix typo in comment...
r44547 /// to be smaller than all existing revisions.
Georges Racinet
rust-core: extracted a revlog submodule...
r44457 pub const NULL_REVISION: Revision = -1;
/// Same as `mercurial.node.wdirrev`
///
/// This is also equal to `i32::max_value()`, but it's better to spell
/// it out explicitely, same as in `mercurial.node`
Raphaël Gomès
rust: do a clippy pass...
r45500 #[allow(clippy::unreadable_literal)]
Georges Racinet
rust-core: extracted a revlog submodule...
r44457 pub const WORKING_DIRECTORY_REVISION: Revision = 0x7fffffff;
Pulkit Goyal
rhg: raise wdir specific error for `hg debugdata`...
r47577 pub const WORKING_DIRECTORY_HEX: &str =
"ffffffffffffffffffffffffffffffffffffffff";
Georges Racinet
rust-core: extracted a revlog submodule...
r44457 /// The simplest expression of what we need of Mercurial DAGs.
pub trait Graph {
/// Return the two parents of the given `Revision`.
///
/// Each of the parents can be independently `NULL_REVISION`
fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError>;
}
#[derive(Clone, Debug, PartialEq)]
pub enum GraphError {
ParentOutOfRange(Revision),
WorkingDirectoryUnsupported,
}
Georges Racinet
rust-revlog: a trait for the revlog index...
r44642
/// The Mercurial Revlog Index
///
/// This is currently limited to the minimal interface that is needed for
/// the [`nodemap`](nodemap/index.html) module
pub trait RevlogIndex {
/// Total number of Revisions referenced in this index
fn len(&self) -> usize;
Raphaël Gomès
rust: do a clippy pass...
r45500 fn is_empty(&self) -> bool {
self.len() == 0
}
Georges Racinet
rust-revlog: a trait for the revlog index...
r44642 /// Return a reference to the Node or `None` if rev is out of bounds
///
/// `NULL_REVISION` is not considered to be out of bounds.
fn node(&self, rev: Revision) -> Option<&Node>;
}