Always have rebase perform finish
To ensure consistent behaviour around encountering conflicts whether in interactive mode or not, or whether there are changes to be carried or not, always have rebase perform the finish step whenever the merge behaviour is enabled. Change-Id: I8f72ebb9fb0fa9fff4943e732cbf4f7d33672837 Related-Bug: #1625876
This commit is contained in:
@@ -118,25 +118,19 @@ class ImportCommand(LogDedentMixin, GitUpstreamCommand):
|
|||||||
else:
|
else:
|
||||||
self.args.real_upstream_branch = self.args.upstream_branch
|
self.args.real_upstream_branch = self.args.upstream_branch
|
||||||
|
|
||||||
def _finish(self, import_upstream):
|
def _finish_report(self, import_upstream):
|
||||||
self.log.notice("Merging import to requested branch '%s'",
|
self.log.notice(
|
||||||
self.args.branch)
|
"""
|
||||||
if import_upstream.finish():
|
Successfully finished import:
|
||||||
self.log.notice(
|
target branch: '%s'
|
||||||
"""
|
upstream branch: '%s'
|
||||||
Successfully finished import:
|
import branch: '%s'""",
|
||||||
target branch: '%s'
|
self.args.branch, self.args.real_upstream_branch,
|
||||||
upstream branch: '%s'
|
import_upstream.import_branch)
|
||||||
import branch: '%s'""",
|
if self.args.branches:
|
||||||
self.args.branch, self.args.real_upstream_branch,
|
for branch in self.args.branches:
|
||||||
import_upstream.import_branch)
|
self.log.notice(" extra branch: '%s'", branch,
|
||||||
if self.args.branches:
|
dedent=False)
|
||||||
for branch in self.args.branches:
|
|
||||||
self.log.notice(" extra branch: '%s'", branch,
|
|
||||||
dedent=False)
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
|
|
||||||
@@ -174,7 +168,11 @@ class ImportCommand(LogDedentMixin, GitUpstreamCommand):
|
|||||||
|
|
||||||
# finish and return if thats all
|
# finish and return if thats all
|
||||||
if self.args.finish:
|
if self.args.finish:
|
||||||
return self._finish(import_upstream)
|
if import_upstream.finish():
|
||||||
|
self._finish_report(import_upstream)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
# otherwise perform fresh import
|
# otherwise perform fresh import
|
||||||
self.log.notice("Starting import of upstream")
|
self.log.notice("Starting import of upstream")
|
||||||
@@ -205,6 +203,7 @@ class ImportCommand(LogDedentMixin, GitUpstreamCommand):
|
|||||||
""", self.args.branch)
|
""", self.args.branch)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return self._finish(import_upstream)
|
self._finish_report(import_upstream)
|
||||||
|
return True
|
||||||
|
|
||||||
# vim:sw=4:sts=4:ts=4:et:
|
# vim:sw=4:sts=4:ts=4:et:
|
||||||
|
@@ -271,7 +271,11 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
if len(commit_list) == 0:
|
if len(commit_list) == 0:
|
||||||
self.log.notice("All carried changes gone upstream")
|
self.log.notice("All carried changes gone upstream")
|
||||||
self._set_branch(self.import_branch, self.upstream, force=True)
|
self._set_branch(self.import_branch, self.upstream, force=True)
|
||||||
return True
|
# no resume_cmdline means to skip merge
|
||||||
|
if resume_cmdline is None:
|
||||||
|
return True
|
||||||
|
# otherwise perform the finish
|
||||||
|
return self.finish()
|
||||||
|
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"""
|
"""
|
||||||
@@ -351,6 +355,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
self.log.notice("Successfully applied all locally carried changes")
|
self.log.notice("Successfully applied all locally carried changes")
|
||||||
|
self.git.checkout(self.branch)
|
||||||
else:
|
else:
|
||||||
self.log.warning("Warning, nothing to do: locally carried " +
|
self.log.warning("Warning, nothing to do: locally carried " +
|
||||||
"changes already rebased onto " + self.upstream)
|
"changes already rebased onto " + self.upstream)
|
||||||
@@ -366,6 +371,8 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
Finish the import by merging the import branch to the target while
|
Finish the import by merging the import branch to the target while
|
||||||
performing suitable verification checks.
|
performing suitable verification checks.
|
||||||
"""
|
"""
|
||||||
|
self.log.notice("Merging import to requested branch '%s'",
|
||||||
|
self.branch)
|
||||||
self.log.info("No verification checks enabled")
|
self.log.info("No verification checks enabled")
|
||||||
in_rebase = False
|
in_rebase = False
|
||||||
if self.is_detached():
|
if self.is_detached():
|
||||||
@@ -413,6 +420,7 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
raise ImportUpstreamError(
|
raise ImportUpstreamError(
|
||||||
"Resulting tree does not match import")
|
"Resulting tree does not match import")
|
||||||
if in_rebase:
|
if in_rebase:
|
||||||
|
self.log.info("Code thinks we're in the middle of a rebase")
|
||||||
self.git.checkout(target_sha)
|
self.git.checkout(target_sha)
|
||||||
except (GitCommandError, ImportUpstreamError) as e:
|
except (GitCommandError, ImportUpstreamError) as e:
|
||||||
self.log.error(
|
self.log.error(
|
||||||
|
@@ -195,6 +195,10 @@ class RebaseEditor(GitMixin, LogDedentMixin):
|
|||||||
cmd = ['git', 'rebase', '--interactive']
|
cmd = ['git', 'rebase', '--interactive']
|
||||||
cmd.extend(self.git.transform_kwargs(**kwargs))
|
cmd.extend(self.git.transform_kwargs(**kwargs))
|
||||||
cmd.extend(args)
|
cmd.extend(args)
|
||||||
|
|
||||||
|
# ensure that the finish will always be called
|
||||||
|
self._insert_exec_to_todo()
|
||||||
|
|
||||||
mode = os.environ.get('TEST_GIT_UPSTREAM_REBASE_EDITOR', "")
|
mode = os.environ.get('TEST_GIT_UPSTREAM_REBASE_EDITOR', "")
|
||||||
if mode.lower() == "debug":
|
if mode.lower() == "debug":
|
||||||
# In general it's not recommended to run rebase in direct
|
# In general it's not recommended to run rebase in direct
|
||||||
@@ -239,8 +243,6 @@ class RebaseEditor(GitMixin, LogDedentMixin):
|
|||||||
finally:
|
finally:
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
else:
|
else:
|
||||||
self._insert_exec_to_todo()
|
|
||||||
|
|
||||||
cmd.append(environ)
|
cmd.append(environ)
|
||||||
os.execlpe('git', *cmd)
|
os.execlpe('git', *cmd)
|
||||||
|
|
||||||
|
@@ -40,6 +40,11 @@ class TestImportCommand(TestWithScenarios, BaseTestCase):
|
|||||||
self.addDetail('description', text_content(self.desc))
|
self.addDetail('description', text_content(self.desc))
|
||||||
|
|
||||||
self.commands, self.parser = main.build_parsers()
|
self.commands, self.parser = main.build_parsers()
|
||||||
|
|
||||||
|
script_cmdline = self.parser.get_default('script_cmdline')
|
||||||
|
script_cmdline[-1] = os.path.join(os.getcwd(), main.__file__)
|
||||||
|
self.parser.set_defaults(script_cmdline=script_cmdline)
|
||||||
|
|
||||||
# builds the tree to be tested
|
# builds the tree to be tested
|
||||||
super(TestImportCommand, self).setUp()
|
super(TestImportCommand, self).setUp()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user