From 69ce0591ad680cd083531e284bd9f8d3d82cb981 Mon Sep 17 00:00:00 2001 From: lxnay Date: Wed, 8 Oct 2008 16:07:42 +0000 Subject: [PATCH] Entropy/ServerInterface: - switch_packages_branch(): also migrate counters git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@2503 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- libraries/entropy.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/libraries/entropy.py b/libraries/entropy.py index 2ae158229..b2c0a1578 100644 --- a/libraries/entropy.py +++ b/libraries/entropy.py @@ -1256,13 +1256,8 @@ class EquoInterface(TextInterface): return packagesMatched,plain_brokenexecs,0 def move_to_branch(self, branch, pretend = False): - availbranches = self.listAllAvailableBranches() - if branch not in availbranches: - return 1 - if pretend: - return 0 + if pretend: return 0 if branch != etpConst['branch']: - etpConst['branch'] = branch # update configuration self.entropyTools.writeNewBranch(branch) # reset treeupdatesactions @@ -1270,10 +1265,10 @@ class EquoInterface(TextInterface): # clean cache self.purge_cache(showProgress = False) # reopen Client Database, this will make treeupdates to be re-read - self.reopenClientDbconn() self.closeAllRepositoryDatabases() - self.validate_repositories() + etpConst['branch'] = branch initConfig_entropyConstants(etpSys['rootdir']) + self.reopenClientDbconn() return 0 # tell if a new equo release is available, returns True or False @@ -17157,6 +17152,10 @@ class ServerInterface(TextInterface): switched.add(idpackage) dbconn.commitChanges() + + # now migrate counters + dbconn.moveCountersToBranch(to_branch) + self.close_server_database(dbconn) mytxt = blue("%s.") % (_("migration loop completed"),) self.updateProgress( @@ -29114,7 +29113,7 @@ class EntropyDatabaseInterface: category = category, sensitive = True ) - else: # server supports multiple branches inside a db + else: # server doesn't support multiple branches inside a db but this is ininfluent searchsimilar = self.searchPackagesByNameAndCategory( name = name, category = category, @@ -32749,6 +32748,15 @@ class EntropyDatabaseInterface: finally: self.WriteLock.release() + def moveCountersToBranch(self, to_branch): + self.WriteLock.acquire() + try: + self.cursor.execute('UPDATE counters SET branch = (?)', to_branch) + self.commitChanges() + self.clearCache() + finally: + self.WriteLock.release() + ######################################################## #### ## Dependency handling functions