[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 6.0-30-ge1a8b41

Sandro Tosi morph at debian.org
Fri Aug 26 23:47:16 UTC 2011


The following commit has been merged in the master branch:
commit e1a8b412ed82f8b33f90c90301c5e1af53ef9b35
Author: Sandro Tosi <morph at debian.org>
Date:   Sat Aug 27 01:46:42 2011 +0200

    make get_report() return the Bugreport instance, containing all the bug information; now the UI does the visualization part, and we just pass objects around storing the info the UI will extract and display; implicitly Closes: #571983
    
    This patch made several changes, removing really old/ugly code. Passing
    Bugreport around allows us to query that object and not the subject/bodies of
    the but report for information about it.
    
    Something is really innatural, like keeping 'exinfo' variable around: we should
    probably rename it at some point in the future, but we'd preferred taking the
    safe side and not remave that too.

diff --git a/bin/reportbug b/bin/reportbug
index a2c6e8f..e0e0eb4 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -75,8 +75,6 @@ except IOError:
 # Magic constant time
 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
@@ -1349,8 +1347,8 @@ class UI(object):
                                           title=VERSION,
                                           archived=False,
                                           mbox_reader_cmd=self.options.mbox_reader_cmd)
-                    if foundpackage:
-                        package = foundpackage
+                    package = exinfo.package or exinfo.source
+                    # XXX: can this ever happen?
                     if not exinfo:
                         dontquery = False
                         bugnumber = False
@@ -1839,7 +1837,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
             subject_ok = False
             while not subject_ok:
                 subject = ui.get_string(
-                    'Please provide a subject for your response.', default="Re: %s" % reporttitle, force_prompt=True)
+                    'Please provide a subject for your response.', default="Re: %s" % exinfo.subject, force_prompt=True)
                 if subject:
                     subject_ok = True
                 else:
diff --git a/debian/changelog b/debian/changelog
index ca13cb6..446d89a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -28,8 +28,13 @@ reportbug (6.2) UNRELEASED; urgency=low
   * reportbug/ui/text_ui.py
     - don't try to decode a unicode string; thanks to Vincent Bernat for the
       report; Closes: #638429
+  * reportbug/debbugs.py + dependeciens
+    - make get_report() return the Bugreport instance, containing all the bug
+      information; now the UI does the visualization part, and we just pass
+      objects around storing the info the UI will extract and display;
+      implicitly Closes: #571983
 
- -- Sandro Tosi <morph at debian.org>  Fri, 26 Aug 2011 18:36:59 +0200
+ -- Sandro Tosi <morph at debian.org>  Sat, 27 Aug 2011 01:42:04 +0200
 
 reportbug (6.1) unstable; urgency=low
 
diff --git a/reportbug/bugreport.py b/reportbug/bugreport.py
index 8ffc198..a1f31f5 100644
--- a/reportbug/bugreport.py
+++ b/reportbug/bugreport.py
@@ -50,9 +50,9 @@ class bugreport(object):
         # the conversion is impossible
         if followup and not isinstance(followup, int):
             try:
-                self.followup = int(followup)
-            except TypeError:
-                ui.long_message('Invalid value for followup, it must be an integer')
+                self.followup = followup.bug_num
+            except:
+                ui.long_message('Invalid value for followup, it must be a debianbts.Bugreport instance or an integer')
                 raise TypeError
         else:
             self.followup = followup
