mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-26 01:46:13 +01:00
- support listings of older revisions with "osc ls -R"
- add --current parameter for linkpac to use current revision of source package fixed. - add osc setlinkrev to add or update revision number in links easily - fix streaming of binary files via "cat" (#493325)
This commit is contained in:
parent
c298692e68
commit
d547203c12
6
NEWS
6
NEWS
@ -1,3 +1,9 @@
|
||||
0.116:
|
||||
- support listings of older revisions with "osc ls -R"
|
||||
- add --current parameter for linkpac to use current revision of source package fixed.
|
||||
- add osc setlinkrev to add or update revision number in links easily
|
||||
- fix streaming of binary files via "cat" (#493325)
|
||||
|
||||
0.115:
|
||||
- optional transfer of devel project during copy_pac and link_pac is fixing
|
||||
opertation with remote build service instance
|
||||
|
@ -142,6 +142,8 @@ class Osc(cmdln.Cmdln):
|
||||
@cmdln.alias('ls')
|
||||
@cmdln.option('-a', '--arch', metavar='ARCH',
|
||||
help='specify architecture')
|
||||
@cmdln.option('-R', '--revision', metavar='REVISION',
|
||||
help='specify revision')
|
||||
@cmdln.option('-r', '--repo', metavar='REPO',
|
||||
help='specify repository')
|
||||
@cmdln.option('-b', '--binaries', action='store_true',
|
||||
@ -198,6 +200,8 @@ class Osc(cmdln.Cmdln):
|
||||
if opts.binaries:
|
||||
if not args:
|
||||
raise oscerr.WrongArgs('There are no binaries to list above project level.')
|
||||
if opts.revision:
|
||||
raise oscerr.WrongOptions('Sorry, the --revision option is not supported for binaries.')
|
||||
|
||||
elif len(args) == 1:
|
||||
#if opts.verbose:
|
||||
@ -227,7 +231,8 @@ class Osc(cmdln.Cmdln):
|
||||
project,
|
||||
package,
|
||||
verbose=opts.verbose,
|
||||
expand=opts.expand)
|
||||
expand=opts.expand,
|
||||
revision=opts.revision)
|
||||
if opts.verbose:
|
||||
out = [ '%s %7d %9d %s %s' % (i.md5, i.rev, i.size, shorttime(i.mtime), i.name) \
|
||||
for i in l if not fname or fname == i.name ]
|
||||
@ -693,6 +698,57 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
return 2
|
||||
|
||||
|
||||
@cmdln.option('-r', '--revision', metavar='rev',
|
||||
help='use the specified revision.')
|
||||
def do_setlinkrev(self, subcmd, opts, *args):
|
||||
"""${cmd_name}: Updates a revision number in a source link.
|
||||
|
||||
This command adds or updates a specified revision number in a source link.
|
||||
The current revision of the source is used, if no revision number is specified.
|
||||
|
||||
usage:
|
||||
osc setlinkrev
|
||||
osc setlinkrev PROJECT PACKAGE
|
||||
${cmd_option_list}
|
||||
"""
|
||||
|
||||
args = slash_split(args)
|
||||
|
||||
if not args or len(args) == 0:
|
||||
p = findpacs(os.curdir)[0]
|
||||
project = p.prjname
|
||||
package = p.name
|
||||
if p.islink() and project and package:
|
||||
src_project = p.linkinfo.project
|
||||
src_package = p.linkinfo.package
|
||||
else:
|
||||
sys.exit('Local directory is no checked out package, aborting')
|
||||
elif len(args) == 2:
|
||||
project = args[0]
|
||||
package = args[1]
|
||||
else:
|
||||
raise oscerr.WrongArgs('Incorrect number of arguments.\n\n' \
|
||||
+ self.get_cmd_help('setlinkrev'))
|
||||
|
||||
rev, dummy = parseRevisionOption(opts.revision)
|
||||
|
||||
if not rev:
|
||||
if not args or len(args) == 0:
|
||||
revision = show_upstream_rev(conf.config['apiurl'], src_project, src_package);
|
||||
else:
|
||||
url = makeurl(conf.config['apiurl'], ['source', project, package, '_link'])
|
||||
try:
|
||||
f = http_GET(url)
|
||||
root = ET.parse(f).getroot()
|
||||
except urllib2.HTTPError, e:
|
||||
e.osc_msg = 'Unable to get _link file in package \'%s\' for project \'%s\'' % (package, project)
|
||||
raise
|
||||
|
||||
return set_link_rev(project, package)
|
||||
|
||||
set_link_rev(project, package, rev)
|
||||
|
||||
|
||||
@cmdln.option('-c', '--current', action='store_true',
|
||||
help='link fixed against current revision.')
|
||||
@cmdln.option('-r', '--revision', metavar='rev',
|
||||
@ -2653,11 +2709,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
get_source_file(conf.config['apiurl'], args[0], args[1], args[2],
|
||||
targetfilename=filename, revision=rev)
|
||||
|
||||
if binary_file(filename):
|
||||
print >>sys.stderr, 'error - cannot display binary file \'%s\'' % args[2]
|
||||
else:
|
||||
for line in open(filename):
|
||||
print line.rstrip('\n')
|
||||
# FIXME: stream directly without temp file and without keeping the entire file in memory
|
||||
f = open(filename, 'rb')
|
||||
sys.stdout.write(f.read())
|
||||
f.close()
|
||||
|
||||
try:
|
||||
os.unlink(filename)
|
||||
|
41
osc/core.py
41
osc/core.py
@ -80,8 +80,13 @@ It also does some weird stuff.
|
||||
<arch>x86_64</arch>
|
||||
<arch>i586</arch>
|
||||
</repository>
|
||||
<repository name="Fedora_9">
|
||||
<path project="Fedora:9" repository="standard" />
|
||||
<repository name="Fedora_10">
|
||||
<path project="Fedora:10" repository="standard" />
|
||||
<arch>x86_64</arch>
|
||||
<arch>i586</arch>
|
||||
</repository>
|
||||
<repository name="SLE_11">
|
||||
<path project="SUSE:SLE-11" repository="standard" />
|
||||
<arch>x86_64</arch>
|
||||
<arch>i586</arch>
|
||||
</repository>
|
||||
@ -1580,7 +1585,7 @@ def meta_get_packagelist(apiurl, prj):
|
||||
return [ node.get('name') for node in root.findall('entry') ]
|
||||
|
||||
|
||||
def meta_get_filelist(apiurl, prj, package, verbose=False, expand=False):
|
||||
def meta_get_filelist(apiurl, prj, package, verbose=False, expand=False, revision=0):
|
||||
"""return a list of file names,
|
||||
or a list File() instances if verbose=True"""
|
||||
|
||||
@ -1588,7 +1593,12 @@ def meta_get_filelist(apiurl, prj, package, verbose=False, expand=False):
|
||||
expand = 'expand=1'
|
||||
else:
|
||||
expand = ''
|
||||
u = makeurl(apiurl, ['source', prj, package], query=expand)
|
||||
if revision and revision > 0:
|
||||
revision = '?rev=%s' % revision
|
||||
else:
|
||||
revision = ''
|
||||
|
||||
u = makeurl(apiurl, ['source', prj, package, revision], query=expand)
|
||||
f = http_GET(u)
|
||||
root = ET.parse(f).getroot()
|
||||
|
||||
@ -3179,12 +3189,35 @@ def search(apiurl, search_list, kind, search_term, verbose = False, exact_matche
|
||||
title = title[:61] + '...'
|
||||
result.append(title)
|
||||
if repos_baseurl:
|
||||
# FIXME: no hardcoded URL of instance
|
||||
result.append('http://download.opensuse.org/repositories/%s/' % project.replace(':', ':/'))
|
||||
if result:
|
||||
return result
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def set_link_rev(project, package, revision = 0):
|
||||
url = makeurl(conf.config['apiurl'], ['source', project, package, '_link'])
|
||||
try:
|
||||
f = http_GET(url)
|
||||
root = ET.parse(f).getroot()
|
||||
except urllib2.HTTPError, e:
|
||||
e.osc_msg = 'Unable to get _link file in package \'%s\' for project \'%s\'' % (package, project)
|
||||
raise
|
||||
|
||||
if not revision or revision == 0:
|
||||
src_project = root.attrib['project']
|
||||
src_package = root.attrib['package']
|
||||
revision = show_upstream_rev(conf.config['apiurl'], src_project, src_package);
|
||||
|
||||
# set revision element
|
||||
root.attrib['rev'] = revision
|
||||
l = ET.tostring(root)
|
||||
# upload _link file again
|
||||
http_PUT(url, data=l)
|
||||
|
||||
|
||||
def delete_dir(dir):
|
||||
# small security checks
|
||||
if os.path.islink(dir):
|
||||
|
Loading…
Reference in New Issue
Block a user