rev 3611 - in debbugs-illa: . bts

Pierre Habouzit madcoder at costa.debian.org
Wed Apr 19 17:40:45 UTC 2006


Author: madcoder
Date: 2006-04-19 17:40:44 +0000 (Wed, 19 Apr 2006)
New Revision: 3611

Modified:
   debbugs-illa/TODO
   debbugs-illa/bts/report.py
   debbugs-illa/bzpull.py
Log:
implement mornfall's suggestion: bzpull can now take only a debian bug
number



Modified: debbugs-illa/TODO
===================================================================
--- debbugs-illa/TODO	2006-04-19 17:01:35 UTC (rev 3610)
+++ debbugs-illa/TODO	2006-04-19 17:40:44 UTC (rev 3611)
@@ -10,8 +10,6 @@
     * set fixed-upstream / wontfix / ... tags on the fly.
 
     * bzpull:
-      + allow to take only the debian bugNumber as an argument,
-        makes perfectly sense to "resync" a bug.
       + use the db-h spool to query statuses of a bug (forwarded e.g.)
         to avoid ldap lag
       + allow bzpull to take multiple actions on the command line, separated

Modified: debbugs-illa/bts/report.py
===================================================================
--- debbugs-illa/bts/report.py	2006-04-19 17:01:35 UTC (rev 3610)
+++ debbugs-illa/bts/report.py	2006-04-19 17:40:44 UTC (rev 3611)
@@ -51,6 +51,13 @@
         else:
             return BtsReport(l[0]['debbugsID'][0], l[0])
 
+    def getReport(self, nb):
+        l = self.search('(debbugsID=%s)' % (nb))
+        if len(l) is 0:
+            return None
+        else:
+            return BtsReport(nb, l[0])
+
 class BtsReport:
     def __init__(self, bugNum, ldapdata):
         self.data = ldapdata

Modified: debbugs-illa/bzpull.py
===================================================================
--- debbugs-illa/bzpull.py	2006-04-19 17:01:35 UTC (rev 3610)
+++ debbugs-illa/bzpull.py	2006-04-19 17:40:44 UTC (rev 3611)
@@ -30,13 +30,15 @@
 ###############################################################################
 
 """
-Usage: %s bzhost [nnn] http://bugzil.la/NNN
+Usage: %s bzhost [nnn] [http://bugzil.la/NNN]
 
     bzhost     the bugzilla that is concerned (see /etc/bzlink.cfg)
     nnn        the debian bug number
     http://bugzil.la/NNN
                the url to the remote bug (with or without the .cgi part)
 
+    at least one of nnn or http://bugzil.la/NNN must be used
+
 -------------------------------------------------------------------------------
 
     if nnn is given:
@@ -51,6 +53,10 @@
 import bz, bts, bzlink
 from bzlink import BzlinkConfig as Cnf
 
+def die(s):
+    print >> sys.stderr, s
+    sys.exit(1)
+
 def usage(exitCode = 1):
     url = Cnf.bugzilla()
     print >> sys.stderr, __doc__.lstrip() % (sys.argv[0].split('/')[-1])
@@ -84,23 +90,32 @@
         print >> sys.stderr, "`%s' is an unknown Bugzilla" % s
         usage(2)
 
-    url = sys.argv[-1]
-    fwd = True
 
     bzi = bz.BzInterface(Cnf.bugzilla())
-    bzBug = bzi.bugnumberFromUrl(url)
-    if bzBug is None: usage(3)
 
     if len(sys.argv) is 3:
         btsi = bts.BtsInterface(Cnf.ldap())
-        bug  = btsi.getReportOfBzBug(Cnf.bugzilla(), bzBug)
-        if bug is None:
-            print >> sys.stderr, "Cannot find any debian bug forwarded to upstream bug %s" % bzBug
-            sys.exit(4)
+
         fwd = False
+        bzBug = bzi.bugnumberFromUrl(sys.argv[2])
+
+        if bzBug is None:
+            bug = btsi.getReport(sys.argv[2])
+            if bug is None:
+                die("#%s does not exists" % (sys.argv[2]))
+            bzBug = bzi.bugnumberFromUrl(bug.data['debbugsForwardedTo'][0])
+            if bzBug is None:
+                die("#%s does not looks to be forwarded" % (bug.bug))
+        else:
+            bug  = btsi.getReportOfBzBug(Cnf.bugzilla(), bzBug)
+            if bug is None:
+                die("Cannot find any debian bug forwarded to upstream bug %s" % (bzBug))
+
         bug = bug.bug
     else:
-        bug = sys.argv[1]
+        fwd   = True
+        bug   = sys.argv[2]
+        bzBug = bzi.bugnumberFromUrl(sys.argv[3])
 
     rep = bzi.getReport(bzBug)
     mailer = bts.BtsMailer(Cnf.debug())




More information about the pkg-kde-commits mailing list