From 87e356c9208e955fcf6c20c0b271db87bdd48014 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 14 Nov 2008 19:25:44 -0500 Subject: Split Bug and Comment class out to bug.py from bugdir.py Comment should probably have it's own file too... I also tried to clean up the interface for setting status and severity. Both attributes involve selecting strings from predefined lists. The lists of valid strings (and descriptions of each string) are now defined in bug.py. The bug.py lists are then used to generate appropriate help strings in becommands/status.py and severity.py. This should make it easier to keep the help strings in synch with the validation information. The original status strings weren't documented, and I didn't know what they all ment, so I elimanted some of them. 'in-progress' and 'disabled' are no longer with us. Of course, it would be simple to add them back in if people don't agree with me on that. Due to the loss of 'disabled' I had to change the status of two bugs (11e and 597) to 'closed'. I removed becommands/inprogress.py as well. It's functionality was replaced by the more general status.py command, which mimics the severity.py command. --- becommands/severity.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'becommands/severity.py') diff --git a/becommands/severity.py b/becommands/severity.py index af99bf7..1a68c31 100644 --- a/becommands/severity.py +++ b/becommands/severity.py @@ -15,8 +15,9 @@ # 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.bug import severity_values, severity_description + __desc__ = __doc__ def execute(args): @@ -46,7 +47,7 @@ def execute(args): 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) @@ -56,19 +57,21 @@ def get_parser(): 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 -- cgit From e7c376ed286b3bf741ae9e364eef7dd2114d77c7 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 16 Nov 2008 14:12:06 -0500 Subject: Added 'remove' command to remove bugs. Use __desc__ for command help. Using the __desc__ reduces documentation duplication. It's also better than using __doc__, because __doc__ could (should?) be more than one-line long, and we just want a short description to jog our memories in the complete command list. Also moved unique_name from cmdutil.py to names.py to avoid the bug->cmdutil->bugdir->bug cyclic include. --- becommands/severity.py | 1 - 1 file changed, 1 deletion(-) (limited to 'becommands/severity.py') diff --git a/becommands/severity.py b/becommands/severity.py index 1a68c31..6845875 100644 --- a/becommands/severity.py +++ b/becommands/severity.py @@ -17,7 +17,6 @@ """Show or change a bug's severity level""" from libbe import cmdutil from libbe.bug import severity_values, severity_description - __desc__ = __doc__ def execute(args): -- cgit From 19b153b9a86377a2b30cc80fa3f475fed892e2fe Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 18 Nov 2008 20:42:50 -0500 Subject: Major rewrite of RCS backends. RCS now represented as a class. Lots of changes and just one commit. This started with bug dac91856-cb6a-4f69-8c03-38ff0b29aab2, when I noticed that new bugs were not being added appropriately with the Git backend. I'd been working with Git trouble before with bug 0cad2ac6-76ef-4a88-abdf-b2e02de76f5c, and decided things would be better off if I just scrapped the current RCS architecture and went to a more object oriented setup. So I did. It's not clear how to add support for an RCS backend: * Create a new module that - defines an inheritor of rsc.RCS, overriding the _rcs_*() methods - provide a new() function for instantizating the new class - defines an inheritor of rcs.RCStestCase, overiding the Class attribute - defines 'suite' a unittest.TestSuite testing the module * Add your new module to the rest in rcs._get_matching_rcs() * Add your new module to the rest in libbe/tests.py Although I'm not sure libbe/tests.py is still usefull. The new framework clears out a bunch of hackery that used to be involved with supporting becommands/diff.py. There's still room for progress though. While implementing the new verision, I moved the testing framework over from doctest to a doctest/unittest combination. Longer tests that don't demonstrate a function's usage should be moved to unittests at the end of the module, since unittest has better support for setup/teardown, etc. The new framework also revealed some underimplented backends, most notably arch. These backends have now been fixed. I also tweaked the test_usage.sh script to run through all the backends if it is called with no arguments. The fix for the dac bug turned out to be an unflushed file write :p. --- becommands/severity.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'becommands/severity.py') diff --git a/becommands/severity.py b/becommands/severity.py index 6845875..b055695 100644 --- a/becommands/severity.py +++ b/becommands/severity.py @@ -21,9 +21,9 @@ __desc__ = __doc__ def execute(args): """ - >>> from libbe import tests + >>> from libbe import bugdir >>> import os - >>> dir = tests.simple_bug_dir() + >>> dir = bugdir.simple_bug_dir() >>> os.chdir(dir.dir) >>> execute(["a"]) minor @@ -33,7 +33,6 @@ 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)) -- cgit From 23179f50092d91dbeab97ad2b88cdaadb79b615f Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 21 Nov 2008 14:56:05 -0500 Subject: Another major rewrite. Now BugDir, Bug, and Comment are more distinct. I pushed a lot of the little helper functions into the main classes, which makes it easier for me to keep track of what's going on. I'm now at the point where I can run through `python test.py` with each of the backends (by changing the search order in rcs.py _get_matching_rcs) without any unexpected errors for each backend (except Arch). I can also run `test_usage.sh` without non-Arch errors either. However, don't consider this a stable commit yet. The bzr backend is *really*slow*, and the other's aren't blazingly fast either. I think I'm rewriting the entire database every time I save it :p. Still, it passes the checks. and I don't like it when zounds of changes build up. --- becommands/severity.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'becommands/severity.py') diff --git a/becommands/severity.py b/becommands/severity.py index b055695..d7df13d 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 cmdutil +from libbe import cmdutil, bugdir from libbe.bug import severity_values, severity_description __desc__ = __doc__ def execute(args): """ - >>> from libbe import bugdir >>> import os - >>> dir = bugdir.simple_bug_dir() - >>> os.chdir(dir.dir) + >>> bd = bugdir.simple_bug_dir() + >>> os.chdir(bd.root) >>> execute(["a"]) minor >>> execute(["a", "wishlist"]) @@ -35,11 +34,11 @@ def execute(args): UserError: Invalid severity level: none """ 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(loadNow=True) + bug = bd.bug_from_shortname(args[0]) if len(args) == 1: print bug.severity elif len(args) == 2: @@ -49,7 +48,7 @@ def execute(args): 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]") -- cgit From 510c9f33393c1f222ee56732c026f229ed8ae49d Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 23 Nov 2008 09:50:56 -0500 Subject: Go back to lazy bug loading to get execution speed back up. Fixes bug b3c6da51-3a30-42c9-8c75-587c7a1705c5 --- becommands/severity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'becommands/severity.py') diff --git a/becommands/severity.py b/becommands/severity.py index d7df13d..3f25445 100644 --- a/becommands/severity.py +++ b/becommands/severity.py @@ -37,7 +37,7 @@ def execute(args): if len(args) not in (1,2): print help() return - bd = bugdir.BugDir(loadNow=True) + bd = bugdir.BugDir(from_disk=True) bug = bd.bug_from_shortname(args[0]) if len(args) == 1: print bug.severity -- cgit From 2c3f6c066ceb03ae3579dff029bf01f0b62c1f82 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 24 Nov 2008 17:02:16 -0500 Subject: Tweaked usage strings to increase consistency. Also added README.dev. I tried to stick to CAPS for argument placeholders. --- becommands/severity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'becommands/severity.py') diff --git a/becommands/severity.py b/becommands/severity.py index 3f25445..3adefaa 100644 --- a/becommands/severity.py +++ b/becommands/severity.py @@ -51,7 +51,7 @@ def execute(args): bd.save() def get_parser(): - parser = cmdutil.CmdOptionParser("be severity bug-id [severity]") + parser = cmdutil.CmdOptionParser("be severity BUG-ID [SEVERITY]") return parser longhelp=[""" -- cgit