[MERGE] Implement lookups into the current working tree for bzr annotate, fixing bug 3439.

John Arbash Meinel john at arbash-meinel.com
Wed Aug 6 21:25:47 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Collins wrote:
| As the topic says, this just tweaks annotate to include unedited changes
| from the working tree, like gannotate does.
|
| -Rob
|

+    def _setup_edited_file(self):
+        """Create a tree with a locally edited file."""
+        tree = self.make_branch_and_tree('.')
+        self.build_tree_contents([('file', 'foo\ngam\n')])
+        tree.add('file')
+        tree.commit('add file', committer="test at host", rev_id="1")
+        self.build_tree_contents([('file', 'foo\nbar\ngam\n')])
+        tree.branch.get_config().set_user_option('email', 'current at host2')
+
+    def test_annotate_edited_file(self):
+        tree = self._setup_edited_file()
+        out, err = self.run_bzr('annotate file')
+        self.assertEqual(
+            '1   test at ho | foo\n'
+            '2?  current | bar\n'
+            '1   test at ho | gam\n',
+            out)
+
+    def test_annotate_edited_file_show_ids(self):
+        tree = self._setup_edited_file()
+        out, err = self.run_bzr('annotate file --show-ids')
+        self.assertEqual(
+            '       1 | foo\n'
+            'current: | bar\n'
+            '       1 | gam\n',
+            out)
+

^- using a revision_id of '1' makes it unclear whether the first case is
showing a revision_id, or a revno.

Also, we should test what happens after a pending merge, lines from the
merge source should be attributed as such. Revno's should probably be
marked as "2.1.1?". That isn't required, though it would be nice.

gannotate just marks it as 'merge', which is ok, though the revision_id
is properly attributed to the right commit.

When I run "bzr annotate bzrlib/tests/blackbox/test_annotate.py" after
merging your patch, I get a:
KeyError: 'robertc at robertcollins.net-20080805054110-9prc026f7yq5iom8'

I assume the problem is that the revision_id_to_revno_map you pulled off
the branch doesn't have the specific revision_id in its ancestry, and
thus dies. You don't have to get super fancy, but we do need it not to
crash when there are pending merges.

You could, I suppose either do the set difference of the
"revision_id_to_revno" and the revision_ids present in the origin. Or
you could just use "revision_id_to_revno.get(rev_id, 'merge')".

Technically, you could fake it with a custom Graph (with
CURRENT:parent_ids put in a _StackedParentProvider). Then the merge
nodes would have revnos (even if they would only be correct if you
actually commit). We could pass that in to
branch.get_revision_id_to_revno_map, or move away from the function to a
different helper.

+
+    # Calculate the lengths of the various columns
+    current_rev = Revision(CURRENT_REVISION)
+    current_rev.parent_ids = tree.get_parent_ids()
+    current_rev.committer = tree.branch.get_config().username()
+    current_rev.message = "?"
+    current_rev.timestamp = round(time.time(), 3)
+    current_rev.timezone = osutils.local_time_offset()

^- The comment here is wrong.


So ultimately, we just need an answer for what to do with nodes assigned
to merge parents the rest seems fine.

BB:tweak

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkiaCMsACgkQJdeBCYSNAAP7kQCguskQFEAVx8q1pcdecqExDzp1
B98AoIpMJ9fLCNPX0Q9Be9FBLfuShBMf
=71H9
-----END PGP SIGNATURE-----



More information about the bazaar mailing list