From 5438e4023a6e6195fa5c8087521a351fe98a02e1 Mon Sep 17 00:00:00 2001 From: "Dr. Peter Poeml" Date: Tue, 3 Jun 2008 15:01:01 +0000 Subject: [PATCH] osc submitreq: look up the develproject of the target, and if there is one, don't create the request, unless forced with --nodevelproject. --- osc/commandline.py | 11 +++++++++++ osc/core.py | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/osc/commandline.py b/osc/commandline.py index e750fc4c..4baf1248 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -402,6 +402,9 @@ class Osc(cmdln.Cmdln): help='specify message TEXT') @cmdln.option('-r', '--revision', metavar='REV', help='for "create", specify a certain source revision ID (the md5 sum)') + @cmdln.option('--nodevelproject', action='store_true', + help='do not follow a defined devel project ' \ + '(primary project where a package is developed)') def do_submitreq(self, subcmd, opts, *args): """${cmd_name}: Handle requests to submit a package into another project @@ -462,6 +465,14 @@ class Osc(cmdln.Cmdln): dst_package = args[3] else: dst_package = src_package + devloc = show_develproject(conf.config['apiurl'], dst_project, dst_package) + if devloc and dst_project != devloc and not opts.nodevelproject: + print """\ +Sorry, but a different project, %s, is defined as the place where development +of the package %s primarily takes place. +Please submit there instead, or use --nodevelproject to force direct submission.""" \ + % (devloc, dst_package) + sys.exit(1) elif cmd == 'list': project = args[0] diff --git a/osc/core.py b/osc/core.py index e896ec92..a476bca3 100755 --- a/osc/core.py +++ b/osc/core.py @@ -1544,6 +1544,14 @@ def show_package_meta(apiurl, prj, pac): raise +def show_develproject(apiurl, prj, pac): + m = show_package_meta(apiurl, prj, pac) + try: + return ET.parse(StringIO(''.join(m))).getroot().find('devel').get('project') + except: + return None + + def show_pattern_metalist(apiurl, prj): url = makeurl(apiurl, ['source', prj, '_pattern']) try: