@@ -304,142 +304,42 @@ def post_translation(self, query, bug):
304304 values += vallist
305305 bug ['sub_component' ] = " " .join (values )
306306
307- def build_external_tracker_boolean_query (
308- self , ext_type_description = None , ext_type_url = None ,
309- ext_bz_bug_id = None , ext_status = None ):
310- """
311- Helper method to build a boolean query to find bugs that contain an
312- external tracker.
313-
314- All parameters that are None will be ignored when building the query.
315-
316- ext_type_description: The external tracker description as used by
317- Bugzilla.
318- ext_type_url: The external tracker url as used by Bugzilla.
319- ext_bz_bug_id: The external bug id (ie: the bug number in the
320- external tracker).
321- ext_status: The status of the external bug.
322- """
323- parts = []
307+ def build_external_tracker_boolean_query (self , * args , ** kwargs ):
308+ ignore1 = args
309+ ignore2 = kwargs
310+ raise RuntimeError ("Building external boolean queries is "
311+ "no longer supported. Please build a URL query "
312+ "via the bugzilla web UI and pass it to 'query --from-url' "
313+ "or url_to_query()" )
324314
325- if ext_type_description is not None :
326- parts .append (
327- 'external_bugzilla.description-equals-{0:s}' .format (
328- ext_type_description ))
329-
330- if ext_type_url is not None :
331- parts .append (
332- 'external_bugzilla.url-equals-{0:s}' .format (ext_type_url ))
333-
334- if ext_bz_bug_id is not None :
335- id_str = str (ext_bz_bug_id )
336- parts .append (
337- 'ext_bz_bug_map.ext_bz_bug_id-equals-{0:s}' .format (id_str ))
338-
339- if ext_status is not None :
340- parts .append (
341- 'ext_bz_bug_map.ext_status-equals-{0:s}' .format (ext_status ))
342-
343- return ' & ' .join (parts )
344315
345316 def build_query (self , ** kwargs ):
346- query = {}
347-
348- def _add_key (paramname , keyname , listify = False ):
349- val = kwargs .pop (paramname , None )
350- if val is None :
351- return
352- if listify :
353- val = self ._listify (val )
354- query [keyname ] = val
355-
356- def bool_smart_split (boolval ):
357- # This parses the CLI command syntax, but we only want to
358- # do space splitting if the space is actually part of a
359- # boolean operator
360- boolchars = ["|" , "&" , "!" ]
361- add = ""
362- retlist = []
363-
364- for word in boolval .split (" " ):
365- if word .strip () in boolchars :
366- word = word .strip ()
367- if add :
368- retlist .append (add )
369- add = ""
370- retlist .append (word )
371- else :
372- if add :
373- add += " "
374- add += word
375-
376- if add :
377- retlist .append (add )
378- return retlist
379-
380- def add_boolean (kwkey , key , bool_id ):
381- value = self ._listify (kwargs .pop (kwkey , None ))
382- if value is None :
383- return bool_id
384-
385- query ["query_format" ] = "advanced"
386- for boolval in value :
387- and_count = 0
388- or_count = 0
389-
390- def make_bool_str (prefix ):
391- # pylint: disable=cell-var-from-loop
392- return "%s%i-%i-%i" % (prefix , bool_id ,
393- and_count , or_count )
394-
395- for par in bool_smart_split (boolval ):
396- field = None
397- fval = par
398- typ = kwargs .get ("booleantype" , "substring" )
399-
400- if par == "&" :
401- and_count += 1
402- elif par == "|" :
403- or_count += 1
404- elif par == "!" :
405- query ['negate%i' % bool_id ] = 1
406- elif not key :
407- if par .find ('-' ) == - 1 :
408- raise RuntimeError ('Malformed boolean query: %s' %
409- value )
410-
411- args = par .split ('-' , 2 )
412- field = args [0 ]
413- typ = args [1 ]
414- fval = None
415- if len (args ) == 3 :
416- fval = args [2 ]
417- else :
418- field = key
419-
420- query [make_bool_str ("field" )] = field
421- if fval :
422- query [make_bool_str ("value" )] = fval
423- query [make_bool_str ("type" )] = typ
424-
425- bool_id += 1
426- return bool_id
427-
428- # Use fancy email specification for RH bugzilla. It isn't
429- # strictly required, but is more powerful, and it is what
430- # bin/bugzilla historically generated. This requires
431- # query_format='advanced' which is an RHBZ only XMLRPC extension
432-
433- chart_id = 0
434- chart_id = add_boolean ("fixed_in" , "cf_fixed_in" , chart_id )
435- chart_id = add_boolean ("blocked" , "blocked" , chart_id )
436- chart_id = add_boolean ("dependson" , "dependson" , chart_id )
437- chart_id = add_boolean ("flag" , "flagtypes.name" , chart_id )
438- chart_id = add_boolean ("qa_whiteboard" , "cf_qa_whiteboard" , chart_id )
439- chart_id = add_boolean ("devel_whiteboard" , "cf_devel_whiteboard" ,
440- chart_id )
441- chart_id = add_boolean ("alias" , "alias" , chart_id )
317+ # We previously accepted a text format to approximate boolean
318+ # queries, and only for RHBugzilla. Upstream bz has --from-url
319+ # support now, so point people to that instead so we don't have
320+ # to document and maintain this logic anymore
321+ def _warn_bool (kwkey ):
322+ vallist = self ._listify (kwargs .get (kwkey , None ))
323+ for value in vallist or []:
324+ for s in value .split (" " ):
325+ if s not in ["|" , "&" , "!" ]:
326+ continue
327+ log .warn ("%s value '%s' appears to use the now "
328+ "unsupported boolean formatting, your query may "
329+ "be incorrect. If you need complicated URL queries, "
330+ "look into bugzilla --from-url/url_to_query()." ,
331+ kwkey , value )
332+ return
333+
334+ _warn_bool ("fixed_in" )
335+ _warn_bool ("blocked" )
336+ _warn_bool ("dependson" )
337+ _warn_bool ("flag" )
338+ _warn_bool ("qa_whiteboard" )
339+ _warn_bool ("devel_whiteboard" )
340+ _warn_bool ("alias" )
442341
342+ query = {}
443343 query .update (self ._process_include_fields (None , None ,
444344 kwargs .pop ('extra_fields' , None )))
445345
0 commit comments