From 0648a8c55558446e860458e9f044b1e7e6f02426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Thu, 14 May 2009 11:50:53 +0000 Subject: [PATCH] - new option for copypac * -r to specify source revision * -m to specify a comment (and send default comment if not specified) mmeeks, jpr: this is for you :) --- NEWS | 3 +++ osc/commandline.py | 17 ++++++++++++++++- osc/core.py | 11 +++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 4e303b5f..f7ef2221 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,9 @@ - new log/rlog output formats (CSV and XML) - new jobhistory/buildhistory output format (CSV) - new option to fetch buildlogs starting at given offset +- new option for copypac + * -r to specify source revision + * -m to specify a comment (and send default comment if not specified) 0.117: - support checkout of single package via "osc co PACKAGE" when local dir is project diff --git a/osc/commandline.py b/osc/commandline.py index 317137a1..016bb40b 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -872,8 +872,12 @@ Please submit there instead, or use --nodevelproject to force direct submission. help='keep original maintainers. Default is remove all and replace with the one calling the script.') @cmdln.option('-d', '--keep-develproject', action='store_true', help='keep develproject tag in the package metadata') + @cmdln.option('-r', '--revision', metavar='rev', + help='link the specified revision.') @cmdln.option('-t', '--to-apiurl', metavar='URL', help='URL of destination api server. Default is the source api server.') + @cmdln.option('-m', '--message', metavar='TEXT', + help='specify message TEXT') @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): @@ -923,12 +927,23 @@ Please submit there instead, or use --nodevelproject to force direct submission. if src_apiurl != dst_apiurl: opts.client_side_copy = True + rev, dummy = parseRevisionOption(opts.revision) + + if opts.message: + comment=opts.comment + else: + if not rev: + rev = show_upstream_rev(src_apiurl, src_project, src_package); + comment='osc copypac from project:%s package:%s revision:%s' % ( src_project, src_package, rev ) + r = copy_pac(src_apiurl, src_project, src_package, dst_apiurl, dst_project, dst_package, client_side_copy=opts.client_side_copy, keep_maintainers=opts.keep_maintainers, keep_develproject=opts.keep_develproject, - expand=opts.expand) + expand=opts.expand, + revision=rev, + comment=comment) print r diff --git a/osc/core.py b/osc/core.py index dff25e49..fe0ef080 100755 --- a/osc/core.py +++ b/osc/core.py @@ -2594,7 +2594,9 @@ def copy_pac(src_apiurl, src_project, src_package, client_side_copy = False, keep_maintainers = False, keep_develproject = False, - expand = False): + expand = False, + revision = None, + comment = None): """ Create a copy of a package. @@ -2617,6 +2619,10 @@ def copy_pac(src_apiurl, src_project, src_package, query = {'cmd': 'copy', 'oproject': src_project, 'opackage': src_package } if expand: query['expand'] = '1' + if revision: + query['orev'] = revision + if comment: + query['comment'] = comment u = makeurl(dst_apiurl, ['source', dst_project, dst_package], query=query) f = http_POST(u) return f.read() @@ -2628,10 +2634,11 @@ def copy_pac(src_apiurl, src_project, src_package, os.chdir(tmpdir) 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) + get_source_file(src_apiurl, src_project, src_package, n, targetfilename=n, revision=revision) u = makeurl(dst_apiurl, ['source', dst_project, dst_package, pathname2url(n)]) http_PUT(u, file = n) os.unlink(n) + #FIXME: add comment when doing the final commit (and no commits for each file) os.rmdir(tmpdir) return 'Done.'