Actually, I think the current API is useful in some cases - like a flag is
both useful for filelog and manifest, filelog wants hash verification but
not manifest. So I'll drop Patch 1 and 2 from patchwork and keep Patch 3,
which is still useful.

Excerpts from Jun Wu's message of 2017-05-10 18:47:34 -0700:
> # HG changeset patch
> # User Jun Wu <qu...@fb.com>
> # Date 1494457921 25200
> #      Wed May 10 16:12:01 2017 -0700
> # Node ID a5a22d616f981e8c220f1c2fd4eae098e104a11c
> # Parent  1b4a17fefa2e67b6bf9294c9fbce586a6646bdaa
> # Available At https://bitbucket.org/quark-zju/hg-draft 
> #              hg pull https://bitbucket.org/quark-zju/hg-draft  -r 
> a5a22d616f98
> flagprocessor: migrate addflagprocessor to registerflagprocessor
> 
> This patch migrates all users of addflagprocessor to registerflagprocessor.
> So addflagprocessor is not used in the code base and could be removed when
> external code completes migration.
> 
> diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> --- a/mercurial/revlog.py
> +++ b/mercurial/revlog.py
> @@ -76,5 +76,5 @@ CensoredNodeError = error.CensoredNodeEr
>  ProgrammingError = error.ProgrammingError
>  
> -# Store flag processors (cf. 'addflagprocessor()' to register)
> +# Store flag processors (cf. 'registerflagprocessor()' to register)
>  _flagprocessors = {
>      REVIDX_ISCENSORED: None,
> diff --git a/mercurial/verify.py b/mercurial/verify.py
> --- a/mercurial/verify.py
> +++ b/mercurial/verify.py
> @@ -408,5 +408,5 @@ class verifier(object):
>                  # L1 should be equal to L2. L3 could be different from them.
>                  # "text" may or may not affect commit hash depending on flag
> -                # processors (see revlog.addflagprocessor).
> +                # processors (see revlog.registerflagprocessor).
>                  #
>                  #              | common  | rename | meta  | ext
> diff --git a/tests/flagprocessorext.py b/tests/flagprocessorext.py
> --- a/tests/flagprocessorext.py
> +++ b/tests/flagprocessorext.py
> @@ -23,24 +23,18 @@ REVIDX_GZIP = (1 << 1)
>  REVIDX_FAIL = 1
>  
> -def validatehash(self, text):
> -    return True
> -
> -def bypass(self, text):
> -    return False
> -
>  def noopdonothing(self, text):
> -    return (text, True)
> +    return text
>  
>  def b64encode(self, text):
> -    return (base64.b64encode(text), False)
> +    return base64.b64encode(text)
>  
>  def b64decode(self, text):
> -    return (base64.b64decode(text), True)
> +    return base64.b64decode(text)
>  
>  def gzipcompress(self, text):
> -    return (zlib.compress(text), False)
> +    return zlib.compress(text)
>  
>  def gzipdecompress(self, text):
> -    return (zlib.decompress(text), True)
> +    return zlib.decompress(text)
>  
>  def supportedoutgoingversions(orig, repo):
> @@ -117,26 +111,17 @@ def extsetup(ui):
>  
>      # Register flag processors for each extension
> -    revlog.addflagprocessor(
> +    revlog.registerflagprocessor(
>          REVIDX_NOOP,
> -        (
> -            noopdonothing,
> -            noopdonothing,
> -            validatehash,
> -        )
> +        noopdonothing,
> +        noopdonothing,
>      )
> -    revlog.addflagprocessor(
> +    revlog.registerflagprocessor(
>          REVIDX_BASE64,
> -        (
> -            b64decode,
> -            b64encode,
> -            bypass,
> -        ),
> +        b64decode,
> +        b64encode,
>      )
> -    revlog.addflagprocessor(
> +    revlog.registerflagprocessor(
>          REVIDX_GZIP,
> -        (
> -            gzipdecompress,
> -            gzipcompress,
> -            bypass
> -        )
> +        gzipdecompress,
> +        gzipcompress,
>      )
> diff --git a/tests/test-revlog-raw.py b/tests/test-revlog-raw.py
> --- a/tests/test-revlog-raw.py
> +++ b/tests/test-revlog-raw.py
> @@ -38,18 +38,13 @@ def readprocessor(self, rawtext):
>      # True: the returned text could be used to verify hash
>      text = rawtext[len(_extheader):].replace(b'i', b'1')
> -    return text, True
> +    return text
>  
>  def writeprocessor(self, text):
>      # False: the returned rawtext shouldn't be used to verify hash
>      rawtext = _extheader + text.replace(b'1', b'i')
> -    return rawtext, False
> +    return rawtext
>  
> -def rawprocessor(self, rawtext):
> -    # False: do not verify hash. Only the content returned by "readprocessor"
> -    # can be used to verify hash.
> -    return False
> -
> -revlog.addflagprocessor(revlog.REVIDX_EXTSTORED,
> -                        (readprocessor, writeprocessor, rawprocessor))
> +revlog.registerflagprocessor(revlog.REVIDX_EXTSTORED, readprocessor,
> +                             writeprocessor)
>  
>  # Utilities about reading and appending revlog
> @@ -229,5 +224,5 @@ def writecases(rlog, tr):
>          # Verify text, rawtext, and rawsize
>          if isext:
> -            rawtext = writeprocessor(None, text)[0]
> +            rawtext = writeprocessor(None, text)
>          else:
>              rawtext = text
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to