aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage/util/upgrade.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/util/upgrade.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/util/upgrade.py')
-rw-r--r--libbe/storage/util/upgrade.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/libbe/storage/util/upgrade.py b/libbe/storage/util/upgrade.py
index 7ef760e..c94f171 100644
--- a/libbe/storage/util/upgrade.py
+++ b/libbe/storage/util/upgrade.py
@@ -24,17 +24,16 @@ import sys
import libbe
import libbe.bug as bug
-import libbe.util.encoding as encoding
import libbe.storage.util.mapfile as mapfile
+import libbe.util.encoding as encoding
+import libbe.util.id
-if libbe.TESTING == True:
- import doctest
# a list of all past versions
-BUGDIR_DISK_VERSIONS = ["Bugs Everywhere Tree 1 0",
- "Bugs Everywhere Directory v1.1",
- "Bugs Everywhere Directory v1.2",
- "Bugs Everywhere Directory v1.3"]
+BUGDIR_DISK_VERSIONS = ['Bugs Everywhere Tree 1 0',
+ 'Bugs Everywhere Directory v1.1',
+ 'Bugs Everywhere Directory v1.2',
+ 'Bugs Everywhere Directory v1.3']
# the current version
BUGDIR_DISK_VERSION = BUGDIR_DISK_VERSIONS[-1]
@@ -43,13 +42,17 @@ class Upgrader (object):
"Class for converting between different on-disk BE storage formats."
initial_version = None
final_version = None
- def __init__(self, root):
- self.root = root
+ def __init__(self, repo):
+ self.repo = repo
- def get_path(self, *args):
+ def get_path(self, id):
"""
- Return a path relative to .root.
+ Return a path relative to .repo.
"""
+ if id == 'version':
+ return os.path.join(self.repo, id)
+
+TODO
dir = os.path.join(self.root, '.be')
if len(args) == 0:
return dir
@@ -58,15 +61,15 @@ class Upgrader (object):
def check_initial_version(self):
path = self.get_path('version')
- version = self.vcs.get_file_contents(path).rstrip('\n')
+ version = encoding.get_file_contents(path).rstrip('\n')
assert version == self.initial_version, version
def set_version(self):
- path = self.get_path("version")
- self.vcs.set_file_contents(path, self.final_version+"\n")
+ path = self.get_path('version')
+ encoding.set_file_contents(path, self.final_version+'\n')
def upgrade(self):
- print >> sys.stderr, "upgrading bugdir from '%s' to '%s'" \
+ print >> sys.stderr, 'upgrading bugdir from "%s" to "%s"' \
% (self.initial_version, self.final_version)
self.check_initial_version()
self.set_version()
@@ -237,6 +240,3 @@ def upgrade(path, current_version,
if version_b == target_version:
break
i += 1
-
-if libbe.TESTING == True:
- suite = doctest.DocTestSuite()