From 2aa4700bcab8ad50a5633e060554315737274c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Mon, 11 Jan 2010 16:36:33 +0100 Subject: [PATCH] add osc linktobranch command --- NEWS | 1 + osc/commandline.py | 23 +++++++++++++++++++++++ osc/core.py | 13 +++++++++++++ 3 files changed, 37 insertions(+) diff --git a/NEWS b/NEWS index 4c761728..db29df23 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ # - new config option 'submitrequest_on_accept_action' to specify a default action if a submitrequest has been accepted + - add "osc linktobranch" command to convert a classic link to a branch package 0.124 - added 'osc bugowner' as a more intelligent version of 'osc maintainer -B' diff --git a/osc/commandline.py b/osc/commandline.py index cd930fb6..3853b121 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -1265,6 +1265,29 @@ Please submit there instead, or use --nodevelproject to force direct submission. set_link_rev(apiurl, project, p, rev) + def do_linktobranch(self, subcmd, opts, *args): + """${cmd_name}: Convert a package containing a classic link with patch to a branch + + This command tells the server to convert a _link with or without a project.diff + to a branch. This is a full copy with a _link file pointing to the branched place. + + usage: + osc linkpac PROJECT PACKAGE + ${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('linktobranch')) + + project = args[0] + package = args[1] + + link_to_branch(project, package) + + @cmdln.option('-C', '--cicount', choices=['add', 'copy', 'local'], help='cicount attribute in the link, known values are add, copy, and local, default in buildservice is currently add.') @cmdln.option('-c', '--current', action='store_true', diff --git a/osc/core.py b/osc/core.py index b57142f7..974cfd46 100644 --- a/osc/core.py +++ b/osc/core.py @@ -3036,6 +3036,19 @@ def replace_pkg_meta(pkgmeta, new_name, new_prj, keep_maintainers = False, root.remove(dp) return ET.tostring(root) +def link_to_branch(project, package): + """ + convert a package with a _link + project.diff to a branch + """ + + if '_link' in meta_get_filelist(conf.config['apiurl'], project, package): + # FIXME, verify that it is no branch already + u = makeurl(conf.config['apiurl'], ['source', project, package], 'cmd=linktobranch') + http_POST(u) + else: + e.osc_msg = 'no _link file inside project \'%s\' package \'%s\'' % (project, package) + raise + def link_pac(src_project, src_package, dst_project, dst_package, force, rev='', cicount='', disable_publish = False): """ create a linked package