Mercurial > hg
view rust/hg-cpython/src/conversion.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 | 33fe96a5c522 |
children | c7fb9b74e753 |
line wrap: on
line source
// conversion.rs // // Copyright 2019 Georges Racinet <georges.racinet@octobus.net> // // This software may be used and distributed according to the terms of the // GNU General Public License version 2 or any later version. //! Bindings for the hg::ancestors module provided by the //! `hg-core` crate. From Python, this will be seen as `rustext.ancestor` use cpython::{ObjectProtocol, PyObject, PyResult, Python}; use hg::Revision; use std::iter::FromIterator; /// Utility function to convert a Python iterable into various collections /// /// We need this in particular to feed to various methods of inner objects /// with `impl IntoIterator<Item=Revision>` arguments, because /// a `PyErr` can arise at each step of iteration, whereas these methods /// expect iterables over `Revision`, not over some `Result<Revision, PyErr>` pub fn rev_pyiter_collect<C>(py: Python, revs: &PyObject) -> PyResult<C> where C: FromIterator<Revision>, { revs.iter(py)? .map(|r| r.and_then(|o| o.extract::<Revision>(py))) .collect() }