This seems like a natual place for a function that only operates on Bugs.
if title != None:
print cmdutil.underlined(title)
for bug in cur_bugs:
- print cmdutil.bug_summary(bug, all_bugs, no_target=no_target,
- shortlist=True),
+ print bug.string(all_bugs, shortlist=True),
list_bugs(bugs, no_target=False)
raise cmdutil.UserError("Please specify a bug id.")
bug_dir = cmdutil.bug_tree()
bug = cmdutil.get_bug(args[0], bug_dir)
- print cmdutil.bug_summary(bug, list(bug_dir.list())).rstrip("\n")
+ print bug.string().rstrip("\n")
unique_name = cmdutil.unique_name(bug, bug_dir.list())
comments = []
name_map = {}
import os.path
import errno
from libbe import bugdir, rcs, cmdutil
-from libbe.bug import Bug
def execute(args):
options, args = get_parser().parse_args(args)
for uuid in root.list_uuids():
old_bug = OldBug(root.bugs_path, uuid)
- new_bug = Bug(root.bugs_path, None)
+ new_bug = root.get_bug(uuid)
new_bug.uuid = old_bug.uuid
new_bug.summary = old_bug.summary
new_bug.creator = old_bug.creator
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:
dict = {}
self.rcs_name = rcs_name
-
+ self.bugdir = bugdir
+
self.summary = dict.get("summary")
self.creator = dict.get("creator")
self.target = dict.get("target")
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)
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):
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
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
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
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 = []
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))