aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-27 05:11:33 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-27 05:11:33 -0400
commit58e2b9fe7a13e7cd99e085059867453496712593 (patch)
tree0a6cec44cea18509f4cb0ef58a8201ef4280b727
parent7c5b0f7abd46b2a6e093e47f7429e5f6c3eadab0 (diff)
downloadbugseverywhere-58e2b9fe7a13e7cd99e085059867453496712593.tar.gz
.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.
-rw-r--r--libbe/bugdir.py9
-rw-r--r--libbe/comment.py3
2 files changed, 8 insertions, 4 deletions
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