add changelog-limit option to restrict the number of changelogs we add, by default
authorSeth Vidal <skvidal@fedoraproject.org>
Tue, 22 Jan 2008 17:44:19 +0000 (12:44 -0500)
committerSeth Vidal <skvidal@fedoraproject.org>
Tue, 22 Jan 2008 17:44:19 +0000 (12:44 -0500)
createrepo/__init__.py
createrepo/yumbased.py
genpkgmetadata.py

index 7d1e5e1ad97b07ca99ecd8780bffcbbf77d04494..eaa79b8070f7629c0c75d8dade8f6c413e8bc84d 100644 (file)
@@ -85,6 +85,8 @@ class MetaDataConfig(object):
         self.mdtimestamp = 0
         self.directory = None
         self.directories = []
+        self.changelog_limit = None # needs to be an int or None
+        
 
 class SimpleMDCallBack(object):
     def errorlog(self, thing):
@@ -367,6 +369,9 @@ class MetaDataGenerator:
             po = yumbased.CreateRepoPackage(self.ts, rpmfile)
         except Errors.MiscError, e:
             raise MDError, "Unable to open package: %s" % e
+        # if we're going to add anything in from outside, here is where
+        # you can do it
+        po.crp_changelog_limit = self.conf.changelog_limit
         po.crp_cachedir = self.conf.cachedir
         return po
 
index 816df6c0c7e908eebb319e39db94046097d1c6d3..ac03bdc2e141464bab810769c10647e1fb5b99c4 100644 (file)
@@ -372,7 +372,11 @@ class CreateRepoPackage(YumLocalPackage):
         if not self.changelog:
             return ""
         msg = "\n"
-        for (ts, author, content) in self.changelog:            
+        clog_count = 0
+        for (ts, author, content) in reversed(sorted(self.changelog)):
+            if self.crp_changelog_limit and clog_count >= self.crp_changelog_limit:
+                break
+            clog_count += 1
             c = self.xml_node.newChild(None, "changelog", None)
             c.addContent(utils.utf8String(content))
             c.newProp('author', utils.utf8String(author))
index a43b281b2a73ec0d25b7c39cf485f20be7da4d8e..e46b0a7885444e2d564c558fd38f8dbb1fd34f5f 100755 (executable)
@@ -81,6 +81,8 @@ def parseArgs(args, conf):
     parser.add_option("-S", "--skip-symlinks", dest="skip_symlinks",
                       default=False, action="store_true",
                       help="ignore symlinks of packages")
+    parser.add_option("--changelog-limit", dest="changelog_limit",
+                      default=None, help="only import the last N changelog entries")
 
     (opts, argsleft) = parser.parse_args()
     if len(argsleft) > 1 and not opts.split:
@@ -121,6 +123,9 @@ def parseArgs(args, conf):
             
     conf.pkglist = lst
 
+    if conf.changelog_limit: # make sure it is an int, not a string
+        conf.changelog_limit = int(conf.changelog_limit)
+        
     return conf
 
 class MDCallBack(object):