diff options
author | W. Trevor King <wking@drexel.edu> | 2008-11-24 18:29:16 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2008-11-24 18:29:16 -0500 |
commit | a711ecf10df62e30d83c1941065404c53fecd35b (patch) | |
tree | 4111ef606fa52dc7f21ca3eb357ff83fae74fe1e /becommands | |
parent | c5d7551e6a6e98bb6da7c7d11360224edfda2f14 (diff) | |
parent | 2c3f6c066ceb03ae3579dff029bf01f0b62c1f82 (diff) | |
download | bugseverywhere-a711ecf10df62e30d83c1941065404c53fecd35b.tar.gz |
Merge from W. Trevor King's tree.
Diffstat (limited to 'becommands')
-rw-r--r-- | becommands/assign.py | 39 | ||||
-rw-r--r-- | becommands/close.py | 34 | ||||
-rw-r--r-- | becommands/comment.py | 74 | ||||
-rw-r--r-- | becommands/diff.py | 45 | ||||
-rw-r--r-- | becommands/help.py | 5 | ||||
-rw-r--r-- | becommands/list.py | 219 | ||||
-rw-r--r-- | becommands/new.py | 29 | ||||
-rw-r--r-- | becommands/open.py | 29 | ||||
-rw-r--r-- | becommands/remove.py (renamed from becommands/inprogress.py) | 45 | ||||
-rw-r--r-- | becommands/set.py | 37 | ||||
-rw-r--r-- | becommands/set_root.py | 60 | ||||
-rw-r--r-- | becommands/severity.py | 40 | ||||
-rw-r--r-- | becommands/show.py | 45 | ||||
-rw-r--r-- | becommands/status.py | 73 | ||||
-rw-r--r-- | becommands/target.py | 18 | ||||
-rw-r--r-- | becommands/template | 21 | ||||
-rw-r--r-- | becommands/upgrade.py | 111 |
17 files changed, 513 insertions, 411 deletions
diff --git a/becommands/assign.py b/becommands/assign.py index 38ece52..cb732b3 100644 --- a/becommands/assign.py +++ b/becommands/assign.py @@ -15,45 +15,52 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Assign an individual or group to fix a bug""" -from libbe import bugdir, cmdutil, names +from libbe import cmdutil, bugdir __desc__ = __doc__ def execute(args): """ - >>> from libbe import tests, names >>> import os - >>> dir = tests.simple_bug_dir() - >>> os.chdir(dir.dir) - >>> dir.get_bug("a").assigned is None + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) + >>> bd.bug_from_shortname("a").assigned is None True + >>> execute(["a"]) - >>> dir.get_bug("a").assigned == names.creator() + >>> bd._clear_bugs() + >>> bd.bug_from_shortname("a").assigned == bd.user_id True + >>> execute(["a", "someone"]) - >>> dir.get_bug("a").assigned - u'someone' + >>> bd._clear_bugs() + >>> print bd.bug_from_shortname("a").assigned + someone + >>> execute(["a","none"]) - >>> dir.get_bug("a").assigned is None + >>> bd._clear_bugs() + >>> bd.bug_from_shortname("a").assigned is None True - >>> tests.clean_up() """ options, args = get_parser().parse_args(args) assert(len(args) in (0, 1, 2)) if len(args) == 0: - print help() - return - bug = cmdutil.get_bug(args[0]) + raise cmdutil.UserError("Please specify a bug id.") + if len(args) > 2: + help() + raise cmdutil.UserError("Too many arguments.") + bd = bugdir.BugDir(from_disk=True) + bug = bd.bug_from_shortname(args[0]) if len(args) == 1: - bug.assigned = names.creator() + bug.assigned = bd.user_id elif len(args) == 2: if args[1] == "none": bug.assigned = None else: bug.assigned = args[1] - bug.save() + bd.save() def get_parser(): - parser = cmdutil.CmdOptionParser("be assign bug-id [assignee]") + parser = cmdutil.CmdOptionParser("be assign BUG-ID [ASSIGNEE]") return parser longhelp = """ diff --git a/becommands/close.py b/becommands/close.py index 52ab735..8d2ccdb 100644 --- a/becommands/close.py +++ b/becommands/close.py @@ -15,33 +15,39 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Close a bug""" -from libbe import cmdutil +from libbe import cmdutil, bugdir +__desc__ = __doc__ + def execute(args): """ - >>> from libbe import tests + >>> from libbe import bugdir >>> import os - >>> dir = tests.simple_bug_dir() - >>> os.chdir(dir.dir) - >>> dir.get_bug("a").status - u'open' + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) + >>> print bd.bug_from_shortname("a").status + open >>> execute(["a"]) - >>> dir.get_bug("a").status - u'closed' - >>> tests.clean_up() + >>> bd._clear_bugs() + >>> print bd.bug_from_shortname("a").status + closed """ options, args = get_parser().parse_args(args) - if len(args) !=1: + if len(args) == 0: raise cmdutil.UserError("Please specify a bug id.") - bug = cmdutil.get_bug(args[0]) + if len(args) > 1: + help() + raise cmdutil.UserError("Too many arguments.") + bd = bugdir.BugDir(from_disk=True) + bug = bd.bug_from_shortname(args[0]) bug.status = "closed" - bug.save() + bd.save() def get_parser(): - parser = cmdutil.CmdOptionParser("be close bug-id") + parser = cmdutil.CmdOptionParser("be close BUG-ID") return parser longhelp=""" -Close the bug identified by bug-id. +Close the bug identified by BUG-ID. """ def help(): diff --git a/becommands/comment.py b/becommands/comment.py index e3a1d93..172f818 100644 --- a/becommands/comment.py +++ b/becommands/comment.py @@ -15,39 +15,72 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Add a comment to a bug""" -from libbe import bugdir, cmdutil, names, utility +from libbe import cmdutil, bugdir, utility import os +__desc__ = __doc__ + def execute(args): """ - >>> from libbe import tests, names - >>> import os, time - >>> dir = tests.simple_bug_dir() - >>> os.chdir(dir.dir) + >>> import time + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) >>> execute(["a", "This is a comment about a"]) - >>> comment = dir.get_bug("a").list_comments()[0] - >>> comment.body - u'This is a comment about a\\n' - >>> comment.From == names.creator() + >>> bd._clear_bugs() + >>> bug = bd.bug_from_shortname("a") + >>> bug.load_comments() + >>> comment = bug.comment_root[0] + >>> print comment.body + This is a comment about a + <BLANKLINE> + >>> comment.From == bd.user_id True - >>> comment.date <= int(time.time()) + >>> comment.time <= int(time.time()) True >>> comment.in_reply_to is None True + >>> if 'EDITOR' in os.environ: ... del os.environ["EDITOR"] >>> execute(["b"]) Traceback (most recent call last): UserError: No comment supplied, and EDITOR not specified. + >>> os.environ["EDITOR"] = "echo 'I like cheese' > " >>> execute(["b"]) - >>> dir.get_bug("b").list_comments()[0].body - u'I like cheese\\n' - >>> tests.clean_up() + >>> bd._clear_bugs() + >>> bug = bd.bug_from_shortname("b") + >>> bug.load_comments() + >>> comment = bug.comment_root[0] + >>> print comment.body + I like cheese + <BLANKLINE> """ options, args = get_parser().parse_args(args) - if len(args) < 1: - raise cmdutil.UsageError() - bug, parent_comment = cmdutil.get_bug_and_comment(args[0]) + if len(args) == 0: + raise cmdutil.UserError("Please specify a bug or comment id.") + if len(args) > 2: + help() + raise cmdutil.UserError("Too many arguments.") + + shortname = args[0] + if shortname.count(':') > 1: + raise cmdutil.UserError("Invalid id '%s'." % shortname) + elif shortname.count(':') == 1: + # Split shortname generated by Comment.comment_shortnames() + bugname = shortname.split(':')[0] + is_reply = True + else: + bugname = shortname + is_reply = False + + bd = bugdir.BugDir(from_disk=True) + bug = bd.bug_from_shortname(bugname) + bug.load_comments() + if is_reply: + parent = bug.comment_root.comment_from_shortname(shortname, bug_shortname=bugname) + else: + parent = bug.comment_root + if len(args) == 1: try: body = utility.editor_string("Please enter your comment above") @@ -61,12 +94,9 @@ def execute(args): body = args[1] if not body.endswith('\n'): body+='\n' - - comment = bugdir.new_comment(bug, body) - if parent_comment is not None: - comment.in_reply_to = parent_comment.uuid - comment.save() - + + comment = parent.new_reply(body=body) + bd.save() def get_parser(): parser = cmdutil.CmdOptionParser("be comment ID COMMENT") diff --git a/becommands/diff.py b/becommands/diff.py index 82ebb2c..77194ff 100644 --- a/becommands/diff.py +++ b/becommands/diff.py @@ -16,25 +16,48 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Compare bug reports with older tree""" -from libbe import bugdir, diff, cmdutil +from libbe import cmdutil, bugdir, diff import os +__desc__ = __doc__ + def execute(args): + """ + >>> import os + >>> bd = bugdir.simple_bug_dir() + >>> original = bd.rcs.commit("Original status") + >>> bug = bd.bug_from_uuid("a") + >>> bug.status = "closed" + >>> bd.save() + >>> changed = bd.rcs.commit("Closed bug a") + >>> os.chdir(bd.root) + >>> if bd.rcs.versioned == True: + ... execute([original]) + ... else: + ... print "a:cm: Bug A\\nstatus: open -> closed\\n" + Modified bug reports: + a:cm: Bug A + status: open -> closed + <BLANKLINE> + """ options, args = get_parser().parse_args(args) if len(args) == 0: - spec = None - elif len(args) == 1: - spec = args[0] - else: - raise cmdutil.UsageError - tree = bugdir.tree_root(".") - if tree.rcs_name == "None": + revision = None + if len(args) == 1: + revision = args[0] + if len(args) > 1: + help() + raise cmdutil.UserError("Too many arguments.") + bd = bugdir.BugDir(from_disk=True) + if bd.rcs.versioned == False: print "This directory is not revision-controlled." else: - diff.diff_report(diff.reference_diff(tree, spec), tree) - + old_bd = bd.duplicate_bugdir(revision) + r,m,a = diff.diff(old_bd, bd) + diff.diff_report((r,m,a), bd) + bd.remove_duplicate_bugdir() def get_parser(): - parser = cmdutil.CmdOptionParser("be diff [specifier]") + parser = cmdutil.CmdOptionParser("be diff [SPECIFIER]") return parser longhelp=""" diff --git a/becommands/help.py b/becommands/help.py index aa4aa64..bf0b4fc 100644 --- a/becommands/help.py +++ b/becommands/help.py @@ -15,7 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Print help for given subcommand""" -from libbe import bugdir, cmdutil, names, utility +from libbe import cmdutil, utility +__desc__ = __doc__ def execute(args): """ @@ -25,7 +26,7 @@ def execute(args): if len(args) > 1: raise cmdutil.UserError("Too many arguments.") if len(args) == 0: - cmdutil.print_command_list() + print cmdutil.help() else: try: print cmdutil.help(args[0]) diff --git a/becommands/list.py b/becommands/list.py index d745702..63e1cd6 100644 --- a/becommands/list.py +++ b/becommands/list.py @@ -15,106 +15,167 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """List bugs""" -from libbe import bugdir, cmdutil, names +from libbe import cmdutil, bugdir +from libbe.bug import cmp_full, severity_values, status_values, \ + active_status_values, inactive_status_values import os +__desc__ = __doc__ + def execute(args): + """ + >>> import os + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) + >>> execute([]) + a:om: Bug A + >>> execute(["--status", "all"]) + a:om: Bug A + b:cm: Bug B + """ options, args = get_parser().parse_args(args) if len(args) > 0: - raise cmdutil.UsageError - active = True - severity = ("minor", "serious", "critical", "fatal") - if options.wishlist: - severity = ("wishlist",) - if options.closed: - active = False - tree = cmdutil.bug_tree() - current_id = names.creator() + help() + raise cmdutil.UserError("Too many arguments.") + bd = bugdir.BugDir(from_disk=True) + bd.load_all_bugs() + # select status + if options.status != None: + if options.status == "all": + status = status_values + else: + status = options.status.split(',') + else: + status = [] + if options.active == True: + status.extend(list(active_status_values)) + if options.unconfirmed == True: + status.append("unconfirmed") + if options.open == True: + status.append("opened") + if options.test == True: + status.append("test") + if status == []: # set the default value + status = active_status_values + # select severity + if options.severity != None: + if options.severity == "all": + severity = severity_values + else: + severity = options.severity.split(',') + else: + severity = [] + if options.wishlist == True: + severity.extend("wishlist") + if options.important == True: + serious = severity_values.index("serious") + severity.append(list(severity_values[serious:])) + if severity == []: # set the default value + severity = severity_values + # select assigned + if options.assigned != None: + if options.assigned == "all": + assigned = "all" + else: + assigned = options.assigned.split(',') + else: + assigned = [] + if options.mine == True: + assigned.extend('-') + if assigned == []: # set the default value + assigned = "all" + for i in range(len(assigned)): + if assigned[i] == '-': + assigned[i] = bd.user_id + # select target + if options.target != None: + if options.target == "all": + target = "all" + else: + target = options.target.split(',') + else: + target = [] + if options.cur_target == True: + target.append(bd.target) + if target == []: # set the default value + target = "all" + def filter(bug): - if options.mine and bug.assigned != current_id: + if status != "all" and not bug.status in status: + return False + if severity != "all" and not bug.severity in severity: return False - if options.cur_target: - if tree.target is None or bug.target != tree.target: - return False - if active is not None: - if bug.active != active: - return False - if bug.severity not in severity: + if assigned != "all" and not bug.assigned in assigned: + return False + if target != "all" and not bug.target in target: return False return True - all_bugs = list(tree.list()) - bugs = [b for b in all_bugs if filter(b) ] + bugs = [b for b in bd if filter(b) ] if len(bugs) == 0: print "No matching bugs found" - my_target_bugs = [] - other_target_bugs = [] - unassigned_target_bugs = [] - my_bugs = [] - other_bugs = [] - unassigned_bugs = [] - if tree.target is not None: - for bug in bugs: - if bug.target != tree.target: - continue - if bug.assigned == current_id: - my_target_bugs.append(bug) - elif bug.assigned is None: - unassigned_target_bugs.append(bug) - else: - other_target_bugs.append(bug) - - for bug in bugs: - if tree.target is not None and bug.target == tree.target: - continue - if bug.assigned == current_id: - my_bugs.append(bug) - elif bug.assigned is None: - unassigned_bugs.append(bug) - else: - other_bugs.append(bug) - - def list_bugs(cur_bugs, title, no_target=False): - def cmp_date(bug1, bug2): - return -cmp(bug1.time, bug2.time) - cur_bugs.sort(cmp_date) - cur_bugs.sort(bugdir.cmp_severity) + def list_bugs(cur_bugs, title=None, no_target=False): + cur_bugs.sort(cmp_full) if len(cur_bugs) > 0: - print cmdutil.underlined(title) + if title != None: + print cmdutil.underlined(title) for bug in cur_bugs: - print cmdutil.bug_summary(bug, all_bugs, no_target=no_target, - shortlist=True) + print bug.string(shortlist=True) - list_bugs(my_target_bugs, - "Bugs assigned to you for target %s" % tree.target, - no_target=True) - list_bugs(unassigned_target_bugs, - "Unassigned bugs for target %s" % tree.target, no_target=True) - list_bugs(other_target_bugs, - "Bugs assigned to others for target %s" % tree.target, - no_target=True) - list_bugs(my_bugs, "Bugs assigned to you") - list_bugs(unassigned_bugs, "Unassigned bugs") - list_bugs(other_bugs, "Bugs assigned to others") - + list_bugs(bugs, no_target=False) def get_parser(): parser = cmdutil.CmdOptionParser("be list [options]") - parser.add_option("-w", "--wishlist", action="store_true", dest="wishlist", - help="List bugs with 'wishlist' severity") - parser.add_option("-c", "--closed", action="store_true", dest="closed", - help="List closed bugs") - parser.add_option("-m", "--mine", action="store_true", dest="mine", - help="List only bugs assigned to you") - parser.add_option("-t", "--cur-target", action="store_true", - dest="cur_target", - help="List only bugs for the current target") + parser.add_option("-s", "--status", metavar="STATUS", dest="status", + help="List options matching STATUS", default=None) + parser.add_option("-v", "--severity", metavar="SEVERITY", dest="severity", + help="List options matching SEVERITY", default=None) + parser.add_option("-a", "--assigned", metavar="ASSIGNED", dest="assigned", + help="List options matching ASSIGNED", default=None) + parser.add_option("-t", "--target", metavar="TARGET", dest="target", + help="List options matching TARGET", default=None) + # boolean shortucts. All of these are special cases of long forms + bools = (("w", "wishlist", "List bugs with 'wishlist' severity"), + ("i", "important", "List bugs with >= 'serious' severity"), + ("A", "active", "List all active bugs"), + ("u", "unconfirmed", "List unconfirmed bugs"), + ("o", "open", "List open bugs"), + ("T", "test", "List bugs in testing"), + ("m", "mine", "List bugs assigned to you"), + ("c", "cur-target", "List bugs for the current target")) + for s in bools: + attr = s[1].replace('-','_') + short = "-%c" % s[0] + long = "--%s" % s[1] + help = s[2] + parser.add_option(short, long, action="store_true", + dest=attr, help=help) return parser longhelp=""" -This command lists bugs. Options are cumulative, so that -mc will list only -closed bugs assigned to you. -""" +This command lists bugs. There are several criteria that you can +search by: + * status + * severity + * assigned (who the bug is assigned to) + * target (bugfix deadline) +Allowed values for each criterion may be given in a comma seperated +list. The special string "all" may be used with any of these options +to match all values of the criterion. + +status + %s +severity + %s +assigned + free form, with the string '-' being a shortcut for yourself. +target + free form + +In addition, there are some shortcut options that set boolean flags. +The boolean options are ignored if the matching string option is used. +""" % (','.join(status_values), + ','.join(severity_values)) def help(): return get_parser().help_str() + longhelp diff --git a/becommands/new.py b/becommands/new.py index 7bd2382..caa1549 100644 --- a/becommands/new.py +++ b/becommands/new.py @@ -15,37 +15,36 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Create a new bug""" -from libbe import bugdir, cmdutil, names, utility +from libbe import cmdutil, bugdir +__desc__ = __doc__ + def execute(args): """ >>> import os, time - >>> from libbe import tests - >>> dir = tests.bug_arch_dir() - >>> os.chdir(dir.dir) - >>> names.uuid = lambda: "a" + >>> from libbe import bug + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) + >>> bug.uuid_gen = lambda: "X" >>> execute (["this is a test",]) - Created bug with ID a - >>> bug = list(dir.list())[0] + Created bug with ID X + >>> bd.load() + >>> bug = bd.bug_from_uuid("X") >>> bug.summary u'this is a test' - >>> bug.creator = os.environ["LOGNAME"] >>> bug.time <= int(time.time()) True >>> bug.severity u'minor' >>> bug.target == None True - >>> tests.clean_up() """ options, args = get_parser().parse_args(args) if len(args) != 1: raise cmdutil.UserError("Please supply a summary message") - dir = cmdutil.bug_tree() - bug = bugdir.new_bug(dir) - bug.summary = args[0] - bug.save() - bugs = (dir.list()) - print "Created bug with ID %s" % cmdutil.unique_name(bug, bugs) + bd = bugdir.BugDir(from_disk=True) + bug = bd.new_bug(summary=args[0]) + bd.save() + print "Created bug with ID %s" % bd.bug_shortname(bug) def get_parser(): parser = cmdutil.CmdOptionParser("be new SUMMARY") diff --git a/becommands/open.py b/becommands/open.py index f7c23c1..788a183 100644 --- a/becommands/open.py +++ b/becommands/open.py @@ -15,26 +15,31 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Re-open a bug""" -from libbe import cmdutil +from libbe import cmdutil, bugdir +__desc__ = __doc__ + def execute(args): """ - >>> from libbe import tests >>> import os - >>> dir = tests.simple_bug_dir() - >>> os.chdir(dir.dir) - >>> dir.get_bug("b").status - u'closed' + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) + >>> print bd.bug_from_shortname("b").status + closed >>> execute(["b"]) - >>> dir.get_bug("b").status - u'open' - >>> tests.clean_up() + >>> bd._clear_bugs() + >>> print bd.bug_from_shortname("b").status + open """ options, args = get_parser().parse_args(args) - if len(args) !=1: + if len(args) == 0: raise cmdutil.UserError("Please specify a bug id.") - bug = cmdutil.get_bug(args[0]) + if len(args) > 1: + help() + raise cmdutil.UserError("Too many arguments.") + bd = bugdir.BugDir(from_disk=True) + bug = bd.bug_from_shortname(args[0]) bug.status = "open" - bug.save() + bd.save() def get_parser(): parser = cmdutil.CmdOptionParser("be open BUG-ID") diff --git a/becommands/inprogress.py b/becommands/remove.py index 05da971..8f7c2c6 100644 --- a/becommands/inprogress.py +++ b/becommands/remove.py @@ -14,34 +14,45 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -"""Bug fixing in progress""" -from libbe import cmdutil +"""Remove (delete) a bug and its comments""" +from libbe import cmdutil, bugdir +__desc__ = __doc__ + def execute(args): """ - >>> from libbe import tests + >>> from libbe import mapfile >>> import os - >>> dir = tests.simple_bug_dir() - >>> os.chdir(dir.dir) - >>> dir.get_bug("a").status - u'open' - >>> execute(["a"]) - >>> dir.get_bug("a").status - u'in-progress' - >>> tests.clean_up() + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) + >>> print bd.bug_from_shortname("b").status + closed + >>> execute (["b"]) + Removed bug b + >>> bd._clear_bugs() + >>> try: + ... bd.bug_from_shortname("b") + ... except KeyError: + ... print "Bug not found" + Bug not found """ options, args = get_parser().parse_args(args) - if len(args) !=1: + if len(args) != 1: raise cmdutil.UserError("Please specify a bug id.") - bug = cmdutil.get_bug(args[0]) - bug.status = "in-progress" - bug.save() + bd = bugdir.BugDir(from_disk=True) + bug = bd.bug_from_shortname(args[0]) + bd.remove_bug(bug) + bd.save() + print "Removed bug %s" % bug.uuid def get_parser(): - parser = cmdutil.CmdOptionParser("be inprogress BUG-ID") + parser = cmdutil.CmdOptionParser("be remove BUG-ID") return parser longhelp=""" -Mark a bug as 'in-progress'. +Remove (delete) an existing bug. Use with caution: if you're not using a +revision control system, there may be no way to recover the lost information. +You should use this command, for example, to get rid of blank or otherwise +mangled bugs. """ def help(): diff --git a/becommands/set.py b/becommands/set.py index e359df1..287ceb4 100644 --- a/becommands/set.py +++ b/becommands/set.py @@ -15,43 +15,44 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Change tree settings""" -from libbe import cmdutil +from libbe import cmdutil, bugdir +__desc__ = __doc__ + def execute(args): """ - >>> from libbe import tests >>> import os - >>> dir = tests.simple_bug_dir() - >>> os.chdir(dir.dir) - >>> execute(["a"]) + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) + >>> execute(["target"]) None - >>> execute(["a", "tomorrow"]) - >>> execute(["a"]) + >>> execute(["target", "tomorrow"]) + >>> execute(["target"]) tomorrow - >>> execute(["a", "none"]) - >>> execute(["a"]) + >>> execute(["target", "none"]) + >>> execute(["target"]) None - >>> tests.clean_up() """ options, args = get_parser().parse_args(args) if len(args) > 2: + help() raise cmdutil.UserError("Too many arguments.") - tree = cmdutil.bug_tree() + bd = bugdir.BugDir(from_disk=True) if len(args) == 0: - keys = tree.settings.keys() + keys = bd.settings.keys() keys.sort() for key in keys: - print "%16s: %s" % (key, tree.settings[key]) + print "%16s: %s" % (key, bd.settings[key]) elif len(args) == 1: - print tree.settings.get(args[0]) + print bd.settings.get(args[0]) else: if args[1] != "none": - tree.settings[args[0]] = args[1] + bd.settings[args[0]] = args[1] else: - del tree.settings[args[0]] - tree.save_settings() + del bd.settings[args[0]] + bd.save() def get_parser(): - parser = cmdutil.CmdOptionParser("be set [name] [value]") + parser = cmdutil.CmdOptionParser("be set [NAME] [VALUE]") return parser longhelp=""" diff --git a/becommands/set_root.py b/becommands/set_root.py index 2ae7e1a..e17bd87 100644 --- a/becommands/set_root.py +++ b/becommands/set_root.py @@ -15,58 +15,72 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Assign the root directory for bug tracking""" -from libbe import bugdir, cmdutil, rcs +import os.path +from libbe import cmdutil, bugdir +__desc__ = __doc__ def execute(args): """ - >>> from libbe import tests + >>> from libbe import utility, rcs >>> import os - >>> dir = tests.Dir() + >>> dir = utility.Dir() >>> try: - ... bugdir.tree_root(dir.name) + ... bugdir.BugDir(dir.path) ... except bugdir.NoBugDir, e: ... True True - >>> execute([dir.name]) + >>> execute([dir.path]) No revision control detected. Directory initialized. - >>> bd = bugdir.tree_root(dir.name) - >>> bd.root = dir.name - >>> dir = tests.arch_dir() - >>> os.chdir(dir.name) - >>> execute(['.']) + >>> del(dir) + + >>> dir = utility.Dir() + >>> os.chdir(dir.path) + >>> rcs = rcs.installed_rcs() + >>> rcs.init('.') + >>> print rcs.name + Arch + >>> execute([]) Using Arch for revision control. Directory initialized. - >>> bd = bugdir.tree_root(dir.name+"/{arch}") - >>> bd.root = dir.name + >>> rcs.cleanup() + >>> try: ... execute(['.']) ... except cmdutil.UserError, e: ... str(e).startswith("Directory already initialized: ") True - >>> tests.clean_up() >>> execute(['/highly-unlikely-to-exist']) Traceback (most recent call last): UserError: No such directory: /highly-unlikely-to-exist + >>> os.chdir('/') """ options, args = get_parser().parse_args(args) - if len(args) != 1: - raise cmdutil.UsageError - dir_rcs = rcs.detect(args[0]) + if len(args) > 1: + print help() + raise cmdutil.UserError, "Too many arguments" + if len(args) == 1: + basedir = args[0] + else: + basedir = "." + if os.path.exists(basedir) == False: + pass + #raise cmdutil.UserError, "No such directory: %s" % basedir try: - bugdir.create_bug_dir(args[0], dir_rcs) + bd = bugdir.BugDir(basedir, from_disk=False, sink_to_existing_root=False, assert_new_BugDir=True) except bugdir.NoRootEntry: - raise cmdutil.UserError("No such directory: %s" % args[0]) + raise cmdutil.UserError("No such directory: %s" % basedir) except bugdir.AlreadyInitialized: - raise cmdutil.UserError("Directory already initialized: %s" % args[0]) - if dir_rcs.name is not "None": - print "Using %s for revision control." % dir_rcs.name + raise cmdutil.UserError("Directory already initialized: %s" % basedir) + bd.save() + if bd.rcs.name is not "None": + print "Using %s for revision control." % bd.rcs.name else: print "No revision control detected." print "Directory initialized." def get_parser(): - parser = cmdutil.CmdOptionParser("be set-root DIRECTORY") + parser = cmdutil.CmdOptionParser("be set-root [DIRECTORY]") return parser longhelp=""" @@ -74,6 +88,8 @@ This command initializes Bugs Everywhere support for the specified directory and all its subdirectories. It will auto-detect any supported revision control system. You can use "be set rcs_name" to change the rcs being used. +The directory defaults to your current working directory. + It is usually a good idea to put the Bugs Everywhere root at the source code root, but you can put it anywhere. If you run "be set-root" in a subdirectory, then only bugs created in that subdirectory (and its children) will appear diff --git a/becommands/severity.py b/becommands/severity.py index af99bf7..3adefaa 100644 --- a/becommands/severity.py +++ b/becommands/severity.py @@ -15,16 +15,15 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Show or change a bug's severity level""" -from libbe import bugdir -from libbe import cmdutil +from libbe import cmdutil, bugdir +from libbe.bug import severity_values, severity_description __desc__ = __doc__ def execute(args): """ - >>> from libbe import tests >>> import os - >>> dir = tests.simple_bug_dir() - >>> os.chdir(dir.dir) + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) >>> execute(["a"]) minor >>> execute(["a", "wishlist"]) @@ -33,42 +32,43 @@ def execute(args): >>> execute(["a", "none"]) Traceback (most recent call last): UserError: Invalid severity level: none - >>> tests.clean_up() """ options, args = get_parser().parse_args(args) - assert(len(args) in (0, 1, 2)) - if len(args) == 0: + if len(args) not in (1,2): print help() return - bug = cmdutil.get_bug(args[0]) + bd = bugdir.BugDir(from_disk=True) + bug = bd.bug_from_shortname(args[0]) if len(args) == 1: print bug.severity elif len(args) == 2: try: bug.severity = args[1] - except bugdir.InvalidValue, e: + except ValueError, e: if e.name != "severity": raise raise cmdutil.UserError ("Invalid severity level: %s" % e.value) - bug.save() + bd.save() def get_parser(): - parser = cmdutil.CmdOptionParser("be severity bug-id [severity]") + parser = cmdutil.CmdOptionParser("be severity BUG-ID [SEVERITY]") return parser -longhelp=""" -Show or change a bug's severity level. +longhelp=[""" +Show or change a bug's severity level. If no severity is specified, the current value is printed. If a severity level is specified, it will be assigned to the bug. Severity levels are: -wishlist: A feature that could improve usefulness, but not a bug. - minor: The standard bug level. - serious: A bug that requires workarounds. -critical: A bug that prevents some features from working at all. - fatal: A bug that makes the package unusable. -""" +"""] +longest_severity_len = max([len(s) for s in severity_values]) +for severity in severity_values : + description = severity_description[severity] + s = "%*s : %s\n" % (longest_severity_len, severity, description) + longhelp.append(s) +longhelp = ''.join(longhelp) + def help(): return get_parser().help_str() + longhelp diff --git a/becommands/show.py b/becommands/show.py index 8e83a1f..abec813 100644 --- a/becommands/show.py +++ b/becommands/show.py @@ -15,33 +15,36 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Show a particular bug""" -from libbe import bugdir, cmdutil, utility -import os +from libbe import cmdutil, bugdir +__desc__ = __doc__ def execute(args): + """ + >>> import os + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) + >>> execute (["a",]) + ID : a + Short name : a + Severity : minor + Status : open + Assigned : + Target : + Creator : John Doe <jdoe@example.com> + Created : Wed, 31 Dec 1969 19:00 (Thu, 01 Jan 1970 00:00:00 +0000) + Bug A + <BLANKLINE> + """ options, args = get_parser().parse_args(args) - if len(args) !=1: + if len(args) == 0: raise cmdutil.UserError("Please specify a bug id.") - bug_dir = cmdutil.bug_tree() - bug = cmdutil.get_bug(args[0], bug_dir) - print cmdutil.bug_summary(bug, list(bug_dir.list())).rstrip("\n") - if bug.time is None: - time_str = "(Unknown time)" - else: - time_str = "%s (%s)" % (utility.handy_time(bug.time), - utility.time_to_str(bug.time)) - print "Created: %s" % time_str - unique_name = cmdutil.unique_name(bug, bug_dir.list()) - comments = [] - name_map = {} - for c_name, comment in cmdutil.iter_comment_name(bug, unique_name): - name_map[comment.uuid] = c_name - comments.append(comment) - threaded = bugdir.thread_comments(comments) - cmdutil.print_threaded_comments(threaded, name_map) + bd = bugdir.BugDir(from_disk=True) + for bugid in args: + bug = bd.bug_from_shortname(bugid) + print bug.string(show_comments=True) def get_parser(): - parser = cmdutil.CmdOptionParser("be show bug-id") + parser = cmdutil.CmdOptionParser("be show BUG-ID [BUG-ID ...]") return parser longhelp=""" diff --git a/becommands/status.py b/becommands/status.py new file mode 100644 index 0000000..a30b3d6 --- /dev/null +++ b/becommands/status.py @@ -0,0 +1,73 @@ +# Copyright (C) 2005 Aaron Bentley and Panometrics, Inc. +# <abentley@panoramicfeedback.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +"""Show or change a bug's status""" +from libbe import cmdutil, bugdir +from libbe.bug import status_values, status_description +__desc__ = __doc__ + +def execute(args): + """ + >>> import os + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) + >>> execute(["a"]) + open + >>> execute(["a", "closed"]) + >>> execute(["a"]) + closed + >>> execute(["a", "none"]) + Traceback (most recent call last): + UserError: Invalid status: none + """ + options, args = get_parser().parse_args(args) + if len(args) not in (1,2): + print help() + return + bd = bugdir.BugDir(from_disk=True) + bug = bd.bug_from_shortname(args[0]) + if len(args) == 1: + print bug.status + elif len(args) == 2: + try: + bug.status = args[1] + except ValueError, e: + if e.name != "status": + raise + raise cmdutil.UserError ("Invalid status: %s" % e.value) + bd.save() + +def get_parser(): + parser = cmdutil.CmdOptionParser("be status BUG-ID [STATUS]") + return parser + +longhelp=[""" +Show or change a bug's severity level. + +If no severity is specified, the current value is printed. If a severity level +is specified, it will be assigned to the bug. + +Severity levels are: +"""] +longest_status_len = max([len(s) for s in status_values]) +for status in status_values : + description = status_description[status] + s = "%*s : %s\n" % (longest_status_len, status, description) + longhelp.append(s) +longhelp = ''.join(longhelp) + +def help(): + return get_parser().help_str() + longhelp diff --git a/becommands/target.py b/becommands/target.py index 4b015b4..dce100f 100644 --- a/becommands/target.py +++ b/becommands/target.py @@ -15,16 +15,14 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Show or change a bug's target for fixing""" -from libbe import bugdir -from libbe import cmdutil +from libbe import cmdutil, bugdir __desc__ = __doc__ def execute(args): """ - >>> from libbe import tests >>> import os - >>> dir = tests.simple_bug_dir() - >>> os.chdir(dir.dir) + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) >>> execute(["a"]) No target assigned. >>> execute(["a", "tomorrow"]) @@ -33,14 +31,14 @@ def execute(args): >>> execute(["a", "none"]) >>> execute(["a"]) No target assigned. - >>> tests.clean_up() """ options, args = get_parser().parse_args(args) assert(len(args) in (0, 1, 2)) if len(args) == 0: print help() return - bug = cmdutil.get_bug(args[0]) + bd = bugdir.BugDir(from_disk=True) + bug = bd.bug_from_shortname(args[0]) if len(args) == 1: if bug.target is None: print "No target assigned." @@ -51,16 +49,16 @@ def execute(args): bug.target = None else: bug.target = args[1] - bug.save() + bd.save() def get_parser(): - parser = cmdutil.CmdOptionParser("be target bug-id [target]") + parser = cmdutil.CmdOptionParser("be target BUG-ID [TARGET]") return parser longhelp=""" Show or change a bug's target for fixing. -If no target is specified, the current value is printed. If a target +If no target is specified, the current value is printed. If a target is specified, it will be assigned to the bug. Targets are freeform; any text may be specified. They will generally be diff --git a/becommands/template b/becommands/template deleted file mode 100644 index 3c871e6..0000000 --- a/becommands/template +++ /dev/null @@ -1,21 +0,0 @@ -"""Short description""" -from libbe import bugdir, cmdutil, names -import os -def execute(args): - options, args = get_parser().parse_args(args) - if len(args) > 0: - raise cmdutil.UsageError - - -def get_parser(): - parser = cmdutil.CmdOptionParser("be list [options]") -# parser.add_option("-w", "--wishlist", action="store_true", dest="wishlist", -# help="List bugs with 'wishlist' severity") - return parser - -longhelp=""" -This is for the longwinded description -""" - -def help(): - return get_parser().help_str() + longhelp diff --git a/becommands/upgrade.py b/becommands/upgrade.py deleted file mode 100644 index 3dcb4eb..0000000 --- a/becommands/upgrade.py +++ /dev/null @@ -1,111 +0,0 @@ -# Copyright (C) 2005 Aaron Bentley and Panometrics, Inc. -# <abentley@panoramicfeedback.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -"""Upgrade the bugs to the latest format""" -import os.path -import errno -from libbe import bugdir, rcs, cmdutil - -def execute(args): - options, args = get_parser().parse_args(args) - root = bugdir.tree_root(".", old_version=True) - for uuid in root.list_uuids(): - old_bug = OldBug(root.bugs_path, uuid) - - new_bug = bugdir.Bug(root.bugs_path, None) - new_bug.uuid = old_bug.uuid - new_bug.summary = old_bug.summary - new_bug.creator = old_bug.creator - new_bug.target = old_bug.target - new_bug.status = old_bug.status - new_bug.severity = old_bug.severity - - new_bug.save() - for uuid in root.list_uuids(): - old_bug = OldBug(root.bugs_path, uuid) - old_bug.delete() - - bugdir.set_version(root.dir) - -def file_property(name, valid=None): - def getter(self): - value = self._get_value(name) - if valid is not None: - if value not in valid: - raise InvalidValue(name, value) - return value - def setter(self, value): - if valid is not None: - if value not in valid and value is not None: - raise InvalidValue(name, value) - return self._set_value(name, value) - return property(getter, setter) - - -class OldBug(object): - def __init__(self, path, uuid): - self.path = os.path.join(path, uuid) - self.uuid = uuid - - def get_path(self, file): - return os.path.join(self.path, file) - - summary = file_property("summary") - creator = file_property("creator") - target = file_property("target") - status = file_property("status", valid=("open", "closed")) - severity = file_property("severity", valid=("wishlist", "minor", "serious", - "critical", "fatal")) - def delete(self): - self.summary = None - self.creator = None - self.target = None - self.status = None - self.severity = None - self._set_value("name", None) - - def _get_active(self): - return self.status == "open" - - active = property(_get_active) - - def _get_value(self, name): - try: - return file(self.get_path(name), "rb").read().rstrip("\n") - except IOError, e: - if e.errno == errno.EEXIST: - return None - - def _set_value(self, name, value): - if value is None: - try: - rcs.unlink(self.get_path(name)) - except OSError, e: - if e.errno != 2: - raise - else: - rcs.set_file_contents(self.get_path(name), "%s\n" % value) - -def get_parser(): - parser = cmdutil.CmdOptionParser("be upgrade") - return parser - -longhelp=""" -Upgrade the bug storage to the latest format. -""" - -def help(): - return get_parser().help_str() + longhelp |