diff options
author | W. Trevor King <wking@tremily.us> | 2012-08-29 23:26:17 -0400 |
---|---|---|
committer | W. Trevor King <wking@tremily.us> | 2012-08-29 23:31:03 -0400 |
commit | 4db1a045a0606bead191a563abc54dfa8352efe0 (patch) | |
tree | 51c891d731555340ffd4432cd889fb67795ae1b6 /libbe/command/new.py | |
parent | 5a32d82284e54facf2f5dcb03ba37afe3805a609 (diff) | |
download | bugseverywhere-4db1a045a0606bead191a563abc54dfa8352efe0.tar.gz |
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 <bugdir> entity. I also split
the guts import_xml's ._run method into sub-methods to make the import
logic more obvious.
Diffstat (limited to 'libbe/command/new.py')
-rw-r--r-- | libbe/command/new.py | 21 |
1 files changed, 18 insertions, 3 deletions
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() |