##// END OF EJS Templates
branching: merge default into stable...
branching: merge default into stable This mark the start of the 5.9 freeze.

File last commit:

r48186:ac60a136 default
r48559:d7515d29 merge 5.9rc0 stable
Show More
flagprocessorext.py
161 lines | 3.8 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 (
clonebundles: move a bundle of clone bundle related code to a new module...
r46369 bundlecaches,
Remi Chaintron
revlog: flag processor...
r30745 changegroup,
extensions,
revlog,
util,
)
Augie Fackler
formatting: blacken the codebase...
r43346 from mercurial.revlogutils import flagutil
revlog: move `offset_type` to `revlogutils`...
r48186 from mercurial.interfaces import repository
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
Raphaël Gomès
sidedata: move to new sidedata storage in revlogv2...
r47443 def noopdonothing(self, text):
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):
Raphaël Gomès
sidedata: move to new sidedata storage in revlogv2...
r47443 return (text, True)
flagprocessors: have the read transform function return side data (API)...
r43255
Augie Fackler
formatting: blacken the codebase...
r43346
Raphaël Gomès
sidedata: move to new sidedata storage in revlogv2...
r47443 def b64encode(self, text):
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):
Raphaël Gomès
sidedata: move to new sidedata storage in revlogv2...
r47443 return (base64.b64decode(text), True)
Remi Chaintron
revlog: flag processor...
r30745
Augie Fackler
formatting: blacken the codebase...
r43346
Raphaël Gomès
sidedata: move to new sidedata storage in revlogv2...
r47443 def gzipcompress(self, text):
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):
Raphaël Gomès
sidedata: move to new sidedata storage in revlogv2...
r47443 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)
revlog: move `offset_type` to `revlogutils`...
r48186 repository.REVISION_FLAGS_KNOWN |= 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
clonebundles: move a bundle of clone bundle related code to a new module...
r46369 for k in bundlecaches._bundlespeccontentopts.keys():
bundlecaches._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
formating: upgrade to black 20.8b1...
r46554 REVIDX_NOOP,
(
noopdonothingread,
noopdonothing,
validatehash,
),
Remi Chaintron
revlog: flag processor...
r30745 )
flagutil: move addflagprocessor to the new module (API)
r42958 flagutil.addflagprocessor(
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 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 )