From caa7b5270d4efaa33843d7c770dccd4f01f42e3e Mon Sep 17 00:00:00 2001 From: Darragh Bailey Date: Thu, 8 Dec 2016 11:06:29 +0000 Subject: [PATCH] Switch to range from xrange for python 3 compatibility xrange no longer exists in python 3, and since it is a small number of iterations there is a limited performance impact under python 2 by using range instead. Add check to ensure linearisation exception does not occur under python 3, due to exception in attempting to use a non existing function. Change-Id: I3e6165b8bce14a44459fc9419792784f64636f5e --- git_upstream/lib/importupstream.py | 2 +- git_upstream/tests/commands/import/test_import.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/git_upstream/lib/importupstream.py b/git_upstream/lib/importupstream.py index a99b114..6058269 100644 --- a/git_upstream/lib/importupstream.py +++ b/git_upstream/lib/importupstream.py @@ -237,7 +237,7 @@ class ImportUpstream(LogDedentMixin, GitMixin): ancestors.add(root) # look for merge commits that are not part of ancestry path - for idx in xrange(counter - 1, -1, -1): + for idx in range(counter - 1, -1, -1): commit = sequence[idx] # if there is only one parent, no need to check the others if len(commit.parents) < 2: diff --git a/git_upstream/tests/commands/import/test_import.py b/git_upstream/tests/commands/import/test_import.py index cc42c38..3402bda 100644 --- a/git_upstream/tests/commands/import/test_import.py +++ b/git_upstream/tests/commands/import/test_import.py @@ -67,6 +67,10 @@ class TestImportCommand(TestWithScenarios, BaseTestCase): self.assertThat(self.logger.output, Contains("Starting execution of import command")) + self.assertThat( + self.logger.output, + Not(Contains("Exception occurred during linearisation"))) + # perform sanity checks on results self._check_tree_state()