Mercurial > hg-stable
changeset 37613:96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
This is also shared between client and server and will need to
exist in a shared module when that code is split into different
modules.
Differential Revision: https://phab.mercurial-scm.org/D3258
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 11 Apr 2018 10:51:38 -0700 |
parents | 5e71dea79aae |
children | a81d02ea65db |
files | hgext/narrow/narrowbundle2.py mercurial/wireproto.py mercurial/wireprototypes.py |
diffstat | 3 files changed, 38 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/narrow/narrowbundle2.py Wed Apr 11 10:50:58 2018 -0700 +++ b/hgext/narrow/narrowbundle2.py Wed Apr 11 10:51:38 2018 -0700 @@ -27,7 +27,7 @@ narrowspec, repair, util, - wireproto, + wireprototypes, ) from mercurial.utils import ( stringutil, @@ -461,13 +461,15 @@ """Enable narrow repo support in bundle2-related extension points.""" extensions.wrapfunction(bundle2, 'getrepocaps', getrepocaps_narrow) - wireproto.gboptsmap['narrow'] = 'boolean' - wireproto.gboptsmap['depth'] = 'plain' - wireproto.gboptsmap['oldincludepats'] = 'csv' - wireproto.gboptsmap['oldexcludepats'] = 'csv' - wireproto.gboptsmap['includepats'] = 'csv' - wireproto.gboptsmap['excludepats'] = 'csv' - wireproto.gboptsmap['known'] = 'csv' + getbundleargs = wireprototypes.GETBUNDLE_ARGUMENTS + + getbundleargs['narrow'] = 'boolean' + getbundleargs['depth'] = 'plain' + getbundleargs['oldincludepats'] = 'csv' + getbundleargs['oldexcludepats'] = 'csv' + getbundleargs['includepats'] = 'csv' + getbundleargs['excludepats'] = 'csv' + getbundleargs['known'] = 'csv' # Extend changegroup serving to handle requests from narrow clients. origcgfn = exchange.getbundle2partsmapping['changegroup']
--- a/mercurial/wireproto.py Wed Apr 11 10:50:58 2018 -0700 +++ b/mercurial/wireproto.py Wed Apr 11 10:51:38 2018 -0700 @@ -145,29 +145,6 @@ return cap[5:].split(',') return ['zlib', 'none'] -# mapping of options accepted by getbundle and their types -# -# Meant to be extended by extensions. It is extensions responsibility to ensure -# such options are properly processed in exchange.getbundle. -# -# supported types are: -# -# :nodes: list of binary nodes -# :csv: list of comma-separated values -# :scsv: list of comma-separated values return as set -# :plain: string with no transformation needed. -gboptsmap = {'heads': 'nodes', - 'bookmarks': 'boolean', - 'common': 'nodes', - 'obsmarkers': 'boolean', - 'phases': 'boolean', - 'bundlecaps': 'scsv', - 'listkeys': 'csv', - 'cg': 'boolean', - 'cbattempted': 'boolean', - 'stream': 'boolean', -} - # client side class wirepeer(repository.legacypeer): @@ -275,7 +252,7 @@ for key, value in kwargs.iteritems(): if value is None: continue - keytype = gboptsmap.get(key) + keytype = wireprototypes.GETBUNDLE_ARGUMENTS.get(key) if keytype is None: raise error.ProgrammingError( 'Unexpectedly None keytype for key %s' % key) @@ -1004,9 +981,10 @@ @wireprotocommand('getbundle', '*', permission='pull', transportpolicy=POLICY_V1_ONLY) def getbundle(repo, proto, others): - opts = options('getbundle', gboptsmap.keys(), others) + opts = options('getbundle', wireprototypes.GETBUNDLE_ARGUMENTS.keys(), + others) for k, v in opts.iteritems(): - keytype = gboptsmap[k] + keytype = wireprototypes.GETBUNDLE_ARGUMENTS[k] if keytype == 'nodes': opts[k] = wireprototypes.decodelist(v) elif keytype == 'csv':
--- a/mercurial/wireprototypes.py Wed Apr 11 10:50:58 2018 -0700 +++ b/mercurial/wireprototypes.py Wed Apr 11 10:51:38 2018 -0700 @@ -134,6 +134,30 @@ .replace(':o', ',') .replace(':c', ':')) +# mapping of options accepted by getbundle and their types +# +# Meant to be extended by extensions. It is extensions responsibility to ensure +# such options are properly processed in exchange.getbundle. +# +# supported types are: +# +# :nodes: list of binary nodes +# :csv: list of comma-separated values +# :scsv: list of comma-separated values return as set +# :plain: string with no transformation needed. +GETBUNDLE_ARGUMENTS = { + 'heads': 'nodes', + 'bookmarks': 'boolean', + 'common': 'nodes', + 'obsmarkers': 'boolean', + 'phases': 'boolean', + 'bundlecaps': 'scsv', + 'listkeys': 'csv', + 'cg': 'boolean', + 'cbattempted': 'boolean', + 'stream': 'boolean', +} + class baseprotocolhandler(zi.Interface): """Abstract base class for wire protocol handlers.