OK, next try.

Fixed overwriting the test flag and a trace back because of code not moved together with some other pieces.

Thanks to Tim and Seth for pointing these out.

Btw: The patch still has its etches. I think we should kill
._run_rpm_check_debug(). We need to do a check anyway so we can use it for debugging (check rpmlib against our own resolver) for free. This means there is no need for an config option switching it on and off. Especially as I have hard times to think about a situation where the rpmlib check fails and one really wants to proceed (no rpm5 discussions, please).

Florian
>From 891531d902c2ed48e223233cdfabe8ce18c63ee5 Mon Sep 17 00:00:00 2001
From: Florian Festi <[EMAIL PROTECTED]>
Date: Thu, 24 Jan 2008 16:00:47 +0100
Subject: [PATCH] Avoid population the transaction object over and over again

---
 cli.py                  |   40 +++++++++++++++++-----------------------
 rpmUtils/transaction.py |   17 ++++++++++++++++-
 yum/__init__.py         |   32 ++++++++++++--------------------
 3 files changed, 45 insertions(+), 44 deletions(-)

diff --git a/cli.py b/cli.py
index 581776a..bcf9fed 100644
--- a/cli.py
+++ b/cli.py
@@ -346,17 +346,23 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         if self.gpgsigcheck(downloadpkgs) != 0:
             return 1
         
-        if self.conf.rpm_check_debug:
-            self.verbose_logger.log(yum.logginglevels.INFO_2, 
-                 'Running rpm_check_debug')
-            msgs = self._run_rpm_check_debug()
-            if msgs:
-                print 'ERROR with rpm_check_debug vs depsolve:'
-                for msg in msgs:
-                    print msg
+        # build transaction object
+        self.initActionTs()
+        # save our dsCallback out
+        dscb = self.dsCallback
+        self.dsCallback = None # dumb, dumb dumb dumb!
+        self.populateTs(keepold=0) # sigh
+
+        # required for ordering
+        self.verbose_logger.log(yum.logginglevels.INFO_2,
+                                'Running Transaction Check')
+        msgs = self._run_rpm_check_debug()
+        if msgs:
+            print 'ERROR with rpm_check_debug vs depsolve:'
+            for msg in msgs:
+                print msg
     
-                return 1, ['Please report this error in bugzilla']
-                
+            return 1, ['Please report this error in bugzilla']
             
         self.verbose_logger.log(yum.logginglevels.INFO_2,
             'Running Transaction Test')
@@ -364,15 +370,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         for feature in ['diskspacecheck']: # more to come, I'm sure
             tsConf[feature] = getattr(self.conf, feature)
         
-        testcb = RPMTransaction(self, test=True)
-        
-        self.initActionTs()
-        # save our dsCallback out
-        dscb = self.dsCallback
-        self.dsCallback = None # dumb, dumb dumb dumb!
-        self.populateTs(keepold=0) # sigh
-        tserrors = self.ts.test(testcb, conf=tsConf)
-        del testcb
+        tserrors = self.ts.test(RPMTransaction(self, test=True), conf=tsConf)
         
         self.verbose_logger.log(yum.logginglevels.INFO_2,
             'Finished Transaction Test')
@@ -385,14 +383,10 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
                  self.errorSummary(errstring)
         self.verbose_logger.log(yum.logginglevels.INFO_2,
              'Transaction Test Succeeded')
-        del self.ts
         
         # unset the sigquit handler
         signal.signal(signal.SIGQUIT, signal.SIG_DFL)
         
-        self.initActionTs() # make a new, blank ts to populate
-        self.populateTs(keepold=0) # populate the ts
-        self.ts.check() #required for ordering
         self.ts.order() # order
 
         # put back our depcheck callback
diff --git a/rpmUtils/transaction.py b/rpmUtils/transaction.py
index bb481e6..57d6452 100644
--- a/rpmUtils/transaction.py
+++ b/rpmUtils/transaction.py
@@ -82,7 +82,19 @@ class TransactionWrapper:
     def addTsFlag(self, flag):
         curflags = self.ts.setFlags(0)
         self.ts.setFlags(curflags | flag)
