allow call only merge old locks and newly added/removed without saving it to file
authorJosef Reidinger <jreidinger@suse.cz>
Thu, 15 May 2008 13:16:51 +0000 (13:16 +0000)
committerJosef Reidinger <jreidinger@suse.cz>
Thu, 15 May 2008 13:16:51 +0000 (13:16 +0000)
VERSION.cmake
tests/zypp/Locks_test.cc
zypp/Locks.cc
zypp/Locks.h

index 4e9b345..3588388 100644 (file)
@@ -45,6 +45,6 @@
 #
 
 SET(LIBZYPP_MAJOR "4")
-SET(LIBZYPP_MINOR "21")
+SET(LIBZYPP_MINOR "22")
 SET(LIBZYPP_COMPATMINOR "21")
-SET(LIBZYPP_PATCH "3")
+SET(LIBZYPP_PATCH "0")
index ff2a47f..bd804b0 100644 (file)
@@ -101,13 +101,13 @@ BOOST_AUTO_TEST_CASE(locks_save_without_redundancy)
   Locks& locks = Locks::instance();
   locks.addLock(q);
   locks.addLock(q);
-  locks.save("/dev/null");
+  locks.merge();
   BOOST_CHECK( locks.size()==1 );
   locks.addLock(q);
-  locks.save("/dev/null");
+  locks.merge();
   BOOST_CHECK( locks.size()==1 );
   locks.removeLock(q);
-  locks.save("/dev/null");
+  locks.merge();
   BOOST_CHECK( locks.size() == 0 );
 }
 
@@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE( locks_empty )
   q.addString("foo-bar-nonexist");
   Locks& locks = Locks::instance();
   locks.addLock(q);
-  locks.save( "/dev/null" ); //only need merge list
+  locks.merge(); //only need merge list
   BOOST_CHECK( locks.existEmpty() );
   locks.removeEmpty();
   BOOST_CHECK( locks.size() == 0 );
index 5976423..84d647e 100644 (file)
@@ -402,6 +402,25 @@ bool Locks::Impl::mergeList(callback::SendReport<SavingLocksReport>& report)
   return true;
 }
 
+void Locks::merge()
+{
+  if( (_pimpl->toAdd.size() | _pimpl->toRemove.size())==0)
+  {
+    return; //nothing to merge
+  }
+
+  callback::SendReport<SavingLocksReport> report;
+  report->start();
+  if (!_pimpl->mergeList(report))
+  {
+    report->finish(SavingLocksReport::ABORTED);
+    return;
+  }
+  DBG << "locks merged" << endl;
+  report->finish(SavingLocksReport::NO_ERROR);
+  _pimpl->locksDirty = true;
+}
+
 void Locks::save( const Pathname& file )
 {
   if( ((_pimpl->toAdd.size() | _pimpl->toRemove.size())==0)
index ee5c4e1..1e18b00 100644 (file)
@@ -113,6 +113,13 @@ namespace zypp
      * \see SavingLocksReport
      */
     void save( const Pathname& file = ZConfig::instance().locksFile() );
+
+    /**
+     * Merges toAdd and ToRemove list to stable list.
+     * \note Can call callback if problem during merging occure
+     * \see SavingLocksReport
+     */
+    void merge();
     
     /**
      * Gets true if some lock doesn't lock any object in pool