[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 4.8-16-gd08173f

Sandro Tosi morph at debian.org
Sat Nov 21 22:24:04 UTC 2009


The following commit has been merged in the master branch:
commit 8ed817d4b27d779889fa0c6e390da4a863a79e73
Author: chaica <chaica at ohmytux.com>
Date:   Wed Aug 12 02:52:46 2009 +0200

    run reportbug on a specific bug

diff --git a/bin/reportbug b/bin/reportbug
index af90a27..7c52978 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -36,6 +36,7 @@ import commands
 import rfc822
 import gettext
 import textwrap
+import re
 
 from reportbug import utils
 from reportbug import (
@@ -77,6 +78,7 @@ except IOError:
 MIN_USER_ID = 250
 quietly = False
 reporttitle= ''
+foundpackage = ''
 
 # Cheat for now.
 # ewrite() may put stuff on the status bar or in message boxes depending on UI
@@ -772,6 +774,8 @@ def main():
     parser.add_option('-n', '--mh', '--nmh', action='store_const', dest='mua',
                       help='send the report using mh/nmh',
                       const=utils.MUA['mh'])
+    parser.add_option('-N', '--bugnumber', action='store_true',
+                      dest='bugnumber',help='Specify a bug number to look for')
     parser.add_option('--mua', dest='mua',
                       help='send the report using the specified mailer')
     parser.add_option('--mta', dest='mta', help='send the report using the '
@@ -999,6 +1003,10 @@ class UI(object):
         rtype = self.options.type or sysinfo.get('type')
         attachments = self.options.attachments
         pgp_addr = self.options.keyid
+        bugnumber = self.options.bugnumber
+
+        if bugnumber:
+            dontquery = True
 
         if self.options.body:
             body = textwrap.fill(self.options.body)
@@ -1192,6 +1200,29 @@ class UI(object):
         issource = installed = usedavail = False
         status = None
 
+        exinfo = None
+        try:
+            if bugnumber:
+                reportre = re.compile(r'^#?(\d+)$')
+                match = reportre.match(package)
+                if match:
+                    report = int(match.group(1))
+                    exinfo = ui.show_report(report, 'debian', self.options.mirrors,
+                                          self.options.http_proxy, queryonly=True,
+                                          title=VERSION,
+                                          archived=False)
+                    if foundpackage:
+                        package = foundpackage
+                    if not exinfo:
+                        dontquery = False
+                        bugnumber = False
+                else:
+                    efail("The report bug number you have provided does not match usual pattern.\n")
+        except NoBugs:
+            efail('No bug reports found.\n')
+        except NoReport:
+            efail('Exiting.\n')
+
         if not pkgversion and self.options.querydpkg and \
                sysinfo.get('query-dpkg', True):
             ewrite("Getting status for %s...\n", package)
@@ -1386,7 +1417,7 @@ class UI(object):
 
         if not pkgversion or usedavail or (not pkgavail and
                                            not self.options.pkgversion):
-            if not (isvirtual or notatty):
+            if not bugnumber and not (isvirtual or notatty):
                 pkgversion = ui.get_string('Please enter the version of the '
                                            'package this report applies to '
                                            '(blank OK)', empty_ok=True, force_prompt=True)
@@ -1482,7 +1513,8 @@ class UI(object):
                     dontquery = True
                 special = True
 
-        exinfo = None
+
+
         if not (dontquery or notatty or self.options.kudos):
             pkg, src = package, issource
             if self.options.query_src:
@@ -1643,7 +1675,6 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
                     subject_ok = True
                 else:
                     ewrite("Providing a subject is mandatory.\n")
-
             # Check to make sure the bug still exists to avoid auto-reopens
             if subject and pkgversion:
                 if not ui.yes_no('Does this bug still exist in version %s '
diff --git a/man/reportbug.1 b/man/reportbug.1
index 6cad440..a16f8a6 100644
--- a/man/reportbug.1
+++ b/man/reportbug.1
@@ -270,6 +270,9 @@ and
 .B mh
 mail systems) to edit and send it.
 .TP
+.B \-N, \-\-bugnumber
+Access only the bug report identified by its report number.
+.TP
 .B \-o FILE, \-\-output=FILE
 Instead of sending an email, redirect it to the specified filename.
 .TP
diff --git a/reportbug/ui/text_ui.py b/reportbug/ui/text_ui.py
index e3f7f6c..87afd78 100644
--- a/reportbug/ui/text_ui.py
+++ b/reportbug/ui/text_ui.py
@@ -403,12 +403,16 @@ def show_report(number, system, mirrors,
 
     if not info:
         ewrite('No report available: #%s\n', number)
-        return
+        raise NoBugs
+
+    # extract the package name
+    foundpackage = info[1][0].split('Package: ')[1].split('\n')[0]
 
     (title, messages) = info
     # save report subject in main
     m = sys.modules['__main__']
     m.reporttitle = ' '.join(title.split()[2:])
+    m.foundpackage = foundpackage
 
     current_message = 0
     skip_pager = False

-- 
Reportbug - reports bugs in the Debian distribution



More information about the Reportbug-commits mailing list