1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-27 02:16:12 +01:00

added checkRevision() method to verify a revision

This commit is contained in:
Marcus Hüwe 2007-07-06 11:54:34 +00:00
parent eaa08653e0
commit 644f8695de
2 changed files with 19 additions and 0 deletions

View File

@ -407,6 +407,9 @@ class Osc(cmdln.Cmdln):
print >>sys.stderr, 'this feature isn\'t implemented yet' print >>sys.stderr, 'this feature isn\'t implemented yet'
sys.exit(1) sys.exit(1)
elif rev1 and (pac.rev != rev1) and (len(pacs) == 1): elif rev1 and (pac.rev != rev1) and (len(pacs) == 1):
if not checkRevision(pac.prjname, pac.name, rev1):
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev1
sys.exit(1)
# make a temp dir for checking out the project # make a temp dir for checking out the project
import tempfile import tempfile
tmpdir = tempfile.mkdtemp(rev1, pac.name, '/tmp') tmpdir = tempfile.mkdtemp(rev1, pac.name, '/tmp')
@ -540,6 +543,10 @@ class Osc(cmdln.Cmdln):
rev, dummy = parseRevisionOption(opts.revision) rev, dummy = parseRevisionOption(opts.revision)
if not checkRevision(project, package, rev):
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev
sys.exit(1)
if filename: if filename:
get_source_file(conf.config['apiurl'], project, package, filename, revision=rev) get_source_file(conf.config['apiurl'], project, package, filename, revision=rev)
@ -807,6 +814,9 @@ class Osc(cmdln.Cmdln):
if opts.revision and ( len(args) == 1): if opts.revision and ( len(args) == 1):
rev, dummy = parseRevisionOption(opts.revision) rev, dummy = parseRevisionOption(opts.revision)
if not checkRevision(pacs[0].prjname, pacs[0].name, rev):
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev
sys.exit(1)
else: else:
rev = None rev = None

View File

@ -1635,3 +1635,12 @@ def parseRevisionOption(string):
return None, None return None, None
else: else:
return None, None return None, None
def checkRevision(prj, pac, revision):
"""
check if revision is valid revision
"""
if int(revision) > int(show_upstream_rev(conf.config['apiurl'], prj, pac)):
return False
else:
return True