Rev 2246: bzr annotate should use Branch's dotted revnos. in http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/annotate_revnos
John Arbash Meinel
john at arbash-meinel.com
Mon Jan 29 21:11:34 GMT 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/annotate_revnos
------------------------------------------------------------
revno: 2246
revision-id: john at arbash-meinel.com-20070129211128-hg0myfxd22jwg38t
parent: pqm at pqm.ubuntu.com-20070125194626-4ded330415b7276d
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: annotate_revnos
timestamp: Mon 2007-01-29 15:11:28 -0600
message:
bzr annotate should use Branch's dotted revnos.
Not the dotted revnos from the last modification of the file.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/annotate.py annotate.py-20050922133147-7c60541d2614f022
bzrlib/tests/test_annotate.py test_annotate.py-20061213215015-sttc9agsxomls7q0-1
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2007-01-24 19:42:26 +0000
+++ b/NEWS 2007-01-29 21:11:28 +0000
@@ -27,6 +27,10 @@
BUGFIXES:
+ * ``bzr annotate`` now uses dotted revnos from the viewpoint of the
+ branch, rather than the last changed revision of the file.
+ (John Arbash Meinel, #82158)
+
TESTING:
* New ``--first`` option to ``bzr selftest`` to run specified tests
=== modified file 'bzrlib/annotate.py'
--- a/bzrlib/annotate.py 2006-12-17 18:57:05 +0000
+++ b/bzrlib/annotate.py 2007-01-29 21:11:28 +0000
@@ -83,7 +83,7 @@
prevanno=anno
-def _annotate_file(branch, rev_id, file_id ):
+def _annotate_file(branch, rev_id, file_id):
"""Yield the origins for each line of a file.
This includes detailed information, such as the committer name, and
@@ -91,10 +91,11 @@
"""
rh = branch.revision_history()
- revision_graph = branch.repository.get_revision_graph(rev_id)
+ branch_last_revision = branch.last_revision()
+ revision_graph = branch.repository.get_revision_graph(branch_last_revision)
merge_sorted_revisions = tsort.merge_sort(
revision_graph,
- rev_id,
+ branch_last_revision,
None,
generate_revno=True)
revision_id_to_revno = dict((rev_id, revno)
=== modified file 'bzrlib/tests/test_annotate.py'
--- a/bzrlib/tests/test_annotate.py 2006-12-17 18:57:05 +0000
+++ b/bzrlib/tests/test_annotate.py 2007-01-29 21:11:28 +0000
@@ -101,6 +101,17 @@
class TestAnnotate(tests.TestCaseWithTransport):
def create_merged_trees(self):
+ """create 2 trees with merges between them.
+
+ rev-1 --+
+ | |
+ rev-2 rev-1_1_1
+ | |
+ +------+
+ |
+ rev-3
+ """
+
tree1 = self.make_branch_and_tree('tree1')
self.build_tree_contents([('tree1/a', 'first\n')])
tree1.add(['a'], ['a-id'])
@@ -132,11 +143,33 @@
return tree1, tree2
def create_deeply_merged_trees(self):
+ """Create some trees with a more complex merge history.
+
+ rev-1 --+
+ | |
+ rev-2 rev-1_1_1 --+
+ | | |
+ +------+ |
+ | | |
+ rev-3 rev-1_1_2 rev-1_1_1_1_1 --+
+ | | | |
+ +------+ | |
+ | | |
+ rev-4 rev-1_1_1_1_2 rev-1_1_1_1_1_1_1
+ | | |
+ +-----------------+ |
+ | |
+ rev-5 |
+ | |
+ +--------------------------------+
+ |
+ rev-6
+ """
tree1, tree2 = self.create_merged_trees()
tree3 = tree2.bzrdir.clone('tree3').open_workingtree()
- tree2.commit('noop', rev_id='rev-1.1.2')
+ tree2.commit('noop', rev_id='rev-1_1_2')
self.assertEqual(0, tree1.merge_from_branch(tree2.branch))
tree1.commit('noop merge', rev_id='rev-4')
@@ -147,7 +180,7 @@
tree4 = tree3.bzrdir.clone('tree4').open_workingtree()
- tree3.commit('noop', rev_id='rev-1.1.1.1.2',
+ tree3.commit('noop', rev_id='rev-1_1_1_1_2',
committer='jerry at foo.com',
timestamp=1166046004.00, timezone=0)
self.assertEqual(0, tree1.merge_from_branch(tree3.branch))
@@ -221,7 +254,25 @@
'1.1.1.1.1.1.1 george at foo.com 20061213 | fifth\n'
'1.1.1.1.1.1.1 george at foo.com 20061213 | sixth\n',
sio.getvalue())
-
+
+ def test_annotate_uses_branch_context(self):
+ """Dotted revnos should use the Branch context.
+
+ When annotating a non-mainline revision, the annotation should still
+ use dotted revnos from the mainline.
+ """
+ tree1 = self.create_deeply_merged_trees()
+
+ sio = StringIO()
+ annotate.annotate_file(tree1.branch, 'rev-1_1_1_1_1_1_1', 'a-id',
+ to_file=sio, verbose=False, full=False)
+ self.assertEqualDiff('1 joe at foo | first\n'
+ '1.1.1 barry at f | third\n'
+ '1.1.1.1.1 jerry at f | fourth\n'
+ '1.1.1.1.1.1> george@ | fifth\n'
+ ' | sixth\n',
+ sio.getvalue())
+
def test_annotate_show_ids(self):
tree1 = self.create_deeply_merged_trees()
More information about the bazaar-commits
mailing list