diff --git a/reportbug/debbugs.py b/reportbug/debbugs.py
index 67a51ef..e2a4624 100644
--- a/reportbug/debbugs.py
+++ b/reportbug/debbugs.py
@@ -1277,7 +1277,7 @@ def get_report(number, timeout, system='debian', mirrors=None,
     number = int(number)
 
     if system == 'debian':
-        status = debianbts.get_status(number)
+        status = debianbts.get_status(number)[0]
         log = debianbts.get_bug_log(number)
 
         # add Date/Subject/From headers to the msg bodies
@@ -1292,11 +1292,8 @@ def get_report(number, timeout, system='debian', mirrors=None,
                     hdrs.append(i + ': ' + h.get(i))
             bodies.append('\n'.join(sorted(hdrs)) + '\n\n' + l['body'])
 
-        # subject, in a more nice format
-        subject = '#%d: %s' %(number, status[0].subject)
-
-        # returns the subject and a list of mail bodies
-        return (subject, bodies)
+        # returns the bug status and a list of mail bodies
+        return (status, bodies)
 
     if SYSTEMS[system].get('cgiroot'):
         result = get_cgi_report(number, timeout, system, http_proxy,
diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py
index 5b49aaa..c392e64 100644
--- a/reportbug/ui/gtk2_ui.py
+++ b/reportbug/ui/gtk2_ui.py
@@ -365,7 +365,7 @@ class BugPage (gtk.EventBox, threading.Thread):
         
     def found (self, info):
         self.drop_progressbar ()
-        desc = info[0].split(':', 1)[1].strip ()
+        desc = info[0].subject
         bodies = info[1]
         vbox = gtk.VBox (spacing=12)
         vbox.set_border_width (12)
diff --git a/reportbug/ui/text_ui.py b/reportbug/ui/text_ui.py
index 8896cd7..9563cd6 100644
--- a/reportbug/ui/text_ui.py
+++ b/reportbug/ui/text_ui.py
@@ -418,33 +418,22 @@ def show_report(number, system, mirrors,
         ewrite('No report available: #%s\n', number)
         raise NoBugs
 
-    # extract the package name, either it's reported against
-    # the binary package or the source one
-    foundpackage = info[1][0].lower()
-    try:
-        foundpackage = foundpackage.split('package: ')[1].split('\n')[0]
-    except IndexError:
-        try:
-            foundpackage = foundpackage.split('source: ')[1].split('\n')[0]
-        except:
-            ewrite('Cannot retrieve bug\'s package, exiting...\n')
-            sys.exit(-1)
+    buginfo, messages = info
 
-    (title, messages) = info
-    # save report subject in main
-    m = sys.modules['__main__']
-    m.reporttitle = ' '.join(title.split()[2:])
-    m.foundpackage = foundpackage
+    # XXX: could this be ever possible?
+    if not (buginfo.package or not buginfo.source):
+        ewrite('Cannot retrieve bug\'s package, exiting...\n')
+        sys.exit(-1)
 
     current_message = 0
     skip_pager = False
 
     while 1:
         if current_message:
-            text = 'Followup %d - %s\n\n%s' % (current_message, title,
+            text = 'Followup %d - %s\n\n%s' % (current_message, buginfo.subject,
                                                  messages[current_message])
         else:
-            text = 'Original report - %s\n\n%s' % (title, messages[0])
+            text = 'Original report - %s\n\n%s' % (buginfo.subject, messages[0])
 
         if not skip_pager:
             fd = os.popen('sensible-pager', 'w')
@@ -478,7 +467,7 @@ def show_report(number, system, mirrors,
                             'q' : "I'm bored; quit please."},
                            allow_numbers = range(1, len(messages)+1))
         if x == 'x':
-            return number
+            return buginfo
         elif x == 'q':
             raise NoReport
         elif x == 'b':
diff --git a/reportbug/ui/urwid_ui.py b/reportbug/ui/urwid_ui.py
index 7a29892..2ec2f58 100644
--- a/reportbug/ui/urwid_ui.py
+++ b/reportbug/ui/urwid_ui.py
@@ -513,17 +513,17 @@ def show_report(number, system, mirrors,
     valid = 'Odmq'
 
     while 1:
-        (bugtitle, bodies) = info
+        (buginfo, bodies) = info
         body = bodies[0]
 
-        r = select_options(body, valid, title=bugtitle, ui=ui, help=options)
+        r = select_options(body, valid, title=buginfo.subject, ui=ui, help=options)
         ui = None
         if not r or (r == 'o'):
             break
         elif r == 'q':
             return -1
         elif r == 'm':
-            return number
+            return buginfo
 
         launch_browser(debbugs.get_report_url(system, number, archived))
     return
diff --git a/reportbug/utils.py b/reportbug/utils.py
index a48e5e2..814134c 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -732,7 +732,7 @@ def get_arch():
 
 def generate_blank_report(package, pkgversion, severity, justification,
                           depinfo, confinfo, foundfile='', incfiles='',
-                          system='debian', exinfo=0, type=None, klass='',
+                          system='debian', exinfo=None, type=None, klass='',
                           subject='', tags='', body='', mode=MODE_EXPERT,
                           pseudos=None, debsumsoutput=None, issource=False):
     # For now...
diff --git a/test/test_bugreport.py b/test/test_bugreport.py
index b7b9352..6c0dffd 100644
--- a/test/test_bugreport.py
+++ b/test/test_bugreport.py
@@ -1,6 +1,8 @@
 import unittest2
 
 from reportbug.bugreport import bugreport
+from nose.plugins.attrib import attr
+import debianbts
 
 class TestBugreport(unittest2.TestCase):
 
@@ -15,6 +17,7 @@ class TestBugreport(unittest2.TestCase):
         self.assertIn(self.body, self.text)
         self.assertIn(self.package, self.text)
 
+    @attr('network') #marking the test as using network
     def test_followup(self):
         self.body = 'test'
         self.package = 'reportbug'
@@ -25,9 +28,10 @@ class TestBugreport(unittest2.TestCase):
         self.assertIn('Followup-For: Bug #123456', self.text)
         self.assertNotIn('Severity: ', self.text)
 
-        # test also a string as followup, and a datatype unconvertible to int
+        # test also a bugreport instance, and a datatype unconvertible to int
+        bug = debianbts.get_status(123456)[0]
         self.report = bugreport(package=self.package, body=self.body,
-                                followup='123456')
+                                followup=bug)
         self.text = self.report.__unicode__()
 
         self.assertIn('Followup-For: Bug #123456', self.text)
diff --git a/test/test_debbugs.py b/test/test_debbugs.py
index 2d271d6..ecf6880 100644
--- a/test/test_debbugs.py
+++ b/test/test_debbugs.py
@@ -126,12 +126,13 @@ class TestGetReports(unittest2.TestCase):
     @attr('network') #marking the test as using network
     def test_get_report(self):
 
-        data = debbugs.get_report(415801, 120)
-        self.assertEqual(data[0],
-               '#415801: reportbug: add support for SOAP interface to BTS')
+        buginfo, bodies = debbugs.get_report(415801, 120)
+        self.assertEqual(buginfo.bug_num, 415801)
+        self.assertEqual(buginfo.subject,
+                         'reportbug: add support for SOAP interface to BTS')
 
         # relative to bts#637994, report with messages without a header
-        subject, bodies = debbugs.get_report(503300, 120)
+        buginfo, bodies = debbugs.get_report(503300, 120)
         self.assertGreater(len(bodies), 0)
 
 class TestUrlFunctions(unittest2.TestCase):
diff --git a/test/test_utils.py b/test/test_utils.py
index 5e92fca..1d76d0d 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -3,6 +3,8 @@ import unittest2
 from reportbug import utils
 import os.path
 import platform
+from nose.plugins.attrib import attr
+import debianbts
 
 class TestUtils(unittest2.TestCase):
 
@@ -351,6 +353,7 @@ Shell: /bin/sh linked to /bin/bash"""
         self.assertIn('Morph', p)
 
 
+    @attr('network') #marking the test as using network
     def test_generate_blank_report(self):
 
         report = utils.generate_blank_report('reportbug', '1.2.3', 'normal',
@@ -367,9 +370,10 @@ Shell: /bin/sh linked to /bin/bash"""
                                              exinfo=123456)
         self.assertIn('Followup-For: Bug #123456', report)
 
+        bug = debianbts.get_status(123456)[0]
         report = utils.generate_blank_report('reportbug', '1.2.3', 'normal',
                                              '', '', '', type='debbugs',
-                                             exinfo='123456')
+                                             exinfo=bug)
         self.assertIn('Followup-For: Bug #123456', report)
 
         with self.assertRaises(TypeError):

-- 
Reportbug - reports bugs in the Debian distribution



More information about the Reportbug-commits mailing list