[Yum-devel] [PATCH 3/4] Make .reinstall a real txmbr attribute

James Antill james at and.org
Thu Jun 10 20:47:59 UTC 2010


---
 yum/__init__.py        |    3 +--
 yum/transactioninfo.py |   14 +++++++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/yum/__init__.py b/yum/__init__.py
index 8e58124..1d7637f 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1424,8 +1424,7 @@ class YumBase(depsolve.Depsolve):
                 if loginuid is None:
                     continue
                 loginuid = str(loginuid)
-                if (txmbr.updates or txmbr.downgrades or
-                    (hasattr(txmbr, 'reinstall') and txmbr.reinstall)):
+                if txmbr.updates or txmbr.downgrades or txmbr.reinstall:
                     if txmbr.updates:
                         opo = txmbr.updates[0]
                     elif txmbr.downgrades:
diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index d574b80..b8e4564 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -349,8 +349,7 @@ class TransactionData:
                     self.updated.append(txmbr)
                     
             elif txmbr.output_state in (TS_INSTALL, TS_TRUEINSTALL):
-                if include_reinstall and self.rpmdb.contains(po=txmbr.po):
-                    txmbr.reinstall = True
+                if include_reinstall and txmbr.reinstall:
                     self.reinstalled.append(txmbr)
                     continue
 
@@ -416,6 +415,10 @@ class TransactionData:
         txmbr.po.state = TS_INSTALL        
         txmbr.ts_state = 'u'
         txmbr.reason = 'user'
+
+        if self.rpmdb.contains(po=txmbr.po):
+            txmbr.reinstall = True
+
         self.add(txmbr)
         return txmbr
 
@@ -506,6 +509,10 @@ class TransactionData:
         txmbr.ts_state = 'u'
         txmbr.relatedto.append((oldpo, 'obsoletes'))
         txmbr.obsoletes.append(oldpo)
+
+        if self.rpmdb.contains(po=txmbr.po):
+            txmbr.reinstall = True
+
         self.add(txmbr)
         return txmbr
 
@@ -607,7 +614,7 @@ class TransactionData:
         for txmbr in self.getMembersWithState(None, TS_INSTALL_STATES):
             # reinstalls have to use their "new" checksum data, in case it's
             # different.
-            if hasattr(txmbr, 'reinstall') and txmbr.reinstall:
+            if txmbr.reinstall:
                 _reinstalled_pkgtups[txmbr.po.pkgtup] = txmbr.po
             pkgs.append(txmbr.po)
 
@@ -720,6 +727,7 @@ class TransactionMember:
         self.updated_by = []
         self.downgrades = []
         self.downgraded_by = []
+        self.reinstall = False
         self.groups = [] # groups it's in
         self._poattr = ['pkgtup', 'repoid', 'name', 'arch', 'epoch', 'version',
                         'release']
-- 
1.7.0.1



More information about the Yum-devel mailing list