Per-tree status levels working.
authorW. Trevor King <wking@drexel.edu>
Thu, 4 Dec 2008 16:32:57 +0000 (11:32 -0500)
committerW. Trevor King <wking@drexel.edu>
Thu, 4 Dec 2008 16:32:57 +0000 (11:32 -0500)
.be/settings
becommands/severity.py
becommands/status.py
libbe/bug.py
libbe/bugdir.py
libbe/diff.py

index 6a8d2f36c6fa968ac2a46f2a62eedcaf804fc810..44c2cd5c5f30138545e54852b45a7dd919dc4cfd 100644 (file)
@@ -1,15 +1,12 @@
 rcs_name: bzr
 
 
-severities:
-- - wishlist
-  - A feature that could improve usefulness, but not a bug.
-- - minor
-  - The standard bug level.
-- - serious
-  - A bug that requires workarounds.
-- - critical
-  - A bug that prevents some features from working at all.
-- - fatal
-  - A bug that makes the package unusable.
-
+inactive_status:
+- - closed
+  - The bug is no longer relevant.
+- - fixed
+  - The bug should no longer occur.
+- - wontfix
+  - It's not a bug, it's a feature.
+- - disabled
+  - Unknown meaning.  For backwards compatibility with old BE bugs.
index 92f31e8aad519e7425e9d8695ca215d2425ed5ff..c44d8eda3a4ce65af567bcde39a74c445003b0ea 100644 (file)
@@ -64,10 +64,10 @@ is specified, it will be assigned to the bug.
 
 Severity levels are:
 """]
-    try:
+    try: # See if there are any per-tree severity configurations
         bd = bugdir.BugDir(from_disk=True, manipulate_encodings=False)
     except bugdir.NoBugDir, e:
-        pass
+        pass # No tree, just show the defaults
     longest_severity_len = max([len(s) for s in bug.severity_values])
     for severity in bug.severity_values :
         description = bug.severity_description[severity]
index 5ff824ee67a88acc9a7685d9a49d675dcb5df0f9..b781a2a31b47b4e13566ccd14b504c5c5330d3a1 100644 (file)
@@ -15,8 +15,7 @@
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 """Show or change a bug's status"""
-from libbe import cmdutil, bugdir
-from libbe.bug import status_values, status_description
+from libbe import cmdutil, bugdir, bug
 __desc__ = __doc__
 
 def execute(args, test=False):
@@ -56,7 +55,9 @@ def get_parser():
     parser = cmdutil.CmdOptionParser("be status BUG-ID [STATUS]")
     return parser
 
