##// END OF EJS Templates
wireproto: move gboptsmap to wireprototypes and rename (API)...
Gregory Szorc -
r37631:96d73560 default
parent child Browse files
Show More
@@ -27,7 +27,7 b' from mercurial import ('
27 narrowspec,
27 narrowspec,
28 repair,
28 repair,
29 util,
29 util,
30 wireproto,
30 wireprototypes,
31 )
31 )
32 from mercurial.utils import (
32 from mercurial.utils import (
33 stringutil,
33 stringutil,
@@ -461,13 +461,15 b' def setup():'
461 """Enable narrow repo support in bundle2-related extension points."""
461 """Enable narrow repo support in bundle2-related extension points."""
462 extensions.wrapfunction(bundle2, 'getrepocaps', getrepocaps_narrow)
462 extensions.wrapfunction(bundle2, 'getrepocaps', getrepocaps_narrow)
463
463
464 wireproto.gboptsmap['narrow'] = 'boolean'
464 getbundleargs = wireprototypes.GETBUNDLE_ARGUMENTS
465 wireproto.gboptsmap['depth'] = 'plain'
465
466 wireproto.gboptsmap['oldincludepats'] = 'csv'
466 getbundleargs['narrow'] = 'boolean'
467 wireproto.gboptsmap['oldexcludepats'] = 'csv'
467 getbundleargs['depth'] = 'plain'
468 wireproto.gboptsmap['includepats'] = 'csv'
468 getbundleargs['oldincludepats'] = 'csv'
469 wireproto.gboptsmap['excludepats'] = 'csv'
469 getbundleargs['oldexcludepats'] = 'csv'
470 wireproto.gboptsmap['known'] = 'csv'
470 getbundleargs['includepats'] = 'csv'
471 getbundleargs['excludepats'] = 'csv'
472 getbundleargs['known'] = 'csv'
471
473
472 # Extend changegroup serving to handle requests from narrow clients.
474 # Extend changegroup serving to handle requests from narrow clients.
473 origcgfn = exchange.getbundle2partsmapping['changegroup']
475 origcgfn = exchange.getbundle2partsmapping['changegroup']
@@ -145,29 +145,6 b' def clientcompressionsupport(proto):'
145 return cap[5:].split(',')
145 return cap[5:].split(',')
146 return ['zlib', 'none']
146 return ['zlib', 'none']
147
147
148 # mapping of options accepted by getbundle and their types
149 #
150 # Meant to be extended by extensions. It is extensions responsibility to ensure
151 # such options are properly processed in exchange.getbundle.
152 #
153 # supported types are:
154 #
155 # :nodes: list of binary nodes
156 # :csv: list of comma-separated values
157 # :scsv: list of comma-separated values return as set
158 # :plain: string with no transformation needed.
159 gboptsmap = {'heads': 'nodes',
160 'bookmarks': 'boolean',
161 'common': 'nodes',
162 'obsmarkers': 'boolean',
163 'phases': 'boolean',
164 'bundlecaps': 'scsv',
165 'listkeys': 'csv',
166 'cg': 'boolean',
167 'cbattempted': 'boolean',
168 'stream': 'boolean',
169 }
170
171 # client side
148 # client side
172
149
173 class wirepeer(repository.legacypeer):
150 class wirepeer(repository.legacypeer):
@@ -275,7 +252,7 b' class wirepeer(repository.legacypeer):'
275 for key, value in kwargs.iteritems():
252 for key, value in kwargs.iteritems():
276 if value is None:
253 if value is None:
277 continue
254 continue
278 keytype = gboptsmap.get(key)
255 keytype = wireprototypes.GETBUNDLE_ARGUMENTS.get(key)
279 if keytype is None:
256 if keytype is None:
280 raise error.ProgrammingError(
257 raise error.ProgrammingError(
281 'Unexpectedly None keytype for key %s' % key)
258 'Unexpectedly None keytype for key %s' % key)
@@ -1004,9 +981,10 b' def find_pullbundle(repo, proto, opts, c'
1004 @wireprotocommand('getbundle', '*', permission='pull',
981 @wireprotocommand('getbundle', '*', permission='pull',
1005 transportpolicy=POLICY_V1_ONLY)
982 transportpolicy=POLICY_V1_ONLY)
1006 def getbundle(repo, proto, others):
983 def getbundle(repo, proto, others):
1007 opts = options('getbundle', gboptsmap.keys(), others)
984 opts = options('getbundle', wireprototypes.GETBUNDLE_ARGUMENTS.keys(),
985 others)
1008 for k, v in opts.iteritems():
986 for k, v in opts.iteritems():
1009 keytype = gboptsmap[k]
987 keytype = wireprototypes.GETBUNDLE_ARGUMENTS[k]
1010 if keytype == 'nodes':
988 if keytype == 'nodes':
1011 opts[k] = wireprototypes.decodelist(v)
989 opts[k] = wireprototypes.decodelist(v)
1012 elif keytype == 'csv':
990 elif keytype == 'csv':
@@ -134,6 +134,30 b' def unescapebatcharg(escaped):'
134 .replace(':o', ',')
134 .replace(':o', ',')
135 .replace(':c', ':'))
135 .replace(':c', ':'))
136
136
137 # mapping of options accepted by getbundle and their types
138 #
139 # Meant to be extended by extensions. It is extensions responsibility to ensure
140 # such options are properly processed in exchange.getbundle.
141 #
142 # supported types are:
143 #
144 # :nodes: list of binary nodes
145 # :csv: list of comma-separated values
146 # :scsv: list of comma-separated values return as set
147 # :plain: string with no transformation needed.
148 GETBUNDLE_ARGUMENTS = {
149 'heads': 'nodes',
150 'bookmarks': 'boolean',
151 'common': 'nodes',
152 'obsmarkers': 'boolean',
153 'phases': 'boolean',
154 'bundlecaps': 'scsv',
155 'listkeys': 'csv',
156 'cg': 'boolean',
157 'cbattempted': 'boolean',
158 'stream': 'boolean',
159 }
160
137 class baseprotocolhandler(zi.Interface):
161 class baseprotocolhandler(zi.Interface):
138 """Abstract base class for wire protocol handlers.
162 """Abstract base class for wire protocol handlers.
139
163
General Comments 0
You need to be logged in to leave comments. Login now