diff --git a/behave/features/copypac.feature b/behave/features/copypac.feature index 0d370f9a..5e8ee20c 100644 --- a/behave/features/copypac.feature +++ b/behave/features/copypac.feature @@ -18,6 +18,12 @@ Scenario: Run `osc copypac / / Then the exit code is 0 +@destructive +Scenario: Run `osc copypac / / --keep-link --revision` + When I execute osc with args "copypac test:factory/test-pkgA test:factory/test-pkgA --keep-link --revision=1" + Then the exit code is 0 + + Scenario: Run `osc copypac` where the source and target are the same When I execute osc with args "copypac test:factory/test-pkgA test:factory" Then the exit code is 1 diff --git a/osc/commandline.py b/osc/commandline.py index c42a46ab..a57adcb2 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -3349,9 +3349,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. if opts.message: comment = opts.message else: - if not rev: - rev = show_upstream_rev(src_apiurl, src_project, src_package) - comment = 'osc copypac from project:%s package:%s revision:%s' % (src_project, src_package, rev) + src_rev = rev or show_upstream_rev(src_apiurl, src_project, src_package) + comment = 'osc copypac from project:%s package:%s revision:%s' % (src_project, src_package, src_rev) if opts.keep_link: comment += ", using keep-link" if opts.expand: diff --git a/osc/core.py b/osc/core.py index 911a05ee..276ad8ce 100644 --- a/osc/core.py +++ b/osc/core.py @@ -5959,8 +5959,10 @@ def copy_pac( or by the server, in a single api call. """ if (src_apiurl, src_project, src_package) == (dst_apiurl, dst_project, dst_package): - # copypac is also used to expand sources, let's allow that - if not expand: + # special cases when source and target can be the same: + # * expanding sources + # * downgrading package to an old revision + if not any([expand, revision]): raise oscerr.OscValueError("Cannot copy package. Source and target are the same.") if not (src_apiurl == dst_apiurl and src_project == dst_project