On Wed, Jul 07, 2010 at 09:08:44AM +0200, Gianluca Montecchi wrote:
> On Tue, Jul 06, 2010 at 06:47:46PM -0400, Chris Ball wrote:
> > Hi Gian,
> > ...
> >    > The patch just add the bug summary to the output of the "be
> >    > depend" command.

I made the summary information optional via --show-summary (to keep
the spirit of the current --show-status option).

> > * There's another place where we print the "blocked by:" string in the
> >   same source file, and you haven't modified that one.  (Line 156.)

This was a design flaw in my earlier implementation.  Now bug printing
is always handled by a single method:
  Depend.bug_string(self, _bug, params).

I also added a 'show-summary' test to the Depend doctests.

-- 
This email may be signed or encrypted with GPG (http://www.gnupg.org).
The GPG signature (if present) will be attached as 'signature.asc'.
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

My public key is at http://www.physics.drexel.edu/~wking/pubkey.txt
commit 3be9276eef9081fa51f8b75516176f203f18b39b
Author: W. Trevor King <[email protected]>
Date:   Wed Jul 14 19:24:12 2010 -0400

    Make Gianluca's bug status display optional for `be depend`.
    
    You might not want the bug status displayed, e.g. if you were writing
    a script that parsed the output of `be depend`.
    
    The new implementation is better anyway since it avoids redundant
    display definitions for blocks vs. blocked by.

diff --git a/NEWS b/NEWS
index 5dff61d..aff73ac 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+July 14, 2010
+ * Added --show-status to `be depend`.
+
 June 25, 2010
  * Added --tags to `be list`.
 
diff --git a/libbe/command/depend.py b/libbe/command/depend.py
index d0dd3b3..baea539 100644
--- a/libbe/command/depend.py
+++ b/libbe/command/depend.py
@@ -71,6 +71,11 @@ class Depend (libbe.command.Command):
     abc/b closed
     abc/a blocks:
     abc/b closed
+    >>> ret = ui.run(cmd, {'show-summary':True}, ['/a']) # doctest: 
+NORMALIZE_WHITESPACE
+    abc/a blocked by:
+    abc/b       Bug B
+    abc/a blocks:
+    abc/b       Bug B
     >>> ret = ui.run(cmd, {'repair':True})
     >>> ret = ui.run(cmd, {'remove':True}, ['/b', '/a'])
     abc/b blocks:
@@ -88,6 +93,8 @@ class Depend (libbe.command.Command):
                     help='Remove dependency (instead of adding it)'),
                 libbe.command.Option(name='show-status', short_name='s',
                     help='Show status of blocking bugs'),
+                libbe.command.Option(name='show-summary', short_name='S',
+                    help='Show summary of blocking bugs'),
                 libbe.command.Option(name='status',
                     help='Only show bugs matching the STATUS specifier',
                     arg=libbe.command.Argument(
@@ -177,27 +184,28 @@ class Depend (libbe.command.Command):
                 add_block(bugA, bugB)
 
         blocked_by = get_blocked_by(bugdir, bugA)
+
         if len(blocked_by) > 0:
             print >> self.stdout, '%s blocked by:' % bugA.id.user()
-            if params['show-status'] == True:
-                print >> self.stdout, \
-                    '\n'.join(['%s\t%s\t%s' % (_bug.id.user(), _bug.status, 
_bug.summary)
-                               for _bug in blocked_by])
-            else:
-                print >> self.stdout, \
-                    '\n'.join(['%s\t%s'%(_bug.id.user(), _bug.summary) for 
_bug in blocked_by])
+            print >> self.stdout, \
+                '\n'.join([self.bug_string(_bug, params)
+                           for _bug in blocked_by])
         blocks = get_blocks(bugdir, bugA)
         if len(blocks) > 0:
             print >> self.stdout, '%s blocks:' % bugA.id.user()
-            if params['show-status'] == True:
-                print >> self.stdout, \
-                    '\n'.join(['%s\t%s\t%s' % (_bug.id.user(), _bug.status, 
_bug.summary)
-                               for _bug in blocks])
-            else:
-                print >> self.stdout, \
-                    '\n'.join(['%s\t%s'%(_bug.id.user(), _bug.summary) for 
_bug in blocks])
+            print >> self.stdout, \
+                '\n'.join([self.bug_string(_bug, params)
+                           for _bug in blocks])
         return 0
 
+    def bug_string(self, _bug, params):
+        fields = [_bug.id.user()]
+        if params['show-status'] == True:
+            fields.append(_bug.status)
+        if params['show-summary'] == True:
+            fields.append(_bug.summary)
+        return '\t'.join(fields)
+
     def _long_help(self):
         return """
 Set a dependency with the second bug (B) blocking the first bug (A).

Attachment: pgpohTJzG4Ij4.pgp
Description: PGP signature

_______________________________________________
Be-devel mailing list
[email protected]
http://void.printf.net/cgi-bin/mailman/listinfo/be-devel

Reply via email to