changeset 21:e04729acf5be

allow bzconsole to implicitly get the product from the component for new bugs, if the component is unique
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 09 Dec 2010 15:25:00 -0800
parents c819c8388ad1
children 3b7f4104cd72
files bzconsole/api.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/bzconsole/api.py	Thu Dec 09 15:16:32 2010 -0800
+++ b/bzconsole/api.py	Thu Dec 09 15:25:00 2010 -0800
@@ -68,12 +68,18 @@
             del retval[d]
         return retval, dupe
 
-    def new(self, product, component, title, version=None, description=None):
+    def new(self, component, title, product=None,
+            version=None, description=None):
         """file a new bug. username and password must be set"""
 
         # sanity check
-        assert product in self.products(), "Product not found"
-        assert component in self.components(product), "Component not found"
+        if product:
+          assert product in self.products(), "Product not found"
+          assert component in self.components(product), "Component not found"
+        else:
+          unique, dupe = self._unique_components()
+          assert component in unique, 'Unique component not found: %s' % component
+          product = unique[component]
         assert title, 'Must provide a bug summary'
         assert self.username and self.password, "Must be authenticated"
 
@@ -81,7 +87,7 @@
         if version is None:
             version = 'unspecified'
         assert version in self._configuration['product'][product]['version'], 'Version not found'
-        
+
         # get the bug description
         if not description:
             description = tmpbuffer()