[Aptitude-devel] r3200 - in branches/aptitude-0.3/aptitude: . src/generic
Daniel Burrows
dburrows@costa.debian.org
Sat, 30 Apr 2005 18:11:35 +0000
Author: dburrows
Date: Sat Apr 30 18:11:32 2005
New Revision: 3200
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h
Log:
Version name mangling in the case of multiple distinct versions
with the same name.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Sat Apr 30 18:11:32 2005
@@ -1,5 +1,10 @@
2005-04-30 Daniel Burrows <dburrows@debian.org>
+ * src/generic/aptitude_resolver.h:
+
+ Adjust the get_name() routine of versions to mangle versions
+ when several versions with the same name are available.
+
* src/generic/aptcache.cc:
Default score tweaking: double the penalty for broken deps, make
Modified: branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h (original)
+++ branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h Sat Apr 30 18:11:32 2005
@@ -41,6 +41,8 @@
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/version.h>
+#include <sstream>
+
#include "apt.h"
#include "aptcache.h"
@@ -150,10 +152,36 @@
return cache->Head().VersionCount+pkg->ID;
}
- const char *get_name() const
+ std::string get_name() const
{
if(!ver.end())
- return ver.VerStr();
+ {
+ // If there are two distinct package files with the same
+ // Version, apt will give them the same VerStr. Detect and
+ // compensate for this.
+ int count=0;
+ int idx;
+
+ for(pkgCache::VerIterator i=pkg.VersionList(); !i.end(); ++i)
+ {
+ if(i==ver)
+ {
+ idx=count;
+ ++count;
+ }
+ else if(!strcmp(i.VerStr(), ver.VerStr()))
+ ++count;
+ }
+
+ if(count>1)
+ {
+ std::ostringstream s;
+ s << ver.VerStr() << "<" << idx+1 << ">";
+ return s.str();
+ }
+ else
+ return ver.VerStr();
+ }
else
// Note that this is an invalid version string for apt, so we
// can't clash with real versions.