1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-26 01:46:13 +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:
- 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:
- 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',
help='do not follow a defined devel project ' \
'(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',
help='branch against a specific revision')
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
home:USERNAME:branches:PROJECT/PACKAGE
if nothing else specified.
usage:
osc branch SOURCEPRJ SOURCEPKG
osc branch SOURCEPROJECT SOURCEPACKAGE
osc branch SOURCEPROJECT SOURCEPACKAGE TARGETPROJECT
osc branch SOURCEPROJECT SOURCEPACKAGE TARGETPROJECT TARGETPACKAGE
${cmd_option_list}
"""
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.')
if len(args) >= 3:
tproject = args[2]
if len(args) >= 4:
tpackage = args[3]
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])
if r != expected:
if len(args) == 2 and r != expected:
devloc = r.split('branches:')[1]
print '\nNote: The branch has been created of a different project,\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' \
' A direct branch of the specified package can be forced\n' \
' with the --nodevelproject option.\n' % devloc
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, args[1])
package = args[1]
if tpackage:
package = tpackage
if opts.checkout:
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):
@ -1154,7 +1172,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if args and len(args) == 1:
localdir = os.getcwd()
if is_project_dir(localdir):
project = Project(os.getcwd()).name
project = Project(localdir).name
project_dir = localdir
package = args[0]
apiurl = Project(localdir).apiurl

View File

@ -7,7 +7,7 @@
# and distributed under the terms of the GNU General Public Licence,
# 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" changes in an incompatible way. Please add any needed migration
# 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)
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)
"""
@ -2516,6 +2516,10 @@ def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None)
query['ignoredevel'] = '1'
if 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'],
['source', src_project, src_package],
query=query)