[yum-git] 2 commits - docs/yum-changelog.1 plugins/changelog plugins/list-data

James Antill james at linux.duke.edu
Fri Feb 22 19:58:54 UTC 2008


 docs/yum-changelog.1           |    5 ++-
 plugins/changelog/changelog.py |   60 ++++++++++++++++++++++++++++++++++-------
 plugins/list-data/list-data.py |    1 
 3 files changed, 55 insertions(+), 11 deletions(-)

New commits:
commit 46243d89028cc7f52fd313b74e64ee289e051e3a
Author: James Antill <james at and.org>
Date:   Fri Feb 22 14:51:51 2008 -0500

    Add recent lists, and allow number of changelogs instead of date

diff --git a/docs/yum-changelog.1 b/docs/yum-changelog.1
index 0f121d7..576a9cc 100644
--- a/docs/yum-changelog.1
+++ b/docs/yum-changelog.1
@@ -23,7 +23,10 @@ command is used with yum.
 Show changelog delta of updated packages
 .SH COMMANDS
 .IP changelog
-Show changelog data of packages since a specified point in time
+Show changelog data of packages listed (same format as the list command).
+The first argument is required and is either "all" for all the changelog
+entries, a date for the changelog entries since a specified point in time or
+a number for a given number of changelog entries.
 .SH FILES
 .I /etc/yum/pluginconf.d/changelog.conf
 .RS
diff --git a/plugins/changelog/changelog.py b/plugins/changelog/changelog.py
index 3a9057b..3dc00cc 100644
--- a/plugins/changelog/changelog.py
+++ b/plugins/changelog/changelog.py
@@ -75,7 +75,7 @@ class ChangeLogCommand:
         return ['changelog', 'ChangeLog']
 
     def getUsage(self):
-        return "<date>|forever [PACKAGE|all|installed|updates|extras|obsoletes|recent]"
+        return "<date>|<number>|all [PACKAGE|all|installed|updates|extras|obsoletes|recent]"
 
     def getSummary(self):
         return """\
@@ -84,6 +84,27 @@ Display changelog data, since a specified time, on a group of packages"""
     def doCheck(self, base, basecmd, extcmds):
         pass
 
+    def changelog(self, pkg):
+        if self._since_all:
+            for date, author, message in pkg.returnChangelog():
+                yield "* %s %s\n%s" % (time.ctime(int(date)), author, message)
+            return
+
+        if self._since_num is not None:
+            num = self._since_num
+            for date, author, message in pkg.returnChangelog():
+                if num <= 0:
+                    return
+                num -= 1
+                yield "* %s %s\n%s" % (time.ctime(int(date)), author, message)
+            return
+        
+        if True:
+            for date, author, message in pkg.returnChangelog():
+                if int(date) < self._since_tt:
+                    return
+                yield "* %s %s\n%s" % (time.ctime(int(date)), author, message)
+
     def show_data(self, msg, pkgs, name):
         done = False
         for pkg in pkgs:
@@ -93,14 +114,19 @@ Display changelog data, since a specified time, on a group of packages"""
 
             self._spkgs += 1
 
-            for line in changelog_delta(pkg, self._since):
+            for line in self.changelog(pkg):
                 if pkg.sourcerpm not in self._done_spkgs:                    
                     if not self._done_spkgs:
                         msg('')
-                        if not self._since:
+                        if self._since_all:
                             msg('Listing all changelogs')
+                        elif self._since_num is not None:
+                            sn = "s"
+                            if self._since_num == 1:
+                                sn = ""
+                            msg('Listing %d changelog%s' % (self._since_num,sn))
                         else:
-                            msg('Listing changelogs since: ' +
+                            msg('Listing changelogs since ' +
                                 str(self._since_dto.date()))
                     msg('')
                     if not done:
@@ -124,16 +150,29 @@ Display changelog data, since a specified time, on a group of packages"""
         self._pkgs = 0
         self._spkgs = 0
         self._changelogs = 0
-        self._since = 0
+        self._since_all = False
         self._since_dto = None
-        if len(extcmds):
-            since = extcmds[0]
-            extcmds = extcmds[1:]
+        self._since_tt  = None
+        self._since_num = None
+
+        if not len(extcmds):
+            return 1, [basecmd + " " + self.getUsage()]
+        
+        since = extcmds[0]
+        extcmds = extcmds[1:]
 
-            if since != 'forever':
+        if since == 'all':
+            self._since_all = True
+        else:
+            try:
+                num = int(since)
+                if num <= 0:
+                    raise ValueError
+                self._since_num = num
+            except:
                 self._since_dto = dateutil.parser.parse(since, fuzzy=True)
                 tt = self._since_dto.timetuple()
-                self._since = time.mktime(tt)
+                self._since_tt = time.mktime(tt)
 
         ypl = base.returnPkgLists(extcmds)
         self.show_data(msg, ypl.installed, 'Installed Packages')
@@ -141,6 +180,7 @@ Display changelog data, since a specified time, on a group of packages"""
         self.show_data(msg, ypl.extras,    'Extra Packages')
         self.show_data(msg, ypl.updates,   'Updated Packages')
         self.show_data(msg, ypl.obsoletes, 'Obsoleting Packages')
+        self.show_data(msg, ypl.recent,    'Recent Packages')
 
         ps = sps = cs = ""
         if self._pkgs       != 1: ps  = "s"
commit 2644cc46cf9b8ca6405ebe578777497336aabb5a
Author: James Antill <james at and.org>
Date:   Fri Feb 22 14:51:04 2008 -0500

    Add recent lists

diff --git a/plugins/list-data/list-data.py b/plugins/list-data/list-data.py
index 539290c..8d5dea4 100755
--- a/plugins/list-data/list-data.py
+++ b/plugins/list-data/list-data.py
@@ -137,6 +137,7 @@ Display aggregate data on the %s attribute of a group of packages""" % self.attr
         self.show_data(msg, ypl.extras,    'Extra Packages')
         self.show_data(msg, ypl.updates,   'Updated Packages')
         self.show_data(msg, ypl.obsoletes, 'Obsoleting Packages')
+        self.show_data(msg, ypl.recent,    'Recent Packages')
         self.cmd_end()
 
         return 0, [basecmd + ' done']



More information about the Yum-cvs-commits mailing list