aboutsummaryrefslogtreecommitdiffstats
path: root/becommands
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-06-22 16:27:46 -0400
committerW. Trevor King <wking@drexel.edu>2009-06-22 16:27:46 -0400
commit4e5dc3888699076e46bdc1d94f901ca889b88b05 (patch)
tree752955efc584d113261c5e5c865faf51113703d8 /becommands
parent0f6e647f18a2d6165c0333cb7d123fc781c8e4e1 (diff)
downloadbugseverywhere-4e5dc3888699076e46bdc1d94f901ca889b88b05.tar.gz
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.
Diffstat (limited to 'becommands')
-rw-r--r--becommands/comment.py4
-rw-r--r--becommands/list.py22
-rw-r--r--becommands/set.py7
3 files changed, 25 insertions, 8 deletions
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 "<bugs>"
if len(cur_bugs) > 0:
@@ -130,7 +140,13 @@ def execute(args, test=False):
print bg.string(shortlist=True)
if xml == True:
print "</bugs>"
-
+
+ # 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()