1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-13 17:16:23 +01:00

- allow to specify target project and package on osc branch (requires

server version 1.6)
- add option to automatic checkout a branched package
This commit is contained in:
Adrian Schröter 2009-04-17 12:02:02 +00:00
parent 65f540161f
commit 89e2e73dca
3 changed files with 37 additions and 13 deletions

2
NEWS
View File

@ -1,5 +1,7 @@
0.117: 0.117:
- support checkout of single package via "osc co PACKAGE" when local dir is project - support checkout of single package via "osc co PACKAGE" when local dir is project
- allow to specify target project and package on osc branch (requires server version 1.6)
- add option to automatic checkout a branched package
0.116: 0.116:
- support listings of older revisions with "osc ls -R" - support listings of older revisions with "osc ls -R"

View File

@ -894,6 +894,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.option('--nodevelproject', action='store_true', @cmdln.option('--nodevelproject', action='store_true',
help='do not follow a defined devel project ' \ help='do not follow a defined devel project ' \
'(primary project where a package is developed)') '(primary project where a package is developed)')
@cmdln.option('-c', '--checkout', action='store_true',
help='Checkout branched package afterwards ' )
@cmdln.option('-r', '--revision', metavar='rev', @cmdln.option('-r', '--revision', metavar='rev',
help='branch against a specific revision') help='branch against a specific revision')
def do_branch(self, subcmd, opts, *args): def do_branch(self, subcmd, opts, *args):
@ -907,21 +909,29 @@ Please submit there instead, or use --nodevelproject to force direct submission.
The branched package will live in The branched package will live in
home:USERNAME:branches:PROJECT/PACKAGE home:USERNAME:branches:PROJECT/PACKAGE
if nothing else specified.
usage: usage:
osc branch SOURCEPRJ SOURCEPKG osc branch SOURCEPROJECT SOURCEPACKAGE
osc branch SOURCEPROJECT SOURCEPACKAGE TARGETPROJECT
osc branch SOURCEPROJECT SOURCEPACKAGE TARGETPROJECT TARGETPACKAGE
${cmd_option_list} ${cmd_option_list}
""" """
args = slash_split(args) args = slash_split(args)
if len(args) != 2: tproject = tpackage = None
if not (len(args) >= 2 and len(args) <= 4):
raise oscerr.WrongArgs('Wrong number of arguments.') raise oscerr.WrongArgs('Wrong number of arguments.')
if len(args) >= 3:
tproject = args[2]
if len(args) >= 4:
tpackage = args[3]
r = branch_pkg(conf.config['apiurl'], args[0], args[1], r = branch_pkg(conf.config['apiurl'], args[0], args[1],
nodevelproject=opts.nodevelproject, rev=opts.revision) nodevelproject=opts.nodevelproject, rev=opts.revision, target_project=tproject, target_package=tpackage)
expected = 'home:%s:branches:%s' % (conf.config['user'], args[0]) expected = 'home:%s:branches:%s' % (conf.config['user'], args[0])
if r != expected: if len(args) == 2 and r != expected:
devloc = r.split('branches:')[1] devloc = r.split('branches:')[1]
print '\nNote: The branch has been created of a different project,\n' \ print '\nNote: The branch has been created of a different project,\n' \
' %s,\n' \ ' %s,\n' \
@ -930,12 +940,20 @@ Please submit there instead, or use --nodevelproject to force direct submission.
' That\'s also where you would normally make changes against.\n' \ ' That\'s also where you would normally make changes against.\n' \
' A direct branch of the specified package can be forced\n' \ ' A direct branch of the specified package can be forced\n' \
' with the --nodevelproject option.\n' % devloc ' with the --nodevelproject option.\n' % devloc
apiopt = ''
if conf.get_configParser().get('general', 'apiurl') != conf.config['apiurl']: package = args[1]
apiopt = '-A %s ' % conf.config['apiurl'] if tpackage:
print 'A working copy of the branched package can be checked out with:\n\n' \ package = tpackage
'osc %sco %s/%s' \ if opts.checkout:
% (apiopt, r, args[1]) checkout_package(conf.config['apiurl'], r, package,
expand_link=True, prj_dir=r)
else:
apiopt = ''
if conf.get_configParser().get('general', 'apiurl') != conf.config['apiurl']:
apiopt = '-A %s ' % conf.config['apiurl']
print 'A working copy of the branched package can be checked out with:\n\n' \
'osc %sco %s/%s' \
% (apiopt, r, package)
def do_deletepac(self, subcmd, opts, *args): def do_deletepac(self, subcmd, opts, *args):
@ -1154,7 +1172,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if args and len(args) == 1: if args and len(args) == 1:
localdir = os.getcwd() localdir = os.getcwd()
if is_project_dir(localdir): if is_project_dir(localdir):
project = Project(os.getcwd()).name project = Project(localdir).name
project_dir = localdir project_dir = localdir
package = args[0] package = args[0]
apiurl = Project(localdir).apiurl apiurl = Project(localdir).apiurl

View File

@ -7,7 +7,7 @@
# and distributed under the terms of the GNU General Public Licence, # and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version. # either version 2, or (at your option) any later version.
__version__ = '0.116' __version__ = '0.117'
# __store_version__ is to be incremented when the format of the working copy # __store_version__ is to be incremented when the format of the working copy
# "store" changes in an incompatible way. Please add any needed migration # "store" changes in an incompatible way. Please add any needed migration
# functionality to check_store_version(). # functionality to check_store_version().
@ -2507,7 +2507,7 @@ def aggregate_pac(src_project, src_package, dst_project, dst_package):
http_PUT(u, data=aggregate_template) http_PUT(u, data=aggregate_template)
print 'Done.' print 'Done.'
def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None): def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None, target_project=None, target_package=None):
""" """
Branch a package (via API call) Branch a package (via API call)
""" """
@ -2516,6 +2516,10 @@ def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None)
query['ignoredevel'] = '1' query['ignoredevel'] = '1'
if rev: if rev:
query['rev'] = rev query['rev'] = rev
if target_project:
query['target_project'] = target_project
if target_package:
query['target_package'] = target_package
u = makeurl(conf.config['apiurl'], u = makeurl(conf.config['apiurl'],
['source', src_project, src_package], ['source', src_project, src_package],
query=query) query=query)