@@ -346,7 +346,7 @@ def _setup_action_info_parser(subparsers):
346346 "bugzilla server." )
347347 p = subparsers .add_parser ("info" , description = description )
348348
349- x = p .add_mutually_exclusive_group ()
349+ x = p .add_mutually_exclusive_group (required = True )
350350 x .add_argument ('-p' , '--products' , action = 'store_true' ,
351351 help = 'Get a list of products' )
352352 x .add_argument ('-c' , '--components' , metavar = "PRODUCT" ,
@@ -355,6 +355,9 @@ def _setup_action_info_parser(subparsers):
355355 help = 'List components (and their owners)' )
356356 x .add_argument ('-v' , '--versions' , metavar = "PRODUCT" ,
357357 help = 'List the versions for the given product' )
358+ p .add_argument ('--active-components' , action = "store_true" ,
359+ help = 'Only show active components. Combine with --components*' )
360+
358361
359362
360363def _setup_action_modify_parser (subparsers ):
@@ -581,15 +584,26 @@ def _do_info(bz, opt):
581584 """
582585 # All these commands call getproducts internally, so do it up front
583586 # with minimal include_fields for speed
587+ def _filter_components (compdetails ):
588+ ret = {}
589+ for k , v in compdetails .items ():
590+ if v .get ("is_active" , True ):
591+ ret [k ] = v
592+ return ret
593+
584594 productname = (opt .components or opt .component_owners or opt .versions )
585595 include_fields = ["name" , "id" ]
596+ fastcomponents = (opt .components and not opt .active_components )
586597 if opt .versions :
587- include_fields . append ( "versions" )
598+ include_fields += [ "versions" ]
588599 if opt .component_owners :
589600 include_fields += [
590601 "components.default_assigned_to" ,
591602 "components.name" ,
592603 ]
604+ if (opt .active_components and
605+ any (["components" in i for i in include_fields ])):
606+ include_fields += ["components.is_active" ]
593607
594608 bz .refresh_products (names = productname and [productname ] or None ,
595609 include_fields = include_fields )
@@ -598,20 +612,25 @@ def _do_info(bz, opt):
598612 for name in sorted ([p ["name" ] for p in bz .getproducts ()]):
599613 print (name )
600614
601- elif opt . components :
615+ elif fastcomponents :
602616 for name in sorted (bz .getcomponents (productname )):
603617 print (name )
604618
619+ elif opt .components :
620+ details = bz .getcomponentsdetails (productname )
621+ for name in sorted (_filter_components (details )):
622+ print (name )
623+
605624 elif opt .versions :
606625 proddict = bz .getproducts ()[0 ]
607626 for v in proddict ['versions' ]:
608627 print (to_encoding (v ["name" ]))
609628
610629 elif opt .component_owners :
611- component_details = bz .getcomponentsdetails (productname )
612- for c in sorted (component_details ):
630+ details = bz .getcomponentsdetails (productname )
631+ for c in sorted (_filter_components ( details ) ):
613632 print (to_encoding (u"%s: %s" % (c ,
614- component_details [c ]['default_assigned_to' ])))
633+ details [c ]['default_assigned_to' ])))
615634
616635
617636def _convert_to_outputformat (output ):
0 commit comments