aboutsummaryrefslogtreecommitdiffstats
path: root/libbe
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2010-01-22 06:40:23 -0500
committerW. Trevor King <wking@drexel.edu>2010-01-22 06:40:23 -0500
commite0ce49ffa3d09d37310ce04c50268275b8e2ca54 (patch)
treee107a4c035956956ec61f27a1b45c15741010532 /libbe
parent36b970de8e5a4b2e1b91372742ce86819c4254b5 (diff)
parent6abea58e9359f14b256edb2dca0690b9c3ffe875 (diff)
downloadbugseverywhere-e0ce49ffa3d09d37310ce04c50268275b8e2ca54.tar.gz
Bugfix merge: better Comment.xml() & libbe.util.id.parse_user()
Highlights: * new Comment.safe_in_reply_to to improve comment xml output. * don't raise MultipleIDMatches if one of the matches is exact.
Diffstat (limited to 'libbe')
-rw-r--r--libbe/comment.py19
-rw-r--r--libbe/util/id.py2
2 files changed, 20 insertions, 1 deletions
diff --git a/libbe/comment.py b/libbe/comment.py
index b80188b..f0cc45c 100644
--- a/libbe/comment.py
+++ b/libbe/comment.py
@@ -253,6 +253,23 @@ class Comment(Tree, settings_object.SavedSettingsObject):
return str(value)
return value
+ def safe_in_reply_to(self):
+ """
+ Return self.in_reply_to, except...
+ * if no comment matches that id, in which case return None.
+ * if that id matches another comments .alt_id, in which case
+ return the matching comments .uuid.
+ """
+ if self.in_reply_to == None:
+ return None
+ else:
+ try:
+ irt_comment = self.bug.comment_from_uuid(
+ self.in_reply_to, match_alt_id=True)
+ return irt_comment.uuid
+ except KeyError:
+ return None
+
def xml(self, indent=0):
"""
>>> comm = Comment(bug=None, body="Some\\ninsightful\\nremarks\\n")
@@ -281,7 +298,7 @@ class Comment(Tree, settings_object.SavedSettingsObject):
info = [('uuid', self.uuid),
('alt-id', self.alt_id),
('short-name', self.id.user()),
- ('in-reply-to', self.in_reply_to),
+ ('in-reply-to', self.safe_in_reply_to()),
('author', self._setting_attr_string('author')),
('date', self.date),
('content-type', self.content_type),
diff --git a/libbe/util/id.py b/libbe/util/id.py
index 3945b20..4537c86 100644
--- a/libbe/util/id.py
+++ b/libbe/util/id.py
@@ -140,6 +140,8 @@ def _expand(truncated_id, common, other_ids):
other_ids = list(other_ids)
for id in other_ids:
if id.startswith(truncated_id):
+ if id == truncated_id:
+ return id
matches.append(id)
if len(matches) > 1:
raise MultipleIDMatches(truncated_id, common, matches)