ref: refs/heads/master
commit 973b9d9606c030681c5bb9664c8c823cf661d530
Author: Michael Andres
Date: Fri Jul 31 18:08:15 2009 +0200
Removing a package lock was not counted as state change (bnc #501850)
---
tests/zypp/ResStatus_test.cc | 32 ++++++++++++++++++++++++++++++++
zypp/PoolItem.cc | 9 +++++++--
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/tests/zypp/ResStatus_test.cc b/tests/zypp/ResStatus_test.cc
index c18e92f..5b975e0 100644
--- a/tests/zypp/ResStatus_test.cc
+++ b/tests/zypp/ResStatus_test.cc
@@ -209,3 +209,35 @@ BOOST_AUTO_TEST_CASE(transition)
testTable( &ResStatus::setSoftTransact, &evaluateSetSoftTransact );
testTable( &ResStatus::setLock, &evaluateSetLock );
}
+
+
+bool WhilePoolItemSameStateIsPrivate( ResStatus ostatus, ResStatus nstatus )
+{
+ if ( nstatus == ostatus )
+ return true;
+ // some bits changed...
+ if ( nstatus.getTransactValue() != ostatus.getTransactValue()
+ && ( ! nstatus.isBySolver() // ignore solver state changes
+ // removing a user lock also goes to bySolver
+ || ostatus.getTransactValue() == ResStatus::LOCKED ) )
+ return false;
+ if ( nstatus.isLicenceConfirmed() != ostatus.isLicenceConfirmed() )
+ return false;
+ return true;
+}
+
+BOOST_AUTO_TEST_CASE(savestate)
+{
+ ResStatus ostatus;
+ ResStatus nstatus;
+
+ BOOST_CHECK_EQUAL( WhilePoolItemSameStateIsPrivate( ostatus, nstatus ), true );
+ nstatus.setLock( true, ResStatus::USER );
+ BOOST_CHECK_EQUAL( WhilePoolItemSameStateIsPrivate( ostatus, nstatus ), false );
+ ostatus = nstatus;
+ nstatus.setLock( false, ResStatus::USER );
+ BOOST_CHECK_EQUAL( WhilePoolItemSameStateIsPrivate( ostatus, nstatus ), false );
+}
+
+
+
diff --git a/zypp/PoolItem.cc b/zypp/PoolItem.cc
index 28ac594..710255a 100644
--- a/zypp/PoolItem.cc
+++ b/zypp/PoolItem.cc
@@ -106,8 +106,13 @@ namespace zypp
{ status() = _savedStatus; }
bool sameState() const
{
- if ( status().getTransactValue() != _savedStatus.getTransactValue()
- && !status().isBySolver() )
+ if ( status() == _savedStatus )
+ return true;
+ // some bits changed...
+ if ( status().getTransactValue() != _savedStatus.getTransactValue()
+ && ( ! status().isBySolver() // ignore solver state changes
+ // removing a user lock also goes to bySolver
+ || _savedStatus.getTransactValue() == ResStatus::LOCKED ) )
return false;
if ( status().isLicenceConfirmed() != _savedStatus.isLicenceConfirmed() )
return false;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org