Details
Details
- Reviewers
Alphare - Group Reviewers
hg-reviewers
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
| Alphare |
| hg-reviewers |
| No Linters Available |
| No Unit Test Coverage |
| Path | Packages | |||
|---|---|---|---|---|
| M | rust/hg-core/src/operations/debugdata.rs (3 lines) | |||
| M | rust/hg-core/src/revlog/changelog.rs (7 lines) | |||
| M | rust/hg-core/src/revlog/filelog.rs (7 lines) | |||
| M | rust/hg-core/src/revlog/manifest.rs (7 lines) | |||
| M | rust/hg-core/src/revlog/revlog.rs (10 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| e0662e3b5f06 | 3d39bebf9ff6 | Martin von Zweigbergk | Wed, Apr 13, 12:25 AM |
| Status | Author | Revision | |
|---|---|---|---|
| Needs Review | martinvonz | ||
| Needs Review | martinvonz | ||
| Accepted | martinvonz | ||
| Accepted | martinvonz | ||
| Needs Review | martinvonz | ||
| Needs Review | martinvonz | ||
| Closed | martinvonz | ||
| Accepted | martinvonz | ||
| Accepted | martinvonz | ||
| Needs Review | martinvonz | ||
| Accepted | martinvonz | ||
| Accepted | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz |
| ) -> Result<Vec<u8>, RevlogError> { | ) -> Result<Vec<u8>, RevlogError> { | ||||
| let index_file = match kind { | let index_file = match kind { | ||||
| DebugDataKind::Changelog => "00changelog.i", | DebugDataKind::Changelog => "00changelog.i", | ||||
| DebugDataKind::Manifest => "00manifest.i", | DebugDataKind::Manifest => "00manifest.i", | ||||
| }; | }; | ||||
| let use_nodemap = repo | let use_nodemap = repo | ||||
| .requirements() | .requirements() | ||||
| .contains(requirements::NODEMAP_REQUIREMENT); | .contains(requirements::NODEMAP_REQUIREMENT); | ||||
| let revlog = Revlog::open(repo, index_file, None, use_nodemap)?; | let revlog = | ||||
| Revlog::open(&repo.store_vfs(), index_file, None, use_nodemap)?; | |||||
| let rev = | let rev = | ||||
| crate::revset::resolve_rev_number_or_hex_prefix(revset, &revlog)?; | crate::revset::resolve_rev_number_or_hex_prefix(revset, &revlog)?; | ||||
| let data = revlog.get_rev_data(rev)?; | let data = revlog.get_rev_data(rev)?; | ||||
| Ok(data.into_owned()) | Ok(data.into_owned()) | ||||
| } | } | ||||
| } | } | ||||
| impl Changelog { | impl Changelog { | ||||
| /// Open the `changelog` of a repository given by its root. | /// Open the `changelog` of a repository given by its root. | ||||
| pub fn open(repo: &Repo) -> Result<Self, HgError> { | pub fn open(repo: &Repo) -> Result<Self, HgError> { | ||||
| let use_nodemap = repo | let use_nodemap = repo | ||||
| .requirements() | .requirements() | ||||
| .contains(requirements::NODEMAP_REQUIREMENT); | .contains(requirements::NODEMAP_REQUIREMENT); | ||||
| let revlog = Revlog::open(repo, "00changelog.i", None, use_nodemap)?; | let revlog = Revlog::open( | ||||
| &repo.store_vfs(), | |||||
| "00changelog.i", | |||||
| None, | |||||
| use_nodemap, | |||||
| )?; | |||||
| Ok(Self { revlog }) | Ok(Self { revlog }) | ||||
| } | } | ||||
| /// Return the `ChangelogEntry` for the given node ID. | /// Return the `ChangelogEntry` for the given node ID. | ||||
| pub fn data_for_node( | pub fn data_for_node( | ||||
| &self, | &self, | ||||
| node: NodePrefix, | node: NodePrefix, | ||||
| ) -> Result<ChangelogRevisionData, RevlogError> { | ) -> Result<ChangelogRevisionData, RevlogError> { | ||||
| /// The generic `revlog` format. | /// The generic `revlog` format. | ||||
| revlog: Revlog, | revlog: Revlog, | ||||
| } | } | ||||
| impl Filelog { | impl Filelog { | ||||
| pub fn open(repo: &Repo, file_path: &HgPath) -> Result<Self, HgError> { | pub fn open(repo: &Repo, file_path: &HgPath) -> Result<Self, HgError> { | ||||
| let index_path = store_path(file_path, b".i"); | let index_path = store_path(file_path, b".i"); | ||||
| let data_path = store_path(file_path, b".d"); | let data_path = store_path(file_path, b".d"); | ||||
| let revlog = Revlog::open(repo, index_path, Some(&data_path), false)?; | let revlog = Revlog::open( | ||||
| &repo.store_vfs(), | |||||
| index_path, | |||||
| Some(&data_path), | |||||
| false, | |||||
| )?; | |||||
| Ok(Self { revlog }) | Ok(Self { revlog }) | ||||
| } | } | ||||
| /// The given node ID is that of the file as found in a filelog, not of a | /// The given node ID is that of the file as found in a filelog, not of a | ||||
| /// changeset. | /// changeset. | ||||
| pub fn data_for_node( | pub fn data_for_node( | ||||
| &self, | &self, | ||||
| file_node: impl Into<NodePrefix>, | file_node: impl Into<NodePrefix>, | ||||
| } | } | ||||
| impl Manifestlog { | impl Manifestlog { | ||||
| /// Open the `manifest` of a repository given by its root. | /// Open the `manifest` of a repository given by its root. | ||||
| pub fn open(repo: &Repo) -> Result<Self, HgError> { | pub fn open(repo: &Repo) -> Result<Self, HgError> { | ||||
| let use_nodemap = repo | let use_nodemap = repo | ||||
| .requirements() | .requirements() | ||||
| .contains(requirements::NODEMAP_REQUIREMENT); | .contains(requirements::NODEMAP_REQUIREMENT); | ||||
| let revlog = Revlog::open(repo, "00manifest.i", None, use_nodemap)?; | let revlog = Revlog::open( | ||||
| &repo.store_vfs(), | |||||
| "00manifest.i", | |||||
| None, | |||||
| use_nodemap, | |||||
| )?; | |||||
| Ok(Self { revlog }) | Ok(Self { revlog }) | ||||
| } | } | ||||
| /// Return the `Manifest` for the given node ID. | /// Return the `Manifest` for the given node ID. | ||||
| /// | /// | ||||
| /// Note: this is a node ID in the manifestlog, typically found through | /// Note: this is a node ID in the manifestlog, typically found through | ||||
| /// `ChangelogEntry::manifest_node`. It is *not* the node ID of any | /// `ChangelogEntry::manifest_node`. It is *not* the node ID of any | ||||
| /// changeset. | /// changeset. | ||||
| use super::index::Index; | use super::index::Index; | ||||
| use super::node::{NodePrefix, NODE_BYTES_LENGTH, NULL_NODE}; | use super::node::{NodePrefix, NODE_BYTES_LENGTH, NULL_NODE}; | ||||
| use super::nodemap; | use super::nodemap; | ||||
| use super::nodemap::{NodeMap, NodeMapError}; | use super::nodemap::{NodeMap, NodeMapError}; | ||||
| use super::nodemap_docket::NodeMapDocket; | use super::nodemap_docket::NodeMapDocket; | ||||
| use super::patch; | use super::patch; | ||||
| use crate::errors::HgError; | use crate::errors::HgError; | ||||
| use crate::repo::Repo; | |||||
| use crate::revlog::Revision; | use crate::revlog::Revision; | ||||
| use crate::vfs::Vfs; | |||||
| use crate::{Node, NULL_REVISION}; | use crate::{Node, NULL_REVISION}; | ||||
| const REVISION_FLAG_CENSORED: u16 = 1 << 15; | const REVISION_FLAG_CENSORED: u16 = 1 << 15; | ||||
| const REVISION_FLAG_ELLIPSIS: u16 = 1 << 14; | const REVISION_FLAG_ELLIPSIS: u16 = 1 << 14; | ||||
| const REVISION_FLAG_EXTSTORED: u16 = 1 << 13; | const REVISION_FLAG_EXTSTORED: u16 = 1 << 13; | ||||
| const REVISION_FLAG_HASCOPIESINFO: u16 = 1 << 12; | const REVISION_FLAG_HASCOPIESINFO: u16 = 1 << 12; | ||||
| // Keep this in sync with REVIDX_KNOWN_FLAGS in | // Keep this in sync with REVIDX_KNOWN_FLAGS in | ||||
| impl Revlog { | impl Revlog { | ||||
| /// Open a revlog index file. | /// Open a revlog index file. | ||||
| /// | /// | ||||
| /// It will also open the associated data file if index and data are not | /// It will also open the associated data file if index and data are not | ||||
| /// interleaved. | /// interleaved. | ||||
| #[timed] | #[timed] | ||||
| pub fn open( | pub fn open( | ||||
| repo: &Repo, | store_vfs: &Vfs, | ||||
| index_path: impl AsRef<Path>, | index_path: impl AsRef<Path>, | ||||
| data_path: Option<&Path>, | data_path: Option<&Path>, | ||||
| use_nodemap: bool, | use_nodemap: bool, | ||||
| ) -> Result<Self, HgError> { | ) -> Result<Self, HgError> { | ||||
| let index_path = index_path.as_ref(); | let index_path = index_path.as_ref(); | ||||
| let index = { | let index = { | ||||
| match repo.store_vfs().mmap_open_opt(&index_path)? { | match store_vfs.mmap_open_opt(&index_path)? { | ||||
| None => Index::new(Box::new(vec![])), | None => Index::new(Box::new(vec![])), | ||||
| Some(index_mmap) => { | Some(index_mmap) => { | ||||
| let index = Index::new(Box::new(index_mmap))?; | let index = Index::new(Box::new(index_mmap))?; | ||||
| Ok(index) | Ok(index) | ||||
| } | } | ||||
| } | } | ||||
| }?; | }?; | ||||
| let default_data_path = index_path.with_extension("d"); | let default_data_path = index_path.with_extension("d"); | ||||
| // type annotation required | // type annotation required | ||||
| // won't recognize Mmap as Deref<Target = [u8]> | // won't recognize Mmap as Deref<Target = [u8]> | ||||
| let data_bytes: Option<Box<dyn Deref<Target = [u8]> + Send>> = | let data_bytes: Option<Box<dyn Deref<Target = [u8]> + Send>> = | ||||
| if index.is_inline() { | if index.is_inline() { | ||||
| None | None | ||||
| } else { | } else { | ||||
| let data_path = data_path.unwrap_or(&default_data_path); | let data_path = data_path.unwrap_or(&default_data_path); | ||||
| let data_mmap = repo.store_vfs().mmap_open(data_path)?; | let data_mmap = store_vfs.mmap_open(data_path)?; | ||||
| Some(Box::new(data_mmap)) | Some(Box::new(data_mmap)) | ||||
| }; | }; | ||||
| let nodemap = if index.is_inline() { | let nodemap = if index.is_inline() { | ||||
| None | None | ||||
| } else if !use_nodemap { | } else if !use_nodemap { | ||||
| None | None | ||||
| } else { | } else { | ||||
| NodeMapDocket::read_from_file(&repo.store_vfs(), index_path)?.map( | NodeMapDocket::read_from_file(store_vfs, index_path)?.map( | ||||
| |(docket, data)| { | |(docket, data)| { | ||||
| nodemap::NodeTree::load_bytes( | nodemap::NodeTree::load_bytes( | ||||
| Box::new(data), | Box::new(data), | ||||
| docket.data_length, | docket.data_length, | ||||
| ) | ) | ||||
| }, | }, | ||||
| ) | ) | ||||
| }; | }; | ||||