1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-13 17:16:23 +01:00

- added revision support for "osc log"

- some other minor fixes (a bit exception handling (some other methods should be improved too!) etc.)
This commit is contained in:
Marcus Hüwe 2007-07-12 00:48:52 +00:00
parent 7e98ecb0cb
commit fd199c66e9
2 changed files with 29 additions and 7 deletions

View File

@ -1310,6 +1310,8 @@ class Osc(cmdln.Cmdln):
print '\n'.join(get_buildhistory(apiurl, project, package, platform, arch))
@cmdln.option('-r', '--revision', metavar='rev',
help='show log of the specified revision')
def do_log(self, subcmd, opts):
"""${cmd_name}: Shows the commit log of a package
@ -1321,8 +1323,12 @@ class Osc(cmdln.Cmdln):
package = store_read_package(wd)
project = store_read_project(wd)
apiurl = store_read_apiurl(wd)
rev, dummy = parseRevisionOption(opts.revision)
if rev and not checkRevision(project, package, rev):
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev
sys.exit(1)
print '\n'.join(get_commitlog(apiurl, project, package))
print '\n'.join(get_commitlog(apiurl, project, package, rev))
@cmdln.option('-f', '--failed', action='store_true',

View File

@ -1501,7 +1501,7 @@ def get_buildhistory(apiurl, prj, package, platform, arch):
return r
def get_commitlog(apiurl, prj, package):
def get_commitlog(apiurl, prj, package, revision):
import time
u = makeurl(apiurl, ['source', prj, package, '_history'])
f = http_GET(u)
@ -1511,8 +1511,14 @@ def get_commitlog(apiurl, prj, package):
revisions = root.findall('revision')
revisions.reverse()
for node in revisions:
rev = int(node.get('rev'))
#vrev = int(node.get('vrev')) # what is the meaning of vrev?
try:
rev = int(node.get('rev'))
#vrev = int(node.get('vrev')) # what is the meaning of vrev?
if revision and rev != int(revision):
continue
except ValueError:
# this part should _never_ be reached but...
return [ 'an unexpected error occured - please file a bug' ]
srcmd5 = node.find('srcmd5').text
version = node.find('version').text
user = node.find('user').text
@ -1558,12 +1564,21 @@ def rebuild(apiurl, prj, package, repo, arch, code=None):
def store_read_project(dir):
p = open(os.path.join(dir, store, '_project')).readlines()[0].strip()
try:
p = open(os.path.join(dir, store, '_project')).readlines()[0].strip()
except IOError:
print >>sys.stderr, 'error: \'%s\' is not an osc project dir ' \
'or working copy' % dir
sys.exit(1)
return p
def store_read_package(dir):
p = open(os.path.join(dir, store, '_package')).readlines()[0].strip()
try:
p = open(os.path.join(dir, store, '_package')).readlines()[0].strip()
except IOError:
print >>sys.stderr, 'error: \'%s\' is not an osc working copy' % dir
sys.exit(1)
return p
def store_read_apiurl(dir):
@ -1677,7 +1692,8 @@ def checkRevision(prj, pac, revision):
check if revision is valid revision
"""
try:
if int(revision) > int(show_upstream_rev(conf.config['apiurl'], prj, pac)):
if int(revision) > int(show_upstream_rev(conf.config['apiurl'], prj, pac)) \
or int(revision) <= 0:
return False
else:
return True