Mercurial > hg
view hgext/strip.py @ 47123:d8ac62374943
dirstate-tree: Make `DirstateMap` borrow from a bytes buffer
… that has the contents of the `.hg/dirstate` file.
This only applies to the tree-based flavor of `DirstateMap`.
For now only the entire `&[u8]` slice is stored, so this is not useful yet.
Adding a lifetime parameter to the `DirstateMap` struct (in hg-core) makes
Python bindings non-trivial because we keep that struct in a Python object
that has a dynamic lifetime tied to Python’s reference-counting and GC.
As long as we keep the `PyBytes` that owns the borrowed bytes buffer next to
the borrowing struct, the buffer will live long enough for the borrows to stay
valid. However this relationship cannot be expressed in safe Rust code in a
way that would statisfy they borrow-checker. We use `unsafe` code to erase
that lifetime parameter, and encapsulate it in a safe abstraction similar to
the owning-ref crate: https://docs.rs/owning_ref/
Differential Revision: https://phab.mercurial-scm.org/D10557
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Fri, 30 Apr 2021 18:24:54 +0200 |
parents | d7a508a75d72 |
children | 6000f5b25c9b |
line wrap: on
line source
"""strip changesets and their descendants from history (DEPRECATED) The functionality of this extension has been included in core Mercurial since version 5.7. Please use :hg:`debugstrip ...` instead. This extension allows you to strip changesets and all their descendants from the repository. See the command help for details. """ from __future__ import absolute_import from mercurial import commands # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should # be specifying the version(s) of Mercurial they are tested with, or # leave the attribute unspecified. testedwith = b'ships-with-hg-core' # This is a bit ugly, but a uisetup function that defines strip as an # alias for debugstrip would override any user alias for strip, # including aliases like "strip = strip --no-backup". commands.command.rename(old=b'debugstrip', new=b'debugstrip|strip')