+
+    def clearTsFlag(self, flag):
+        curflags = self.ts.setFlags(0)
+        self.ts.setFlags(curflags & ~flag)
+
+    def getTsFlags(self):
+        curflags = self.ts.setFlags(0)
+        self.ts.setFlags(curflags)
+        return curflags
         
+    def setTsFlags(self, flags):
+        return self.ts.setFlags(flags)
+
     def test(self, cb, conf={}):
         """tests the ts we've setup, takes a callback function and a conf dict 
            for flags and what not"""
@@ -90,13 +102,16 @@ class TransactionWrapper:
         # I don't like this function - it should test, sure - but not
         # with this conf dict, we should be doing that beforehand and
         # we should be packing this information away elsewhere.
+        curflags = self.getTsFlags()
         self.addTsFlag(rpm.RPMTRANS_FLAG_TEST)
         if conf.has_key('diskspacecheck'):
             if conf['diskspacecheck'] == 0:
                 self.ts.setProbFilter(rpm.RPMPROB_FILTER_DISKSPACE)
     
         tserrors = self.ts.run(cb.callback, '')
-    
+
+        self.setTsFlags(curflags)
+
         reserrors = []
         if tserrors:
             for (descr, (etype, mount, need)) in tserrors:
diff --git a/yum/__init__.py b/yum/__init__.py
index 29e00df..bc9584b 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2545,6 +2545,18 @@ class YumBase(depsolve.Depsolve):
     def _doTestTransaction(self,callback,display=None):
         ''' Do the RPM test transaction '''
         # This can be overloaded by a subclass.    
+
+        tsConf = {}
+        for feature in ['diskspacecheck']: # more to come, I'm sure
+            tsConf[feature] = getattr( self.conf, feature )
+
+        self.initActionTs()
+        # save our dsCallback out
+        dscb = self.dsCallback
+        self.dsCallback = None # dumb, dumb dumb dumb!
+        self.populateTs( keepold=0 ) # sigh
+        tserrors = self.ts.test( RPMTransaction(self, test=True), conf=tsConf )
+
         if self.conf.rpm_check_debug:
             self.verbose_logger.log(logginglevels.INFO_2, 
                  'Running rpm_check_debug')
@@ -2555,24 +2567,9 @@ class YumBase(depsolve.Depsolve):
                 retmsgs.append('Please report this error in bugzilla')
                 raise Errors.YumRPMCheckError,retmsgs
         
-        tsConf = {}
-        for feature in ['diskspacecheck']: # more to come, I'm sure
-            tsConf[feature] = getattr( self.conf, feature )
-        #
-        testcb = RPMTransaction(self, test=True)
         # overwrite the default display class
         if display:
             testcb.display = display
-        # clean out the ts b/c we have to give it new paths to the rpms 
-        del self.ts
-  
-        self.initActionTs()
-        # save our dsCallback out
-        dscb = self.dsCallback
-        self.dsCallback = None # dumb, dumb dumb dumb!
-        self.populateTs( keepold=0 ) # sigh
-        tserrors = self.ts.test( testcb, conf=tsConf )
-        del testcb
   
         if len( tserrors ) > 0:
             errstring =  'Test Transaction Errors: '
@@ -2601,10 +2598,6 @@ class YumBase(depsolve.Depsolve):
     def _run_rpm_check_debug(self):
         import rpm
         results = []
-        # save our dsCallback out
-        dscb = self.dsCallback
-        self.dsCallback = None # dumb, dumb dumb dumb!
-        self.populateTs(test=1)
         deps = self.ts.check()
         for deptuple in deps:
             ((name, version, release), (needname, needversion), flags,
@@ -2619,6 +2612,5 @@ class YumBase(depsolve.Depsolve):
                       (name, rpmUtils.miscutils.formatRequire(needname, 
                                                               needversion, flags))
                 results.append(msg)
-        self.dsCallback = dscb
         return results
        
-- 
1.5.3.3

_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to