Handle all local changes landed upstream

Allow importing an upstream that contains all local changes by simply
merging to replace the existing target with the upstream branch given.

In certain workflows it is possible for the local changes to have all
landed upstream. In such a case, applying of the changes carried should
detect there is nothing to apply and create import branch to point to
the upstream branch to allow the standard finish actions to complete.

Change-Id: I61ae706f2b240a0e2590e03d2e83db97dafdf962
Closes-Bug: #1367985
This commit is contained in:
Darragh Bailey
2016-07-04 11:25:02 +01:00
parent 8ab6ccc3be
commit e231483adc
3 changed files with 62 additions and 2 deletions

View File

@@ -269,8 +269,9 @@ class ImportUpstream(LogDedentMixin, GitMixin):
commit_list = list(strategy.filtered_iter())
if len(commit_list) == 0:
self.log.notice("There are no local changes to be applied!")
return False
self.log.notice("All carried changes gone upstream")
self._set_branch(self.import_branch, self.upstream, force=True)
return True
self.log.debug(
"""

View File

@@ -0,0 +1,48 @@
#
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
- desc: |
Test importing where everything is upstreamed
Checks that importing an upstream where all local changes have
gone upstream, will correctly replace the local master with
the latest upstream branch.
C---D local/master
/
A---B---E---C1--D1 upstream/master
tree:
- [A, []]
- [B, [A]]
- [C, [B]]
- [D, [C]]
- [C1, [E]]
- [D1, [C1]]
- [E, [B]]
branches:
head: [master, D]
upstream: [upstream/master, D1]
parser_args:
- -q
- import
- --into=master
- upstream/master
expect_found: []

View File

@@ -124,3 +124,14 @@ class TestImportCommand(TestWithScenarios, BaseTestCase):
self.assertThat(
self.logger.output,
Contains("No updated additional branch given, nothing to be done"))
def _verify_import_everything_already_upstreamed(self):
"""Additional verification for the finished results"""
self.assertThat(
self.logger.output,
Contains("All carried changes gone upstream"))
self.assertThat(
self.logger.output,
Contains("Creating branch 'import/test_command' from specified "
"commit 'upstream/master'"))