Mercurial > hg
view rust/hg-core/src/revset.rs @ 46472:98e39f04d60e
upgrade: implement partial upgrade for upgrading persistent-nodemap
Upgrading repositories to use persistent nodemap should be fast and easy as it
requires only two things:
1) Updating the requirements
2) Writing a persistent-nodemap on disk
For both of the steps above, we don't need to edit existing revlogs.
This patch makes upgrade only do the above mentioned two steps if we are
only upgarding to use persistent-nodemap feature.
Since `nodemap.persist_nodemap()` assumes that there exists a nodemap file for
the given revlog if we are trying to call it, this patch adds `force` argument
to create a file if does not exist which is true in our upgrade case.
The test changes demonstrate that we no longer write nodemap files for manifest
after upgrade which I think is desirable.
Differential Revision: https://phab.mercurial-scm.org/D9936
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 01 Feb 2021 00:02:00 +0530 |
parents | 4b381dbbf8b7 |
children | df247f58ecee |
line wrap: on
line source
//! The revset query language //! //! <https://www.mercurial-scm.org/repo/hg/help/revsets> use crate::repo::Repo; use crate::revlog::changelog::Changelog; use crate::revlog::revlog::{Revlog, RevlogError}; use crate::revlog::NodePrefix; use crate::revlog::{Revision, NULL_REVISION}; /// Resolve a query string into a single revision. /// /// Only some of the revset language is implemented yet. pub fn resolve_single( input: &str, repo: &Repo, ) -> Result<Revision, RevlogError> { let changelog = Changelog::open(repo)?; match resolve_rev_number_or_hex_prefix(input, &changelog.revlog) { Err(RevlogError::InvalidRevision) => {} // Try other syntax result => return result, } if input == "null" { return Ok(NULL_REVISION); } // TODO: support for the rest of the language here. Err(RevlogError::InvalidRevision) } /// Resolve the small subset of the language suitable for revlogs other than /// the changelog, such as in `hg debugdata --manifest` CLI argument. /// /// * A non-negative decimal integer for a revision number, or /// * An hexadecimal string, for the unique node ID that starts with this /// prefix pub fn resolve_rev_number_or_hex_prefix( input: &str, revlog: &Revlog, ) -> Result<Revision, RevlogError> { if let Ok(integer) = input.parse::<i32>() { if integer >= 0 && revlog.has_rev(integer) { return Ok(integer); } } if let Ok(prefix) = NodePrefix::from_hex(input) { return revlog.get_node_rev(prefix); } Err(RevlogError::InvalidRevision) }