From 3ad4de1cfa8b28974b2e0c3a4626315c4aea14ef Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 28 Oct 2010 13:27:43 -0400 Subject: Add `list --sort time` test reproducing Gianluca's bug. --- libbe/command/list.py | 1 + 1 file changed, 1 insertion(+) (limited to 'libbe') diff --git a/libbe/command/list.py b/libbe/command/list.py index c353e09..48606f6 100644 --- a/libbe/command/list.py +++ b/libbe/command/list.py @@ -91,6 +91,7 @@ class List (libbe.command.Command): abc/a:om: Bug A >>> ret = ui.run(cmd, {'status':'closed'}) abc/b:cm: Bug B + >>> ret = ui.run(cmd, {'status':'all', 'sort':'time'}) >>> bd.storage.writeable True >>> ui.cleanup() -- cgit From aa1230e03b3859bbcf22d710a2b25a68b691e740 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 28 Oct 2010 13:29:16 -0400 Subject: Fixed `list --sort ...` bug. --- libbe/command/list.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libbe') diff --git a/libbe/command/list.py b/libbe/command/list.py index 48606f6..3eb1932 100644 --- a/libbe/command/list.py +++ b/libbe/command/list.py @@ -92,6 +92,8 @@ class List (libbe.command.Command): >>> ret = ui.run(cmd, {'status':'closed'}) abc/b:cm: Bug B >>> ret = ui.run(cmd, {'status':'all', 'sort':'time'}) + abc/a:om: Bug A + abc/b:cm: Bug B >>> bd.storage.writeable True >>> ui.cleanup() @@ -190,7 +192,7 @@ class List (libbe.command.Command): def _parse_params(self, bugdir, params): cmp_list = [] if params['sort'] != None: - for cmp in params['sort'].sort_by.split(','): + for cmp in params['sort'].split(','): if cmp not in AVAILABLE_CMPS: raise libbe.command.UserError( 'Invalid sort on "%s".\nValid sorts:\n %s' -- cgit From bd2d5ab3bf6301bdf1f08cf3133fa60ebfdf9b9f Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 28 Oct 2010 15:31:44 -0400 Subject: libbe.command.depend now shares libbe.command.list's status/severity parsing for consistency. --- libbe/command/depend.py | 27 ++++++++------------------- libbe/command/list.py | 46 +++++++++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 38 deletions(-) (limited to 'libbe') diff --git a/libbe/command/depend.py b/libbe/command/depend.py index baea539..a5c3e5e 100644 --- a/libbe/command/depend.py +++ b/libbe/command/depend.py @@ -23,6 +23,7 @@ import libbe import libbe.bug import libbe.command import libbe.command.util +from libbe.command.list import Filter, parse_status, parse_severity import libbe.util.tree BLOCKS_TAG="BLOCKS:" @@ -145,20 +146,15 @@ class Depend (libbe.command.Command): '\n'.join(['%s |-- %s' % (blockee.id.user(), blocker.id.user()) for blockee,blocker in fixed]) return 0 - allowed_status_values = \ - libbe.command.util.select_values( - params['status'], libbe.bug.status_values) - allowed_severity_values = \ - libbe.command.util.select_values( - params['severity'], libbe.bug.severity_values) + status = parse_status(params['status']) + severity = parse_severity(params['severity']) + filter = Filter(status, severity) bugA, dummy_comment = libbe.command.util.bug_comment_from_user_id( bugdir, params['bug-id']) if params['tree-depth'] != None: - dtree = DependencyTree(bugdir, bugA, params['tree-depth'], - allowed_status_values, - allowed_severity_values) + dtree = DependencyTree(bugdir, bugA, params['tree-depth'], filter) if len(dtree.blocked_by_tree()) > 0: print >> self.stdout, '%s blocked by:' % bugA.id.user() for depth,node in dtree.blocked_by_tree().thread(): @@ -374,14 +370,11 @@ class DependencyTree (object): """ Note: should probably be DependencyDiGraph. """ - def __init__(self, bugdir, root_bug, depth_limit=0, - allowed_status_values=None, - allowed_severity_values=None): + def __init__(self, bugdir, root_bug, depth_limit=0, filter=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 + self.filter = filter def _build_tree(self, child_fn): root = libbe.util.tree.Tree() @@ -393,11 +386,7 @@ 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: + if not self.filter(self.bugdir, bug): continue child = libbe.util.tree.Tree() child.bug = bug diff --git a/libbe/command/list.py b/libbe/command/list.py index 3eb1932..645ae04 100644 --- a/libbe/command/list.py +++ b/libbe/command/list.py @@ -75,6 +75,30 @@ class Filter (object): return False return True +def parse_status(status): + if status == 'all': + status = libbe.bug.status_values + elif status == 'active': + status = list(libbe.bug.active_status_values) + elif status == 'inactive': + status = list(libbe.bug.inactive_status_values) + else: + status = libbe.command.util.select_values( + status, libbe.bug.status_values) + return status + +def parse_severity(severity, important=False): + if severity == 'all': + severity = libbe.bug.severity_values + elif important == True: + serious = libbe.bug.severity_values.index('serious') + severity.append(list(libbe.bug.severity_values[serious:])) + else: + severity = libbe.command.util.select_values( + severity, libbe.bug.severity_values) + return severity + + class List (libbe.command.Command): """List bugs @@ -198,25 +222,9 @@ class List (libbe.command.Command): 'Invalid sort on "%s".\nValid sorts:\n %s' % (cmp, '\n '.join(AVAILABLE_CMPS))) cmp_list.append(eval('libbe.bug.cmp_%s' % cmp)) - # select status - if params['status'] == 'all': - status = libbe.bug.status_values - elif params['status'] == 'active': - status = list(libbe.bug.active_status_values) - elif params['status'] == 'inactive': - status = list(libbe.bug.inactive_status_values) - else: - status = libbe.command.util.select_values( - params['status'], libbe.bug.status_values) - # select severity - if params['severity'] == 'all': - severity = libbe.bug.severity_values - elif params['important'] == True: - serious = libbe.bug.severity_values.index('serious') - severity.append(list(libbe.bug.severity_values[serious:])) - else: - severity = libbe.command.util.select_values( - params['severity'], libbe.bug.severity_values) + status = parse_status(params['status']) + severity = parse_severity(params['severity'], + important=params['important']) # select assigned if params['assigned'] == None: if params['mine'] == True: -- cgit From f7e59d8f264577bf44fe4bc043d1107843e31f7c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 28 Oct 2010 18:55:41 -0400 Subject: Move Filter, parse_status, and parse_severity from list to depend. This breaks an import dependency cycle. --- libbe/command/depend.py | 68 ++++++++++++++++++++++++++++++++++++++++++++++++- libbe/command/list.py | 67 +----------------------------------------------- 2 files changed, 68 insertions(+), 67 deletions(-) (limited to 'libbe') diff --git a/libbe/command/depend.py b/libbe/command/depend.py index a5c3e5e..1868dbc 100644 --- a/libbe/command/depend.py +++ b/libbe/command/depend.py @@ -23,12 +23,78 @@ import libbe import libbe.bug import libbe.command import libbe.command.util -from libbe.command.list import Filter, parse_status, parse_severity import libbe.util.tree BLOCKS_TAG="BLOCKS:" BLOCKED_BY_TAG="BLOCKED-BY:" + +class Filter (object): + def __init__(self, status='all', severity='all', assigned='all', + target='all', extra_strings_regexps=[]): + self.status = status + self.severity = severity + self.assigned = assigned + self.target = target + self.extra_strings_regexps = extra_strings_regexps + + def __call__(self, bugdir, bug): + if self.status != 'all' and not bug.status in self.status: + return False + if self.severity != 'all' and not bug.severity in self.severity: + return False + if self.assigned != 'all' and not bug.assigned in self.assigned: + return False + if self.target == 'all': + pass + else: + target_bug = libbe.command.target.bug_target(bugdir, bug) + if self.target in ['none', None]: + if target_bug.summary != None: + return False + else: + if target_bug.summary != self.target: + return False + if len(bug.extra_strings) == 0: + if len(self.extra_strings_regexps) > 0: + return False + elif len(self.extra_strings_regexps) > 0: + matched = False + for string in bug.extra_strings: + for regexp in self.extra_strings_regexps: + if regexp.match(string): + matched = True + break + if matched == True: + break + if matched == False: + return False + return True + +def parse_status(status): + if status == 'all': + status = libbe.bug.status_values + elif status == 'active': + status = list(libbe.bug.active_status_values) + elif status == 'inactive': + status = list(libbe.bug.inactive_status_values) + else: + status = libbe.command.util.select_values( + status, libbe.bug.status_values) + return status + +def parse_severity(severity, important=False): + if severity == 'all': + severity = libbe.bug.severity_values + elif important == True: + serious = libbe.bug.severity_values.index('serious') + severity.append(list(libbe.bug.severity_values[serious:])) + else: + severity = libbe.command.util.select_values( + severity, libbe.bug.severity_values) + return severity + + class BrokenLink (Exception): def __init__(self, blocked_bug, blocking_bug, blocks=True): if blocks == True: diff --git a/libbe/command/list.py b/libbe/command/list.py index 645ae04..06249a0 100644 --- a/libbe/command/list.py +++ b/libbe/command/list.py @@ -25,6 +25,7 @@ import libbe import libbe.bug import libbe.command import libbe.command.depend +from libbe.command.depend import Filter, parse_status, parse_severity import libbe.command.tag import libbe.command.target import libbe.command.util @@ -33,72 +34,6 @@ import libbe.command.util AVAILABLE_CMPS = [fn[4:] for fn in dir(libbe.bug) if fn[:4] == 'cmp_'] AVAILABLE_CMPS.remove('attr') # a cmp_* template. -class Filter (object): - def __init__(self, status='all', severity='all', assigned='all', - target='all', extra_strings_regexps=[]): - self.status = status - self.severity = severity - self.assigned = assigned - self.target = target - self.extra_strings_regexps = extra_strings_regexps - - def __call__(self, bugdir, bug): - if self.status != 'all' and not bug.status in self.status: - return False - if self.severity != 'all' and not bug.severity in self.severity: - return False - if self.assigned != 'all' and not bug.assigned in self.assigned: - return False - if self.target == 'all': - pass - else: - target_bug = libbe.command.target.bug_target(bugdir, bug) - if self.target in ['none', None]: - if target_bug.summary != None: - return False - else: - if target_bug.summary != self.target: - return False - if len(bug.extra_strings) == 0: - if len(self.extra_strings_regexps) > 0: - return False - elif len(self.extra_strings_regexps) > 0: - matched = False - for string in bug.extra_strings: - for regexp in self.extra_strings_regexps: - if regexp.match(string): - matched = True - break - if matched == True: - break - if matched == False: - return False - return True - -def parse_status(status): - if status == 'all': - status = libbe.bug.status_values - elif status == 'active': - status = list(libbe.bug.active_status_values) - elif status == 'inactive': - status = list(libbe.bug.inactive_status_values) - else: - status = libbe.command.util.select_values( - status, libbe.bug.status_values) - return status - -def parse_severity(severity, important=False): - if severity == 'all': - severity = libbe.bug.severity_values - elif important == True: - serious = libbe.bug.severity_values.index('serious') - severity.append(list(libbe.bug.severity_values[serious:])) - else: - severity = libbe.command.util.select_values( - severity, libbe.bug.severity_values) - return severity - - class List (libbe.command.Command): """List bugs -- cgit From 6a9fc1dfa151b84221963ac738a2072aea61504b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 28 Oct 2010 19:01:42 -0400 Subject: Make dependency tree output respect --show-status/--show-summary flags. --- libbe/command/depend.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libbe') diff --git a/libbe/command/depend.py b/libbe/command/depend.py index 1868dbc..e1446fe 100644 --- a/libbe/command/depend.py +++ b/libbe/command/depend.py @@ -225,16 +225,16 @@ class Depend (libbe.command.Command): print >> self.stdout, '%s blocked by:' % bugA.id.user() for depth,node in dtree.blocked_by_tree().thread(): if depth == 0: continue - print >> self.stdout, \ - '%s%s' % (' '*(depth), - node.bug.string(shortlist=True)) + print >> self.stdout, ( + '%s%s' + % (' '*(depth), self.bug_string(node.bug, params))) if len(dtree.blocks_tree()) > 0: print >> self.stdout, '%s blocks:' % bugA.id.user() for depth,node in dtree.blocks_tree().thread(): if depth == 0: continue - print >> self.stdout, \ - '%s%s' % (' '*(depth), - node.bug.string(shortlist=True)) + print >> self.stdout, ( + '%s%s' + % (' '*(depth), self.bug_string(node.bug, params))) return 0 if params['blocking-bug-id'] != None: -- cgit