From ab1b33b702c4c84a90fd5d7ba8c6dd0078fc303a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 6 Jul 2009 15:54:13 -0400 Subject: Added ability to show individual comments with "be show". --- becommands/show.py | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'becommands') diff --git a/becommands/show.py b/becommands/show.py index ff434ab..dfaece1 100644 --- a/becommands/show.py +++ b/becommands/show.py @@ -53,27 +53,47 @@ def execute(args, test=False): parser = get_parser() options, args = parser.parse_args(args) cmdutil.default_complete(options, args, parser, - bugid_args={0: lambda bug : bug.active==True}) + bugid_args={-1: lambda bug : bug.active==True}) if len(args) == 0: raise cmdutil.UsageError bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test) - for bugid in args: - bug = bd.bug_from_shortname(bugid) - if options.dumpXML: - print bug.xml(show_comments=True) + for shortname in args: + 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_comment = True else: - print bug.string(show_comments=True) - if bugid != args[-1]: - print "" # add a blank line between bugs + bugname = shortname + is_comment = False + bug = bd.bug_from_shortname(bugname) + if is_comment == False: + if options.dumpXML: + print bug.xml(show_comments=True) + else: + print bug.string(show_comments=True) + else: + comment = bug.comment_root.comment_from_shortname( + shortname, bug_shortname=bugname) + if options.dumpXML: + print comment.xml(shortname=shortname) + else: + print comment.string(shortname=shortname) + if shortname != args[-1] and options.dumpXML == False: + print "" # add a blank line between bugs/comments def get_parser(): - parser = cmdutil.CmdOptionParser("be show [options] BUG-ID [BUG-ID ...]") + parser = cmdutil.CmdOptionParser("be show [options] ID [ID ...]") parser.add_option("-x", "--xml", action="store_true", dest='dumpXML', help="Dump as XML") return parser longhelp=""" -Show all information about a bug. +Show all information about the bugs or comments whose IDs are given. + +It's probably not a good idea to mix bug and comment IDs in a single +call, but you're free to do so if you like. """ def help(): -- cgit From 9e1430329040913810378bdbaf5c9b7919821fd7 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 6 Jul 2009 16:15:09 -0400 Subject: Added "be show --only-raw-body COMMENT-ID". --- becommands/show.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'becommands') diff --git a/becommands/show.py b/becommands/show.py index dfaece1..d72b3a8 100644 --- a/becommands/show.py +++ b/becommands/show.py @@ -19,6 +19,7 @@ # 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""" +import sys from libbe import cmdutil, bugdir __desc__ = __doc__ @@ -79,7 +80,10 @@ def execute(args, test=False): if options.dumpXML: print comment.xml(shortname=shortname) else: - print comment.string(shortname=shortname) + if len(args) == 1 and options.only_raw_body == True: + sys.__stdout__.write(comment.body) + else: + print comment.string(shortname=shortname) if shortname != args[-1] and options.dumpXML == False: print "" # add a blank line between bugs/comments @@ -87,6 +91,8 @@ def get_parser(): parser = cmdutil.CmdOptionParser("be show [options] ID [ID ...]") parser.add_option("-x", "--xml", action="store_true", dest='dumpXML', help="Dump as XML") + parser.add_option("--only-raw-body", action="store_true", + dest='only_raw_body', help="When printing only a single comment, just print it's body. This allows extraction of non-text content types.") return parser longhelp=""" -- cgit From e5c0d5f2f3f7637cad6baca9e33778d0c054195d Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 7 Jul 2009 22:18:56 -0400 Subject: Added new-bug-from-stdin to mirror comments-from-stdin. --- becommands/new.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'becommands') diff --git a/becommands/new.py b/becommands/new.py index 32e070a..ec28138 100644 --- a/becommands/new.py +++ b/becommands/new.py @@ -45,7 +45,11 @@ def execute(args, test=False): if len(args) != 1: raise cmdutil.UsageError("Please supply a summary message") bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test) - bug = bd.new_bug(summary=args[0]) + if args[0] == '-': # read summary from stdin + summary = sys.stdin.readline() + else: + summary = args[0] + bug = bd.new_bug(summary=summary.strip()) if options.reporter != None: bug.reporter = options.reporter else: @@ -66,8 +70,9 @@ def get_parser(): return parser longhelp=""" -Create a new bug, with a new ID. The summary specified on the commandline -is a string that describes the bug briefly. +Create a new bug, with a new ID. The summary specified on the +commandline is a string (only one line) that describes the bug briefly +or "-", in which case the string will be read from stdin. """ def help(): -- cgit From c5da71a900d6263e29deb94d81aa22e6ba6f34ea Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 10 Jul 2009 14:14:24 -0400 Subject: Save whole bugdir in becommands/tag.py. It doesn't matter now, but at some point Bugdir might implement some sort of repo-wide caching which would need to be saved. The BugDir.save() method should be intelligent enough to not save things that have not changed, so efficiency should not be effected either. --- becommands/tag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'becommands') diff --git a/becommands/tag.py b/becommands/tag.py index ab0324e..1b20ddb 100644 --- a/becommands/tag.py +++ b/becommands/tag.py @@ -102,7 +102,7 @@ def execute(args, test=False): else: # add the tag estrs.append(tag_string) bug.extra_strings = estrs # reassign to notice change - bug.save() + bd.save() tags = [] for estr in bug.extra_strings: -- cgit From f0300038113e2754d83ee73f32a51072ad9b1f3b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 10 Jul 2009 17:58:49 -0400 Subject: seems to work ;) --- becommands/comment.py | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'becommands') diff --git a/becommands/comment.py b/becommands/comment.py index 0b3a576..a11cd90 100644 --- a/becommands/comment.py +++ b/becommands/comment.py @@ -1,7 +1,6 @@ # Copyright (C) 2005-2009 Aaron Bentley and Panometrics, Inc. # Chris Ball # W. Trevor King -# # # 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 @@ -17,9 +16,13 @@ # 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 cmdutil, bugdir, settings_object, editor +from libbe import cmdutil, bugdir, comment, settings_object, editor import os import sys +try: # import core module, Python >= 2.5 + from xml.etree import ElementTree +except ImportError: # look for non-core module + from elementtree import ElementTree __desc__ = __doc__ def execute(args, test=False): @@ -108,15 +111,45 @@ def execute(args, test=False): if not body.endswith('\n'): body+='\n' - comment = parent.new_reply(body=body) - if options.content_type != None: - comment.content_type = options.content_type + if options.XML == False: + new = parent.new_reply(body=body) + if options.content_type != None: + new.content_type = options.content_type + else: # import XML comment [list] + # read in the comments + comment_list = ElementTree.XML(body) + if comment_list.tag not in ["bug", "comment-list"]: + raise comment.InvalidXML( + comment_list, "root element must be or ") + new_comments = [] + uuids = [c.uuid for c in bug.comment_root.traverse()] # unique uuid check should be unique alt_id check + for child in comment_list.getchildren(): + if child.tag == "comment": + new = comment.Comment(bug) + new.from_xml(ElementTree.tostring(child)) + if new.uuid in uuids: + raise cmdutil.UserError( + "Clashing comment uuids: %s" % new.uuid) + uuids.append(new.uuid) + if new.in_reply_to in [settings_object.EMPTY, None]: + new.in_reply_to = parent.uuid + new_comments.append(new) + else: + print >> sys.stderr, "Ignoring unknown tag %s in %s" \ + % (child.tag, comment_list.tag) + comment.list_to_root(new_comments,bug,root=parent) # link new comments + # Protect against programmer error causing data loss: + kids = [c.uuid for c in parent.traverse()] + for nc in new_comments: + assert nc.uuid in kids, "%s wasn't added to %s" % (nc.uuid, parent.uuid) 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) + parser.add_option("-x", "--xml", action="store_true", default=False, + dest='XML', help="Use COMMENT to specify an XML comment description rather than the comment body. The root XML element should be either or with one or more children. The syntax for the elements should match that generated by 'be show --xml COMMENT-ID'. Unrecognized tags are ignored. Missing tags are left at the default value (e.g. ) or auto-generated (e.g ). An exception is raised if conflicts with an existing comment.") # Are comment UUIDs global? no. should match on alt_id anyway... return parser longhelp=""" -- cgit From f87355fddc2a931e3f984d074a713f4313d5f709 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 11 Jul 2009 07:46:22 -0400 Subject: Adjustments to new versioned_property behavior. Also adjusted libbe/comment.py to move to user-specified alt_ids, rather than uuids. --- becommands/assign.py | 6 +++--- becommands/comment.py | 6 +++--- becommands/new.py | 6 +++--- becommands/set.py | 2 +- becommands/target.py | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'becommands') diff --git a/becommands/assign.py b/becommands/assign.py index 985cfdd..871a3af 100644 --- a/becommands/assign.py +++ b/becommands/assign.py @@ -18,7 +18,7 @@ # 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 cmdutil, bugdir, settings_object +from libbe import cmdutil, bugdir __desc__ = __doc__ def execute(args, test=False): @@ -26,7 +26,7 @@ def execute(args, test=False): >>> import os >>> bd = bugdir.simple_bug_dir() >>> os.chdir(bd.root) - >>> bd.bug_from_shortname("a").assigned is settings_object.EMPTY + >>> bd.bug_from_shortname("a").assigned is None True >>> execute(["a"], test=True) @@ -41,7 +41,7 @@ def execute(args, test=False): >>> execute(["a","none"], test=True) >>> bd._clear_bugs() - >>> bd.bug_from_shortname("a").assigned is settings_object.EMPTY + >>> bd.bug_from_shortname("a").assigned is None True """ parser = get_parser() diff --git a/becommands/comment.py b/becommands/comment.py index a11cd90..f350291 100644 --- a/becommands/comment.py +++ b/becommands/comment.py @@ -16,7 +16,7 @@ # 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 cmdutil, bugdir, comment, settings_object, editor +from libbe import cmdutil, bugdir, comment, editor import os import sys try: # import core module, Python >= 2.5 @@ -42,7 +42,7 @@ def execute(args, test=False): True >>> comment.time <= int(time.time()) True - >>> comment.in_reply_to is settings_object.EMPTY + >>> comment.in_reply_to is None True >>> if 'EDITOR' in os.environ: @@ -131,7 +131,7 @@ def execute(args, test=False): raise cmdutil.UserError( "Clashing comment uuids: %s" % new.uuid) uuids.append(new.uuid) - if new.in_reply_to in [settings_object.EMPTY, None]: + if new.in_reply_to == None: new.in_reply_to = parent.uuid new_comments.append(new) else: diff --git a/becommands/new.py b/becommands/new.py index ec28138..922b5ed 100644 --- a/becommands/new.py +++ b/becommands/new.py @@ -16,7 +16,7 @@ # 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 cmdutil, bugdir, settings_object +from libbe import cmdutil, bugdir __desc__ = __doc__ def execute(args, test=False): @@ -36,7 +36,7 @@ def execute(args, test=False): True >>> print bug.severity minor - >>> bug.target == settings_object.EMPTY + >>> bug.target == None True """ parser = get_parser() @@ -56,7 +56,7 @@ def execute(args, test=False): bug.reporter = bug.creator if options.assigned != None: bug.assigned = options.assigned - elif bd.default_assignee != settings_object.EMPTY: + elif bd.default_assignee != None: bug.assigned = bd.default_assignee bd.save() print "Created bug with ID %s" % bd.bug_shortname(bug) diff --git a/becommands/set.py b/becommands/set.py index e771018..939236a 100644 --- a/becommands/set.py +++ b/becommands/set.py @@ -26,7 +26,7 @@ def _value_string(bd, setting): val = bd.settings.get(setting, settings_object.EMPTY) if val == settings_object.EMPTY: default = getattr(bd, bd._setting_name_to_attr_name(setting)) - if default != settings_object.EMPTY: + if default not in [None, settings_object.EMPTY]: val = "None (%s)" % default else: val = None diff --git a/becommands/target.py b/becommands/target.py index 283998a..aa027e0 100644 --- a/becommands/target.py +++ b/becommands/target.py @@ -20,7 +20,7 @@ # 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 cmdutil, bugdir, settings_object +from libbe import cmdutil, bugdir __desc__ = __doc__ def execute(args, test=False): @@ -56,7 +56,7 @@ def execute(args, test=False): return bug = bd.bug_from_shortname(args[0]) if len(args) == 1: - if bug.target is None or bug.target is settings_object.EMPTY: + if bug.target is None: print "No target assigned." else: print bug.target -- cgit From c5fcffdcf6944eecc8fac0582ab938961eb987a8 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 11 Jul 2009 08:01:45 -0400 Subject: "be comment --xml" now translates comment uuids to alt_ids. --- becommands/comment.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'becommands') diff --git a/becommands/comment.py b/becommands/comment.py index f350291..1e6ecd4 100644 --- a/becommands/comment.py +++ b/becommands/comment.py @@ -122,15 +122,21 @@ def execute(args, test=False): raise comment.InvalidXML( comment_list, "root element must be or ") new_comments = [] - uuids = [c.uuid for c in bug.comment_root.traverse()] # unique uuid check should be unique alt_id check + ids = [] + for c in bug.comment_root.traverse(): + ids.append(c.uuid) + if c.alt_id != None: + ids.append(c.alt_id) for child in comment_list.getchildren(): if child.tag == "comment": new = comment.Comment(bug) new.from_xml(ElementTree.tostring(child)) - if new.uuid in uuids: + if new.alt_id in ids: raise cmdutil.UserError( - "Clashing comment uuids: %s" % new.uuid) - uuids.append(new.uuid) + "Clashing comment alt_id: %s" % new.alt_id) + ids.append(new.uuid) + if new.alt_id != None: + ids.append(new.alt_id) if new.in_reply_to == None: new.in_reply_to = parent.uuid new_comments.append(new) @@ -149,7 +155,7 @@ def get_parser(): parser.add_option("-c", "--content-type", metavar="MIME", dest="content_type", help="Set comment content-type (e.g. text/plain)", default=None) parser.add_option("-x", "--xml", action="store_true", default=False, - dest='XML', help="Use COMMENT to specify an XML comment description rather than the comment body. The root XML element should be either or with one or more children. The syntax for the elements should match that generated by 'be show --xml COMMENT-ID'. Unrecognized tags are ignored. Missing tags are left at the default value (e.g. ) or auto-generated (e.g ). An exception is raised if conflicts with an existing comment.") # Are comment UUIDs global? no. should match on alt_id anyway... + dest='XML', help="Use COMMENT to specify an XML comment description rather than the comment body. The root XML element should be either or with one or more children. The syntax for the elements should match that generated by 'be show --xml COMMENT-ID'. Unrecognized tags are ignored. Missing tags are left at the default value. The comment UUIDs are always auto-generated, so if you set a field, but no field, your will be used as the comment's . An exception is raised if conflicts with an existing comment.") return parser longhelp=""" -- cgit From a03fea1b2b2eeb95d8ab62c49724bbf0cf631f19 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 11 Jul 2009 08:13:34 -0400 Subject: Removed from copyright blurbs. These didn't work with my update_copyright.sh. I went with Aaron Bentley and Panometrics, Inc. instead of Aaron Bentley and Panometrics, Inc. just because of line length, but I'm open to convincing if people prefer the latter... --- becommands/assign.py | 1 - becommands/close.py | 1 - becommands/diff.py | 1 - becommands/init.py | 1 - becommands/list.py | 1 - becommands/merge.py | 1 - becommands/new.py | 1 - becommands/open.py | 1 - becommands/remove.py | 1 - becommands/set.py | 1 - becommands/severity.py | 1 - becommands/show.py | 1 - becommands/status.py | 1 - becommands/target.py | 1 - 14 files changed, 14 deletions(-) (limited to 'becommands') diff --git a/becommands/assign.py b/becommands/assign.py index 871a3af..e6126b8 100644 --- a/becommands/assign.py +++ b/becommands/assign.py @@ -2,7 +2,6 @@ # Marien Zwart # Thomas Gerigk # W. Trevor King -# # # 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 diff --git a/becommands/close.py b/becommands/close.py index deaccce..ddffaa5 100644 --- a/becommands/close.py +++ b/becommands/close.py @@ -2,7 +2,6 @@ # Marien Zwart # Thomas Gerigk # W. Trevor King -# # # 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 diff --git a/becommands/diff.py b/becommands/diff.py index 2bdea93..aa782b4 100644 --- a/becommands/diff.py +++ b/becommands/diff.py @@ -1,6 +1,5 @@ # Copyright (C) 2005-2009 Aaron Bentley and Panometrics, Inc. # W. Trevor King -# # # 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 diff --git a/becommands/init.py b/becommands/init.py index 390dd15..5d9ccda 100644 --- a/becommands/init.py +++ b/becommands/init.py @@ -1,6 +1,5 @@ # Copyright (C) 2005-2009 Aaron Bentley and Panometrics, Inc. # W. Trevor King -# # # 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 diff --git a/becommands/list.py b/becommands/list.py index 443704b..0fc0609 100644 --- a/becommands/list.py +++ b/becommands/list.py @@ -2,7 +2,6 @@ # Chris Ball # Oleg Romanyshyn # W. Trevor King -# # # 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 diff --git a/becommands/merge.py b/becommands/merge.py index 4bec6bf..3839774 100644 --- a/becommands/merge.py +++ b/becommands/merge.py @@ -1,5 +1,4 @@ # Copyright (C) 2008-2009 W. Trevor King -# # # 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 diff --git a/becommands/new.py b/becommands/new.py index 922b5ed..ceb4949 100644 --- a/becommands/new.py +++ b/becommands/new.py @@ -1,6 +1,5 @@ # Copyright (C) 2005-2009 Aaron Bentley and Panometrics, Inc. # W. Trevor King -# # # 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 diff --git a/becommands/open.py b/becommands/open.py index f9abcbb..6d13af0 100644 --- a/becommands/open.py +++ b/becommands/open.py @@ -2,7 +2,6 @@ # Marien Zwart # Thomas Gerigk # W. Trevor King -# # # 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 diff --git a/becommands/remove.py b/becommands/remove.py index 213a8d9..e20440b 100644 --- a/becommands/remove.py +++ b/becommands/remove.py @@ -1,5 +1,4 @@ # Copyright (C) 2008-2009 W. Trevor King -# # # 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 diff --git a/becommands/set.py b/becommands/set.py index 939236a..a7a47cc 100644 --- a/becommands/set.py +++ b/becommands/set.py @@ -3,7 +3,6 @@ # Marien Zwart # Thomas Gerigk # W. Trevor King -# # # 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 diff --git a/becommands/severity.py b/becommands/severity.py index f8a0c02..36dea6e 100644 --- a/becommands/severity.py +++ b/becommands/severity.py @@ -2,7 +2,6 @@ # Marien Zwart # Thomas Gerigk # W. Trevor King -# # # 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 diff --git a/becommands/show.py b/becommands/show.py index d72b3a8..a4208c3 100644 --- a/becommands/show.py +++ b/becommands/show.py @@ -3,7 +3,6 @@ # Thomas Gerigk # Thomas Habets # W. Trevor King -# # # 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 diff --git a/becommands/status.py b/becommands/status.py index d8bd4c4..7413136 100644 --- a/becommands/status.py +++ b/becommands/status.py @@ -1,5 +1,4 @@ # Copyright (C) 2008-2009 W. Trevor King -# # # 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 diff --git a/becommands/target.py b/becommands/target.py index aa027e0..e2283f4 100644 --- a/becommands/target.py +++ b/becommands/target.py @@ -4,7 +4,6 @@ # Marien Zwart # Thomas Gerigk # W. Trevor King -# # # 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 -- cgit From 5208a2808a2a87cbfa9d8589d5ac254aa0dea64f Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 11 Jul 2009 09:46:38 -0400 Subject: Updating "be set --help" and "be status --help". I don't really like the "defaults to None" for the settings that have funky initialization procedures (most of them :p), but I'm not sure how to handle that cleanly yet. Perhaps be set --current I also need to find a method of adding complicated settings like the nested lists for severities, etc from the "be set" commandline. --- becommands/set.py | 38 ++++++++++++++++++++++++++++++-------- becommands/status.py | 39 +++++++++++++++++++++++++++------------ 2 files changed, 57 insertions(+), 20 deletions(-) (limited to 'becommands') diff --git a/becommands/set.py b/becommands/set.py index a7a47cc..b050b35 100644 --- a/becommands/set.py +++ b/becommands/set.py @@ -18,7 +18,8 @@ # 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, bugdir, settings_object +import textwrap +from libbe import cmdutil, bugdir, rcs, settings_object __desc__ = __doc__ def _value_string(bd, setting): @@ -75,6 +76,30 @@ def get_parser(): parser = cmdutil.CmdOptionParser("be set [NAME] [VALUE]") return parser +def get_bugdir_settings(): + settings = [] + for s in bugdir.BugDir.settings_properties: + settings.append(s) + settings.sort() + documented_settings = [] + for s in settings: + set = getattr(bugdir.BugDir, s) + dstr = set.__doc__.strip() + # per-setting comment adjustments + if s == "rcs_name": + lines = dstr.split('\n') + while lines[0].startswith("This property defaults to") == False: + lines.pop(0) + assert len(lines) != None, \ + "Unexpected rcs_name docstring:\n '%s'" % dstr + lines.insert( + 0, "The name of the revision control system to use.\n") + dstr = '\n'.join(lines) + doc = textwrap.wrap(dstr, width=70, initial_indent=' ', + subsequent_indent=' ') + documented_settings.append("%s\n%s" % (s, '\n'.join(doc))) + return documented_settings + longhelp=""" Show or change per-tree settings. @@ -82,14 +107,11 @@ If name and value are supplied, the name is set to a new value. If no value is specified, the current value is printed. If no arguments are provided, all names and values are listed. -Interesting settings are: -rcs_name - The name of the revision control system. "Arch" and "None" are supported. -target - The current development goal - To unset a setting, set it to "none". -""" + +Allowed settings are: + +%s""" % ('\n'.join(get_bugdir_settings()),) def help(): return get_parser().help_str() + longhelp diff --git a/becommands/status.py b/becommands/status.py index 7413136..882f7b3 100644 --- a/becommands/status.py +++ b/becommands/status.py @@ -55,24 +55,39 @@ def get_parser(): def help(): - longhelp=[""" -Show or change a bug's status. - -If no status is specified, the current value is printed. If a status -is specified, it will be assigned to the bug. - -Status levels are: -"""] try: # See if there are any per-tree status configurations bd = bugdir.BugDir(from_disk=True, manipulate_encodings=False) except bugdir.NoBugDir, e: pass # No tree, just show the defaults longest_status_len = max([len(s) for s in bug.status_values]) - for status in bug.status_values : + active_statuses = [] + for status in bug.active_status_values : + description = bug.status_description[status] + s = "%*s : %s" % (longest_status_len, status, description) + active_statuses.append(s) + inactive_statuses = [] + for status in bug.inactive_status_values : description = bug.status_description[status] - s = "%*s : %s\n" % (longest_status_len, status, description) - longhelp.append(s) - longhelp = ''.join(longhelp) + s = "%*s : %s" % (longest_status_len, status, description) + inactive_statuses.append(s) + longhelp=""" +Show or change a bug's status. + +If no status is specified, the current value is printed. If a status +is specified, it will be assigned to the bug. + +There are two classes of statuses, active and inactive, which are only +important for commands like "be list" that show only active bugs by +default. + +Active status levels are: + %s +Inactive status levels are: + %s + +You can overide the list of allowed statuses on a per-repository basis. +See "be set --help" for more details. +""" % ('\n '.join(active_statuses), '\n '.join(inactive_statuses)) return get_parser().help_str() + longhelp def complete(options, args, parser): -- cgit From a65b273fa14df2a085342bac14abb8a2167ff98a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 11 Jul 2009 10:09:27 -0400 Subject: Went through "closed" bugs looking for miss-categorized bugs. Found a few that were actually "fixed" and one that I reopened. Perhaps we should add a "merged" status to the default, so that the merged bugs don't clutter up the closed bugs category... --- becommands/set.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'becommands') diff --git a/becommands/set.py b/becommands/set.py index b050b35..fa431e9 100644 --- a/becommands/set.py +++ b/becommands/set.py @@ -60,7 +60,9 @@ def execute(args, test=False): elif len(args) == 1: print _value_string(bd, args[0]) else: - if args[1] != "none": + if args[1] == "none": + del bd.settings[args[0]] + else: if args[0] not in bd.settings_properties: msg = "Invalid setting %s\n" % args[0] msg += 'Allowed settings:\n ' @@ -68,8 +70,6 @@ def execute(args, test=False): raise cmdutil.UserError(msg) old_setting = bd.settings.get(args[0]) setattr(bd, args[0], args[1]) - else: - del bd.settings[args[0]] bd.save() def get_parser(): -- cgit From 76d552e5401df990a601f245f30f45d7c13cdd1e Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 12 Jul 2009 08:38:40 -0400 Subject: Added be-mbox-to-xml. Reworked to allow "be comment" to handle unicode strings (see bug e4ed63f6-9000-4d0b-98c3-487269140141). The solution was to escape all the unicode to produce and ASCII string before calling ElementTree.XML, and then converting back to unicode afterwards. Added a unicode-containing comment to the end of bug f7ccd916-b5c7-4890-a2e3-8c8ace17ae3a so that there's a handy unicode comment for testing. XML headers (e.g. '') are now added to all xml output from be. Switched non-text/* encoding library to base64 instead of email.encoders, which makes that code in libbe/comment.py simpler. Changed libbe/mapfile.py error encoding from string_escape to unicode_escape so it can handle unicode. Everything's still untested, and be-xml-to-mbox doesn't handle unicode yet, but I felt this commit was getting a bit unwieldy ;). --- becommands/comment.py | 5 +++-- becommands/show.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'becommands') diff --git a/becommands/comment.py b/becommands/comment.py index 1e6ecd4..c4b074f 100644 --- a/becommands/comment.py +++ b/becommands/comment.py @@ -117,7 +117,8 @@ def execute(args, test=False): new.content_type = options.content_type else: # import XML comment [list] # read in the comments - comment_list = ElementTree.XML(body) + str_body = body.strip().encode("unicode_escape") + comment_list = ElementTree.XML(str_body) if comment_list.tag not in ["bug", "comment-list"]: raise comment.InvalidXML( comment_list, "root element must be or ") @@ -130,7 +131,7 @@ def execute(args, test=False): for child in comment_list.getchildren(): if child.tag == "comment": new = comment.Comment(bug) - new.from_xml(ElementTree.tostring(child)) + new.from_xml(unicode(ElementTree.tostring(child)).decode("unicode_escape")) if new.alt_id in ids: raise cmdutil.UserError( "Clashing comment alt_id: %s" % new.alt_id) diff --git a/becommands/show.py b/becommands/show.py index a4208c3..f700caa 100644 --- a/becommands/show.py +++ b/becommands/show.py @@ -40,6 +40,7 @@ def execute(args, test=False): Bug A >>> execute (["--xml", "a"], test=True) # doctest: +ELLIPSIS + a a @@ -70,6 +71,7 @@ def execute(args, test=False): bug = bd.bug_from_shortname(bugname) if is_comment == False: if options.dumpXML: + print '' % bd.encoding print bug.xml(show_comments=True) else: print bug.string(show_comments=True) -- cgit From e757fd3eb3a600a919b9d1542bc68c3a4e9ae939 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 12 Jul 2009 09:05:05 -0400 Subject: Not escaping whitespace (e.g. endlines) outside the XML document root. ElementTree.XML was choking on them. I should unescape all whitespace (e.g. tabs, etc.), but I'm lazy and don't have any XML that's strange enough to need it ;). --- becommands/comment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'becommands') diff --git a/becommands/comment.py b/becommands/comment.py index c4b074f..9a1e2ec 100644 --- a/becommands/comment.py +++ b/becommands/comment.py @@ -117,7 +117,7 @@ def execute(args, test=False): new.content_type = options.content_type else: # import XML comment [list] # read in the comments - str_body = body.strip().encode("unicode_escape") + str_body = body.encode("unicode_escape").replace(r'\n', '\n') comment_list = ElementTree.XML(str_body) if comment_list.tag not in ["bug", "comment-list"]: raise comment.InvalidXML( -- cgit From d49efee62f70c9f49a5236719fd8c52dabd37dae Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 12 Jul 2009 13:12:08 -0400 Subject: Altered be-xml-to-mbox to work with non-ASCII input. Now it runs off xml.etree instead of xml.sax. Removed "No matching bugs found" from "be list --xml" output. --- becommands/list.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'becommands') diff --git a/becommands/list.py b/becommands/list.py index 0fc0609..76614a0 100644 --- a/becommands/list.py +++ b/becommands/list.py @@ -134,11 +134,12 @@ def execute(args, test=False): return True bugs = [b for b in bd if filter(b) ] - if len(bugs) == 0: + if len(bugs) == 0 and options.xml == False: print "No matching bugs found" def list_bugs(cur_bugs, title=None, just_uuids=False, xml=False): if xml == True: + print '' % bd.encoding print "" if len(cur_bugs) > 0: if title != None and xml == False: -- cgit From b5c4896d7ffd219a3118a3e6885db5956bf79e55 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 12 Jul 2009 14:32:55 -0400 Subject: Added "be comment --xml --ignore-missing-references ID COMMENT". Now you don't have to edit them out by hand. --- becommands/comment.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'becommands') diff --git a/becommands/comment.py b/becommands/comment.py index 9a1e2ec..da82854 100644 --- a/becommands/comment.py +++ b/becommands/comment.py @@ -144,7 +144,11 @@ def execute(args, test=False): else: print >> sys.stderr, "Ignoring unknown tag %s in %s" \ % (child.tag, comment_list.tag) - comment.list_to_root(new_comments,bug,root=parent) # link new comments + try: + comment.list_to_root(new_comments,bug,root=parent, # link new comments + ignore_missing_references=options.ignore_missing_references) + except comment.MissingReference, e: + raise cmdutil.UserError(e) # Protect against programmer error causing data loss: kids = [c.uuid for c in parent.traverse()] for nc in new_comments: @@ -157,6 +161,9 @@ def get_parser(): help="Set comment content-type (e.g. text/plain)", default=None) parser.add_option("-x", "--xml", action="store_true", default=False, dest='XML', help="Use COMMENT to specify an XML comment description rather than the comment body. The root XML element should be either or with one or more children. The syntax for the elements should match that generated by 'be show --xml COMMENT-ID'. Unrecognized tags are ignored. Missing tags are left at the default value. The comment UUIDs are always auto-generated, so if you set a field, but no field, your will be used as the comment's . An exception is raised if conflicts with an existing comment.") + parser.add_option("-i", "--ignore-missing-references", action="store_true", + dest="ignore_missing_references", + help="For XML import, if any comment's refers to a non-existent comment, ignore it (instead of raising an exception).") return parser longhelp=""" -- cgit