From ce9f504105c8795e20e04ac5114d8ca6a582a517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Thu, 15 Mar 2012 09:54:56 +0100 Subject: [PATCH] - add unlock command for osc 0.134.1 --- NEWS | 1 + osc/commandline.py | 43 +++++++++++++++++++++++++++++++++++++++++++ osc/core.py | 11 +++++++++++ 3 files changed, 55 insertions(+) diff --git a/NEWS b/NEWS index bd447f06..967f54be 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ - "osc my patchinfos" is showing patchinfos where any open bug is assigned to user - "osc my" or "osc my work" is including assigned patchinfos - "osc branch --maintenance" is creating setups for maintenance + - "osc unlock" command to unlock packages or projects 0.133 - add --meta option also to "list", "cat" and "less" commands diff --git a/osc/commandline.py b/osc/commandline.py index d5cfc60e..ff947cb9 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -3016,6 +3016,49 @@ Please submit there instead, or use --nodevelproject to force direct submission. else: delete_project(apiurl, prj, opts.force, msg) + + @cmdln.option('-m', '--message', metavar='TEXT', + help='specify log message TEXT') + def do_unlock(self, subcmd, opts, *args): + """${cmd_name}: Unlocks a project or package + + Unlocks a locked project or package. A comment is required. + + usage: + osc unlock PROJECT [PACKAGE] + + ${cmd_option_list} + """ + + args = slash_split(args) + if len(args) < 1 or len(args) > 2: + raise oscerr.WrongArgs('Wrong number of arguments') + + apiurl = self.get_api_url() + prj = args[0] + + msg = '' + if opts.message: + msg = opts.message + else: + msg = edit_message() + + # empty arguments result in recursive project delete ... + if not len(prj): + raise oscerr.WrongArgs('Project argument is empty') + + if len(args) > 1: + pkg = args[1] + + if not len(pkg): + raise oscerr.WrongArgs('Package argument is empty') + + unlock_package(apiurl, prj, pkg, msg) + + else: + unlock_project(apiurl, prj, msg) + + @cmdln.hide(1) def do_deletepac(self, subcmd, opts, *args): print """${cmd_name} is obsolete ! diff --git a/osc/core.py b/osc/core.py index 410081a6..e136319a 100644 --- a/osc/core.py +++ b/osc/core.py @@ -4549,6 +4549,17 @@ def copy_pac(src_apiurl, src_project, src_package, return 'Done.' +def unlock_package(apiurl, prj, pac, msg): + query={'cmd': 'unlock', 'comment': msg} + u = makeurl(apiurl, ['source', prj, pac], query) + http_POST(u) + +def unlock_project(apiurl, prj, msg=None): + query={'cmd': 'unlock', 'comment': msg} + u = makeurl(apiurl, ['source', prj], query) + http_POST(u) + + def undelete_package(apiurl, prj, pac, msg=None): query={'cmd': 'undelete'} if msg: