[python-bugzilla] [PATCH] modify: new option --dependson

Don Zickus dzickus at redhat.com
Mon Mar 11 21:25:57 UTC 2013


A lot of our bugs are collected into higher level bugzillas.  Having the
ability to add, remove, overwrite the --dependson field becomes necessary.

All the backend logic exists, just implement the front end logic.

The patch is pretty straightforward except for the duplicate code to handle
comma seperated lists.

The expected command is

bugzilla modify --dependons=123456,456789 987654

This would add bugs 123456 and 456789 to the depends on field for bz987654

Signed-off-by: Don Zickus <dzickus at redhat.com>
---
 bin/bugzilla |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/bin/bugzilla b/bin/bugzilla
index 3ec2be8..90282e8 100755
--- a/bin/bugzilla
+++ b/bin/bugzilla
@@ -279,6 +279,9 @@ def setup_action_parser(action):
                      '(Use a new option for each flag)')
         p.add_option('--cc', action='append',
                 help='Add an email to the cc list')
+        p.add_option('--dependson', metavar='BUGID[, BUGID, ...]',
+                help=('Alter depends_on list.  BUGID appends, '
+                     '-BUGID removes, =BUGID overwrites'))
         p.add_option('-F', '--fixed_in', metavar="VERSION",
                 help='"Fixed in version" field')
         p.add_option("", "--whiteboard", metavar="TEXT",
@@ -732,12 +735,32 @@ def _do_modify(bz, opt, args):
             add_val = val
         return add_val, rm_val, set_val
 
+    def parse_triset_list(val):
+        val = val or ""
+        add_val = None
+        rm_val = None
+        set_val = None
+
+        if val.startswith("+"):
+            add_val = val[1:].split(",")
+        elif val.startswith("-"):
+            rm_val = val[1:].split(",")
+        elif val.startswith("="):
+            set_val = val[1:].split(",")
+        else:
+            add_val = val.split(",")
+        return add_val, rm_val, set_val
+
     add_wb, rm_wb, set_wb = parse_triset(opt.whiteboard)
+    add_deps, rm_deps, set_deps = parse_triset_list(opt.dependson)
 
     update = bz.build_update(
         comment=opt.comment or None,
         comment_private=opt.private or None,
         cc_add=opt.cc and opt.cc[:] or None,
+        depends_on_add=add_deps or None,
+        depends_on_remove=rm_deps or None,
+        depends_on_set=set_deps or None,
         qa_contact=opt.qa_contact or None,
         assigned_to=opt.assignee or None,
         status=status,
@@ -966,7 +989,7 @@ def main(bzinstance=None):
         if not (opt.status or opt.close or
                 opt.assignee or opt.qa_contact or
                 opt.flag or opt.cc or opt.comment or
-                opt.fixed_in or opt.whiteboard):
+                opt.fixed_in or opt.whiteboard or opt.dependson):
             parser.error("'modify' command requires additional arguments")
 
         if not args:
-- 
1.7.1



More information about the python-bugzilla mailing list