aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage/util
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-27 16:30:54 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-27 16:30:54 -0500
commitdff704764d77bffbf6cc94c5ba4bb03309da45f8 (patch)
tree3d0287d30718224903e3737545cbc970f3bdc898 /libbe/storage/util
parent214c4317bb90684dcfdab4d2402daa66fbad2e77 (diff)
downloadbugseverywhere-dff704764d77bffbf6cc94c5ba4bb03309da45f8.tar.gz
Added storage.Storage.storage_version() and command.InvalidStorageVersion.
Now commands automatically check for storage version compatibility.
Diffstat (limited to 'libbe/storage/util')
-rw-r--r--libbe/storage/util/upgrade.py24
1 files changed, 7 insertions, 17 deletions
diff --git a/libbe/storage/util/upgrade.py b/libbe/storage/util/upgrade.py
index ce6831d..20ef1e4 100644
--- a/libbe/storage/util/upgrade.py
+++ b/libbe/storage/util/upgrade.py
@@ -25,6 +25,7 @@ import sys
import libbe
import libbe.bug
import libbe.storage.util.mapfile as mapfile
+from libbe.storage import STORAGE_VERSIONS, STORAGE_VERSION
#import libbe.storage.vcs # delay import to avoid cyclic dependency
import libbe.ui.util.editor
import libbe.util
@@ -32,17 +33,6 @@ import libbe.util.encoding as encoding
import libbe.util.id
-# 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',
- 'Bugs Everywhere Directory v1.4',
- ]
-
-# the current version
-BUGDIR_DISK_VERSION = BUGDIR_DISK_VERSIONS[-1]
-
class Upgrader (object):
"Class for converting between different on-disk BE storage formats."
initial_version = None
@@ -304,16 +294,16 @@ for upgrader in upgraders:
upgrade_classes[(upgrader.initial_version,upgrader.final_version)]=upgrader
def upgrade(path, current_version,
- target_version=BUGDIR_DISK_VERSION):
+ target_version=STORAGE_VERSION):
"""
Call the appropriate upgrade function to convert current_version
to target_version. If a direct conversion function does not exist,
use consecutive conversion functions.
"""
- if current_version not in BUGDIR_DISK_VERSIONS:
+ if current_version not in STORAGE_VERSIONS:
raise NotImplementedError, \
"Cannot handle version '%s' yet." % current_version
- if target_version not in BUGDIR_DISK_VERSIONS:
+ if target_version not in STORAGE_VERSIONS:
raise NotImplementedError, \
"Cannot handle version '%s' yet." % current_version
@@ -324,10 +314,10 @@ def upgrade(path, current_version,
u.upgrade()
else:
# consecutive single-step conversion
- i = BUGDIR_DISK_VERSIONS.index(current_version)
+ i = STORAGE_VERSIONS.index(current_version)
while True:
- version_a = BUGDIR_DISK_VERSIONS[i]
- version_b = BUGDIR_DISK_VERSIONS[i+1]
+ version_a = STORAGE_VERSIONS[i]
+ version_b = STORAGE_VERSIONS[i+1]
try:
upgrade_class = upgrade_classes[(version_a, version_b)]
except KeyError: