sets/files.py cleanPackages function stop calling lock and load
authorMounir Lamouri <volkmar@gentoo.org>
Sat, 15 Aug 2009 19:24:12 +0000 (19:24 -0000)
committerMounir Lamouri <volkmar@gentoo.org>
Sat, 15 Aug 2009 19:24:12 +0000 (19:24 -0000)
and requires the caller to do that
changing unmerge to reflect this change

svn path=/main/trunk/; revision=14069

pym/_emerge/unmerge.py
pym/portage/sets/files.py

index 25c3e4e4f66d9be485c447e97e72e69d07d37b2b..2c9e7576e9b5db31a0ff329db44d1fb2a264eeff 100644 (file)
@@ -510,11 +510,22 @@ def unmerge(root_config, myopts, unmerge_action,
                                        raise UninstallFailure(retval)
                                sys.exit(retval)
                        else:
-                               if clean_world and hasattr(sets["world"], "cleanPackage"):
+                               if clean_world and hasattr(sets["world"], "cleanPackage")\
+                                               and hasattr(sets["world"], "lock"):
+                                       sets["world"].lock()
+                                       if hasattr(sets["world"], "load"):
+                                               sets["world"].load()
                                        sets["world"].cleanPackage(vartree.dbapi, y)
+                                       sets["world"].unlock()
                                emergelog(xterm_titles, " >>> unmerge success: "+y)
-       if clean_world and hasattr(sets["world"], "remove"):
+
+       if clean_world and hasattr(sets["world"], "remove")\
+                       and hasattr(sets["world"], "lock"):
+               sets["world"].lock()
+               # load is called inside remove()
                for s in root_config.setconfig.active:
                        sets["world"].remove(SETPREFIX+s)
+               sets["world"].unlock()
+
        return 1
 
index acf556b7f649e99cfdfce6f13e131a953456fa07..035c2dc999e7208d562348953b5756bcd472451d 100644 (file)
@@ -294,8 +294,13 @@ class WorldSet(EditablePackageSet):
                self._lock = None
 
        def cleanPackage(self, vardb, cpv):
-               self.lock()
-               self._load() # loads latest from disk
+               '''
+               Before calling this function you should call lock and load.
+               After calling this function you should call unlock.
+               '''
+               if not self._lock:
+                       raise AssertionError('cleanPackage needs the set to be locked')
+
                worldlist = list(self._atoms)
                mykey = cpv_getkey(cpv)
                newworldlist = []
@@ -317,7 +322,6 @@ class WorldSet(EditablePackageSet):
 
                newworldlist.extend(self._nonatoms)
                self.replace(newworldlist)
-               self.unlock()
 
        def singleBuilder(self, options, settings, trees):
                return WorldSet(settings["ROOT"])