aboutsummaryrefslogtreecommitdiffstats
path: root/RepSys/commands/rpmlog.py
blob: 5ba5fdd64de6ffda69299071303a2051e6d3b21f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python
#
# This program will convert the output of "svn log" to be suitable
# for usage in an rpm %changelog session.
#
from RepSys import Error
from RepSys.command import *
from RepSys.log import svn2rpm
import getopt
import sys

HELP = """\
Usage: repsys rpmlog [OPTIONS] REPPKGDIRURL

Prints the RPM changelog of a given package.

Options:
    -r REV   Collect logs from given revision to revision 0
    -n NUM   Output only last NUM entries
    -T FILE  %changelog template file to be used
    -h       Show this message

Examples:
    repsys rpmlog python
    repsys rpmlog http://svn.mandriva.com/svn/packages/cooker/python
"""

def parse_options():
    parser = OptionParser(help=HELP)
    parser.add_option("-r", dest="revision")
    parser.add_option("-n", dest="size", type="int")
    parser.add_option("-T", "--template", dest="template", type="string")
    opts, args = parser.parse_args()
    if len(args) != 1:
        raise Error, "invalid arguments"
    opts.pkgdirurl = default_parent(args[0])
    return opts

def rpmlog(pkgdirurl, revision, size, template):
    sys.stdout.write(svn2rpm(pkgdirurl, revision, size, template=template))

def main():
    do_command(parse_options, rpmlog)

# vim:sw=4:ts=4:et