mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-12 00:46:14 +01:00
- use cmd=branch&dryrun=1 for search of maintained packages to get same result as on branching
This commit is contained in:
parent
836423d2cf
commit
3651508724
4
NEWS
4
NEWS
@ -1,5 +1,9 @@
|
|||||||
0.134
|
0.134
|
||||||
-
|
-
|
||||||
|
#
|
||||||
|
# Features which requires OBS 2.3
|
||||||
|
#
|
||||||
|
- support dryrun of branching to preview the expected result. "osc sm" is doing this now by default.
|
||||||
|
|
||||||
0.133
|
0.133
|
||||||
- add --meta option also to "list", "cat" and "less" commands
|
- add --meta option also to "list", "cat" and "less" commands
|
||||||
|
@ -2671,24 +2671,34 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
'(\'osc bco\' is a shorthand for this option)' )
|
'(\'osc bco\' is a shorthand for this option)' )
|
||||||
@cmdln.option('-a', '--attribute', metavar='ATTRIBUTE',
|
@cmdln.option('-a', '--attribute', metavar='ATTRIBUTE',
|
||||||
help='Use this attribute to find affected packages (default is OBS:Maintained)')
|
help='Use this attribute to find affected packages (default is OBS:Maintained)')
|
||||||
@cmdln.option('--noaccess', action='store_true',
|
|
||||||
help='Create a hidden project')
|
|
||||||
@cmdln.option('-u', '--update-project-attribute', metavar='UPDATE_ATTRIBUTE',
|
@cmdln.option('-u', '--update-project-attribute', metavar='UPDATE_ATTRIBUTE',
|
||||||
help='Use this attribute to find update projects (default is OBS:UpdateProject) ')
|
help='Use this attribute to find update projects (default is OBS:UpdateProject) ')
|
||||||
|
@cmdln.option('--dryrun', action='store_true',
|
||||||
|
help='Just simulate the action and report back the result.')
|
||||||
|
@cmdln.option('--noaccess', action='store_true',
|
||||||
|
help='Create a hidden project')
|
||||||
|
@cmdln.option('--nodevelproject', action='store_true',
|
||||||
|
help='do not follow a defined devel project ' \
|
||||||
|
'(primary project where a package is developed)')
|
||||||
|
@cmdln.alias('sm')
|
||||||
|
@cmdln.alias('maintained')
|
||||||
def do_mbranch(self, subcmd, opts, *args):
|
def do_mbranch(self, subcmd, opts, *args):
|
||||||
"""${cmd_name}: Multiple branch of a package
|
"""${cmd_name}: Search or banch multiple instances of a package
|
||||||
|
|
||||||
|
This command is used for searching all relevant instances of packages
|
||||||
|
and creating links of them in one project.
|
||||||
|
This is esp. used for maintenance updates. It can also be used to branch
|
||||||
|
all packages marked before with a given attribute.
|
||||||
|
|
||||||
[See http://en.opensuse.org/openSUSE:Build_Service_Concept_Maintenance
|
[See http://en.opensuse.org/openSUSE:Build_Service_Concept_Maintenance
|
||||||
for information on this topic.]
|
for information on this topic.]
|
||||||
|
|
||||||
This command is used for creating multiple links of defined version of a package
|
|
||||||
in one project. This is esp. used for maintenance updates.
|
|
||||||
|
|
||||||
The branched package will live in
|
The branched package will live in
|
||||||
home:USERNAME:branches:ATTRIBUTE:PACKAGE
|
home:USERNAME:branches:ATTRIBUTE:PACKAGE
|
||||||
if nothing else specified.
|
if nothing else specified.
|
||||||
|
|
||||||
usage:
|
usage:
|
||||||
|
osc sm [SOURCEPACKAGE] [-a ATTRIBUTE]
|
||||||
osc mbranch [ SOURCEPACKAGE [ TARGETPROJECT ] ]
|
osc mbranch [ SOURCEPACKAGE [ TARGETPROJECT ] ]
|
||||||
${cmd_option_list}
|
${cmd_option_list}
|
||||||
"""
|
"""
|
||||||
@ -2710,23 +2720,31 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
if len(args) >= 2:
|
if len(args) >= 2:
|
||||||
tproject = args[1]
|
tproject = args[1]
|
||||||
|
|
||||||
r = attribute_branch_pkg(apiurl, maintained_attribute, maintained_update_project_attribute, \
|
if subcmd == 'sm' or subcmd == 'maintained':
|
||||||
package, tproject, noaccess = opts.noaccess)
|
opts.dryrun = 1
|
||||||
|
|
||||||
if r is None:
|
result = attribute_branch_pkg(apiurl, maintained_attribute, maintained_update_project_attribute, \
|
||||||
|
package, tproject, noaccess = opts.noaccess, nodevelproject=opts.nodevelproject, dryrun=opts.dryrun)
|
||||||
|
|
||||||
|
if result is None:
|
||||||
print >>sys.stderr, 'ERROR: Attribute branch call came not back with a project.'
|
print >>sys.stderr, 'ERROR: Attribute branch call came not back with a project.'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print "Project " + r + " created."
|
if opts.dryrun:
|
||||||
|
for r in result.findall('package'):
|
||||||
|
print " ", r.get('project'), r.get('package')
|
||||||
|
return
|
||||||
|
|
||||||
|
print "Project " + result + " created."
|
||||||
|
|
||||||
if opts.checkout:
|
if opts.checkout:
|
||||||
Project.init_project(apiurl, r, r, conf.config['do_package_tracking'])
|
Project.init_project(apiurl, result, result, conf.config['do_package_tracking'])
|
||||||
print statfrmt('A', r)
|
print statfrmt('A', result)
|
||||||
|
|
||||||
# all packages
|
# all packages
|
||||||
for package in meta_get_packagelist(apiurl, r):
|
for package in meta_get_packagelist(apiurl, result):
|
||||||
try:
|
try:
|
||||||
checkout_package(apiurl, r, package, expand_link = True, prj_dir = r)
|
checkout_package(apiurl, result, package, expand_link = True, prj_dir = result)
|
||||||
except:
|
except:
|
||||||
print >>sys.stderr, 'Error while checkout package:\n', package
|
print >>sys.stderr, 'Error while checkout package:\n', package
|
||||||
|
|
||||||
@ -5836,7 +5854,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
help='search binary packages')
|
help='search binary packages')
|
||||||
@cmdln.option('-B', '--baseproject', metavar='PROJECT',
|
@cmdln.option('-B', '--baseproject', metavar='PROJECT',
|
||||||
help='search packages built for PROJECT (implies --binary)')
|
help='search packages built for PROJECT (implies --binary)')
|
||||||
@cmdln.alias('sm')
|
|
||||||
@cmdln.alias('se')
|
@cmdln.alias('se')
|
||||||
@cmdln.alias('bse')
|
@cmdln.alias('bse')
|
||||||
def do_search(self, subcmd, opts, *args):
|
def do_search(self, subcmd, opts, *args):
|
||||||
@ -5848,7 +5865,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
|
|
||||||
usage:
|
usage:
|
||||||
osc search \'search term\' <options>
|
osc search \'search term\' <options>
|
||||||
osc sm \'source package name\' ('osc search --maintained')
|
|
||||||
osc bse ... ('osc search --binary')
|
osc bse ... ('osc search --binary')
|
||||||
osc se 'perl(Foo::Bar)' ('osc --package perl-Foo-Bar')
|
osc se 'perl(Foo::Bar)' ('osc --package perl-Foo-Bar')
|
||||||
${cmd_option_list}
|
${cmd_option_list}
|
||||||
@ -5886,8 +5902,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
if opts.substring and opts.exact:
|
if opts.substring and opts.exact:
|
||||||
raise oscerr.WrongOptions('Sorry, the options \'--substring\' and \'--exact\' are mutually exclusive')
|
raise oscerr.WrongOptions('Sorry, the options \'--substring\' and \'--exact\' are mutually exclusive')
|
||||||
|
|
||||||
if subcmd == 'sm' or opts.maintained:
|
|
||||||
opts.package = True
|
|
||||||
if not opts.substring:
|
if not opts.substring:
|
||||||
opts.exact = True
|
opts.exact = True
|
||||||
if subcmd == 'bse' or opts.baseproject:
|
if subcmd == 'bse' or opts.baseproject:
|
||||||
@ -5930,10 +5944,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
xpath = xpath_join(xpath, build_xpath('title', search_term, opts.substring), inner=True)
|
xpath = xpath_join(xpath, build_xpath('title', search_term, opts.substring), inner=True)
|
||||||
xpath = xpath_join(xpath, build_xpath('description', search_term, opts.substring), inner=True)
|
xpath = xpath_join(xpath, build_xpath('description', search_term, opts.substring), inner=True)
|
||||||
what = {'project': xpath, 'package': xpath}
|
what = {'project': xpath, 'package': xpath}
|
||||||
if subcmd == 'sm' or opts.maintained:
|
if opts.project and not opts.package:
|
||||||
xpath = xpath_join(xpath, '(project/attribute/@name=\'%(attr)s\' or attribute/@name=\'%(attr)s\')' % {'attr': conf.config['maintained_attribute']}, op='and')
|
|
||||||
what = {'package': xpath}
|
|
||||||
elif opts.project and not opts.package:
|
|
||||||
what = {'project': xpath}
|
what = {'project': xpath}
|
||||||
elif not opts.project and opts.package:
|
elif not opts.project and opts.package:
|
||||||
what = {'package': xpath}
|
what = {'package': xpath}
|
||||||
|
@ -4293,7 +4293,7 @@ def aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map =
|
|||||||
print 'Done.'
|
print 'Done.'
|
||||||
|
|
||||||
|
|
||||||
def attribute_branch_pkg(apiurl, attribute, maintained_update_project_attribute, package, targetproject, return_existing=False, force=False, noaccess=False, add_repositories=False):
|
def attribute_branch_pkg(apiurl, attribute, maintained_update_project_attribute, package, targetproject, return_existing=False, force=False, noaccess=False, add_repositories=False, dryrun=False, nodevelproject=False):
|
||||||
"""
|
"""
|
||||||
Branch packages defined via attributes (via API call)
|
Branch packages defined via attributes (via API call)
|
||||||
"""
|
"""
|
||||||
@ -4301,10 +4301,14 @@ def attribute_branch_pkg(apiurl, attribute, maintained_update_project_attribute,
|
|||||||
query['attribute'] = attribute
|
query['attribute'] = attribute
|
||||||
if targetproject:
|
if targetproject:
|
||||||
query['target_project'] = targetproject
|
query['target_project'] = targetproject
|
||||||
|
if dryrun:
|
||||||
|
query['dryrun'] = "1"
|
||||||
if force:
|
if force:
|
||||||
query['force'] = "1"
|
query['force'] = "1"
|
||||||
if noaccess:
|
if noaccess:
|
||||||
query['noaccess'] = "1"
|
query['noaccess'] = "1"
|
||||||
|
if nodevelproject:
|
||||||
|
query['ignoredevel'] = '1'
|
||||||
if add_repositories:
|
if add_repositories:
|
||||||
query['add_repositories'] = "1"
|
query['add_repositories'] = "1"
|
||||||
if package:
|
if package:
|
||||||
@ -4323,6 +4327,9 @@ def attribute_branch_pkg(apiurl, attribute, maintained_update_project_attribute,
|
|||||||
raise oscerr.APIError(msg)
|
raise oscerr.APIError(msg)
|
||||||
|
|
||||||
r = f.read()
|
r = f.read()
|
||||||
|
if dryrun:
|
||||||
|
return ET.fromstring(r)
|
||||||
|
|
||||||
r = r.split('targetproject">')[1]
|
r = r.split('targetproject">')[1]
|
||||||
r = r.split('</data>')[0]
|
r = r.split('</data>')[0]
|
||||||
return r
|
return r
|
||||||
|
Loading…
Reference in New Issue
Block a user