[yum-commits] Branch 'yum-3_2_X' - 3 commits - docs/yum.8 output.py yumcommands.py yum/history.py yum/__init__.py

skvidal at osuosl.org skvidal at osuosl.org
Wed Jun 30 13:37:54 UTC 2010


 docs/yum.8      |    2 +-
 output.py       |   44 ++++++++++++++++++++++++++++++++++++++++++++
 yum/__init__.py |    5 ++---
 yum/history.py  |   17 ++++++++++++++++-
 yumcommands.py  |    4 +++-
 5 files changed, 66 insertions(+), 6 deletions(-)

New commits:
commit 3fa0672db21c0a4b50f1fcf30101dd5b378b4495
Merge: 5a319b5... 5c61137...
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Wed Jun 30 09:36:41 2010 -0400

    Merge branch 'yum-3_2_X' of ssh://yum.baseurl.org/srv/projects/yum/git/yum into yum-3_2_X
    
    * 'yum-3_2_X' of ssh://yum.baseurl.org/srv/projects/yum/git/yum:
      Fix the not possible yet, edge case slots deadlock.
      Save the full args. (including options) for the cmdline data.

commit 5a319b50b4086e4d0d04b0cc6f9aa1e0e39fdc59
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Wed Jun 30 09:34:01 2010 -0400

    - fixes to addon history info
    
    - fix issue writing out config
    - change name of default addon info to make people happy

diff --git a/output.py b/output.py
index ca6f667..36aea07 100755
--- a/output.py
+++ b/output.py
@@ -1591,7 +1591,7 @@ to exit.
         addon_info = self.history.return_addon_data(old.tid)
         
         # for the ones we create by default - don't display them as there
-        default_addons = set(['activeconfig', 'enabled-repos'])
+        default_addons = set(['config-main', 'config-repos'])
         non_default = set(addon_info).difference(default_addons)
         if len(non_default) > 0:
                 print _("Additional non-default information stored: %d" 
diff --git a/yum/__init__.py b/yum/__init__.py
index 54f24f2..8ead5d8 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4694,11 +4694,10 @@ class YumBase(depsolve.Depsolve):
         return True    
 
     def _store_config_in_history(self):
-        myconf += self.conf.dump()
-        self.history.write_addon_data('activeconfig', myconf)
+        self.history.write_addon_data('config-main', self.conf.dump())
         myrepos = ''
         for repo in self.repos.listEnabled():
             myrepos += repo.dump()
             myrepos += '\n'
-        self.history.write_addon_data('enabled-repos', myrepos)
+        self.history.write_addon_data('config-repos', myrepos)
         
commit a7fdbfc7449be03f2b4820368306b6488adc1289
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Tue Jun 29 17:03:27 2010 -0400

    display/retrieve additional history info we have stored
    
    - add 'addon-info' as an option to history cmd
    - add return_addon_data as method of history class
    - display that addon info is available in yum history info results
    - update docs to mention it

diff --git a/docs/yum.8 b/docs/yum.8
index d5ede0a..527b33e 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -71,7 +71,7 @@ gnome\-packagekit application\&.
 .br
 .I \fR * version [ all | installed | available | group-* | nogroups* | grouplist | groupinfo ]
 .br
-.I \fR * history [info|list|summary|redo|undo|new] 
+.I \fR * history [info|list|summary|redo|undo|new|addon-info] 
 .br
 .I \fR * check
 .br 
diff --git a/output.py b/output.py
index 468b2df..ca6f667 100755
--- a/output.py
+++ b/output.py
@@ -1584,9 +1584,19 @@ to exit.
             print _("Return-Code    :"), _("Failure:"), old.return_code
         else:
             print _("Return-Code    :"), _("Success")
+            
         if old.cmdline is not None:
             print _("Command Line   :"), old.cmdline
 
+        addon_info = self.history.return_addon_data(old.tid)
+        
+        # for the ones we create by default - don't display them as there
+        default_addons = set(['activeconfig', 'enabled-repos'])
+        non_default = set(addon_info).difference(default_addons)
+        if len(non_default) > 0:
+                print _("Additional non-default information stored: %d" 
+                            % len(non_default))
+
         print _("Transaction performed with:")
         for hpkg in old.trans_with:
             _simple_pkg(hpkg, 4, was_installed=True)
@@ -1740,6 +1750,40 @@ to exit.
                              utf8_width_fill(uperiod, 19, 19),
                              utf8_width_fill(uiacts, 16, 16), count)
 
+    def historyAddonInfoCmd(self, extcmds):
+        tid = extcmds[1]
+        try:
+            int(tid)
+        except ValueError:
+            self.logger.critical(_('No transaction ID given'))
+            return 1, ['Failed history addon-info']
+
+        old = self.history.old(tids=[tid])
+        if old is None:
+            self.logger.critical(_('No Transaction %s found') % tid)
+            return 1, ['Failed history addon-info']
+            
+        hist_data = old[0]
+        addon_info = self.history.return_addon_data(hist_data.tid)
+        if len(extcmds) <= 2:
+            print 'Available additional history information:'
+            for itemname in self.history.return_addon_data(hist_data.tid):
+                print '  %s' % itemname
+            print ''
+            
+            return 0, ['history addon-info']
+            
+        
+        for item in extcmds[2:]:
+            if item in addon_info:
+                print '%s:' % item
+                print self.history.return_addon_data(hist_data.tid, item)
+            else:
+                print '%s: No additional data found by this name' % item
+
+            print ''
+
+
 
 class DepSolveProgressCallBack:
     """provides text output callback functions for Dependency Solver callback"""
diff --git a/yum/history.py b/yum/history.py
index 91c6f8d..502b908 100644
--- a/yum/history.py
+++ b/yum/history.py
@@ -619,7 +619,22 @@ class YumHistory:
         # return
         return True
         
-
+    def return_addon_data(self, tid, item=None):
+        hist_and_tid = self.conf.addon_path + '/' + str(tid) + '/'
+        addon_info = glob.glob(hist_and_tid + '*')
+        addon_names = [ i.replace(hist_and_tid, '') for i in addon_info ]
+        if not item:
+            return addon_names
+        
+        if item not in addon_names:
+            # XXX history needs SOME kind of exception, or warning, I think?
+            return None
+        
+        fo = open(hist_and_tid + item, 'r')
+        data = fo.read()
+        fo.close()
+        return data
+        
     def _old_with_pkgs(self, tid):
         cur = self._get_cursor()
         executeSQL(cur,
diff --git a/yumcommands.py b/yumcommands.py
index 6b134a4..a7f5d9e 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -1323,7 +1323,7 @@ class HistoryCommand(YumCommand):
         base.history._create_db_file()
 
     def doCheck(self, base, basecmd, extcmds):
-        cmds = ('list', 'info', 'summary', 'repeat', 'redo', 'undo', 'new')
+        cmds = ('list', 'info', 'summary', 'repeat', 'redo', 'undo', 'new', 'addon-info')
         if extcmds and extcmds[0] not in cmds:
             base.logger.critical(_('Invalid history sub-command, use: %s.'),
                                  ", ".join(cmds))
@@ -1347,6 +1347,8 @@ class HistoryCommand(YumCommand):
             ret = base.historyInfoCmd(extcmds)
         elif vcmd == 'summary':
             ret = base.historySummaryCmd(extcmds)
+        elif vcmd == 'addon-info':
+            ret = base.historyAddonInfoCmd(extcmds)
         elif vcmd == 'undo':
             ret = self._hcmd_undo(base, extcmds)
         elif vcmd in ('redo', 'repeat'):


More information about the Yum-commits mailing list