aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/upgrade.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-06 00:44:22 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-06 00:44:22 -0500
commit61010c1c6b055ef8fd33b01c088e3d095914e89a (patch)
treee967aadbc99dee314b5fc3deb8036369e79a4c99 /libbe/upgrade.py
parentaf8bd49a6215029c08676a3d4a59cfcab1d80976 (diff)
parentff1ca79e6781447dbad6279d6c4cdad44fad5cdd (diff)
downloadbugseverywhere-61010c1c6b055ef8fd33b01c088e3d095914e89a.tar.gz
Merged be.target-as-bug
Highlights: * targets are now a special type of bug (severity 'target'), so you can do all the things you do with normal bugs to them as well (e.g. comment on them, link them into dependency trees, etc.) * new command `be due` to get/set bug due dates. * changes to `be depend` * added options --status, --severity * changes to `be list` * added blacklist capability to --status, --severity, --assigned * removed options --target, --cur-target Replace: 'be list --target TARGET' with 'be depend --status -closed,fixed,wontfix --severity -target \ $(be target --resolve TARGET)' 'be list --cur-target' with 'be depend --status -closed,fixed,wontfix --severity -target \ $(be target --resolve)' * changes to `be target` * added option --resolve * removed option --list Replace: 'be target --list' with 'be list --status all --severity target' * new function cmdutil.select_values() for whitelist/blacklist selection. * assorted cleanups and bugfixes
Diffstat (limited to 'libbe/upgrade.py')
-rw-r--r--libbe/upgrade.py60
1 files changed, 58 insertions, 2 deletions
diff --git a/libbe/upgrade.py b/libbe/upgrade.py
index 785249d..dc9d54f 100644
--- a/libbe/upgrade.py
+++ b/libbe/upgrade.py
@@ -22,6 +22,7 @@ import os, os.path
import sys
import libbe
+import bug
import encoding
import mapfile
import vcs
@@ -31,7 +32,8 @@ if libbe.TESTING == True:
# 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.2",
+ "Bugs Everywhere Directory v1.3"]
# the current version
BUGDIR_DISK_VERSION = BUGDIR_DISK_VERSIONS[-1]
@@ -142,9 +144,63 @@ class Upgrade_1_1_to_1_2 (Upgrader):
settings["vcs_name"] = settings.pop("rcs_name")
mapfile.map_save(self.vcs, path, settings)
+class Upgrade_1_2_to_1_3 (Upgrader):
+ initial_version = "Bugs Everywhere Directory v1.2"
+ final_version = "Bugs Everywhere Directory v1.3"
+ def __init__(self, *args, **kwargs):
+ Upgrader.__init__(self, *args, **kwargs)
+ self._targets = {} # key: target text,value: new target bug
+ path = self.get_path('settings')
+ settings = mapfile.map_load(self.vcs, path)
+ if 'vcs_name' in settings:
+ old_vcs = self.vcs
+ self.vcs = vcs.vcs_by_name(settings['vcs_name'])
+ self.vcs.root(self.root)
+ self.vcs.encoding = old_vcs.encoding
+
+ def _target_bug(self, target_text):
+ if target_text not in self._targets:
+ _bug = bug.Bug(bugdir=self, summary=target_text)
+ # note: we're not a bugdir, but all Bug.save() needs is
+ # .root, .vcs, and .get_path(), which we have.
+ _bug.severity = 'target'
+ self._targets[target_text] = _bug
+ return self._targets[target_text]
+
+ def _upgrade_bugdir_mapfile(self):
+ path = self.get_path('settings')
+ settings = mapfile.map_load(self.vcs, path)
+ if 'target' in settings:
+ settings['target'] = self._target_bug(settings['target']).uuid
+ mapfile.map_save(self.vcs, path, settings)
+
+ def _upgrade_bug_mapfile(self, bug_uuid):
+ import becommands.depend
+ path = self.get_path('bugs', bug_uuid, 'values')
+ settings = mapfile.map_load(self.vcs, path)
+ if 'target' in settings:
+ target_bug = self._target_bug(settings['target'])
+ _bug = bug.Bug(bugdir=self, uuid=bug_uuid, from_disk=True)
+ # note: we're not a bugdir, but all Bug.load_settings()
+ # needs is .root, .vcs, and .get_path(), which we have.
+ becommands.depend.add_block(target_bug, _bug)
+ _bug.settings.pop('target')
+ _bug.save()
+
+ def _upgrade(self):
+ """
+ Bug value field "target" -> target bugs.
+ Bugdir value field "target" -> pointer to current target bug.
+ """
+ for bug_uuid in os.listdir(self.get_path('bugs')):
+ self._upgrade_bug_mapfile(bug_uuid)
+ self._upgrade_bugdir_mapfile()
+ for _bug in self._targets.values():
+ _bug.save()
upgraders = [Upgrade_1_0_to_1_1,
- Upgrade_1_1_to_1_2]
+ Upgrade_1_1_to_1_2,
+ Upgrade_1_2_to_1_3]
upgrade_classes = {}
for upgrader in upgraders:
upgrade_classes[(upgrader.initial_version,upgrader.final_version)]=upgrader