1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-26 09:56:13 +01:00

- fixed #490023: add --expand option to copypac

This commit is contained in:
Marcus Hüwe 2009-03-30 22:17:18 +00:00
parent 151dc92e21
commit 4ed272b2a2
2 changed files with 15 additions and 6 deletions

View File

@ -782,6 +782,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='keep develproject tag in the package metadata')
@cmdln.option('-t', '--to-apiurl', metavar='URL',
help='URL of destination api server. Default is the source api server.')
@cmdln.option('-e', '--expand', action='store_true',
help='if the source package is a link then copy the expanded version of the link')
def do_copypac(self, subcmd, opts, *args):
"""${cmd_name}: Copy a package
@ -833,7 +835,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
dst_apiurl, dst_project, dst_package,
client_side_copy=opts.client_side_copy,
keep_maintainers=opts.keep_maintainers,
keep_develproject=opts.keep_develproject)
keep_develproject=opts.keep_develproject,
expand=opts.expand)
print r

View File

@ -1566,11 +1566,15 @@ 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):
def meta_get_filelist(apiurl, prj, package, verbose=False, expand=False):
"""return a list of file names,
or a list File() instances if verbose=True"""
u = makeurl(apiurl, ['source', prj, package])
if expand:
expand = 'expand=1'
else:
expand = ''
u = makeurl(apiurl, ['source', prj, package], query=expand)
f = http_GET(u)
root = ET.parse(f).getroot()
@ -2499,14 +2503,14 @@ def copy_pac(src_apiurl, src_project, src_package,
dst_apiurl, dst_project, dst_package,
client_side_copy = False,
keep_maintainers = False,
keep_develproject = False):
keep_develproject = False,
expand = False):
"""
Create a copy of a package.
Copying can be done by downloading the files from one package and commit
them into the other by uploading them (client-side copy) --
or by the server, in a single api call.
"""
src_meta = show_package_meta(src_apiurl, src_project, src_package)
@ -2521,6 +2525,8 @@ def copy_pac(src_apiurl, src_project, src_package,
print 'Copying files...'
if not client_side_copy:
query = {'cmd': 'copy', 'oproject': src_project, 'opackage': src_package }
if expand:
query['expand'] = '1'
u = makeurl(dst_apiurl, ['source', dst_project, dst_package], query=query)
f = http_POST(u)
return f.read()
@ -2530,7 +2536,7 @@ def copy_pac(src_apiurl, src_project, src_package,
import tempfile
tmpdir = tempfile.mkdtemp(prefix='osc_copypac', dir='/tmp')
os.chdir(tmpdir)
for n in meta_get_filelist(src_apiurl, src_project, src_package):
for n in meta_get_filelist(src_apiurl, src_project, src_package, expand=expand):
print ' ', n
get_source_file(src_apiurl, src_project, src_package, n, targetfilename=n)
u = makeurl(dst_apiurl, ['source', dst_project, dst_package, pathname2url(n)])