aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage/base.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-15 06:44:20 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-15 06:44:20 -0500
commit89b7a1411e4658e831f5d635534b24355dbb941d (patch)
tree77f84979931ac4bf8bcf14d293154fe29e8491bc /libbe/storage/base.py
parent380889988b6d7881c4e0b5968053f85676d27211 (diff)
downloadbugseverywhere-89b7a1411e4658e831f5d635534b24355dbb941d.tar.gz
Fixed libbe.command.diff + ugly BugDir.duplicate_bugdir implementation
duplicate_bugdir() works, but for the vcs backends, it could require shelling out for _every_ file read. This could, and probably will, be horribly slow. Still it works ;). I'm not sure what a better implementation would be. The old implementation checked out the entire earlier state into a temporary directory pros: single shell out, simple upgrade implementation cons: wouldn't work well for HTTP backens I think a good solution would run along the lines of the currently commented out code in duplicate_bugdir(), where a VersionedStorage.changed_since(revision) call would give you a list of changed files. diff could work off of that directly, without the need to generate a whole duplicate bugdir. I'm stuck on how to handle upgrades though... Also removed trailing whitespace from all python files.
Diffstat (limited to 'libbe/storage/base.py')
-rw-r--r--libbe/storage/base.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/libbe/storage/base.py b/libbe/storage/base.py
index dd35586..97c8b29 100644
--- a/libbe/storage/base.py
+++ b/libbe/storage/base.py
@@ -256,8 +256,10 @@ class Storage (object):
else:
decode = False
value = self._get(*args, **kwargs)
- if decode == True:
+ if decode == True and type(value) != types.UnicodeType:
return unicode(value, self.encoding)
+ if decode == False and type(value) != types.StringType:
+ return value.encode(self.encoding)
return value
def _get(self, id, default=InvalidObject, revision=None):
@@ -673,7 +675,7 @@ if TESTING == True:
self.failUnless(s == val,
"%s.get() returned %s not %s"
% (vars(self.Class)['name'], s, self.val))
-
+
class Storage_persistence_TestCase (StorageTestCase):
"""Test cases for Storage.disconnect and .connect methods."""
@@ -767,7 +769,7 @@ if TESTING == True:
revs.append(self.s.commit('%s: %d' % (self.commit_msg, i),
self.commit_body))
for i in range(10):
- rev = self.s.revision_id(i+1)
+ rev = self.s.revision_id(i+1)
self.failUnless(rev == revs[i],
"%s.revision_id(%d) returned %s not %s"
% (vars(self.Class)['name'], i+1, rev, revs[i]))
@@ -794,7 +796,7 @@ if TESTING == True:
self.failUnless(ret == val(i),
"%s.get() returned %s not %s for revision %s"
% (vars(self.Class)['name'], ret, val(i), revs[i]))
-
+
def make_storage_testcase_subclasses(storage_class, namespace):
"""Make StorageTestCase subclasses for storage_class in namespace."""
storage_testcase_classes = [