From: W. Trevor King Date: Mon, 27 Jul 2009 09:11:33 +0000 (-0400) Subject: .sync_with_disk fixes for libbe.bugdir and .comment. X-Git-Tag: 1.0.0~62^2~46^2~9^2~10 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=58e2b9fe7a13e7cd99e085059867453496712593;p=be.git .sync_with_disk fixes for libbe.bugdir and .comment. In BugDir, only call bug.remove if bug.sync_with_disk==True. If it's just in memory, automatic garbage collection is sufficient cleanup. Comment.set_sync_with_disk() had been setting .sync_with_disk=True regardless of the value passed in. Fixed now. Also some minor textual adjustments. --- diff --git a/libbe/bugdir.py b/libbe/bugdir.py index 7380172..e9854c9 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -352,6 +352,8 @@ settings easy. Don't set this attribute. Set .rcs instead, and new_rcs.init(self.root) return new_rcs + # methods for saving/loading/accessing settings and properties. + def get_path(self, *args): """ Return a path relative to .root. @@ -362,8 +364,6 @@ settings easy. Don't set this attribute. Set .rcs instead, and assert args[0] in ["version", "settings", "bugs"], str(args) return os.path.join(my_dir, *args) - # methods for saving/loading/accessing settings and properties. - def _get_settings(self, settings_path, for_duplicate_bugdir=False): allow_no_rcs = not self.rcs.path_in_root(settings_path) if allow_no_rcs == True: @@ -556,7 +556,8 @@ settings easy. Don't set this attribute. Set .rcs instead, and def remove_bug(self, bug): self.remove(bug) - bug.remove() + if bug.sync_with_disk == True: + bug.remove() def bug_shortname(self, bug): """ @@ -763,6 +764,7 @@ class SimpleBugDirTestCase (unittest.TestCase): def testOnDiskCleanLoad(self): """simple_bug_dir(sync_with_disk==True) should not import preexisting bugs.""" bugdir = simple_bug_dir(sync_with_disk=True) + self.failUnless(bugdir.sync_with_disk==True, bugdir.sync_with_disk) uuids = sorted([bug.uuid for bug in bugdir]) self.failUnless(uuids == ['a', 'b'], uuids) bugdir._clear_bugs() @@ -774,6 +776,7 @@ class SimpleBugDirTestCase (unittest.TestCase): def testInMemoryCleanLoad(self): """simple_bug_dir(sync_with_disk==False) should not import preexisting bugs.""" bugdir = simple_bug_dir(sync_with_disk=False) + self.failUnless(bugdir.sync_with_disk==False, bugdir.sync_with_disk) uuids = sorted([bug.uuid for bug in bugdir]) self.failUnless(uuids == ['a', 'b'], uuids) self.failUnlessRaises(DiskAccessRequired, bugdir.load_all_bugs) diff --git a/libbe/comment.py b/libbe/comment.py index 20dab7e..7b43c08 100644 --- a/libbe/comment.py +++ b/libbe/comment.py @@ -551,7 +551,7 @@ class Comment(Tree, settings_object.SavedSettingsObject): return os.path.join(my_dir, name) def set_sync_with_disk(self, value): - self.sync_with_disk = True + self.sync_with_disk = value def load_settings(self): if self.sync_with_disk == False: @@ -608,6 +608,7 @@ class Comment(Tree, settings_object.SavedSettingsObject): if self.bug != None: reply.set_sync_with_disk(self.bug.sync_with_disk) if reply.sync_with_disk == True: + raise Exception, self.bug.sync_with_disk reply.save() self.add_reply(reply) return reply