From 4dc236dea4cd3388587eb0858825013041cf5368 Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Sat, 30 May 2015 16:27:54 +0200 Subject: [PATCH] - added "lock" command to lock a project or package --- osc/commandline.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/osc/commandline.py b/osc/commandline.py index ff355b32..c09ec50f 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -3321,6 +3321,33 @@ Please submit there instead, or use --nodevelproject to force direct submission. delete_project(apiurl, prj, opts.force, msg) + def do_lock(self, subcmd, opts, project, package=None): + """${cmd_name}: Locks a project or package. + + usage: + osc lock PROJECT [PACKAGE] + + ${cmd_option_list} + """ + apiurl = self.get_api_url() + kind = 'prj' + path_args = (project,) + if package is not None: + kind = 'pkg' + path_args = (project, package) + meta = meta_exists(kind, path_args, create_new=False, apiurl=apiurl) + root = ET.fromstring(''.join(meta)) + if root.find('lock') is not None: + print('Already locked', file=sys.stderr) + sys.exit(1) + # alternatively, we could also use the set_flag api call + # instead of manually manipulating the xml + lock = ET.SubElement(root, 'lock') + ET.SubElement(lock, 'enable') + meta = ET.tostring(root) + edit_meta(kind, path_args=path_args, data=meta) + + @cmdln.option('-m', '--message', metavar='TEXT', help='specify log message TEXT') def do_unlock(self, subcmd, opts, *args):