File osc-0.142.0-support-osc-copyprj-in-api.patch of Package osc
From 8ece19de2181fdf76aeb49072592852dccd49745 Mon Sep 17 00:00:00 2001
From: David Greaves <david@dgreaves.com>
Date: Tue, 1 May 2012 18:30:14 +0100
Subject: [PATCH] Support 'osc copyprj' in api by Islam Amer
usage: osc copyprj SOURCEPRJ DESTPRJ
A way to copy a project and all packages in it
It can not yet be done across buildservice instances
The user must be able to create DESTPRJ
Signed-off-by: David Greaves <david@dgreaves.com>
---
osc/commandline.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
osc/core.py | 28 ++++++++++++++++++++++++++++
2 files changed, 82 insertions(+)
diff --git a/osc/commandline.py b/osc/commandline.py
index 0972245..12ff75b 100644
--- a/osc/commandline.py
+++ b/osc/commandline.py
@@ -2939,6 +2939,60 @@ Please submit there instead, or use --nodevelproject to force direct submission.
sys.stdout.write(buf)
+ @cmdln.option('-b', '--with-binaries', action='store_true',
+ help='copy the built binaries over to avoid a rebuild')
+ @cmdln.option('-H', '--with-history', action='store_true',
+ help='replicate the history of each package.')
+ @cmdln.option('-o', '--make-older', action='store_true',
+ help='No idea')
+ @cmdln.option('-r', '--re-sign', action='store_true',
+ help='re-sign the binaries')
+ @cmdln.option('-m', '--message', metavar='TEXT',
+ help='specify message TEXT')
+ def do_copyprj(self, subcmd, opts, *args):
+ """${cmd_name}: Copy a project
+
+ A way to copy a project and all packages in it
+
+ It can not yet be done across buildservice instances
+
+ The user must be able to create DESTPRJ
+
+ usage:
+ osc copyprj SOURCEPRJ DESTPRJ
+ ${cmd_option_list}
+ """
+
+ args = slash_split(args)
+
+ if not args or len(args) != 2:
+ raise oscerr.WrongArgs('Incorrect number of arguments.\n\n' \
+ + self.get_cmd_help('copypac'))
+
+ src_project = args[0]
+ dst_project = args[1]
+
+ src_apiurl = conf.config['apiurl']
+
+ if opts.message:
+ comment = opts.message
+ else:
+ comment = 'osc copyprj from project:%s' % ( src_project )
+
+ if src_project == dst_project:
+ raise oscerr.WrongArgs('Source and destination are the same.')
+
+ print("calling cp")
+ r = copy_prj(src_apiurl, src_project, dst_project,
+ withbinaries = opts.with_binaries,
+ withhistory = opts.with_history,
+ makeolder = opts.make_older,
+ resign = opts.re_sign,
+ comment = comment)
+ print("done cp")
+ print(r)
+
+
@cmdln.option('-m', '--message', metavar='TEXT',
help='specify message TEXT')
def do_releaserequest(self, subcmd, opts, *args):
diff --git a/osc/core.py b/osc/core.py
index 3bdb25d..986db3d 100644
--- a/osc/core.py
+++ b/osc/core.py
@@ -5215,6 +5215,34 @@ def copy_pac(src_apiurl, src_project, src_package,
raise oscerr.APIError('failed to copy: %s' % ', '.join(todo))
return 'Done.'
+def copy_prj(src_apiurl, src_project, dst_project,
+ withbinaries = False,
+ withhistory = False,
+ makeolder = False,
+ resign = False,
+ comment = None):
+ """
+ Create a copy of a project.
+
+ Copying can only be done on the server, in a single api call.
+ """
+
+ print('Copying project...')
+ query = {'cmd': 'copy', 'oproject': src_project }
+ if withbinaries:
+ query['withbinaries'] = '1'
+ if withhistory:
+ query['withhistory'] = '1'
+ if makeolder:
+ query['makeolder'] = '1'
+ if resign:
+ query['resign'] = '1'
+ if comment:
+ query['comment'] = comment
+ u = makeurl(src_apiurl, ['source', dst_project], query=query)
+ print("copyprj ", u, file=sys.stderr)
+ f = http_POST(u)
+ return f.read()
def unlock_package(apiurl, prj, pac, msg):
query = {'cmd': 'unlock', 'comment': msg}
--
2.5.5