We really only want the txmbr in the key, everything else can be
reached through it. This avoids copying any data around as txmbrs
reside in memory anyway, so the key is just a cheap reference
to what we already have. With the new key -> txmbr helper in the
callback, this is truly trivial to handle there.

Additionally, enable this new mode for yum itself.

P.S. The "self.txmbrCallback" name is horrible. Better ideas wanted...
---
 cli.py          |    1 +
 yum/depsolve.py |   10 +++++++++-
 yum/rpmtrans.py |    5 ++++-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/cli.py b/cli.py
index 0441c02..74739b7 100644
--- a/cli.py
+++ b/cli.py
@@ -73,6 +73,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         self.logger = logging.getLogger("yum.cli")
         self.verbose_logger = logging.getLogger("yum.verbose.cli")
         self.yum_cli_commands = {}
+        self.txmbrCallback = True
         self.registerCommand(yumcommands.InstallCommand())
         self.registerCommand(yumcommands.UpdateCommand())
         self.registerCommand(yumcommands.InfoCommand())
diff --git a/yum/depsolve.py b/yum/depsolve.py
index 3aaba0e..3d4ecb8 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -69,6 +69,9 @@ class Depsolve(object):
         self._ts = None
         self._tsInfo = None
         self.dsCallback = None
+        # Callback-style switch, default to legacy (hdr, file) mode
+        # Pretty please, find me a better name...
+        self.txmbrCallback = False
         self.logger = logging.getLogger("yum.Depsolve")
         self.verbose_logger = logging.getLogger("yum.verbose.Depsolve")
 
@@ -220,8 +223,13 @@ class Depsolve(object):
                         txmbr.ts_state = 'i'
                         txmbr.output_state = TS_INSTALL
 
+                # New-style callback with just txmbr instead of full headers?
+                if self.txmbrCallback:
+                    cbkey = txmbr
+                else:
+                    cbkey = (hdr, rpmfile)
                 
-                self.ts.addInstall(hdr, (hdr, rpmfile), txmbr.ts_state)
+                self.ts.addInstall(hdr, cbkey, txmbr.ts_state)
                 self.verbose_logger.log(logginglevels.DEBUG_1,
                     _('Adding Package %s in mode %s'), txmbr.po, 
txmbr.ts_state)
                 if self.dsCallback:
diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py
index cdd7238..f27733a 100644
--- a/yum/rpmtrans.py
+++ b/yum/rpmtrans.py
@@ -25,6 +25,7 @@ import types
 import sys
 from yum.constants import *
 from yum import _
+from yum.transactioninfo import TransactionMember
 import misc
 import tempfile
 
@@ -258,7 +259,9 @@ class RPMTransaction:
     # the exact txmbr but we always have a name, so return (name, txmbr)
     # tuples so callers have less twists to deal with.
     def _getTxmbr(self, cbkey):
-        if isinstance(cbkey, tuple):
+        if isinstance(cbkey, TransactionMember):
+            return (cbkey.name, cbkey)
+        elif isinstance(cbkey, tuple):
             pkgtup = self._dopkgtup(cbkey[0])
             txmbrs = self.base.tsInfo.getMembers(pkgtup=pkgtup)
             # if this is not one, somebody screwed up
-- 
1.7.4

_______________________________________________
Yum-devel mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to