aboutsummaryrefslogtreecommitdiffstats
path: root/becommands
diff options
context:
space:
mode:
authorAaron Bentley <abentley@panoramicfeedback.com>2005-03-17 21:29:00 +0000
committerAaron Bentley <abentley@panoramicfeedback.com>2005-03-17 21:29:00 +0000
commitd7e4f9a09ffee3d248f5cc4be3cd4248a5c97af4 (patch)
tree12bd4e5c85b2f06ee9f3fabf06cf31a5a715b979 /becommands
parent22083d49fd56fb016df0cd7e416d1dd447182a93 (diff)
downloadbugseverywhere-d7e4f9a09ffee3d248f5cc4be3cd4248a5c97af4.tar.gz
Switched tree format to mapfile-based
Diffstat (limited to 'becommands')
-rw-r--r--becommands/close.py4
-rw-r--r--becommands/new.py2
-rw-r--r--becommands/open.py1
-rw-r--r--becommands/severity.py1
-rw-r--r--becommands/upgrade.py86
5 files changed, 92 insertions, 2 deletions
diff --git a/becommands/close.py b/becommands/close.py
index 11c5c74..2344a90 100644
--- a/becommands/close.py
+++ b/becommands/close.py
@@ -2,4 +2,6 @@
from libbe import cmdutil
def execute(args):
assert(len(args) == 1)
- cmdutil.get_bug(args[0]).status = "closed"
+ bug = cmdutil.get_bug(args[0])
+ bug.status = "closed"
+ bug.save()
diff --git a/becommands/new.py b/becommands/new.py
index 284f730..eae9688 100644
--- a/becommands/new.py
+++ b/becommands/new.py
@@ -10,5 +10,5 @@ def execute(args):
bug.severity = "minor"
bug.status = "open"
bug.summary = args[0]
-
+ bug.save()
diff --git a/becommands/open.py b/becommands/open.py
index bd0e4fa..dd50f93 100644
--- a/becommands/open.py
+++ b/becommands/open.py
@@ -4,3 +4,4 @@ def execute(args):
assert(len(args) == 1)
bug = cmdutil.get_bug(args[0])
bug.status = "open"
+ bug.save()
diff --git a/becommands/severity.py b/becommands/severity.py
index a421dd2..0b35c50 100644
--- a/becommands/severity.py
+++ b/becommands/severity.py
@@ -18,6 +18,7 @@ def execute(args):
if e.name != "severity":
raise
raise cmdutil.UserError ("Invalid severity level: %s" % e.value)
+ bug.save()
def help():
diff --git a/becommands/upgrade.py b/becommands/upgrade.py
new file mode 100644
index 0000000..2d2c242
--- /dev/null
+++ b/becommands/upgrade.py
@@ -0,0 +1,86 @@
+""" Upgrade the bugs to the latest format """
+import os.path
+import errno
+from libbe import bugdir, rcs
+
+def execute(args):
+ root = bugdir.tree_root(".", old_version=True)
+ for uuid in root.list_uuids():
+ old_bug = OldBug(root.bugs_path, uuid)
+
+ new_bug = bugdir.Bug(root.bugs_path, None)
+ new_bug.uuid = old_bug.uuid
+ new_bug.summary = old_bug.summary
+ new_bug.creator = old_bug.creator
+ new_bug.target = old_bug.target
+ new_bug.status = old_bug.status
+ new_bug.severity = old_bug.severity
+
+ new_bug.save()
+ for uuid in root.list_uuids():
+ old_bug = OldBug(root.bugs_path, uuid)
+ old_bug.delete()
+
+ bugdir.set_version(root.dir)
+
+def file_property(name, valid=None):
+ def getter(self):
+ value = self._get_value(name)
+ if valid is not None:
+ if value not in valid:
+ raise InvalidValue(name, value)
+ return value
+ def setter(self, value):
+ if valid is not None:
+ if value not in valid and value is not None:
+ raise InvalidValue(name, value)
+ return self._set_value(name, value)
+ return property(getter, setter)
+
+
+class OldBug(object):
+ def __init__(self, path, uuid):
+ self.path = os.path.join(path, uuid)
+ self.uuid = uuid
+
+ def get_path(self, file):
+ return os.path.join(self.path, file)
+
+ summary = file_property("summary")
+ creator = file_property("creator")
+ target = file_property("target")
+ status = file_property("status", valid=("open", "closed"))
+ severity = file_property("severity", valid=("wishlist", "minor", "serious",
+ "critical", "fatal"))
+ def delete(self):
+ self.summary = None
+ self.creator = None
+ self.target = None
+ self.status = None
+ self.severity = None
+ self._set_value("name", None)
+
+ def _get_active(self):
+ return self.status == "open"
+
+ active = property(_get_active)
+
+ def _get_value(self, name):
+ try:
+ return file(self.get_path(name), "rb").read().rstrip("\n")
+ except IOError, e:
+ if e.errno == errno.EEXIST:
+ return None
+
+ def _set_value(self, name, value):
+ if value is None:
+ try:
+ rcs.unlink(self.get_path(name))
+ except OSError, e:
+ if e.errno != 2:
+ raise
+ else:
+ rcs.set_file_contents(self.get_path(name), "%s\n" % value)
+
+
+