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

* support linktobranch with local dir

* update local checkout on linktobranch and revert
This commit is contained in:
Adrian Schröter 2010-01-14 12:24:48 +01:00
parent b198845b2c
commit 727c66c2cf
2 changed files with 27 additions and 12 deletions

View File

@ -1272,20 +1272,33 @@ Please submit there instead, or use --nodevelproject to force direct submission.
to a branch. This is a full copy with a _link file pointing to the branched place.
usage:
osc linkpac PROJECT PACKAGE
osc linktobranch # can be used in checked out package
osc linktobranch PROJECT PACKAGE
${cmd_option_list}
"""
args = slash_split(args)
if len(args) == 0:
wd = os.curdir
project = store_read_project(wd)
package = store_read_package(wd)
apiurl = store_read_apiurl(wd)
update_local_dir = 1
elif len(args) < 2:
raise oscerr.WrongArgs('Too few arguments (required none or two)')
elif len(args) > 2:
raise oscerr.WrongArgs('Too many arguments (required none or two)')
else:
apiurl = conf.config['apiurl']
project = args[0]
package = args[1]
update_local_dir = 0
if not args or len(args) != 2:
raise oscerr.WrongArgs('Incorrect number of arguments.\n\n' \
+ self.get_cmd_help('linktobranch'))
project = args[0]
package = args[1]
link_to_branch(project, package)
# execute
link_to_branch(apiurl, project, package)
if update_local_dir == 1:
pac = findpacs(wd)[0]
pac.update()
@cmdln.option('-C', '--cicount', choices=['add', 'copy', 'local'],
@ -3373,6 +3386,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
apiurl, project, package,
revision=rev, comment=message)
print r
if update_local_dir == 1:
pac = findpacs(wd)[0]
pac.update()
@cmdln.option('-r', '--revision', metavar='rev',

View File

@ -3072,14 +3072,13 @@ def replace_pkg_meta(pkgmeta, new_name, new_prj, keep_maintainers = False,
root.remove(dp)
return ET.tostring(root)
def link_to_branch(project, package):
def link_to_branch(apiurl, project, package):
"""
convert a package with a _link + project.diff to a branch
"""
if '_link' in meta_get_filelist(conf.config['apiurl'], project, package):
# FIXME, verify that it is no branch already
u = makeurl(conf.config['apiurl'], ['source', project, package], 'cmd=linktobranch')
u = makeurl(apiurl, ['source', project, package], 'cmd=linktobranch')
http_POST(u)
else:
raise oscerr.OscIOError(None, 'no _link file inside project \'%s\' package \'%s\'' % (project, package))