Bug 966420 - Prefer using :: to separate Product :: Component, r=jdm
authorSteve Fink <sfink@mozilla.com>
Sat, 01 Feb 2014 12:13:11 -0800
changeset 133 ff9678ca0c74
parent 132 f1b2724ebc97
child 134 b2e26e4759bc
push id63
push usersfink@mozilla.com
push dateSat, 01 Feb 2014 20:13:33 +0000
reviewersjdm
bugs966420
Bug 966420 - Prefer using :: to separate Product :: Component, r=jdm
__init__.py
--- a/__init__.py
+++ b/__init__.py
@@ -466,25 +466,32 @@ def choose_prodcomponent(ui, cache, orig
                 products.append(p)
         return products
 
     # Tricky case: components can legitimately contain '/'. If the user
     # specified such a component with no product, then we will have generated a
     # bogus list of candidate products and a bogus list of candidate components
     # (one of which is the correct one, since it contains the substring.)
     # Restrict to just that component.
+    #
+    # Note that using a '/' as a separator is deprecated. If you use '::',
+    # there is no ambiguity.
     if component and not product:
+        doublecolon = component.find('::')
         slash = component.find('/')
-        if slash != -1:
+        if doublecolon != -1:
+            product = component[0:doublecolon].rstrip()
+            component = component[doublecolon + 2:].lstrip()
+        elif slash != -1:
             all_components = set()
             for p in all_products:
                 all_components.update(products_info[p]['component'].keys())
             if component.lower() not in [ c.lower() for c in all_components ]:
-                product = component[0:slash]
-                component = component[slash + 1:]
+                product = component[0:slash].rstrip()
+                component = component[slash + 1:].lstrip()
 
     # 'products' and 'components' will be the set of valid products/components
     # remaining after filtering by the 'product' and 'component' passed in
     products = all_products
     components = set()
 
     if product is None:
         if component is None:
@@ -500,17 +507,17 @@ def choose_prodcomponent(ui, cache, orig
     else:
         products = filter_strings(all_products, product)
 
     for p in products:
         components.update(products_info[p]['component'].keys())
     if component is not None:
         components = filter_strings(components, component)
 
-    # Now choose a final product/component (unless finalize is false, in which
+    # Now choose a final product::component (unless finalize is false, in which
     # case if there are multiple possibilities, the passed-in value will be
     # preserved)
 
     if len(products) == 0:
         product = None
     elif len(products) == 1:
         product = products.pop()
     else:
@@ -682,17 +689,17 @@ def find_reviewers(ui, api_server, user_
 def flag_type_id(ui, api_server, config_cache_filename, flag_name, product, component):
     """
     Look up the numeric type id for the 'review' flag from the given bugzilla server
     """
     configuration = bzauth.load_configuration(ui, api_server, config_cache_filename)
     if not configuration or not configuration["flag_type"]:
         raise util.Abort(_("Could not find configuration object"))
 
-    # Get the set of flag ids used for this product/component
+    # Get the set of flag ids used for this product::component
     prodflags = configuration['product'][product]['component'][component]['flag_type']
     flagdefs = configuration['flag_type']
 
     flag_ids = [ id for id in prodflags if flagdefs[str(id)]['name'] == flag_name ]
 
     if len(flag_ids) != 1:
         raise util.Abort(_("Could not find unique %s flag id") % flag_name)
 
@@ -907,17 +914,17 @@ def bzexport(ui, repo, *args, **opts):
             filename = values['ATTACHMENT_FILENAME']
 
     values = fill_values(values, ui, api_server, finalize=True)
 
     if opts["new"]:
         if bug is not None:
             raise util.Abort("Bug %s given but creation of new bug requested!" % bug)
 
-        if opts['interactive'] and ui.prompt(_("Create bug in '%s'/'%s' (y/n)?") % (values['PRODUCT'], values['COMPONENT'])) != 'y':
+        if opts['interactive'] and ui.prompt(_("Create bug in '%s' :: '%s' (y/n)?") % (values['PRODUCT'], values['COMPONENT'])) != 'y':
             ui.write(_("Exiting without creating bug\n"))
             return
 
         try:
             create_opts = {}
             if not opts['no_take_bug']:
                 create_opts['assign_to'] = auth.username(api_server)
             req = bz.create_bug(api_server, auth,
@@ -1037,17 +1044,17 @@ def newbug(ui, repo, *args, **opts):
 
     The -e option brings up an editor that will allow editing all handled
     fields of the bug.
 
     The product and/or component given on the command line or the edited form
     may be case-insensitive substrings rather than exact matches of valid
     values. Ambiguous matches will be resolved with a menu. The -C
     (--component) option may be used to set both the product and component by
-    separating them with a forward slash ('/'), though usually just giving the
+    separating them with a double colon ('::'), though usually just giving the
     component should be sufficient.
     """
     auth, api_server, bugzilla = bugzilla_info(ui, opts.get('ffprofile'))
 
     if args:
         args = list(args)
 
     if args and not opts['title']:
@@ -1076,17 +1083,17 @@ def newbug(ui, repo, *args, **opts):
 
     fill_values(values, ui, api_server, finalize=True)
 
     cc = validate_users(ui, api_server, auth, values['CC'], multi_user_prompt, 'reviewer')
     if cc is None:
         raise util.Abort("Invalid users")
     cc = select_users(cc, values['CC'])
 
-    if opts['interactive'] and ui.prompt(_("Create bug in '%s'/'%s' (y/n)?") % (values['PRODUCT'], values['COMPONENT'])) != 'y':
+    if opts['interactive'] and ui.prompt(_("Create bug in '%s' :: '%s' (y/n)?") % (values['PRODUCT'], values['COMPONENT'])) != 'y':
         ui.write(_("Exiting without creating bug\n"))
         return
 
     create_opts = {}
     if opts['take_bug']:
         create_opts['assign_to'] = auth.username(api_server)
 
     req = bz.create_bug(api_server, auth,