aboutsummaryrefslogtreecommitdiffstats
path: root/libbe
diff options
context:
space:
mode:
Diffstat (limited to 'libbe')
-rw-r--r--libbe/bug.py36
-rw-r--r--libbe/bugdir.py4
-rw-r--r--libbe/cmdutil.py23
-rw-r--r--libbe/diff.py6
4 files changed, 39 insertions, 30 deletions
diff --git a/libbe/bug.py b/libbe/bug.py
index b0ebca4..02c0d7a 100644
--- a/libbe/bug.py
+++ b/libbe/bug.py
@@ -88,7 +88,7 @@ class Bug(object):
severity = checked_property("severity", severity_values)
status = checked_property("status", status_values)
- def __init__(self, path, uuid, rcs_name):
+ def __init__(self, path, uuid, rcs_name, bugdir):
self.path = path
self.uuid = uuid
if uuid is not None:
@@ -97,7 +97,8 @@ class Bug(object):
dict = {}
self.rcs_name = rcs_name
-
+ self.bugdir = bugdir
+
self.summary = dict.get("summary")
self.creator = dict.get("creator")
self.target = dict.get("target")
@@ -111,6 +112,37 @@ class Bug(object):
def __repr__(self):
return "Bug(uuid=%r)" % self.uuid
+ def string(self, bugs=None, shortlist=False):
+ if shortlist == False:
+ if bugs == None:
+ bugs = list(self.bugdir.list())
+ htime = utility.handy_time(bug.time)
+ ftime = utility.time_to_str(bug.time)
+ info = [("ID", bug.uuid),
+ ("Short name", unique_name(bug, bugs)),
+ ("Severity", bug.severity),
+ ("Status", bug.status),
+ ("Assigned", bug.assigned),
+ ("Target", bug.target),
+ ("Creator", bug.creator),
+ ("Created", "%s (%s)" % (htime, ftime))]
+ newinfo = []
+ for k,v in info:
+ if v == None:
+ newinfo.append((k,""))
+ else:
+ newinfo.append((k,v))
+ info = newinfo
+ longest_key_len = max([len(k) for k,v in info])
+ infolines = [" %*s : %s\n" % (longest_key_len,k,v) for k,v in info]
+ return "".join(infolines) + "%s\n" % bug.summary
+ else:
+ statuschar = bug.status[0]
+ severitychar = bug.severity[0]
+ chars = "%c%c" % (statuschar, severitychar)
+ return "%s:%s: %s\n" % (cmdutil.unique_name(bug, bugs), chars, bug.summary)
+ def __str__(self):
+ return self.string(shortlist=True)
def get_path(self, file):
return os.path.join(self.path, self.uuid, file)
diff --git a/libbe/bugdir.py b/libbe/bugdir.py
index 7570bb3..f8f45b8 100644
--- a/libbe/bugdir.py
+++ b/libbe/bugdir.py
@@ -174,7 +174,7 @@ class BugDir:
return bugs
def get_bug(self, uuid):
- return Bug(self.bugs_path, uuid, self.rcs_name)
+ return Bug(self.bugs_path, uuid, self.rcs_name, self)
def list_uuids(self):
for uuid in os.listdir(self.bugs_path):
@@ -187,7 +187,7 @@ class BugDir:
uuid = names.uuid()
path = os.path.join(self.bugs_path, uuid)
self.rcs.mkdir(path)
- bug = Bug(self.bugs_path, None, self.rcs_name)
+ bug = Bug(self.bugs_path, None, self.rcs_name, self)
bug.uuid = uuid
return bug
diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py
index 69cfe84..b5a93c7 100644
--- a/libbe/cmdutil.py
+++ b/libbe/cmdutil.py
@@ -72,29 +72,6 @@ def get_bug(spec, bug_dir=None):
raise UserError("No bug matches %s" % spec)
return matches[0]
-def bug_summary(bug, bugs, no_target=False, shortlist=False):
- info = [("ID", bug.uuid),
- ("Short name", unique_name(bug, bugs)),
- ("Severity", bug.severity),
- ("Status", bug.status),
- ("Assigned", bug.assigned),
- ("Target", bug.target),
- ("Creator", bug.creator),
- ("Created", "%s (%s)" % (utility.handy_time(bug.time),utility.time_to_str(bug.time)))]
- newinfo = []
- for k,v in info:
- if v == None:
- newinfo.append((k,""))
- else:
- newinfo.append((k,v))
- info = newinfo
- if shortlist == False:
- longest_key_len = max([len(k) for k,v in info])
- infolines = [" %*s : %s\n" % (longest_key_len,k,v) for k,v in info]
- return "".join(infolines) + "%s\n" % bug.summary
- else:
- return "%s: %s\n" % (unique_name(bug, bugs), bug.summary)
-
def iter_commands():
for name, module in plugin.iter_plugins("becommands"):
yield name.replace("_", "-"), module
diff --git a/libbe/diff.py b/libbe/diff.py
index 97eca54..fb3cfea 100644
--- a/libbe/diff.py
+++ b/libbe/diff.py
@@ -54,7 +54,7 @@ def diff_report(diff_data, bug_dir):
if len(added) > 0:
print "New bug reports:"
for bug in added:
- print cmdutil.bug_summary(bug, bugs, no_target=True)
+ print bug.string(shortlist=True)
if len(modified) > 0:
printed = False
@@ -70,7 +70,7 @@ def diff_report(diff_data, bug_dir):
if len(removed) > 0:
print "Removed bug reports:"
for bug in removed:
- print cmdutil.bug_summary(bug, bugs, no_target=True)
+ print bug.string(bug, bugs, shortlist=True)
def change_lines(old, new, attributes):
change_list = []
@@ -102,7 +102,7 @@ def bug_changes(old, new, bugs):
if len(change_strings) == 0:
return None
- return "%s%s\n" % (cmdutil.bug_summary(new, bugs, shortlist=True),
+ return "%s%s\n" % (new.string(bugs, shortlist=True),
"\n".join(change_strings))