This better describes the input and outputs of this method.
Also rewrite the doc-comment, which seemed to have been left from copy-paste
of another method.
Alphare |
hg-reviewers |
This better describes the input and outputs of this method.
Also rewrite the doc-comment, which seemed to have been left from copy-paste
of another method.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | rust/hg-core/src/revlog/changelog.rs (2 lines) | |||
M | rust/hg-core/src/revlog/filelog.rs (2 lines) | |||
M | rust/hg-core/src/revlog/manifest.rs (2 lines) | |||
M | rust/hg-core/src/revlog/revlog.rs (4 lines) | |||
M | rust/hg-core/src/revset.rs (2 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin |
Ok(Self { revlog }) | Ok(Self { revlog }) | ||||
} | } | ||||
/// Return the `ChangelogEntry` a given node id. | /// Return the `ChangelogEntry` a given node id. | ||||
pub fn get_node( | pub fn get_node( | ||||
&self, | &self, | ||||
node: NodePrefix, | node: NodePrefix, | ||||
) -> Result<ChangelogEntry, RevlogError> { | ) -> Result<ChangelogEntry, RevlogError> { | ||||
let rev = self.revlog.get_node_rev(node)?; | let rev = self.revlog.rev_from_node(node)?; | ||||
self.get_rev(rev) | self.get_rev(rev) | ||||
} | } | ||||
/// Return the `ChangelogEntry` of a given node revision. | /// Return the `ChangelogEntry` of a given node revision. | ||||
pub fn get_rev( | pub fn get_rev( | ||||
&self, | &self, | ||||
rev: Revision, | rev: Revision, | ||||
) -> Result<ChangelogEntry, RevlogError> { | ) -> Result<ChangelogEntry, RevlogError> { |
} | } | ||||
/// The given node ID is that of the file as found in a manifest, not of a | /// The given node ID is that of the file as found in a manifest, not of a | ||||
/// changeset. | /// changeset. | ||||
pub fn get_node( | pub fn get_node( | ||||
&self, | &self, | ||||
file_node: impl Into<NodePrefix>, | file_node: impl Into<NodePrefix>, | ||||
) -> Result<FilelogEntry, RevlogError> { | ) -> Result<FilelogEntry, RevlogError> { | ||||
let file_rev = self.revlog.get_node_rev(file_node.into())?; | let file_rev = self.revlog.rev_from_node(file_node.into())?; | ||||
self.get_rev(file_rev) | self.get_rev(file_rev) | ||||
} | } | ||||
/// The given revision is that of the file as found in a manifest, not of a | /// The given revision is that of the file as found in a manifest, not of a | ||||
/// changeset. | /// changeset. | ||||
pub fn get_rev( | pub fn get_rev( | ||||
&self, | &self, | ||||
file_rev: Revision, | file_rev: Revision, |
/// 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 revlog = Revlog::open(repo, "00manifest.i", None)?; | let revlog = Revlog::open(repo, "00manifest.i", None)?; | ||||
Ok(Self { revlog }) | Ok(Self { revlog }) | ||||
} | } | ||||
/// Return the `ManifestEntry` of a given node id. | /// Return the `ManifestEntry` of a given node id. | ||||
pub fn get_node(&self, node: NodePrefix) -> Result<Manifest, RevlogError> { | pub fn get_node(&self, node: NodePrefix) -> Result<Manifest, RevlogError> { | ||||
let rev = self.revlog.get_node_rev(node)?; | let rev = self.revlog.rev_from_node(node)?; | ||||
self.get_rev(rev) | self.get_rev(rev) | ||||
} | } | ||||
/// Return the `ManifestEntry` of a given node revision. | /// Return the `ManifestEntry` of a given node revision. | ||||
pub fn get_rev(&self, rev: Revision) -> Result<Manifest, RevlogError> { | pub fn get_rev(&self, rev: Revision) -> Result<Manifest, RevlogError> { | ||||
let bytes = self.revlog.get_rev_data(rev)?; | let bytes = self.revlog.get_rev_data(rev)?; | ||||
Ok(Manifest { bytes }) | Ok(Manifest { bytes }) | ||||
} | } |
self.index.is_empty() | self.index.is_empty() | ||||
} | } | ||||
/// Returns the node ID for the given revision number, if it exists in this revlog | /// Returns the node ID for the given revision number, if it exists in this revlog | ||||
pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> { | pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> { | ||||
Some(self.index.get_entry(rev)?.hash()) | Some(self.index.get_entry(rev)?.hash()) | ||||
} | } | ||||
/// Return the full data associated to a node. | /// Return the revision number for the given node ID, if it exists in this revlog | ||||
#[timed] | #[timed] | ||||
pub fn get_node_rev( | pub fn rev_from_node( | ||||
&self, | &self, | ||||
node: NodePrefix, | node: NodePrefix, | ||||
) -> Result<Revision, RevlogError> { | ) -> Result<Revision, RevlogError> { | ||||
if node.is_prefix_of(&NULL_NODE) { | if node.is_prefix_of(&NULL_NODE) { | ||||
return Ok(NULL_REVISION); | return Ok(NULL_REVISION); | ||||
} | } | ||||
if let Some(nodemap) = &self.nodemap { | if let Some(nodemap) = &self.nodemap { |
return Ok(integer); | return Ok(integer); | ||||
} | } | ||||
} | } | ||||
if let Ok(prefix) = NodePrefix::from_hex(input) { | if let Ok(prefix) = NodePrefix::from_hex(input) { | ||||
if prefix.is_prefix_of(&Node::from_hex(WORKING_DIRECTORY_HEX).unwrap()) | if prefix.is_prefix_of(&Node::from_hex(WORKING_DIRECTORY_HEX).unwrap()) | ||||
{ | { | ||||
return Err(RevlogError::WDirUnsupported); | return Err(RevlogError::WDirUnsupported); | ||||
} | } | ||||
return revlog.get_node_rev(prefix); | return revlog.rev_from_node(prefix); | ||||
} | } | ||||
Err(RevlogError::InvalidRevision) | Err(RevlogError::InvalidRevision) | ||||
} | } |