From: W. Trevor King Date: Sat, 11 Jul 2009 12:01:45 +0000 (-0400) Subject: "be comment --xml" now translates comment uuids to alt_ids. X-Git-Tag: 1.0.0~64^2~14 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c5fcffdcf6944eecc8fac0582ab938961eb987a8;p=be.git "be comment --xml" now translates comment uuids to alt_ids. --- 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=""" diff --git a/libbe/comment.py b/libbe/comment.py index f573cea..d4d47a8 100644 --- a/libbe/comment.py +++ b/libbe/comment.py @@ -338,7 +338,7 @@ class Comment(Tree, settings_object.SavedSettingsObject): elif verbose == True: print >> sys.stderr, "Ignoring unknown tag %s in %s" \ % (child.tag, comment.tag) - if self.alt_id == None and uuid != None: + if self.alt_id == None and uuid not in [None, self.uuid]: self.alt_id = uuid def string(self, indent=0, shortname=None):