diff options
author | W. Trevor King <wking@drexel.edu> | 2008-11-24 21:20:56 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2008-11-24 21:20:56 -0500 |
commit | e6d48051cbce1f74ec3c50fc0ccb72003258889e (patch) | |
tree | 91a4ea040eda5f35e3feba3a58d4294d33458126 /libbe | |
parent | 4c6f8ceeafd1eadb4de8f86fed93f779613deece (diff) | |
download | bugseverywhere-e6d48051cbce1f74ec3c50fc0ccb72003258889e.tar.gz |
Added becommands/merge to join duplicate bugs.
Diffstat (limited to 'libbe')
-rw-r--r-- | libbe/bug.py | 37 | ||||
-rw-r--r-- | libbe/comment.py | 19 |
2 files changed, 39 insertions, 17 deletions
diff --git a/libbe/bug.py b/libbe/bug.py index c75c968..68cff7b 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -95,6 +95,22 @@ class Bug(object): active = property(_get_active) + def _get_comment_root(self): + if self._comment_root == None: + if self._comments_loaded == True: + self._comment_root = comment.loadComments(self) + else: + self._comment_root = comment.Comment(self, + uuid=comment.INVALID_UUID) + return self._comment_root + + def _set_comment_root(self, comment_root): + self._comment_root = comment_root + + _comment_root = None + comment_root = property(_get_comment_root, _set_comment_root, + doc="The trunk of the comment tree") + def __init__(self, bugdir=None, uuid=None, from_disk=False, load_comments=False, summary=None): self.bugdir = bugdir @@ -123,7 +139,6 @@ class Bug(object): self.severity = "minor" self.assigned = None self.time = int(time.time()) # only save to second precision - self.comment_root = comment.Comment(self, uuid=comment.INVALID_UUID) def __repr__(self): return "Bug(uuid=%r)" % self.uuid @@ -162,7 +177,7 @@ class Bug(object): statuschar = self.status[0] severitychar = self.severity[0] chars = "%c%c" % (statuschar, severitychar) - bugout = "%s:%s: %s" % (shortname, chars, self.summary.rstrip('\n')) + bugout = "%s:%s: %s" % (shortname,chars,self.summary.rstrip('\n')) if show_comments == True: if self._comments_loaded == False: @@ -203,9 +218,10 @@ class Bug(object): self.load_comments() def load_comments(self): - self.comment_root = comment.loadComments(self) + # clear _comment_root, so _get_comment_root returns a fresh version + self._comment_root = None self._comments_loaded = True - + def comments(self): if self._comments_loaded == False: self.load_comments() @@ -233,23 +249,22 @@ class Bug(object): path = self.get_path("values") mapfile.map_save(self.rcs, path, map) - if self._comments_loaded: - if len(self.comment_root) > 0: - self.rcs.mkdir(self.get_path("comments")) - comment.saveComments(self) + if len(self.comment_root) > 0: + self.rcs.mkdir(self.get_path("comments")) + comment.saveComments(self) def remove(self): - self.load_comments() self.comment_root.remove() path = self.get_path() self.rcs.recursive_remove(path) def new_comment(self, body=None): - comm = comment.comment_root.new_reply(body=body) + comm = self.comment_root.new_reply(body=body) return comm def comment_from_shortname(self, shortname, *args, **kwargs): - return self.comment_root.comment_from_shortname(shortname, *args, **kwargs) + return self.comment_root.comment_from_shortname(shortname, + *args, **kwargs) def comment_from_uuid(self, uuid): return self.comment_root.comment_from_uuid(uuid) diff --git a/libbe/comment.py b/libbe/comment.py index c89fd9d..579e294 100644 --- a/libbe/comment.py +++ b/libbe/comment.py @@ -73,6 +73,14 @@ def saveComments(bug): for comment in bug.comment_root.traverse(): comment.save() +class InvalidShortname(KeyError): + def __init__(self, shortname, shortnames): + msg = "Invalid shortname %s\n%s" % (shortname, shortnames) + KeyError.__init__(self, msg) + self.shortname = shortname + self.shortnames = shortnames + + class Comment(Tree): def __init__(self, bug=None, uuid=None, from_disk=False, in_reply_to=None, body=None): @@ -133,12 +141,12 @@ class Comment(Tree): def string(self, indent=0, shortname=None): """ >>> comm = Comment(bug=None, body="Some\\ninsightful\\nremarks\\n") - >>> comm.time = utility.str_to_time("Thu, 20 Nov 2008 15:55:11 +0000") + >>> comm.time = utility.str_to_time("Thu, 01 Jan 1970 00:00:00 +0000") >>> print comm.string(indent=2, shortname="com-1") --------- Comment --------- Name: com-1 From: - Date: Thu, 20 Nov 2008 15:55:11 +0000 + Date: Thu, 01 Jan 1970 00:00:00 +0000 <BLANKLINE> Some insightful @@ -220,9 +228,7 @@ class Comment(Tree): path = comment.get_path() self.rcs.recursive_remove(path) - def add_reply(self, reply): - if reply.time != None and self.time != None: - assert reply.time >= self.time + def add_reply(self, reply, allow_time_inversion=False): if self.uuid != INVALID_UUID: reply.in_reply_to = self.uuid self.append(reply) @@ -362,7 +368,8 @@ class Comment(Tree): for cur_name, comment in self.comment_shortnames(*args, **kwargs): if comment_shortname == cur_name: return comment - raise KeyError(comment_shortname) + raise InvalidShortname(comment_shortname, + list(self.comment_shortnames(*args, **kwargs))) def comment_from_uuid(self, uuid): """ |