mpcdf_branch.py 1.2 KB
Newer Older
Lorenz Huedepohl's avatar
Lorenz Huedepohl committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from __future__ import print_function

import mpcdf_common

import osc
import osc.conf
import osc.core
import osc.cmdln


def do_mpcdf_branch(self, subcmd, opts, *args):
    """${cmd_name}: Branch package from software to your home project

    This creates a branch of the package PACKAGE in the central
    'software' repository into your home:$USER project, and sets
    all required meta-data for the enabled repositories.

    Usage:
19
        osc mpcdf_branch PACKAGE [home:$USER]
Lorenz Huedepohl's avatar
Lorenz Huedepohl committed
20
21
22
23
24
25
26
27

    ${cmd_option_list}
    """

    apiurl = self.get_api_url()

    if len(args) == 0:
        raise osc.oscerr.WrongArgs("Missing argument: PACKAGENAME")
28
29
30
31
32
33
34
35
    elif len(args) == 1:
        package, = args
        target_project = "home:" + osc.conf.get_apiurl_usr(apiurl)
    elif len(args) == 2:
        package, target_project = args
        if not target_project.startswith("home:"):  # + osc.conf.get_apiurl_usr(apiurl)):
            raise osc.oscerr.WrongArgs("Target must be a home project")
    if len(args) > 2:
Lorenz Huedepohl's avatar
Lorenz Huedepohl committed
36
37
38
39
        raise osc.oscerr.WrongArgs("Too many arguments")

    mpcdf_common.sync_projects(apiurl, package=package, from_project="software",
                               to_projects=(target_project,), add_to_maintainers=False)