Rev 5100: (vila) Cleanup bt.per_branch.test_iter_merge_sorted_revisions in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Mar 19 10:47:31 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5100 [merge]
revision-id: pqm at pqm.ubuntu.com-20100319104730-5jdnpkz0ghxd96no
parent: pqm at pqm.ubuntu.com-20100319084540-odnankeqqjlnjfjh
parent: v.ladeuil+lp at free.fr-20100319101606-rday4106fhseiepl
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-03-19 10:47:30 +0000
message:
(vila) Cleanup bt.per_branch.test_iter_merge_sorted_revisions
modified:
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/tests/per_branch/test_iter_merge_sorted_revisions.py test_merge_sorted_re-20090121004847-to3gvjwigstu93eh-1
=== modified file 'bzrlib/log.py'
--- a/bzrlib/log.py 2010-03-19 07:54:29 +0000
+++ b/bzrlib/log.py 2010-03-19 10:16:06 +0000
@@ -561,6 +561,8 @@
if (start_rev_id is not None
and not graph.is_ancestor(start_rev_id, end_rev_id)):
raise _StartNotLinearAncestor()
+ # Since we collected the revisions so far, we need to
+ # adjust end_rev_id.
end_rev_id = rev_id
break
else:
@@ -579,6 +581,9 @@
raise errors.BzrCommandError('Start revision not found in'
' history of end revision.')
+ # We exit the loop above because we encounter a revision with merges, from
+ # this revision, we need to switch to _graph_view_revisions.
+
# A log including nested merges is required. If the direction is reverse,
# we rebase the initial merge depths so that the development line is
# shown naturally, i.e. just like it is for linear logging. We can easily
@@ -586,7 +591,7 @@
# indented at the end seems slightly nicer in that case.
view_revisions = chain(iter(initial_revisions),
_graph_view_revisions(branch, start_rev_id, end_rev_id,
- rebase_initial_depths=direction == 'reverse'))
+ rebase_initial_depths=(direction == 'reverse')))
if direction == 'reverse':
return view_revisions
elif direction == 'forward':
@@ -658,7 +663,7 @@
def _graph_view_revisions(branch, start_rev_id, end_rev_id,
- rebase_initial_depths=True):
+ rebase_initial_depths=True):
"""Calculate revisions to view including merges, newest to oldest.
:param branch: the branch
=== modified file 'bzrlib/tests/per_branch/test_iter_merge_sorted_revisions.py'
--- a/bzrlib/tests/per_branch/test_iter_merge_sorted_revisions.py 2010-02-17 17:11:16 +0000
+++ b/bzrlib/tests/per_branch/test_iter_merge_sorted_revisions.py 2010-03-19 10:14:26 +0000
@@ -21,176 +21,135 @@
revision,
)
-from bzrlib.tests.per_branch import TestCaseWithBranch
-
-
-class TestIterMergeSortedRevisions(TestCaseWithBranch):
+from bzrlib.tests import per_branch
+
+
+class TestIterMergeSortedRevisions(per_branch.TestCaseWithBranch):
+
+ def setUp(self):
+ super(TestIterMergeSortedRevisions, self).setUp()
+ tree = self.create_tree_with_merge()
+ self.branch = tree.bzrdir.open_branch()
+
+ def assertRevisions(self, expected, *args, **kwargs):
+ self.assertEqual(expected,
+ list(self.branch.iter_merge_sorted_revisions(
+ *args, **kwargs)))
def test_merge_sorted(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-3', 0, (3,), False),
- ('rev-1.1.1', 1, (1,1,1), True),
- ('rev-2', 0, (2,), False),
- ('rev-1', 0, (1,), True),
- ], list(the_branch.iter_merge_sorted_revisions()))
+ self.assertRevisions([('rev-3', 0, (3,), False),
+ ('rev-1.1.1', 1, (1,1,1), True),
+ ('rev-2', 0, (2,), False),
+ ('rev-1', 0, (1,), True),])
def test_merge_sorted_range(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-1.1.1', 1, (1,1,1), True),
- ('rev-2', 0, (2,), False),
- ], list(the_branch.iter_merge_sorted_revisions(
- start_revision_id='rev-1.1.1', stop_revision_id='rev-1')))
+ self.assertRevisions(
+ [('rev-1.1.1', 1, (1,1,1), True),
+ ('rev-2', 0, (2,), False),],
+ start_revision_id='rev-1.1.1', stop_revision_id='rev-1')
def test_merge_sorted_range_start_only(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-1.1.1', 1, (1,1,1), True),
- ('rev-2', 0, (2,), False),
- ('rev-1', 0, (1,), True),
- ], list(the_branch.iter_merge_sorted_revisions(
- start_revision_id='rev-1.1.1')))
+ self.assertRevisions(
+ [('rev-1.1.1', 1, (1,1,1), True),
+ ('rev-2', 0, (2,), False),
+ ('rev-1', 0, (1,), True),],
+ start_revision_id='rev-1.1.1')
def test_merge_sorted_range_stop_exclude(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-3', 0, (3,), False),
- ('rev-1.1.1', 1, (1,1,1), True),
- ('rev-2', 0, (2,), False),
- ], list(the_branch.iter_merge_sorted_revisions(
- stop_revision_id='rev-1')))
+ self.assertRevisions(
+ [('rev-3', 0, (3,), False),
+ ('rev-1.1.1', 1, (1,1,1), True),
+ ('rev-2', 0, (2,), False),],
+ stop_revision_id='rev-1')
def test_merge_sorted_range_stop_include(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-3', 0, (3,), False),
- ('rev-1.1.1', 1, (1,1,1), True),
- ('rev-2', 0, (2,), False),
- ], list(the_branch.iter_merge_sorted_revisions(
- stop_revision_id='rev-2', stop_rule='include')))
+ self.assertRevisions(
+ [('rev-3', 0, (3,), False),
+ ('rev-1.1.1', 1, (1,1,1), True),
+ ('rev-2', 0, (2,), False),],
+ stop_revision_id='rev-2', stop_rule='include')
def test_merge_sorted_range_stop_with_merges(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-3', 0, (3,), False),
- ('rev-1.1.1', 1, (1,1,1), True),
- ], list(the_branch.iter_merge_sorted_revisions(
- stop_revision_id='rev-3', stop_rule='with-merges')))
+ self.assertRevisions(
+ [('rev-3', 0, (3,), False),
+ ('rev-1.1.1', 1, (1,1,1), True),],
+ stop_revision_id='rev-3', stop_rule='with-merges')
def test_merge_sorted_range_stop_with_merges_can_show_non_parents(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
# rev-1.1.1 gets logged before the end revision is reached.
# so it is returned even though rev-1.1.1 is not a parent of rev-2.
- self.assertEqual([
- ('rev-3', 0, (3,), False),
- ('rev-1.1.1', 1, (1,1,1), True),
- ('rev-2', 0, (2,), False),
- ], list(the_branch.iter_merge_sorted_revisions(
- stop_revision_id='rev-2', stop_rule='with-merges')))
+ self.assertRevisions(
+ [('rev-3', 0, (3,), False),
+ ('rev-1.1.1', 1, (1,1,1), True),
+ ('rev-2', 0, (2,), False),],
+ stop_revision_id='rev-2', stop_rule='with-merges')
def test_merge_sorted_range_stop_with_merges_ignore_non_parents(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
# rev-2 is not a parent of rev-1.1.1 so it must not be returned
- self.assertEqual([
- ('rev-3', 0, (3,), False),
- ('rev-1.1.1', 1, (1,1,1), True),
- ], list(the_branch.iter_merge_sorted_revisions(
- stop_revision_id='rev-1.1.1', stop_rule='with-merges')))
+ self.assertRevisions(
+ [('rev-3', 0, (3,), False),
+ ('rev-1.1.1', 1, (1,1,1), True),],
+ stop_revision_id='rev-1.1.1', stop_rule='with-merges')
def test_merge_sorted_single_stop_exclude(self):
# from X..X exclusive is an empty result
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([], list(the_branch.iter_merge_sorted_revisions(
- start_revision_id='rev-3', stop_revision_id='rev-3')))
+ self.assertRevisions(
+ [],
+ start_revision_id='rev-3', stop_revision_id='rev-3')
def test_merge_sorted_single_stop_include(self):
# from X..X inclusive is [X]
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-3', 0, (3,), False),
- ], list(the_branch.iter_merge_sorted_revisions(
- start_revision_id='rev-3', stop_revision_id='rev-3',
- stop_rule='include')))
+ self.assertRevisions(
+ [('rev-3', 0, (3,), False),],
+ start_revision_id='rev-3', stop_revision_id='rev-3',
+ stop_rule='include')
def test_merge_sorted_single_stop_with_merges(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-3', 0, (3,), False),
- ('rev-1.1.1', 1, (1,1,1), True),
- ], list(the_branch.iter_merge_sorted_revisions(
- start_revision_id='rev-3', stop_revision_id='rev-3',
- stop_rule='with-merges')))
+ self.assertRevisions(
+ [('rev-3', 0, (3,), False),
+ ('rev-1.1.1', 1, (1,1,1), True),],
+ start_revision_id='rev-3', stop_revision_id='rev-3',
+ stop_rule='with-merges')
def test_merge_sorted_forward(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-1', 0, (1,), True),
- ('rev-2', 0, (2,), False),
- ('rev-1.1.1', 1, (1,1,1), True),
- ('rev-3', 0, (3,), False),
- ], list(the_branch.iter_merge_sorted_revisions(
- direction='forward')))
+ self.assertRevisions(
+ [('rev-1', 0, (1,), True),
+ ('rev-2', 0, (2,), False),
+ ('rev-1.1.1', 1, (1,1,1), True),
+ ('rev-3', 0, (3,), False),],
+ direction='forward')
def test_merge_sorted_range_forward(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-2', 0, (2,), False),
- ('rev-1.1.1', 1, (1,1,1), True),
- ], list(the_branch.iter_merge_sorted_revisions(
- start_revision_id='rev-1.1.1', stop_revision_id='rev-1',
- direction='forward')))
+ self.assertRevisions(
+ [('rev-2', 0, (2,), False),
+ ('rev-1.1.1', 1, (1,1,1), True),],
+ start_revision_id='rev-1.1.1', stop_revision_id='rev-1',
+ direction='forward')
def test_merge_sorted_range_start_only_forward(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-1', 0, (1,), True),
- ('rev-2', 0, (2,), False),
- ('rev-1.1.1', 1, (1,1,1), True),
- ], list(the_branch.iter_merge_sorted_revisions(
- start_revision_id='rev-1.1.1', direction='forward')))
+ self.assertRevisions(
+ [('rev-1', 0, (1,), True),
+ ('rev-2', 0, (2,), False),
+ ('rev-1.1.1', 1, (1,1,1), True),],
+ start_revision_id='rev-1.1.1', direction='forward')
def test_merge_sorted_range_stop_exclude_forward(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-2', 0, (2,), False),
- ('rev-1.1.1', 1, (1,1,1), True),
- ('rev-3', 0, (3,), False),
- ], list(the_branch.iter_merge_sorted_revisions(
- stop_revision_id='rev-1', direction='forward')))
+ self.assertRevisions(
+ [('rev-2', 0, (2,), False),
+ ('rev-1.1.1', 1, (1,1,1), True),
+ ('rev-3', 0, (3,), False),],
+ stop_revision_id='rev-1', direction='forward')
def test_merge_sorted_range_stop_include_forward(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-2', 0, (2,), False),
- ('rev-1.1.1', 1, (1,1,1), True),
- ('rev-3', 0, (3,), False),
- ], list(the_branch.iter_merge_sorted_revisions(
- stop_revision_id='rev-2', stop_rule='include',
- direction='forward')))
+ self.assertRevisions(
+ [('rev-2', 0, (2,), False),
+ ('rev-1.1.1', 1, (1,1,1), True),
+ ('rev-3', 0, (3,), False),],
+ stop_revision_id='rev-2', stop_rule='include', direction='forward')
def test_merge_sorted_range_stop_with_merges_forward(self):
- tree = self.create_tree_with_merge()
- the_branch = tree.bzrdir.open_branch()
- self.assertEqual([
- ('rev-1.1.1', 1, (1,1,1), True),
- ('rev-3', 0, (3,), False),
- ], list(the_branch.iter_merge_sorted_revisions(
- stop_revision_id='rev-3', stop_rule='with-merges',
- direction='forward')))
+ self.assertRevisions(
+ [('rev-1.1.1', 1, (1,1,1), True),
+ ('rev-3', 0, (3,), False),],
+ stop_revision_id='rev-3', stop_rule='with-merges',
+ direction='forward')
More information about the bazaar-commits
mailing list