1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-11 16:36:14 +01:00

support new package instances on branching when using -N parameter

This commit is contained in:
Adrian Schröter 2015-07-21 13:02:48 +02:00
parent e9d7ac9c82
commit 083f23f77b
4 changed files with 28 additions and 3 deletions

1
NEWS
View File

@ -1,6 +1,7 @@
0.153
OBS 2.7 only:
- add "addchannels" and "enablechannel" commands
- support new package instances on branching when using -N parameter
0.152
- add support searching for groups via "group:" prefix

View File

@ -3221,7 +3221,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if len(args) >= 4:
tpackage = args[3]
exists, targetprj, targetpkg, srcprj, srcpkg = \
try:
exists, targetprj, targetpkg, srcprj, srcpkg = \
branch_pkg(apiurl, args[0], args[1],
nodevelproject=opts.nodevelproject, rev=opts.revision,
target_project=tproject, target_package=tpackage,
@ -3231,6 +3232,21 @@ Please submit there instead, or use --nodevelproject to force direct submission.
extend_package_names=opts.extend_package_names,
missingok=opts.new_package,
maintenance=opts.maintenance)
except oscerr.NotMissing as e:
print('NOTE: Package target exists already via project links, link will point to given project.')
print(' A submission will initialize a new instance.')
exists, targetprj, targetpkg, srcprj, srcpkg = \
branch_pkg(apiurl, args[0], args[1],
nodevelproject=opts.nodevelproject, rev=opts.revision,
target_project=tproject, target_package=tpackage,
return_existing=opts.checkout, msg=opts.message or '',
force=opts.force, noaccess=opts.noaccess,
add_repositories=opts.add_repositories,
extend_package_names=opts.extend_package_names,
missingok=False,
maintenance=opts.maintenance,
newinstance=opts.new_package)
if exists:
print('Using existing branch project: %s' % targetprj, file=sys.stderr)

View File

@ -4956,7 +4956,7 @@ def attribute_branch_pkg(apiurl, attribute, maintained_update_project_attribute,
return r
def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None, target_project=None, target_package=None, return_existing=False, msg='', force=False, noaccess=False, add_repositories=False, extend_package_names=False, missingok=False, maintenance=False):
def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None, target_project=None, target_package=None, return_existing=False, msg='', force=False, noaccess=False, add_repositories=False, extend_package_names=False, missingok=False, maintenance=False, newinstance=False):
"""
Branch a package (via API call)
"""
@ -4973,6 +4973,8 @@ def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None,
query['maintenance'] = "1"
if missingok:
query['missingok'] = "1"
if newinstance:
query['newinstance'] = "1"
if extend_package_names:
query['extend_package_names'] = "1"
if rev:
@ -4987,9 +4989,12 @@ def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None,
try:
f = http_POST(u)
except HTTPError as e:
root = ET.fromstring(e.read())
if missingok:
if root and root.get('code') == "not_missing":
raise oscerr.NotMissing("Package exists already via project link, but link will point to given project")
if not return_existing:
raise
root = ET.fromstring(e.read())
summary = root.find('summary')
if summary is None:
raise oscerr.APIError('unexpected response:\n%s' % ET.tostring(root, encoding=ET_ENCODING))

View File

@ -68,6 +68,9 @@ class WrongOptions(OscBaseError):
class NoWorkingCopy(OscBaseError):
"""Exception raised when directory is neither a project dir nor a package dir"""
class NotMissing(OscBaseError):
"""Exception raised when link target should not exist, but it does"""
class WorkingCopyWrongVersion(OscBaseError):
"""Exception raised when working copy's .osc/_osclib_version doesn't match"""