0
@@ -85,6 +85,7 @@ class Person:
0
def __init__(self, issue, author, comment):
0
@@ -92,6 +93,7 @@ class Comment:
0
self.attachments = [] # records filename and blob
0
+ self.issue.comments[self.get_name()] = self # register into issue
0
self.modified = datetime.now()
0
@@ -103,7 +105,7 @@ class Comment:
0
del odict['self_dirty'] # remove self dirty flag
0
- def __setstate__(self,
dict):
0
+ def __setstate__(self,
dict):
0
self.__dict__.update(dict) # update attributes
0
self.self_dirty = False
0
@@ -314,6 +316,27 @@ class IssueSet:
0
self.shelf[self.comment_path(comment)] = comment
0
self.mark_dirty(self_dirty = False)
0
+ def get_comment(self, idx_or_partial_hash):
0
+ idx = int(idx_or_partial_hash) - 1
0
+ comment = self.shelf[self.shelf.keys()[idx]]
0
+ clean = lambda x: x.split('comment')[0].replace('/', '')
0
+ matching = [(clean(key), key) for key in self.shelf.iterkeys()
0
+ if clean(key).startswith(idx_or_partial_hash) and not "issue.xml" in clean(key)]
0
+ if len(matching) == 0:
0
+ elif len(matching) == 1:
0
+ comment = self.shelf[matching[0][1]]
0
+ print ("Ambiguous hash matches:\n" +
0
+ '\t\n'.join(a[0] for a in matching))
0
+ raise Exception("There is no issue matching the identifier '%s'.\n" %
0
def __getitem__(self, idx_or_partial_hash):
0
@@ -322,7 +345,7 @@ class IssueSet:
0
clean = lambda x: x.replace('issue.xml', '').replace('/','')
0
matching = [(clean(key), key) for key in self.shelf.iterkeys()
0
- if clean(key).startswith(idx_or_partial_hash)
]
0
+ if clean(key).startswith(idx_or_partial_hash)
and not "comment" in clean(key)]
0
elif len(matching) == 1:
0
@@ -644,6 +667,25 @@ class XmlIssueBuilder:
0
build = classmethod(build)
0
+class XmlCommentBuilder:
0
+ def build(cls, comment, node, doc):
0
+ commentNode = doc.createElement("comment")
0
+ created = doc.createElement("created")
0
+ XmlBuilder.build(comment.created, created, doc)
0
+ commentNode.appendChild(created)
0
+ author = doc.createElement("author")
0
+ XmlBuilder.build(comment.author, author, doc)
0
+ commentNode.appendChild(author)
0
+ commentText = doc.createElement("comment")
0
+ XmlBuilder.build(comment.comment, commentText, doc)
0
+ commentNode.appendChild(commentText)
0
+ node.appendChild(commentNode)
0
+ build = classmethod(build)
0
#class XmlIssueChangesBuilder:
0
# def build(cls, data, node, doc):
0
# changes = doc.createElement("changes")
0
@@ -741,7 +783,12 @@ class XmlBuilder:
0
doc = xml.dom.minidom.Document()
0
XmlIssueSetBuilder.build(data, doc, doc)
0
+ elif isinstance(data, Comment):
0
+ doc = xml.dom.minidom.Document()
0
+ XmlCommentBuilder.build(data, doc, doc)
0
+ print "Unknown type %s" % data
0
@@ -763,7 +810,7 @@ class GitComment(Comment):
0
hash_func = self.issue.issueSet.shelf.hash_blob
0
- name = hash_
blob(str(self.created)
0
+ name = hash_
func(str(self.created)
0
@@ -954,6 +1001,8 @@ if __name__ == '__main__':
0
filteredStati = options.filterStatus.split(":")
0
for item in issueSet.shelf.iteritems():
0
+ if "comment" in item[0]:
0
issue = item[1].get_data()
0
if issue.status in filteredStati:
0
@@ -965,7 +1014,7 @@ if __name__ == '__main__':
0
######################################################################
0
elif command == "show" or command == "dump":
0
@@ -973,6 +1022,8 @@ if __name__ == '__main__':
0
print "Shows needs an index or Id."
0
issue = issueSet[args[0]]
0
+ comments = "\n".join(["Comment (%s): %s" % (comment[0:7], comment[0:7])
0
+ for comment in issue.comments])
0
@@ -998,7 +1049,7 @@ if __name__ == '__main__':
0
format_long_text(issue.summary),
0
@@ -1021,7 +1072,8 @@ if __name__ == '__main__':
0
@@ -1073,6 +1125,14 @@ if __name__ == '__main__':
0
if options.printNewBugs:
0
print "%s: %s (%s)" % (issue.status, issue.title, issue.name[0:7])
0
+ elif command == "comment":
0
+ print "Usage: %s comment <issue-id> <comment-title>" % sys.argv[0]
0
+ issue = issueSet[args[0]]
0
+ comment = issueSet.new_comment(issue, args[1])
0
+ if options.printNewBugs:
0
+ print "### Comment(%s): %s" % (comment.name[0:7], comment.comment)
0
######################################################################
Comments
No one has commented yet.