From: W. Trevor King Date: Mon, 22 Jun 2009 20:27:46 +0000 (-0400) Subject: Added `be list --sort *` for user-selectable sorting. X-Git-Tag: 1.0.0~71^2~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4e5dc3888699076e46bdc1d94f901ca889b88b05;p=be.git Added `be list --sort *` for user-selectable sorting. Also added libbe.bug.cmp_last_modified, which handles part of 9ce2f015-8ea0-43a5-a03d-fc36f6d202fe. To do better we could extend the RCS framework. I also transcribed a few emails from the be-devel list onto their relavent bugs and closed a few bugs. Finally, I removed some left over InvalidValue cruft. --- diff --git a/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/72dab0c4-f04d-4ff0-9319-f55aafaea627/body b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/72dab0c4-f04d-4ff0-9319-f55aafaea627/body new file mode 100644 index 0000000..fd86659 --- /dev/null +++ b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/72dab0c4-f04d-4ff0-9319-f55aafaea627/body @@ -0,0 +1 @@ +Hello world diff --git a/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/72dab0c4-f04d-4ff0-9319-f55aafaea627/values b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/72dab0c4-f04d-4ff0-9319-f55aafaea627/values new file mode 100644 index 0000000..3a2ebfb --- /dev/null +++ b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/72dab0c4-f04d-4ff0-9319-f55aafaea627/values @@ -0,0 +1,11 @@ +Content-type: text/html + + +Date: Mon, 22 Jun 2009 20:05:00 +0000 + + +From: W. Trevor King + + +In-reply-to: c454aa67-ca30-43e8-9be4-58cbddd01b63 + diff --git a/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/c454aa67-ca30-43e8-9be4-58cbddd01b63/body b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/c454aa67-ca30-43e8-9be4-58cbddd01b63/body new file mode 100644 index 0000000..f673cc5 --- /dev/null +++ b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/c454aa67-ca30-43e8-9be4-58cbddd01b63/body @@ -0,0 +1,30 @@ +Excerpt from my mail to the list on Sat, 20 Jun 2009 21:55:54 -0400: + +On Mon, Nov 24, 2008 at 07:15:08PM -0500, Aaron Bentley wrote: +> 576:om: Allow attachments +> Sensible. + +I'm not as convinced they are a good idea as I once was. I've just +added comments-from-stdin, e.g. + some-invalid-command | be comment - +Which is mostly what I'd be using attachments for anyway. If you +really want to support the attachments/mime-types etc. like we had +maybe been leaning towards before, you'd need to look at the output of +`be show ...' with an email client, which seems a bit excessive. Do +we even want mime types at all? With the xml output a la Thomas, you +should be able to pipe into whatever sort of `viewer' you want, and it +doesn't end up being hardcoded into the main repo. + + +Notes since my email: + +be->xml->mutt has since been implemented, and it preserves comment +mime-type. This allows those that want to go crazy to attach whatever +they want to their comments: + + $ echo "Hello world" | be comment --content-type text/html 576:2 - + +I think non-text attachments without a browser/mail-viewer don't make +sense, so I'm closing this bug. Feel free to keep it open in your own +repo, or argue with me on the list ;). + diff --git a/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/c454aa67-ca30-43e8-9be4-58cbddd01b63/values b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/c454aa67-ca30-43e8-9be4-58cbddd01b63/values new file mode 100644 index 0000000..1456cca --- /dev/null +++ b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/c454aa67-ca30-43e8-9be4-58cbddd01b63/values @@ -0,0 +1,11 @@ +Content-type: text/plain + + +Date: Mon, 22 Jun 2009 20:03:27 +0000 + + +From: W. Trevor King + + +In-reply-to: d83a5436-85e3-42c7-9a89-a6d50df9d279 + diff --git a/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/values b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/values index 7d5bb11..16906f1 100644 --- a/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/values +++ b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/values @@ -4,7 +4,7 @@ creator: abentley severity: minor -status: open +status: closed summary: Allow attachments diff --git a/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/comments/3e7144eb-c934-4b62-94b7-7dbfa90ed6ee/body b/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/comments/3e7144eb-c934-4b62-94b7-7dbfa90ed6ee/body new file mode 100644 index 0000000..635893b --- /dev/null +++ b/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/comments/3e7144eb-c934-4b62-94b7-7dbfa90ed6ee/body @@ -0,0 +1,4 @@ +From Aaron's Mon, 24 Nov 2008 19:15:09 -0500 email: + +8e9:om: list X most recent entries +Closeable. (And yes, I would do it instead of 'be diff') diff --git a/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/comments/3e7144eb-c934-4b62-94b7-7dbfa90ed6ee/values b/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/comments/3e7144eb-c934-4b62-94b7-7dbfa90ed6ee/values new file mode 100644 index 0000000..cebf3cf --- /dev/null +++ b/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/comments/3e7144eb-c934-4b62-94b7-7dbfa90ed6ee/values @@ -0,0 +1,8 @@ +Content-type: text/plain + + +Date: Mon, 22 Jun 2009 19:46:45 +0000 + + +From: W. Trevor King + diff --git a/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/comments/7d7e703f-22f2-4c47-86a3-fcc3c8ead576/values b/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/comments/7d7e703f-22f2-4c47-86a3-fcc3c8ead576/values index 6f59e9c..560e158 100644 --- a/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/comments/7d7e703f-22f2-4c47-86a3-fcc3c8ead576/values +++ b/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/comments/7d7e703f-22f2-4c47-86a3-fcc3c8ead576/values @@ -1,21 +1,8 @@ +Content-type: text/plain - -Content-type=text/plain - - - - - - -Date=Mon, 24 Nov 2008 13:10:38 +0000 - - - - - - -From=W. Trevor King +Date: Mon, 24 Nov 2008 13:10:38 +0000 +From: W. Trevor King diff --git a/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/values b/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/values index b827901..391d092 100644 --- a/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/values +++ b/.be/bugs/8e948522-c6a1-4c97-af93-2cf4090f44b5/values @@ -1,35 +1,14 @@ +creator: abentley +severity: minor -creator=abentley +status: closed +summary: list X most recent entries - -severity=minor - - - - - - -status=open - - - - - - -summary=list X most recent entries - - - - - - -time=Wed, 25 Jan 2006 15:44:18 +0000 - - +time: Wed, 25 Jan 2006 15:44:18 +0000 diff --git a/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/comments/095ade7c-9378-41bd-8137-f2731c6afcac/body b/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/comments/095ade7c-9378-41bd-8137-f2731c6afcac/body new file mode 100644 index 0000000..bfb1037 --- /dev/null +++ b/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/comments/095ade7c-9378-41bd-8137-f2731c6afcac/body @@ -0,0 +1,19 @@ +Presumably this would be to allow sorting of bugs by last-modified +date instead of by creation date. With the xml output, this is no +longer needed. For example, I view bugs in mutt with + $ be list | xml/be-xml-to-mbox | xml/catmutt +and use mutt to sort the threads by last-modified, e.g. by adding + set sort=threads + set sort_aux=last-date +to my ~/.muttrc. + +That being said, I could go for a user-specified sort command in +becommands/list.py, rather than the current bug.cmp_full, since other +mail readers may suck more than mutt ;), and even mutt might not have +that perfect sort you desire coded into it :p. The problem is that +while the cmp_* functions in bug are short, they are not really the +sort of thing you'd want to type in on the command line. Perhaps we +can just slowly accumulate a rich array of bug.cmp_* functions as +they are requested, and allow the user to prepend their favorites to +the default cmp_full list... + diff --git a/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/comments/095ade7c-9378-41bd-8137-f2731c6afcac/values b/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/comments/095ade7c-9378-41bd-8137-f2731c6afcac/values new file mode 100644 index 0000000..7ba64d0 --- /dev/null +++ b/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/comments/095ade7c-9378-41bd-8137-f2731c6afcac/values @@ -0,0 +1,8 @@ +Content-type: text/plain + + +Date: Mon, 22 Jun 2009 18:40:43 +0000 + + +From: W. Trevor King + diff --git a/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/comments/d81d0df9-e6d9-4fe8-8dbe-989ef2c81f00/body b/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/comments/d81d0df9-e6d9-4fe8-8dbe-989ef2c81f00/body new file mode 100644 index 0000000..5e3ef6b --- /dev/null +++ b/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/comments/d81d0df9-e6d9-4fe8-8dbe-989ef2c81f00/body @@ -0,0 +1,9 @@ +User specfied sort added, along with bug.cmp_last_modified. + +Hmm, perhaps you don't want the last comment date, but e.g. the last +time one of the bug attributes are changed. In that case, I suggest + bzr log .be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/ + +Maybe log(file) functionality should be incorperated into libbe/rcs... +Perhaps accessed through a --history. I'm not sure I remember enough +Arch to do that ;). diff --git a/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/comments/d81d0df9-e6d9-4fe8-8dbe-989ef2c81f00/values b/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/comments/d81d0df9-e6d9-4fe8-8dbe-989ef2c81f00/values new file mode 100644 index 0000000..2355aa5 --- /dev/null +++ b/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/comments/d81d0df9-e6d9-4fe8-8dbe-989ef2c81f00/values @@ -0,0 +1,8 @@ +Content-type: text/plain + + +Date: Mon, 22 Jun 2009 19:43:21 +0000 + + +From: W. Trevor King + diff --git a/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/values b/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/values index 0292ab5..a4d67fd 100644 --- a/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/values +++ b/.be/bugs/9ce2f015-8ea0-43a5-a03d-fc36f6d202fe/values @@ -1,35 +1,14 @@ +creator: abentley +severity: minor -creator=abentley +status: open +summary: Add last-modified field to bugs - -severity=minor - - - - - - -status=open - - - - - - -summary=Add last-modified field to bugs - - - - - - -time=Thu, 14 Sep 2006 18:08:53 +0000 - - +time: Thu, 14 Sep 2006 18:08:53 +0000 diff --git a/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/22348320-40d3-422c-bdf0-0f6a6bde3fab/body b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/22348320-40d3-422c-bdf0-0f6a6bde3fab/body new file mode 100644 index 0000000..2767d69 --- /dev/null +++ b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/22348320-40d3-422c-bdf0-0f6a6bde3fab/body @@ -0,0 +1,6 @@ +In my Tue, 25 Nov 2008 08:30:19 -0500 email: + +I thought feature requests would just have "wishlist" severity. What +would be an example of a to-do item that is not a feature request or a +bug? + diff --git a/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/22348320-40d3-422c-bdf0-0f6a6bde3fab/values b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/22348320-40d3-422c-bdf0-0f6a6bde3fab/values new file mode 100644 index 0000000..bfc4ff7 --- /dev/null +++ b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/22348320-40d3-422c-bdf0-0f6a6bde3fab/values @@ -0,0 +1,11 @@ +Content-type: text/plain + + +Date: Mon, 22 Jun 2009 20:12:35 +0000 + + +From: W. Trevor King + + +In-reply-to: 354dcfc6-5997-4ffe-b7a0-baa852213539 + diff --git a/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/354dcfc6-5997-4ffe-b7a0-baa852213539/body b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/354dcfc6-5997-4ffe-b7a0-baa852213539/body new file mode 100644 index 0000000..7fcd766 --- /dev/null +++ b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/354dcfc6-5997-4ffe-b7a0-baa852213539/body @@ -0,0 +1,7 @@ +In Aaron's Mon, 24 Nov 2008 19:15:08 -0500 email, he adds: + +Issue trackers should provide tracking of +1. bugs +2. feature requests +3. to-do items. + diff --git a/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/354dcfc6-5997-4ffe-b7a0-baa852213539/values b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/354dcfc6-5997-4ffe-b7a0-baa852213539/values new file mode 100644 index 0000000..bc3434d --- /dev/null +++ b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/354dcfc6-5997-4ffe-b7a0-baa852213539/values @@ -0,0 +1,8 @@ +Content-type: text/plain + + +Date: Mon, 22 Jun 2009 20:11:02 +0000 + + +From: W. Trevor King + diff --git a/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/c129067c-2341-4e7a-92a6-2dcd30d3bbf5/body b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/c129067c-2341-4e7a-92a6-2dcd30d3bbf5/body new file mode 100644 index 0000000..04a97cd --- /dev/null +++ b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/c129067c-2341-4e7a-92a6-2dcd30d3bbf5/body @@ -0,0 +1,14 @@ +If you want more granularity than just `wishlist' what about the +`severities': + todo-critical + todo-minor + todo-... +Then get a list of available severities with + $ be list --help | grep -A1 '^severity' + severity + wishlist,minor,serious,critical,fatal,todo-critical,todo-minor +And show all the todos: + $ be list --severity todo-critical,todo-minor + +You can configure all the severities you'd like with + $ be set severity wishlist,minor,... diff --git a/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/c129067c-2341-4e7a-92a6-2dcd30d3bbf5/values b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/c129067c-2341-4e7a-92a6-2dcd30d3bbf5/values new file mode 100644 index 0000000..172a87c --- /dev/null +++ b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/c129067c-2341-4e7a-92a6-2dcd30d3bbf5/values @@ -0,0 +1,11 @@ +Content-type: text/plain + + +Date: Mon, 22 Jun 2009 20:20:39 +0000 + + +From: W. Trevor King + + +In-reply-to: f847c981-873e-41ae-b5ce-83dfe60b9afe + diff --git a/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/f847c981-873e-41ae-b5ce-83dfe60b9afe/body b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/f847c981-873e-41ae-b5ce-83dfe60b9afe/body new file mode 100644 index 0000000..cc02836 --- /dev/null +++ b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/f847c981-873e-41ae-b5ce-83dfe60b9afe/body @@ -0,0 +1,10 @@ +In Aaron's Tue, 25 Nov 2008 09:32:29 -0500 email: + +I think that approach doesn't give features the richness they need. +Features also have severities-- some features are important, and others +are just nice-to-have. And there should be a way to list *only* bugs, +or *only* features. + +In a bug tracker, "wishlist" is either an aberration, or it means a very +low severity. + diff --git a/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/f847c981-873e-41ae-b5ce-83dfe60b9afe/values b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/f847c981-873e-41ae-b5ce-83dfe60b9afe/values new file mode 100644 index 0000000..0ecd143 --- /dev/null +++ b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/comments/f847c981-873e-41ae-b5ce-83dfe60b9afe/values @@ -0,0 +1,11 @@ +Content-type: text/plain + + +Date: Mon, 22 Jun 2009 20:14:26 +0000 + + +From: W. Trevor King + + +In-reply-to: 22348320-40d3-422c-bdf0-0f6a6bde3fab + diff --git a/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/values b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/values index a81bcc9..d000d2e 100644 --- a/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/values +++ b/.be/bugs/c76d7899-d495-4103-9355-012c0a6fece3/values @@ -1,35 +1,14 @@ +creator: abentley +severity: minor -creator=abentley +status: closed +summary: Support 'issues', like todo, better - -severity=minor - - - - - - -status=open - - - - - - -summary=Support 'issues', like todo, better - - - - - - -time=Wed, 04 Jan 2006 21:09:02 +0000 - - +time: Wed, 04 Jan 2006 21:09:02 +0000 diff --git a/.be/bugs/cf56e648-3b09-4131-8847-02dff12b4db2/comments/0e5fab2a-66eb-4f7d-979f-b50181f604d4/body b/.be/bugs/cf56e648-3b09-4131-8847-02dff12b4db2/comments/0e5fab2a-66eb-4f7d-979f-b50181f604d4/body new file mode 100644 index 0000000..89d64c5 --- /dev/null +++ b/.be/bugs/cf56e648-3b09-4131-8847-02dff12b4db2/comments/0e5fab2a-66eb-4f7d-979f-b50181f604d4/body @@ -0,0 +1,8 @@ +From Aaron's Mon, 24 Nov 2008 19:15:09 -0500 email + +cf5:oc: OK, maybe not fatal, but how about a new name that suggests +process tracking, not just bugs? + +If you can come with a better name, that would be great. But naming an +issue tracker for its bug-tracking features isn't a terrible idea. + diff --git a/.be/bugs/cf56e648-3b09-4131-8847-02dff12b4db2/comments/0e5fab2a-66eb-4f7d-979f-b50181f604d4/values b/.be/bugs/cf56e648-3b09-4131-8847-02dff12b4db2/comments/0e5fab2a-66eb-4f7d-979f-b50181f604d4/values new file mode 100644 index 0000000..e8c9da6 --- /dev/null +++ b/.be/bugs/cf56e648-3b09-4131-8847-02dff12b4db2/comments/0e5fab2a-66eb-4f7d-979f-b50181f604d4/values @@ -0,0 +1,8 @@ +Content-type: text/plain + + +Date: Mon, 22 Jun 2009 19:48:44 +0000 + + +From: W. Trevor King + diff --git a/becommands/comment.py b/becommands/comment.py index 29e9f88..f7459dd 100644 --- a/becommands/comment.py +++ b/becommands/comment.py @@ -102,10 +102,14 @@ def execute(args, test=False): body+='\n' comment = parent.new_reply(body=body) + if options.content_type != None: + comment.content_type = options.content_type bd.save() def get_parser(): parser = cmdutil.CmdOptionParser("be comment ID [COMMENT]") + parser.add_option("-c", "--content-type", metavar="MIME", dest="content_type", + help="Set comment content-type (e.g. text/plain)", default=None) return parser longhelp=""" diff --git a/becommands/list.py b/becommands/list.py index 9f4e037..1f06569 100644 --- a/becommands/list.py +++ b/becommands/list.py @@ -19,6 +19,10 @@ from libbe import cmdutil, bugdir, bug import os __desc__ = __doc__ +# get a list of * for cmp_*() comparing two bugs. +AVAILABLE_CMPS = [fn[4:] for fn in dir(bug) if fn[:4] == 'cmp_'] +AVAILABLE_CMPS.remove("attr") # a cmp_* template. + def execute(args, test=False): """ >>> import os @@ -35,6 +39,13 @@ def execute(args, test=False): complete(options, args, parser) if len(args) > 0: raise cmdutil.UsageError("Too many arguments.") + cmp_list = [] + if options.sort_by != None: + for cmp in options.sort_by.split(','): + if cmp not in AVAILABLE_CMPS: + raise cmdutil.UserError("Invalid sort on '%s'.\nValid sorts:\n %s" + % (cmp, '\n '.join(AVAILABLE_CMPS))) + cmp_list.append(eval('bug.cmp_%s' % cmp)) bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test) bd.load_all_bugs() @@ -115,7 +126,6 @@ def execute(args, test=False): print "No matching bugs found" def list_bugs(cur_bugs, title=None, just_uuids=False, xml=False): - cur_bugs.sort(bug.cmp_full) if xml == True: print "" if len(cur_bugs) > 0: @@ -130,7 +140,13 @@ def execute(args, test=False): print bg.string(shortlist=True) if xml == True: print "" - + + # sort bugs + cmp_list.extend(bug.DEFAULT_CMP_FULL_CMP_LIST) + cmp_fn = bug.BugCompoundComparator(cmp_list=cmp_list) + bugs.sort(cmp_fn) + + # print list of bugs list_bugs(bugs, just_uuids=options.uuids, xml=options.xml) def get_parser(): @@ -143,6 +159,8 @@ def get_parser(): help="List options matching ASSIGNED", default=None) parser.add_option("-t", "--target", metavar="TARGET", dest="target", help="List options matching TARGET", default=None) + parser.add_option("-S", "--sort", metavar="SORT-BY", dest="sort_by", + help="Adjust bug-sort criteria with comma-separated list SORT-BY. e.g. \"--sort creator,time\". Available criteria: %s" % ','.join(AVAILABLE_CMPS), default=None) # boolean options. All but uuids and xml are special cases of long forms bools = (("u", "uuids", "Only print the bug UUIDS"), ("w", "wishlist", "List bugs with 'wishlist' severity"), diff --git a/becommands/set.py b/becommands/set.py index b8a125e..c8bbe4f 100644 --- a/becommands/set.py +++ b/becommands/set.py @@ -63,12 +63,7 @@ def execute(args, test=False): msg += '\n '.join(bd.settings_properties) raise cmdutil.UserError(msg) old_setting = bd.settings.get(args[0]) - try: - setattr(bd, args[0], args[1]) - except bugdir.InvalidValue, e: - bd.settings[args[0]] = old_setting - bd.save() - raise cmdutil.UserError(e) + setattr(bd, args[0], args[1]) else: del bd.settings[args[0]] bd.save() diff --git a/libbe/bug.py b/libbe/bug.py index 8c095c5..43974dd 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -276,8 +276,8 @@ class Bug(settings_object.SavedSettingsObject): else: shortname = self.bugdir.bug_shortname(self) if shortlist == False: - if self.time_string == "": - timestring = self.time_string + if self.time == None: + timestring = "" else: htime = utility.handy_time(self.time) timestring = "%s (%s)" % (htime, self.time_string) @@ -466,19 +466,37 @@ cmp_assigned = lambda bug_1, bug_2 : cmp_attr(bug_1, bug_2, "assigned") # chronological rankings (newer < older) cmp_time = lambda bug_1, bug_2 : cmp_attr(bug_1, bug_2, "time", invert=True) -def cmp_full(bug_1, bug_2, cmp_list=(cmp_status,cmp_severity,cmp_assigned, - cmp_time,cmp_creator)): - for comparison in cmp_list : - val = comparison(bug_1, bug_2) - if val != 0 : - return val - return 0 - -class InvalidValue(ValueError): - def __init__(self, name, value): - msg = "Cannot assign value %s to %s" % (value, name) - Exception.__init__(self, msg) - self.name = name - self.value = value +DEFAULT_CMP_FULL_CMP_LIST = \ + (cmp_status,cmp_severity,cmp_assigned,cmp_time,cmp_creator) + +class BugCompoundComparator (object): + def __init__(self, cmp_list=DEFAULT_CMP_FULL_CMP_LIST): + self.cmp_list = cmp_list + def __call__(self, bug_1, bug_2): + for comparison in self.cmp_list : + val = comparison(bug_1, bug_2) + if val != 0 : + return val + return 0 + +cmp_full = BugCompoundComparator() + + +# define some bonus cmp_* functions +def cmp_last_modified(bug_1, bug_2): + """ + Like cmp_time(), but use most recent comment instead of bug + creation for the timestamp. + """ + def last_modified(bug): + time = bug.time + for comment in bug.comment_root.traverse(): + if comment.time > time: + time = comment.time + return time + val_1 = last_modified(bug_1) + val_2 = last_modified(bug_2) + return -cmp(val_1, val_2) + suite = doctest.DocTestSuite() diff --git a/libbe/bugdir.py b/libbe/bugdir.py index 7885224..a9ec42e 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -51,13 +51,6 @@ class AlreadyInitialized(Exception): Exception.__init__(self, "Specified root is already initialized: %s" % path) -class InvalidValue(ValueError): - def __init__(self, name, value): - msg = "Cannot assign value %s to %s" % (value, name) - Exception.__init__(self, msg) - self.name = name - self.value = value - class MultipleBugMatches(ValueError): def __init__(self, shortname, matches): msg = ("More than one bug matches %s. "