aboutsummaryrefslogtreecommitdiffstats
path: root/becommands
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-11-21 13:49:32 -0500
committerW. Trevor King <wking@drexel.edu>2009-11-21 13:49:32 -0500
commit607c72ea7f3382f3a51598593b71eabbbdbef664 (patch)
treecd60e44c62b30c4dac06f20d749e02a86a6dd5aa /becommands
parent65bf5f8d9ddf51625d6b3b282838a9a4c71868d3 (diff)
downloadbugseverywhere-607c72ea7f3382f3a51598593b71eabbbdbef664.tar.gz
Adjusted `be import-xml` to properly handle croot_bug==None.
If there aren't any root comments, then the user needn't specify --comment-root, in which case croot_bug will be None and we want to skip all the croot processing.
Diffstat (limited to 'becommands')
-rw-r--r--becommands/import_xml.py57
1 files changed, 31 insertions, 26 deletions
diff --git a/becommands/import_xml.py b/becommands/import_xml.py
index 2572075..928ca46 100644
--- a/becommands/import_xml.py
+++ b/becommands/import_xml.py
@@ -105,37 +105,42 @@ def execute(args, manipulate_encodings=True):
% (child.tag, comment_list.tag)
# merge the new root_comments
- croot_cids = []
- for c in croot_bug.comment_root.traverse():
- croot_cids.append(c.uuid)
- if c.alt_id != None:
- croot_cids.append(c.alt_id)
- for new in root_comments:
- if new.alt_id in croot_cids:
- raise cmdutil.UserError(
- 'clashing comment alt_id: %s' % new.alt_id)
- croot_cids.append(new.uuid)
- if new.alt_id != None:
- croot_cids.append(new.alt_id)
- if new.in_reply_to == None:
- new.in_reply_to = croot_comment.uuid
- try:
- # link new comments
- comment.list_to_root(root_comments,croot_bug,root=croot_comment,
- ignore_missing_references= \
- options.ignore_missing_references)
- except comment.MissingReference, e:
- raise cmdutil.UserError(e)
-
+ if len(root_comments) > 0:
+ if croot_bug == None:
+ raise UserError(
+ '--comment-root option is required for your root comments:\n%s'
+ % '\n\n'.join([c.string() for c in root_comments]))
+ croot_cids = []
+ for c in croot_bug.comment_root.traverse():
+ croot_cids.append(c.uuid)
+ if c.alt_id != None:
+ croot_cids.append(c.alt_id)
+ for new in root_comments:
+ if new.alt_id in croot_cids:
+ raise cmdutil.UserError(
+ 'clashing comment alt_id: %s' % new.alt_id)
+ croot_cids.append(new.uuid)
+ if new.alt_id != None:
+ croot_cids.append(new.alt_id)
+ if new.in_reply_to == None:
+ new.in_reply_to = croot_comment.uuid
+ try:
+ # link new comments
+ comment.list_to_root(root_comments,croot_bug,root=croot_comment,
+ ignore_missing_references= \
+ options.ignore_missing_references)
+ except comment.MissingReference, e:
+ raise cmdutil.UserError(e)
# merge the new croot_bugs
for new in root_bugs:
bd.append(new)
# protect against programmer error causing data loss:
- comms = [c.uuid for c in croot_comment.traverse()]
- for new in root_comments:
- assert new.uuid in comms, \
- "comment %s wasn't added to %s" % (new.uuid, croot_comment.uuid)
+ if croot_bug != None:
+ comms = [c.uuid for c in croot_comment.traverse()]
+ for new in root_comments:
+ assert new.uuid in comms, \
+ "comment %s wasn't added to %s" % (new.uuid, croot_comment.uuid)
for new in root_bugs:
assert bd.has_bug(new.uuid), \
"bug %s wasn't added" % (new.uuid)