[Aptitude-svn-commit] r3675 - in branches/aptitude-0.3/aptitude: . src/cmdline src/generic

Daniel Burrows dburrows at costa.debian.org
Mon Jul 25 18:35:41 UTC 2005


Author: dburrows
Date: Mon Jul 25 18:35:39 2005
New Revision: 3675

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/cmdline/cmdline_changelog.cc
   branches/aptitude-0.3/aptitude/src/generic/pkg_changelog.cc
   branches/aptitude-0.3/aptitude/src/generic/pkg_changelog.h
Log:
Add code to look a package up directly from a source package name.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Mon Jul 25 18:35:39 2005
@@ -1,5 +1,13 @@
 2005-07-25  Daniel Burrows  <dburrows at debian.org>
 
+	* src/generic/cmdling_changelog.cc, src/generic/pkg_changelog.cc, src/generic/pkg_changelog.h:
+
+	  Add the ability to find changelog based on the source package
+	  name as well as an iterator to a binary package version.  Also
+	  eliminated the hardcoded default for PulseInterval and changed
+	  the invocation of pkg_changelog in cmdline_changelog.cc
+	  accordingly.
+
 	* src/pkg_grouppolicy.cc:
 
 	  Patch up a memory leak in the matchers grouping policy.

Modified: branches/aptitude-0.3/aptitude/src/cmdline/cmdline_changelog.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/cmdline/cmdline_changelog.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/cmdline/cmdline_changelog.cc	Mon Jul 25 18:35:39 2005
@@ -73,7 +73,8 @@
 	    }
 
 	  pkg_changelog *cl=get_changelog(ver,
-					  gen_cmdline_download_progress());
+					  gen_cmdline_download_progress(),
+					  500000);
 
 	  if(!cl)
 	    _error->Error(_("Couldn't find a changelog for %s"), input.c_str());

Modified: branches/aptitude-0.3/aptitude/src/generic/pkg_changelog.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/pkg_changelog.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/pkg_changelog.cc	Mon Jul 25 18:35:39 2005
@@ -35,6 +35,7 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/acquire-item.h>
+#include <apt-pkg/srcrecords.h>
 #include <apt-pkg/strutl.h>
 
 using namespace std;
@@ -79,12 +80,20 @@
   if(ver.FileList().end())
     return NULL;
 
-  string filename="aptitudeXXXXXX";
-
   // Look up the source package.
   pkgRecords::Parser &rec=apt_package_records->Lookup(ver.FileList());
   string srcpkg=rec.SourcePkg().empty()?ver.ParentPkg().Name():rec.SourcePkg();
 
+  return get_changelog_from_source(srcpkg, status, PulseInterval, ver.ParentPkg().Name());
+}
+
+pkg_changelog *get_changelog_from_source(const string &srcpkg,
+					 pkgAcquireStatus *status,
+					 int PulseInterval,
+					 const string &name)
+{
+  string filename="aptitudeXXXXXX";
+
   if(getenv("HOME"))
     {
       string dotdir(getenv("HOME"));
@@ -114,22 +123,32 @@
 
   char uribuf[1024];
 
-  string section=ver.Section();
+  pkgSrcRecords src_recs(*apt_source_list);
+  pkgSrcRecords::Parser *parser = src_recs.Find(srcpkg.c_str());
+
+  if(parser == NULL)
+    {
+      _error->Error(_("Unable to find source for package \"%s\""),
+		    srcpkg.c_str());
+      return NULL;
+    }
+
+  string section=parser->Section();
 
   if(section.find('/')!=section.npos)
-    section=string(section, 0, section.find('/'));
+    section.assign(section, 0, section.find('/'));
   else
     section="main";
 
   string prefix;
 
-  prefix+=srcpkg[0];
-
   if(srcpkg.size()>3 && srcpkg[0]=='l' && srcpkg[1]=='i' && srcpkg[2]=='b')
-    prefix=std::string("lib")+srcpkg[3];
+    prefix = std::string("lib")+srcpkg[3];
+  else
+    prefix = srcpkg[0];
 
   // packages.d.o uses a munged version number.
-  string verstr=ver.VerStr();
+  string verstr=parser->Version();
 
   if(verstr.find(':')!=verstr.npos)
     verstr=string(verstr, verstr.find(':')+1);
@@ -146,7 +165,7 @@
   pkgAcquire fetcher(status);
 
   char buf[512];
-  snprintf(buf, 512, _("ChangeLog of %s"), ver.ParentPkg().Name());
+  snprintf(buf, 512, _("ChangeLog of %s"), name.c_str());
 
   bool failed=false;
   new AcqWithFail(&fetcher,

Modified: branches/aptitude-0.3/aptitude/src/generic/pkg_changelog.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/pkg_changelog.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/pkg_changelog.h	Mon Jul 25 18:35:39 2005
@@ -34,9 +34,10 @@
   std::string filename;
 
   pkg_changelog::pkg_changelog(const std::string &_filename);
-  friend pkg_changelog *get_changelog(pkgCache::VerIterator,
-				      pkgAcquireStatus *,
-				      int);
+  friend pkg_changelog *get_changelog_from_source(const std::string &,
+						  pkgAcquireStatus *,
+						  int,
+						  const std::string &);
 public:
   std::string get_filename() {return filename;}
 
@@ -45,6 +46,21 @@
 
 pkg_changelog *get_changelog(pkgCache::VerIterator ver,
 			     pkgAcquireStatus *status,
-			     int PulseInterval=500000);
+			     int PulseInterval);
+
+/** Return a changelog object for the given source package.
+ *
+ *  \param srcpkg the source package name
+ *  \param status the object to which the download status should be reported
+ *  \param PulseInterval the interval at which to update the display
+ *                       and poll for input
+ *  \param name the name of the package that the user provided
+ *              (e.g., the binary package that the changelog command
+ *               was executed on)
+ */
+pkg_changelog *get_changelog_from_source(const std::string &srcpkg,
+					 pkgAcquireStatus *status,
+					 int PulseInterval,
+					 const std::string &name);
 
 #endif



More information about the Aptitude-svn-commit mailing list