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/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