From 4db1a045a0606bead191a563abc54dfa8352efe0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 29 Aug 2012 23:26:17 -0400 Subject: Rewrite commands to use bugdirs instead of a single bugdir. The bulk of the work is in regard to XML, with new BugDir.xml and .from_xml methods to support the new entity. I also split the guts import_xml's ._run method into sub-methods to make the import logic more obvious. --- libbe/command/new.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'libbe/command/new.py') diff --git a/libbe/command/new.py b/libbe/command/new.py index 725326e..5404271 100644 --- a/libbe/command/new.py +++ b/libbe/command/new.py @@ -95,6 +95,13 @@ class New (libbe.command.Command): arg=libbe.command.Argument( name='severity', metavar='SEVERITY', completion_callback=libbe.command.util.complete_severity)), + libbe.command.Option(name='bugdir', short_name='b', + help='Short bugdir UUID for the new bug. You ' + 'only need to set this if you have multiple bugdirs in ' + 'your repository.', + arg=libbe.command.Argument( + name='bugdir', metavar='ID', default=None, + completion_callback=libbe.command.util.complete_bugdir_id)), libbe.command.Option(name='full-uuid', short_name='f', help='Print the full UUID for the new bug') ]) @@ -107,8 +114,16 @@ class New (libbe.command.Command): summary = self.stdin.readline() else: summary = params['summary'] - bugdir = self._get_bugdir() - bugdir.storage.writeable = False + storage = self._get_storage() + bugdirs = self._get_bugdirs() + if params['bugdir']: + bugdir = bugdirs[bugdir] + elif len(bugdirs) == 1: + bugdir = bugdirs.values()[0] + else: + raise libbe.command.UserError( + 'Ambiguous bugdir {}'.format(sorted(bugdirs.values()))) + storage.writeable = False bug = bugdir.new_bug(summary=summary.strip()) if params['creator'] != None: bug.creator = params['creator'] @@ -124,7 +139,7 @@ class New (libbe.command.Command): bug.status = params['status'] if params['severity'] != None: bug.severity = params['severity'] - bugdir.storage.writeable = True + storage.writeable = True bug.save() if params['full-uuid']: bug_id = bug.id.long_user() -- cgit