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
This commit is contained in:
Darragh Bailey 2016-12-08 11:06:29 +00:00
parent 34c72e9e39
commit caa7b5270d
2 changed files with 5 additions and 1 deletions

View File

@ -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:

View File

@ -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()