ref: refs/heads/ma-misc
commit db04ce4846e34b67b30069757bbe7b5fe1f7c1b0
Author: Michael Andres
Date: Fri Jul 31 18:12:00 2009 +0200
Take solver_allowVendorChange option into account when computing the Selectables default candidate.
---
zypp/Vendor.h | 1 +
zypp/VendorAttr.cc | 6 ++++++
zypp/VendorAttr.h | 2 ++
zypp/ui/SelectableImpl.h | 25 +++++++++++++++++++------
4 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/zypp/Vendor.h b/zypp/Vendor.h
index 73368be..8de5063 100644
--- a/zypp/Vendor.h
+++ b/zypp/Vendor.h
@@ -13,6 +13,7 @@
#define ZYPP_VENDOR_H
#include <string>
+#include "zypp/IdString.h"
///////////////////////////////////////////////////////////////////
namespace zypp
diff --git a/zypp/VendorAttr.cc b/zypp/VendorAttr.cc
index 6e00e85..5481a96 100644
--- a/zypp/VendorAttr.cc
+++ b/zypp/VendorAttr.cc
@@ -226,6 +226,12 @@ namespace zypp
return true;
}
+ bool VendorAttr::equivalent( IdString lVendor, IdString rVendor ) const
+ {
+ if ( lVendor == rVendor )
+ return true;
+ return equivalent( lVendor.asString(), rVendor.asString() );
+ }
bool VendorAttr::equivalent( const Vendor & lVendor, const Vendor & rVendor ) const
{
diff --git a/zypp/VendorAttr.h b/zypp/VendorAttr.h
index 55f0408..7ddda98 100644
--- a/zypp/VendorAttr.h
+++ b/zypp/VendorAttr.h
@@ -63,6 +63,8 @@ class VendorAttr
* different vendor usually must be confirmed by the user.
*/
bool equivalent( const Vendor & lVendor, const Vendor & rVendor ) const;
+ /** \overload using IdStrings */
+ bool equivalent( IdString lVendor, IdString rVendor ) const;
private:
VendorAttr();
diff --git a/zypp/ui/SelectableImpl.h b/zypp/ui/SelectableImpl.h
index 3c70d67..008333b 100644
--- a/zypp/ui/SelectableImpl.h
+++ b/zypp/ui/SelectableImpl.h
@@ -17,6 +17,7 @@
#include "zypp/base/PtrTypes.h"
+#include "zypp/ZConfig.h"
#include "zypp/ui/Selectable.h"
#include "zypp/ui/SelectableTraits.h"
@@ -68,6 +69,7 @@ namespace zypp
else
_availableItems.insert( *it );
}
+ _defaultCandidate = defaultCandidate();
}
public:
@@ -106,10 +108,7 @@ namespace zypp
PoolItem ret( transactingCandidate() );
if ( ret )
return ret;
-
- if ( _candidate )
- return _candidate;
- return defaultCandidate();
+ return _candidate ? _candidate : _defaultCandidate;
}
/** Set a userCandidate (out of available objects).
@@ -213,18 +212,30 @@ namespace zypp
{
if ( !installedEmpty() )
{
- // prefer the installed objects arch.
+ // prefer the installed objects arch and vendor
+ bool solver_allowVendorChange( ZConfig::instance().solver_allowVendorChange() );
for ( installed_const_iterator iit = installedBegin();
iit != installedEnd(); ++iit )
{
+ PoolItem sameArch; // in case there's no same vendor at least stay with same arch
for ( available_const_iterator it = availableBegin();
it != availableEnd(); ++it )
{
if ( (*iit)->arch() == (*it)->arch() )
{
- return (*it);
+ if ( ! solver_allowVendorChange )
+ {
+ if ( VendorAttr::instance().equivalent( (*iit).satSolvable().vendor(), (*it).satSolvable().vendor() ) )
+ return *it;
+ else if ( ! sameArch ) // remember best same arch in case no same vendor found
+ sameArch = *it;
+ }
+ else // same arch is sufficient
+ return *it;
}
}
+ if ( sameArch )
+ return sameArch;
}
}
if ( _availableItems.empty() )
@@ -250,6 +261,8 @@ namespace zypp
const std::string _name;
InstalledItemSet _installedItems;
AvailableItemSet _availableItems;
+ //! Best among availabe with restpect to installed.
+ PoolItem _defaultCandidate;
//! The object selected by setCandidateObj() method.
PoolItem _candidate;
};
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org