diff options
author | W. Trevor King <wking@drexel.edu> | 2009-06-23 11:35:23 -0400 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-06-23 11:35:23 -0400 |
commit | 83e06581ad007e1a1f27f311ccb3a747f0a81ade (patch) | |
tree | da64348e2f7a638e6f0664d5277aa24f1500e3c5 /libbe/comment.py | |
parent | 37195a33108299504f8d37042dec06df0540d0d2 (diff) | |
download | bugseverywhere-83e06581ad007e1a1f27f311ccb3a747f0a81ade.tar.gz |
Added Bug.extra_strings to support add-on functionality, e.g. `be tag`.
Versioned properties whose data is a mutable type are tricky, since
the simple comparisons we'd been using in
libbe.properties.change_hook_property don't work for mutables. For
now, we avoid that problem by assuming a change happened whenever a
mutable property is set. change_hook_property is a bit untidy at the
moment while I work out how to deal with mutables.
As an example of using Bug.extra_strings to patch on some useful
functionality, I've written becommands/tag.py. I'd suggest future
add-ons (e.g. becommands/depend.py?) use the "<LABEL>:<value>" string
format to keep it easy to sort out which strings belong to which
add-ons. tag.py is still missing command line tag-removal and
tag-searching for `be list'. Perhaps something like
be list --extra-strings TAG:<your-tag>,TAG:<another-tag>,DEPEND:<bug-id>
would be good, although it would requre escaping commas from the tags,
or refusing to allow commas in the tags...
libbe.properties.ValueCheckError also got a minor update so the
printed error message makes sense when raised with allowed being an
iterable (i.e. check_property) or a function
(e.g. fn_checked_property).
All of this digging around turned up a really buggy
libbe.bugdir.MultipleBugMatches. Obviously I had never actually
called it before :p. Should be fixed now.
libbe.comment._set_comment_body has also been normalized to match the
suggested change_hook interface: change_hook(self, old, new).
Although, I'm not sure why it hadn't been causing obvious problems
before, so maybe I'm misunderstanding something about that.
Diffstat (limited to 'libbe/comment.py')
-rw-r--r-- | libbe/comment.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libbe/comment.py b/libbe/comment.py index 80b97a1..df5a63f 100644 --- a/libbe/comment.py +++ b/libbe/comment.py @@ -151,10 +151,10 @@ class Comment(Tree, settings_object.SavedSettingsObject): if self.rcs != None and self.sync_with_disk == True: import rcs return self.rcs.get_file_contents(self.get_path("body")) - def _set_comment_body(self, value, force=False): + def _set_comment_body(self, old=None, new=None, force=False): if (self.rcs != None and self.sync_with_disk == True) or force==True: - assert value != None, "Can't save empty comment" - self.rcs.set_file_contents(self.get_path("body"), value) + assert new != None, "Can't save empty comment" + self.rcs.set_file_contents(self.get_path("body"), new) @Property @change_hook_property(hook=_set_comment_body) @@ -323,7 +323,7 @@ class Comment(Tree, settings_object.SavedSettingsObject): # raise Exception, str(self)+'\n'+str(self.settings)+'\n'+str(self._settings_loaded) #assert self.in_reply_to != None, "Comment must be a reply to something" self.save_settings() - self._set_comment_body(self.body, force=True) + self._set_comment_body(new=self.body, force=True) def remove(self): for comment in self.traverse(): |