From afec1621896e459194c526b41d2804e4e2a4b75b Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 30 Apr 2008 12:28:25 +0000 Subject: [PATCH] - added --keep-maintainers switch to copypac (do not remove original maintainers and replace them with caller) --- CREDITS | 7 ++++--- osc/commandline.py | 5 ++++- osc/core.py | 18 ++++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/CREDITS b/CREDITS index ec200eba..911298eb 100644 --- a/CREDITS +++ b/CREDITS @@ -2,7 +2,8 @@ There is a number of people who have helped: Marcus Huewe - wipebinaries command, abortbuild command, editmeta error handling Marcus Rueckert - help and countless suggestions -Christoph Thiel - patch enabling build log following. +Christoph Thiel - patch enabling build log following. Adrian Schroeter - one-liner showing how to handle an error ;-) -Michael Marek -Michael Wolf +Michal Marek +Michael Wolf +Pavol Rusnak diff --git a/osc/commandline.py b/osc/commandline.py index fea53ccd..7028849a 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -605,6 +605,8 @@ class Osc(cmdln.Cmdln): @cmdln.option('-c', '--client-side-copy', action='store_true', help='do a (slower) client-side copy') + @cmdln.option('-k', '--keep-maintainers', action='store_true', + help='keep original maintainers. Default is remove all and replace with the one calling the script.') @cmdln.option('-t', '--to-apiurl', metavar='URL', help='URL of destination api server. Default is the source api server.') def do_copypac(self, subcmd, opts, *args): @@ -656,7 +658,8 @@ class Osc(cmdln.Cmdln): r = copy_pac(src_apiurl, src_project, src_package, dst_apiurl, dst_project, dst_package, - client_side_copy=opts.client_side_copy) + client_side_copy=opts.client_side_copy, + keep_maintainers=opts.keep_maintainers) print r diff --git a/osc/core.py b/osc/core.py index 1759682b..92446bf7 100755 --- a/osc/core.py +++ b/osc/core.py @@ -2233,18 +2233,19 @@ def checkout_package(apiurl, project, package, os.chdir(olddir) -def replace_pkg_meta(pkgmeta, new_name, new_prj): +def replace_pkg_meta(pkgmeta, new_name, new_prj, keep_maintainers = False): """ update pkgmeta with new new_name and new_prj and set calling user as the - only maintainer + only maintainer (unless keep_maintainers is set) """ root = ET.fromstring(''.join(pkgmeta)) root.set('name', new_name) root.set('project', new_prj) - for person in root.findall('person'): - root.remove(person) - ET.SubElement(root, 'person', - userid = conf.config['user'], role = 'maintainer') + if not keep_maintainers: + for person in root.findall('person'): + root.remove(person) + ET.SubElement(root, 'person', + userid = conf.config['user'], role = 'maintainer') return ET.tostring(root) def link_pac(src_project, src_package, dst_project, dst_package): @@ -2318,7 +2319,8 @@ def aggregate_pac(src_project, src_package, dst_project, dst_package): def copy_pac(src_apiurl, src_project, src_package, dst_apiurl, dst_project, dst_package, - client_side_copy = False): + client_side_copy = False, + keep_maintainers = False): """ Create a copy of a package. @@ -2329,7 +2331,7 @@ def copy_pac(src_apiurl, src_project, src_package, """ src_meta = show_package_meta(src_apiurl, src_project, src_package) - src_meta = replace_pkg_meta(src_meta, dst_package, dst_project) + src_meta = replace_pkg_meta(src_meta, dst_package, dst_project, keep_maintainers) print 'Sending meta data...' u = makeurl(dst_apiurl, ['source', dst_project, dst_package, '_meta'])