mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-28 07:26:15 +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:
parent
7e98ecb0cb
commit
fd199c66e9
@ -1310,6 +1310,8 @@ class Osc(cmdln.Cmdln):
|
|||||||
print '\n'.join(get_buildhistory(apiurl, project, package, platform, arch))
|
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):
|
def do_log(self, subcmd, opts):
|
||||||
"""${cmd_name}: Shows the commit log of a package
|
"""${cmd_name}: Shows the commit log of a package
|
||||||
|
|
||||||
@ -1321,8 +1323,12 @@ class Osc(cmdln.Cmdln):
|
|||||||
package = store_read_package(wd)
|
package = store_read_package(wd)
|
||||||
project = store_read_project(wd)
|
project = store_read_project(wd)
|
||||||
apiurl = store_read_apiurl(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',
|
@cmdln.option('-f', '--failed', action='store_true',
|
||||||
|
20
osc/core.py
20
osc/core.py
@ -1501,7 +1501,7 @@ def get_buildhistory(apiurl, prj, package, platform, arch):
|
|||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def get_commitlog(apiurl, prj, package):
|
def get_commitlog(apiurl, prj, package, revision):
|
||||||
import time
|
import time
|
||||||
u = makeurl(apiurl, ['source', prj, package, '_history'])
|
u = makeurl(apiurl, ['source', prj, package, '_history'])
|
||||||
f = http_GET(u)
|
f = http_GET(u)
|
||||||
@ -1511,8 +1511,14 @@ def get_commitlog(apiurl, prj, package):
|
|||||||
revisions = root.findall('revision')
|
revisions = root.findall('revision')
|
||||||
revisions.reverse()
|
revisions.reverse()
|
||||||
for node in revisions:
|
for node in revisions:
|
||||||
|
try:
|
||||||
rev = int(node.get('rev'))
|
rev = int(node.get('rev'))
|
||||||
#vrev = int(node.get('vrev')) # what is the meaning of vrev?
|
#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
|
srcmd5 = node.find('srcmd5').text
|
||||||
version = node.find('version').text
|
version = node.find('version').text
|
||||||
user = node.find('user').text
|
user = node.find('user').text
|
||||||
@ -1558,12 +1564,21 @@ def rebuild(apiurl, prj, package, repo, arch, code=None):
|
|||||||
|
|
||||||
|
|
||||||
def store_read_project(dir):
|
def store_read_project(dir):
|
||||||
|
try:
|
||||||
p = open(os.path.join(dir, store, '_project')).readlines()[0].strip()
|
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
|
return p
|
||||||
|
|
||||||
|
|
||||||
def store_read_package(dir):
|
def store_read_package(dir):
|
||||||
|
try:
|
||||||
p = open(os.path.join(dir, store, '_package')).readlines()[0].strip()
|
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
|
return p
|
||||||
|
|
||||||
def store_read_apiurl(dir):
|
def store_read_apiurl(dir):
|
||||||
@ -1677,7 +1692,8 @@ def checkRevision(prj, pac, revision):
|
|||||||
check if revision is valid revision
|
check if revision is valid revision
|
||||||
"""
|
"""
|
||||||
try:
|
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
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user