tag 476988 patch
thanks

On Sun, 20 Apr 2008 19:04:28 +0200 Francesco Poli wrote:

> On Sun, 20 Apr 2008 17:40:03 +0200 Francesco Poli wrote:
> 
> [...]
> >    ยท  query  <package[/version]>  <bugnumber1> <bugnumber2>... 
[...]
> I hope I managed to explain what I mean.

I think I successfully implemented the query command, more or less as I
wanted it to be.

The attached patch modifies /usr/sbin/apt-listbugs in order to add the
feature I requested.  It also updates the documentation (from which the
manpage is generated) and adds my copyright notice.

If my modifications look OK to you, please apply my patch and update
debian/copyright accordingly.


Legal details:
I hereby release my patch under the same terms of
/usr/sbin/apt-listbugs, that is to say, under the terms of the GNU
General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.


-- 
 http://frx.netsons.org/doc/index.html#nanodocs
 The nano-document series is here!
..................................................... Francesco Poli .
 GnuPG key fpr == C979 F34B 27CE 5CD8 DC12  31B5 78F4 279B DD6D FCF4
diff -ruN s/apt-listbugs b/apt-listbugs
--- s/apt-listbugs	2008-06-08 12:11:35.000000000 +0200
+++ b/apt-listbugs	2008-06-09 23:04:50.000000000 +0200
@@ -4,6 +4,7 @@
 #
 # Copyright (C) 2002  Masato Taruishi <[EMAIL PROTECTED]>
 # Copyright (C) 2006-2008  Junichi Uekawa <[EMAIL PROTECTED]>
+# Copyright (C) 2008  Francesco Poli <[EMAIL PROTECTED]>
 #
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
@@ -127,6 +128,13 @@
   Reads package names from the arguments and lists bugs of these packages
   in rss format.
 
+* query <package[/version]> <bugnumber1> <bugnumber2>...
+
+  Reads a package name from the first argument and bug numbers from the
+  remaining arguments; among given bugs, lists those that affect the
+  given package. Package version may be specified with a slash, for
+  example, like apt/1.0
+
 == ENVIRONMENT VARIABLES
 
 * APT_LISTBUGS_FRONTEND
@@ -203,7 +211,8 @@
 apt-listbugs was originally written by Masato Taruishi
 <[EMAIL PROTECTED]>, and rewritten by Junichi Uekawa
 <[EMAIL PROTECTED]> in 2006 to handle BTS Versioning features and the
-SOAP interface.
+SOAP interface. The query command was added by Francesco Poli
+<[EMAIL PROTECTED]> in 2008.
 
 Latest source-code is available from
 http://git.debian.org/?p=apt-listbugs/apt-listbugs.git
@@ -267,6 +276,7 @@
       _(" apt              : apt mode\n"),
       _(" list <pkg...>    : list bug reports of the specified packages\n"),
       _(" rss <pkg...>     : list bug reports of the specified packages in rss\n"),
+      _(" query <pkg> <bug>: list specified bugs if they affect specified package\n"),
       _("See the manual page for the long options.\n")
   end
 
@@ -420,6 +430,8 @@
       @command = "apt"
     when "rss"
       @command = "rss"
+    when "query"
+      @command = "query"
     else
       STDERR.puts _("E: Unknown command ") +  "'#{command}'."
       usage
@@ -511,7 +523,7 @@
         return true
       end
 
-      if @config.command == "list"
+      if @config.command == "list" || @config.command == "query"
 	return true
       end
 
@@ -953,6 +965,8 @@
 	  f = ListFactory.field(pkgnames[index])
 	when "rss"
 	  f = ListFactory.field(pkgnames[index])
+	when "query"
+	  f = ListFactory.field(pkgnames[index])
 	else
 	  raise _("Not Implemented")
 	end
@@ -1087,6 +1101,11 @@
       bugs.delete_if { |bug| config.system_ignore_bugs.include?(bug.bug_number)}
     end
 
+    def delete_uninteresting_bugs(bugs, interesting_bugs)
+      # ignoring all bugs but the interesting ones
+      bugs.delete_if { |bug| !interesting_bugs.include?(bug.bug_number)}
+    end
+
     def iterate_fixed_found_version(space_delimited_bts_version, pkg_name)
       # iterate relevant versions
       if space_delimited_bts_version.nil?
@@ -1228,6 +1247,7 @@
     end
     
     module_function :create, :delete_ignore_bugs,
+    :delete_uninteresting_bugs,
     :delete_threshold_bugs, :delete_unwanted_tag_bugs, 
     :find_max_version_below_new_ver, 
     :iterate_fixed_found_version
@@ -1310,6 +1330,7 @@
 
 # handle arguments
 pkgnames = []
+bugnumbs = []
 holdpkgs = {}
 case config.command
 when "apt"
@@ -1358,6 +1379,12 @@
   ARGV.each { |pkg|
     pkgnames << "#{pkg}"
   }
+when "query"
+  pkg = ARGV.shift
+  pkgnames << "#{pkg}"
+  ARGV.each { |bug|
+    bugnumbs << "#{bug}"
+  }
 end
 
 exit 0 if pkgnames.size == 0
@@ -1390,6 +1417,7 @@
 end
 
 Factory::BugsFactory.delete_ignore_bugs(bugs) if config.command == "apt"
+Factory::BugsFactory.delete_uninteresting_bugs(bugs, bugnumbs) if config.command == "query"
 Factory::BugsFactory.delete_unwanted_tag_bugs(bugs) if config.tag
 begin
   Factory::BugsFactory.delete_threshold_bugs(bugs, cur_pkgs, new_pkgs) { |msg, val|
@@ -1409,6 +1437,8 @@
   viewer = Viewer::SimpleViewer.new(config)
 when "list"
   viewer = Viewer::SimpleViewer.new(config)
+when "query"
+  viewer = Viewer::SimpleViewer.new(config)
 when "rss"
   viewer = Viewer::RSSViewer.new(config)
 end

Attachment: pgpa4aloYAmro.pgp
Description: PGP signature

Reply via email to