##// END OF EJS Templates
errors: name arguments to UnknownCommand constructor...
errors: name arguments to UnknownCommand constructor Differential Revision: https://phab.mercurial-scm.org/D9166

File last commit:

r43346:2372284d default
r46272:bb1a988e default
Show More
flagprocessorext.py
149 lines | 3.6 KiB | text/x-python | PythonLexer
/ tests / flagprocessorext.py
Remi Chaintron
revlog: flag processor...
r30745 # coding=UTF-8
from __future__ import absolute_import
import base64
import zlib
from mercurial import (
changegroup,
Jun Wu
test-flagprocessor: use changegroup3 in bundle2...
r31832 exchange,
Remi Chaintron
revlog: flag processor...
r30745 extensions,
revlog,
util,
)
Augie Fackler
formatting: blacken the codebase...
r43346 from mercurial.revlogutils import flagutil
Remi Chaintron
revlog: flag processor...
r30745
# Test only: These flags are defined here only in the context of testing the
# behavior of the flag processor. The canonical way to add flags is to get in
# touch with the community and make them known in revlog.
Augie Fackler
formatting: blacken the codebase...
r43346 REVIDX_NOOP = 1 << 3
REVIDX_BASE64 = 1 << 2
REVIDX_GZIP = 1 << 1
Remi Chaintron
revlog: flag processor...
r30745 REVIDX_FAIL = 1
Augie Fackler
formatting: blacken the codebase...
r43346
Remi Chaintron
revlog: flag processor...
r30745 def validatehash(self, text):
return True
Augie Fackler
formatting: blacken the codebase...
r43346
Remi Chaintron
revlog: flag processor...
r30745 def bypass(self, text):
return False
Augie Fackler
formatting: blacken the codebase...
r43346
flagprocessors: writetransform function take side data as parameter (API)...
r43258 def noopdonothing(self, text, sidedata):
Remi Chaintron
revlog: flag processor...
r30745 return (text, True)
Augie Fackler
formatting: blacken the codebase...
r43346
flagprocessors: have the read transform function return side data (API)...
r43255 def noopdonothingread(self, text):
return (text, True, {})
Augie Fackler
formatting: blacken the codebase...
r43346
flagprocessors: writetransform function take side data as parameter (API)...
r43258 def b64encode(self, text, sidedata):
Remi Chaintron
revlog: flag processor...
r30745 return (base64.b64encode(text), False)
Augie Fackler
formatting: blacken the codebase...
r43346
Remi Chaintron
revlog: flag processor...
r30745 def b64decode(self, text):
flagprocessors: have the read transform function return side data (API)...
r43255 return (base64.b64decode(text), True, {})
Remi Chaintron
revlog: flag processor...
r30745
Augie Fackler
formatting: blacken the codebase...
r43346
flagprocessors: writetransform function take side data as parameter (API)...
r43258 def gzipcompress(self, text, sidedata):
Remi Chaintron
revlog: flag processor...
r30745 return (zlib.compress(text), False)
Augie Fackler
formatting: blacken the codebase...
r43346
Remi Chaintron
revlog: flag processor...
r30745 def gzipdecompress(self, text):
flagprocessors: have the read transform function return side data (API)...
r43255 return (zlib.decompress(text), True, {})
Remi Chaintron
revlog: flag processor...
r30745
Augie Fackler
formatting: blacken the codebase...
r43346
Remi Chaintron
revlog: flag processor...
r30745 def supportedoutgoingversions(orig, repo):
versions = orig(repo)
Gregory Szorc
py3: use b'' for changegroup version literals...
r36131 versions.discard(b'01')
versions.discard(b'02')
versions.add(b'03')
Remi Chaintron
revlog: flag processor...
r30745 return versions
Augie Fackler
formatting: blacken the codebase...
r43346
Remi Chaintron
revlog: flag processor...
r30745 def allsupportedversions(orig, ui):
versions = orig(ui)
Gregory Szorc
py3: use b'' for changegroup version literals...
r36131 versions.add(b'03')
Remi Chaintron
revlog: flag processor...
r30745 return versions
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
simplestore: correctly implement flag processors...
r37454 def makewrappedfile(obj):
class wrappedfile(obj.__class__):
Augie Fackler
formatting: blacken the codebase...
r43346 def addrevision(
self,
text,
transaction,
link,
p1,
p2,
cachedelta=None,
node=None,
flags=flagutil.REVIDX_DEFAULT_FLAGS,
):
Gregory Szorc
simplestore: correctly implement flag processors...
r37454 if b'[NOOP]' in text:
flags |= REVIDX_NOOP
Remi Chaintron
revlog: flag processor...
r30745
Gregory Szorc
simplestore: correctly implement flag processors...
r37454 if b'[BASE64]' in text:
flags |= REVIDX_BASE64
if b'[GZIP]' in text:
flags |= REVIDX_GZIP
Remi Chaintron
revlog: flag processor...
r30745
Gregory Szorc
simplestore: correctly implement flag processors...
r37454 # This addrevision wrapper is meant to add a flag we will not have
# transforms registered for, ensuring we handle this error case.
if b'[FAIL]' in text:
flags |= REVIDX_FAIL
Augie Fackler
formatting: blacken the codebase...
r43346 return super(wrappedfile, self).addrevision(
text,
transaction,
link,
p1,
p2,
cachedelta=cachedelta,
node=node,
flags=flags,
)
Remi Chaintron
revlog: flag processor...
r30745
Gregory Szorc
simplestore: correctly implement flag processors...
r37454 obj.__class__ = wrappedfile
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
simplestore: correctly implement flag processors...
r37454 def reposetup(ui, repo):
class wrappingflagprocessorrepo(repo.__class__):
def file(self, f):
orig = super(wrappingflagprocessorrepo, self).file(f)
makewrappedfile(orig)
return orig
repo.__class__ = wrappingflagprocessorrepo
Remi Chaintron
revlog: flag processor...
r30745
Augie Fackler
formatting: blacken the codebase...
r43346
Remi Chaintron
revlog: flag processor...
r30745 def extsetup(ui):
# Enable changegroup3 for flags to be sent over the wire
wrapfunction = extensions.wrapfunction
Augie Fackler
formatting: blacken the codebase...
r43346 wrapfunction(
changegroup, 'supportedoutgoingversions', supportedoutgoingversions
)
wrapfunction(changegroup, 'allsupportedversions', allsupportedversions)
Remi Chaintron
revlog: flag processor...
r30745
# Teach revlog about our test flags
flags = [REVIDX_NOOP, REVIDX_BASE64, REVIDX_GZIP, REVIDX_FAIL]
flagutil: move REVIDX_KNOWN_FLAGS source of truth in flagutil (API)...
r42956 flagutil.REVIDX_KNOWN_FLAGS |= util.bitsfrom(flags)
Remi Chaintron
revlog: flag processor...
r30745 revlog.REVIDX_FLAGS_ORDER.extend(flags)
Jun Wu
test-flagprocessor: use changegroup3 in bundle2...
r31832 # Teach exchange to use changegroup 3
Boris Feld
bundlespec: move computing the bundle contentops in parsebundlespec...
r37182 for k in exchange._bundlespeccontentopts.keys():
Gregory Szorc
tests: add b'' prefixes to flagprocessorext.py...
r41458 exchange._bundlespeccontentopts[k][b"cg.version"] = b"03"
Jun Wu
test-flagprocessor: use changegroup3 in bundle2...
r31832
Remi Chaintron
revlog: flag processor...
r30745 # Register flag processors for each extension
flagutil: move addflagprocessor to the new module (API)
r42958 flagutil.addflagprocessor(
Augie Fackler
formatting: blacken the codebase...
r43346 REVIDX_NOOP, (noopdonothingread, noopdonothing, validatehash,)
Remi Chaintron
revlog: flag processor...
r30745 )
flagutil: move addflagprocessor to the new module (API)
r42958 flagutil.addflagprocessor(
Augie Fackler
formatting: blacken the codebase...
r43346 REVIDX_BASE64, (b64decode, b64encode, bypass,),
Remi Chaintron
revlog: flag processor...
r30745 )
flagutil: move addflagprocessor to the new module (API)
r42958 flagutil.addflagprocessor(
Augie Fackler
formatting: blacken the codebase...
r43346 REVIDX_GZIP, (gzipdecompress, gzipcompress, bypass)
Remi Chaintron
revlog: flag processor...
r30745 )