aboutsummaryrefslogtreecommitdiffstats
path: root/becommands/depend.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 /becommands/depend.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 'becommands/depend.py')
-rw-r--r--becommands/depend.py55
1 files changed, 42 insertions, 13 deletions
diff --git a/becommands/depend.py b/becommands/depend.py
index f50d693..6336793 100644
--- a/becommands/depend.py
+++ b/becommands/depend.py
@@ -15,7 +15,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""Add/remove bug dependencies"""
-from libbe import cmdutil, bugdir, tree
+from libbe import cmdutil, bugdir, bug, tree
import os, copy
__desc__ = __doc__
@@ -69,8 +69,8 @@ def execute(args, manipulate_encodings=True, restrict_file_access=False):
parser = get_parser()
options, args = parser.parse_args(args)
cmdutil.default_complete(options, args, parser,
- bugid_args={0: lambda bug : bug.active==True,
- 1: lambda bug : bug.active==True})
+ bugid_args={0: lambda _bug : _bug.active==True,
+ 1: lambda _bug : _bug.active==True})
if options.repair == True:
if len(args) > 0:
@@ -82,7 +82,6 @@ def execute(args, manipulate_encodings=True, restrict_file_access=False):
raise cmdutil.UsageError("Too many arguments.")
elif len(args) == 2 and options.tree_depth != None:
raise cmdutil.UsageError("Only one bug id used in tree mode.")
-
bd = bugdir.BugDir(from_disk=True,
manipulate_encodings=manipulate_encodings)
@@ -95,10 +94,17 @@ def execute(args, manipulate_encodings=True, restrict_file_access=False):
for blockee,blocker in fixed])
return 0
+ allowed_status_values = \
+ cmdutil.select_values(options.status, bug.status_values)
+ allowed_severity_values = \
+ cmdutil.select_values(options.severity, bug.severity_values)
+
bugA = cmdutil.bug_from_id(bd, args[0])
if options.tree_depth != None:
- dtree = DependencyTree(bd, bugA, options.tree_depth)
+ dtree = DependencyTree(bd, bugA, options.tree_depth,
+ allowed_status_values,
+ allowed_severity_values)
if len(dtree.blocked_by_tree()) > 0:
print "%s blocked by:" % bugA.uuid
for depth,node in dtree.blocked_by_tree().thread():
@@ -122,18 +128,18 @@ def execute(args, manipulate_encodings=True, restrict_file_access=False):
if len(blocked_by) > 0:
print "%s blocked by:" % bugA.uuid
if options.show_status == True:
- print '\n'.join(["%s\t%s" % (bug.uuid, bug.status)
- for bug in blocked_by])
+ print '\n'.join(["%s\t%s" % (_bug.uuid, _bug.status)
+ for _bug in blocked_by])
else:
- print '\n'.join([bug.uuid for bug in blocked_by])
+ print '\n'.join([_bug.uuid for _bug in blocked_by])
blocks = get_blocks(bd, bugA)
if len(blocks) > 0:
print "%s blocks:" % bugA.uuid
if options.show_status == True:
- print '\n'.join(["%s\t%s" % (bug.uuid, bug.status)
- for bug in blocks])
+ print '\n'.join(["%s\t%s" % (_bug.uuid, _bug.status)
+ for _bug in blocks])
else:
- print '\n'.join([bug.uuid for bug in blocks])
+ print '\n'.join([_bug.uuid for _bug in blocks])
def get_parser():
parser = cmdutil.CmdOptionParser("be depend BUG-ID [BUG-ID]\nor: be depend --repair")
@@ -143,6 +149,10 @@ def get_parser():
parser.add_option("-s", "--show-status", action="store_true",
dest="show_status", default=False,
help="Show status of blocking bugs")
+ parser.add_option("--status", dest="status", metavar="STATUS",
+ help="Only show bugs matching the STATUS specifier")
+ parser.add_option("--severity", dest="severity", metavar="SEVERITY",
+ help="Only show bugs matching the SEVERITY specifier")
parser.add_option("-t", "--tree-depth", metavar="DEPTH", default=None,
type="int", dest="tree_depth",
help="Print dependency tree rooted at BUG-ID with DEPTH levels of both blockers and blockees. Set DEPTH <= 0 to disable the depth limit.")
@@ -158,6 +168,15 @@ If bug B is not specified, just print a list of bugs blocking (A).
To search for bugs blocked by a particular bug, try
$ be list --extra-strings BLOCKED-BY:<your-bug-uuid>
+The --status and --severity options allow you to either blacklist or
+whitelist values, for example
+ $ be list --status open,assigned
+will only follow and print dependencies with open or assigned status.
+You select blacklist mode by starting the list with a minus sign, for
+example
+ $ be list --severity -target
+which will only follow and print dependencies with non-target severity.
+
In repair mode, add the missing direction to any one-way links.
The "|--" symbol in the repair-mode output is inspired by the
@@ -239,7 +258,7 @@ def get_blocks(bugdir, bug):
def get_blocked_by(bugdir, bug):
"""
- Return a list of bugs blocking the given bug blocks.
+ Return a list of bugs blocking the given bug.
"""
blocked_by = []
for uuid in _get_blocked_by(bug):
@@ -310,10 +329,14 @@ class DependencyTree (object):
"""
Note: should probably be DependencyDiGraph.
"""
- def __init__(self, bugdir, root_bug, depth_limit=0):
+ def __init__(self, bugdir, root_bug, depth_limit=0,
+ allowed_status_values=None,
+ allowed_severity_values=None):
self.bugdir = bugdir
self.root_bug = root_bug
self.depth_limit = depth_limit
+ self.allowed_status_values = allowed_status_values
+ self.allowed_severity_values = allowed_severity_values
def _build_tree(self, child_fn):
root = tree.Tree()
root.bug = self.root_bug
@@ -324,6 +347,12 @@ class DependencyTree (object):
if self.depth_limit > 0 and node.depth == self.depth_limit:
continue
for bug in child_fn(self.bugdir, node.bug):
+ if self.allowed_status_values != None \
+ and not bug.status in self.allowed_status_values:
+ continue
+ if self.allowed_severity_values != None \
+ and not bug.severity in self.allowed_severity_values:
+ continue
child = tree.Tree()
child.bug = bug
child.depth = node.depth+1