-longhelp=["""
+
+def help():
+    longhelp=["""
 Show or change a bug's severity level.
 
 If no severity is specified, the current value is printed.  If a severity level
@@ -64,12 +65,14 @@ is specified, it will be assigned to the bug.
 
 Severity levels are:
 """]
-longest_status_len = max([len(s) for s in status_values])
-for status in status_values :
-    description = status_description[status]
-    s = "%*s : %s\n" % (longest_status_len, status, description)
-    longhelp.append(s)
-longhelp = ''.join(longhelp)
-
-def help():
+    try: # See if there are any per-tree status configurations
+        bd = bugdir.BugDir(from_disk=True, manipulate_encodings=False)
+    except bugdir.NoBugDir, e:
+        pass # No tree, just show the defaults
+    longest_status_len = max([len(s) for s in bug.status_values])
+    for status in bug.status_values :
+        description = bug.status_description[status]
+        s = "%*s : %s\n" % (longest_status_len, status, description)
+        longhelp.append(s)
+    longhelp = ''.join(longhelp)
     return get_parser().help_str() + longhelp
index 2cd05e349b2d7911d9746a903a497fdd214091c6..f871c7ac4a5457310b2fb8ce5bdc4f2a2cbc5981 100644 (file)
@@ -52,8 +52,7 @@ active_status_def = (
 inactive_status_def = (
   ("closed", "The bug is no longer relevant."),
   ("fixed", "The bug should no longer occur."),
-  ("wontfix","It's not a bug, it's a feature."),
-  ("disabled", "?"))
+  ("wontfix","It's not a bug, it's a feature."))
 
 
 ### Convert the description tuples to more useful formats
@@ -65,6 +64,8 @@ def load_severities(severity_def):
     global severity_values
     global severity_description
     global severity_index
+    if severity_def == settings_object.EMPTY:
+        return
     severity_values = tuple([val for val,description in severity_def])
     severity_description = dict(severity_def)
     severity_index = {}
@@ -72,13 +73,29 @@ def load_severities(severity_def):
         severity_index[severity] = i
 load_severities(severity_def)
 
-active_status_values = tuple(val for val,description in active_status_def)
-inactive_status_values = tuple(val for val,description in inactive_status_def)
-status_values = active_status_values + inactive_status_values
-status_description = dict(active_status_def+inactive_status_def)
+active_status_values = []
+inactive_status_values = []
+status_values = []
+status_description = {}
 status_index = {}
-for i in range(len(status_values)):
-    status_index[status_values[i]] = i
+def load_status(active_status_def, inactive_status_def):
+    global active_status_values
+    global inactive_status_values
+    global status_values
+    global status_description
+    global status_index
+    if active_status_def == settings_object.EMPTY:
+        active_status_def = globals()["active_status_def"]
+    if inactive_status_def == settings_object.EMPTY:
+        inactive_status_def = globals()["inactive_status_def"]
+    active_status_values = tuple([val for val,description in active_status_def])
+    inactive_status_values = tuple([val for val,description in inactive_status_def])
+    status_values = active_status_values + inactive_status_values
+    status_description = dict(tuple(active_status_def) + tuple(inactive_status_def))
+    status_index = {}
+    for i,status in enumerate(status_values):
+        status_index[status] = i
+load_status(active_status_def, inactive_status_def)
 
 
 class Bug(settings_object.SavedSettingsObject):
@@ -128,7 +145,7 @@ class Bug(settings_object.SavedSettingsObject):
     @_versioned_property(name="status",
                          doc="The bug's current status",
                          default="open",
-                         allowed=status_values,
+                         check_fn=lambda s: s in status_values,
                          require_save=True)
     def status(): return {}
     
index cdb4cf5a2ae349e683c47661cd6d2db608c889b8..443dfc5bbd6e3587d7bbddc63a1fea28a82babfe 100644 (file)
@@ -229,6 +229,24 @@ settings easy.  Don't set this attribute.  Set .rcs instead, and
                          change_hook=_set_severities)
     def severities(): return {}
 
+    def _setup_status(self, active_status, inactive_status):
+        bug.load_status(active_status, inactive_status)
+    def _set_active_status(self, old_active_status, new_active_status):
+        self._setup_status(new_active_status, self.inactive_status)
+        self._prop_save_settings(old_active_status, new_active_status)
+    @_versioned_property(name="active_status",
+                         doc="The allowed active bug states and their descriptions.",
+                         change_hook=_set_active_status)
+    def active_status(): return {}
+
+    def _set_inactive_status(self, old_inactive_status, new_inactive_status):
+        self._setup_status(self.active_status, new_inactive_status)
+        self._prop_save_settings(old_inactive_status, new_inactive_status)
+    @_versioned_property(name="inactive_status",
+                         doc="The allowed inactive bug states and their descriptions.",
+                         change_hook=_set_inactive_status)
+    def inactive_status(): return {}
+
 
     def __init__(self, root=None, sink_to_existing_root=True,
                  assert_new_BugDir=False, allow_rcs_init=False,
@@ -330,6 +348,7 @@ settings easy.  Don't set this attribute.  Set .rcs instead, and
             self.rcs = rcs.rcs_by_name(self.rcs_name)
             self._setup_encoding(self.encoding)
             self._setup_severities(self.severities)
+            self._setup_status(self.active_status, self.inactive_status)
 
     def load_all_bugs(self):
         "Warning: this could take a while."
@@ -381,7 +400,10 @@ settings easy.  Don't set this attribute.  Set .rcs instead, and
         if "rcs_name" in duplicate_settings:
             duplicate_settings["rcs_name"] = "None"
             duplicate_settings["user_id"] = self.user_id
-            self._save_settings(duplicate_settings_path, duplicate_settings)
+        if "disabled" in bug.status_values:
+            # Hack to support old versions of BE bugs
+            duplicate_settings["inactive_status"] = self.inactive_status
+        self._save_settings(duplicate_settings_path, duplicate_settings)
 
         return BugDir(duplicate_path, from_disk=True, manipulate_encodings=self._manipulate_encodings)
 
index 5fc0166ac0fd0cb6e45aa0276d0a11ecb133dd5f..17d6c5094725f4d3cc679a40bb4892c9daa544d7 100644 (file)
@@ -15,9 +15,8 @@
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 """Compare two bug trees"""
-from libbe import cmdutil, bugdir
+from libbe import cmdutil, bugdir, bug
 from libbe.utility import time_to_str
-from libbe.bug import cmp_severity
 import doctest
 
 def diff(old_bugdir, new_bugdir):
@@ -41,17 +40,17 @@ def diff(old_bugdir, new_bugdir):
 def diff_report(diff_data, bug_dir):
     (removed, modified, added) = diff_data
     def modified_cmp(left, right):
-        return cmp_severity(left[1], right[1])
+        return bug.cmp_severity(left[1], right[1])
 
-    added.sort(cmp_severity)
-    removed.sort(cmp_severity)
+    added.sort(bug.cmp_severity)
+    removed.sort(bug.cmp_severity)
     modified.sort(modified_cmp)
     lines = []
     
     if len(added) > 0:
         lines.append("New bug reports:")
-        for bug in added:
-            lines.extend(bug.string(shortlist=True).splitlines())
+        for bg in added:
+            lines.extend(bg.string(shortlist=True).splitlines())
         lines.append("")
 
     if len(modified) > 0:
@@ -69,8 +68,8 @@ def diff_report(diff_data, bug_dir):
 
     if len(removed) > 0:
         lines.append("Removed bug reports:")
-        for bug in removed:
-            lines.extend(bug.string(shortlist=True).splitlines())
+        for bg in removed:
+            lines.extend(bg.string(shortlist=True).splitlines())
         lines.append("")
     
     return '\n'.join(lines)