[PATCH 3 of 3 V3] memctx: allow the memlightctx thats reusing the manifest node

Yuya Nishihara yuya at tcha.org
Thu Dec 15 09:29:24 EST 2016


On Mon, 21 Nov 2016 08:13:32 -0800, Mateusz Kwapich wrote:
> # HG changeset patch
> # User Mateusz Kwapich <mitrandir at fb.com>
> # Date 1479744581 28800
> #      Mon Nov 21 08:09:41 2016 -0800
> # Node ID 4af70f21264ac8e52d9b218080bbc96ee5505606
> # Parent  4a0824bead3ba5980bd8528937fba5f7bb31ba9f
> memctx: allow the memlightctx thats reusing the manifest node

> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -1975,3 +1975,101 @@ class memfilectx(committablefilectx):
>      def write(self, data, flags):
>          """wraps repo.wwrite"""
>          self._data = data
> +
> +class memlightctx(committablectx):
> +    """Like memctx but it's reusing the manifest of different commit.
> +    Intended to be used by lightweight operations that are creating
> +    metadata-only changes.
> +
> +    Revision information is supplied at initialization time.  'repo' is the
> +    current localrepo, 'ctx' is original revision which manifest we're reuisng
> +    'parents' is a sequence of two parent revisions identifiers (pass None for
> +    every missing parent), 'text' is the commit.
> +
> +    user receives the committer name and defaults to current repository
> +    username, date is the commit date in any format supported by
> +    util.parsedate() and defaults to current date, extra is a dictionary of
> +    metadata or is left empty.
> +    """
> +    def __new__(cls, repo, path, *args, **kwargs):
> +        return super(memlightctx, cls).__new__(cls, repo)

Nit: the argument name 'path' is misleading since it should actually be
an 'originalctx'. Maybe that can be fixed by a follow-up patch.

> +
> +    def __init__(self, repo, originalctx, parents, text, user=None, date=None,
> +                 extra=None, editor=False):


More information about the Mercurial-devel mailing list