mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 14:56:14 +01:00
Support expansion/unexpansion of a link when updating to certain rev
There is no good reason why "--revision <rev>" and "--expand-link" or "--revision <rev>" and "--unexpand-link" should be mutually exclusive during an "osc up" of a package wc. Introduce the new "--linkrev <rev>" option to specify a rev of the link target that is used during link expansion.
This commit is contained in:
parent
f698103977
commit
9116d8ff97
@ -4737,6 +4737,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
help='update to specified revision (this option will be ignored '
|
||||
'if you are going to update the complete project or more than '
|
||||
'one package)')
|
||||
@cmdln.option('', '--linkrev', metavar='REV',
|
||||
help='revision of the link target that is used during link expansion')
|
||||
@cmdln.option('-u', '--unexpand-link', action='store_true',
|
||||
help='if a package is an expanded link, update to the raw _link file')
|
||||
@cmdln.option('-e', '--expand-link', action='store_true',
|
||||
@ -4774,11 +4776,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
${cmd_option_list}
|
||||
"""
|
||||
|
||||
if (opts.expand_link and opts.unexpand_link) \
|
||||
or (opts.expand_link and opts.revision) \
|
||||
or (opts.unexpand_link and opts.revision):
|
||||
raise oscerr.WrongOptions('Sorry, the options --expand-link, --unexpand-link and '
|
||||
'--revision are mutually exclusive.')
|
||||
if opts.expand_link and opts.unexpand_link:
|
||||
raise oscerr.WrongOptions('Sorry, the options --expand-link and '
|
||||
'--unexpand-link and are mutually '
|
||||
'exclusive.')
|
||||
|
||||
args = parseargs(args)
|
||||
arg_list = args[:]
|
||||
@ -4809,6 +4810,28 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
if not checkRevision(pacs[0].prjname, pacs[0].name, rev, pacs[0].apiurl):
|
||||
print('Revision \'%s\' does not exist' % rev, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if opts.expand_link or opts.unexpand_link:
|
||||
meta = show_files_meta(pacs[0].apiurl, pacs[0].prjname,
|
||||
pacs[0].name, revision=rev,
|
||||
linkrev=opts.linkrev,
|
||||
expand=opts.server_side_source_service_files)
|
||||
directory = ET.fromstring(meta)
|
||||
li_node = directory.find('linkinfo')
|
||||
if li_node is None:
|
||||
print('Revision \'%s\' is no link' % rev, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
li = Linkinfo()
|
||||
li.read(li_node)
|
||||
if li.haserror() and opts.expand_link:
|
||||
raise oscerr.LinkExpandError(pacs[0].prjname, pacs[0].name,
|
||||
li.error)
|
||||
rev = li.lsrcmd5
|
||||
if opts.expand_link:
|
||||
rev = li.xsrcmd5
|
||||
if rev is None:
|
||||
# 2 cases: a) unexpand and passed rev has linkerror
|
||||
# b) expand and passed rev is already expanded
|
||||
rev = directory.get('srcmd5')
|
||||
else:
|
||||
rev = None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user