[PATCH] lfs: register the flag processors per repository

Yuya Nishihara yuya at tcha.org
Thu Oct 4 09:08:32 EDT 2018


On Thu, 04 Oct 2018 00:39:12 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1538626646 14400
> #      Thu Oct 04 00:17:26 2018 -0400
> # Node ID e010a7be6dc96ea7d48be81a7c5e8a8ed8bf6c31
> # Parent  7a347d362a455d84bccf34347171d89724b9c9df
> lfs: register the flag processors per repository

> +    if b'lfs' in requirements:
> +        options[b'enableextstored'] = True
> +
>      if repository.NARROW_REQUIREMENT in requirements:
>          options[b'enableellipsis'] = True
>  
> diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> --- a/mercurial/revlog.py
> +++ b/mercurial/revlog.py
> @@ -110,6 +110,26 @@ parsers = policy.importmod(r'parsers')
>      REVIDX_ISCENSORED: None,
>  }
>  
> +# Flag processors for REVIDX_EXTSTORED.
> +def extstoredreadprocessor(rl, text):
> +    raise error.ProgrammingError(b'extstored flags processor enabled without'
> +                                 b' wrapping processor function')
> +
> +def extstoredwriteprocessor(rl, text):
> +    raise error.ProgrammingError(b'extstored flags processor enabled without'
> +                                 b' wrapping processor function')
> +
> +def extstoredrawprocessor(rl, text):
> +    raise error.ProgrammingError(b'extstored flags processor enabled without'
> +                                 b' wrapping processor function')
> +
> +# Lambdas are needed here so that these methods can be wrapped by lfs.
> +extstoredprocessor = (
> +    lambda rl, text: extstoredreadprocessor(rl, text),
> +    lambda rl, text: extstoredwriteprocessor(rl, text),
> +    lambda rl, text: extstoredrawprocessor(rl, text),
> +)
> +
>  # Flag processors for REVIDX_ELLIPSIS.
>  def ellipsisreadprocessor(rl, text):
>      return text, False
> @@ -405,6 +425,8 @@ class revlog(object):
>                  self._srdensitythreshold = opts['sparse-read-density-threshold']
>              if 'sparse-read-min-gap-size' in opts:
>                  self._srmingapsize = opts['sparse-read-min-gap-size']
> +            if opts.get('enableextstored'):
> +                self._flagprocessors[REVIDX_EXTSTORED] = extstoredprocessor

I feel it's awkward that we have to wrap the stub extstoredprocessor and
pass in enableextstored=True.

I don't have a concrete idea, but maybe we can provide an API to register
a stock flagprocessor which won't be copied to the revlog instance by default.


More information about the Mercurial-devel mailing list