From 5768e35047741317f328607ef091e7e992df4c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20H=C3=BCwe?= Date: Thu, 26 Jun 2008 10:47:58 +0000 Subject: [PATCH] - applied slightly modified version of Node's patch which added a --revision option to do_linkpac --- osc/commandline.py | 11 ++++++++++- osc/core.py | 13 +++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 37108b31..36a3e7fb 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -589,6 +589,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. return 2 + @cmdln.option('-r', '--revision', metavar='rev', + help='link the specified revision.') def do_linkpac(self, subcmd, opts, *args): """${cmd_name}: "Link" a package to another package @@ -616,6 +618,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. raise oscerr.WrongArgs('Incorrect number of arguments.\n\n' \ + self.get_cmd_help('linkpac')) + rev, dummy = parseRevisionOption(opts.revision) + src_project = args[0] src_package = args[1] dst_project = args[2] @@ -627,7 +631,12 @@ Please submit there instead, or use --nodevelproject to force direct submission. if src_project == dst_project and src_package == dst_package: print >>sys.stderr, 'Error: source and destination are the same.' return 1 - link_pac(src_project, src_package, dst_project, dst_package) + + if rev and not checkRevision(src_project, src_package, rev): + print >>sys.stderr, 'Revision \'%s\' does not exist' % rev + sys.exit(1) + + link_pac(src_project, src_package, dst_project, dst_package, rev) def do_aggregatepac(self, subcmd, opts, *args): """${cmd_name}: "Aggregate" a package to another package diff --git a/osc/core.py b/osc/core.py index cae4340d..fdbb7743 100755 --- a/osc/core.py +++ b/osc/core.py @@ -2267,7 +2267,7 @@ def replace_pkg_meta(pkgmeta, new_name, new_prj, keep_maintainers = False): userid = conf.config['user'], role = 'maintainer') return ET.tostring(root) -def link_pac(src_project, src_package, dst_project, dst_package): +def link_pac(src_project, src_package, dst_project, dst_package, rev=''): """ create a linked package - "src" is the original package @@ -2287,16 +2287,21 @@ def link_pac(src_project, src_package, dst_project, dst_package): print >>sys.stderr print >>sys.stderr, '_link file already exists...! Aborting' sys.exit(1) - + + if rev: + rev = 'rev="%s"' % rev + else: + rev = '' + print 'Creating _link...', link_template = """\ - + -""" % (src_project, src_package) +""" % (src_project, src_package, rev) u = makeurl(conf.config['apiurl'], ['source', dst_project, dst_package, '_link']) http_PUT(u, data=link_template)