Rev 5971: (jr) ``bzr annotate`` can be run without setting whoami data first. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Jun 14 09:56:58 UTC 2011


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5971 [merge]
revision-id: pqm at pqm.ubuntu.com-20110614095654-xgw6kju0oxw1gp1z
parent: pqm at pqm.ubuntu.com-20110614080836-d06kod1br6j1rx6j
parent: jriddell at canonical.com-20110614090808-bp4oz123shq8loxk
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2011-06-14 09:56:54 +0000
message:
  (jr) ``bzr annotate`` can be run without setting whoami data first.
   (Jonathan Riddell, LP: #667408) (Jonathan Riddell)
modified:
  bzrlib/annotate.py             annotate.py-20050922133147-7c60541d2614f022
  bzrlib/tests/blackbox/test_ancestry.py test_ancestry.py-20060131142602-6d9524c490537e90
  bzrlib/tests/blackbox/test_annotate.py testannotate.py-20051013044000-457f44801bfa9d39
  bzrlib/tests/per_repository/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
  doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/annotate.py'
--- a/bzrlib/annotate.py	2011-05-03 15:04:00 +0000
+++ b/bzrlib/annotate.py	2011-06-13 09:54:39 +0000
@@ -38,6 +38,7 @@
 from bzrlib import (
     errors,
     osutils,
+    i18n,
     )
 from bzrlib.config import extract_email_address
 from bzrlib.repository import _strip_NULL_ghosts
@@ -104,7 +105,10 @@
         # bugfixes etc.
         current_rev = Revision(CURRENT_REVISION)
         current_rev.parent_ids = tree.get_parent_ids()
-        current_rev.committer = branch.get_config().username()
+        try:
+            current_rev.committer = branch.get_config().username()
+        except errors.NoWhoami:
+            current_rev.committer = i18n.gettext("local user")
         current_rev.message = "?"
         current_rev.timestamp = round(time.time(), 3)
         current_rev.timezone = osutils.local_time_offset()

=== modified file 'bzrlib/tests/blackbox/test_ancestry.py'
--- a/bzrlib/tests/blackbox/test_ancestry.py	2009-08-18 16:53:50 +0000
+++ b/bzrlib/tests/blackbox/test_ancestry.py	2011-06-13 15:16:17 +0000
@@ -17,9 +17,6 @@
 import os
 
 from bzrlib.tests import TestCaseWithTransport
-from bzrlib.workingtree import WorkingTree
-from bzrlib.branch import Branch
-
 
 class TestAncestry(TestCaseWithTransport):
 

=== modified file 'bzrlib/tests/blackbox/test_annotate.py'
--- a/bzrlib/tests/blackbox/test_annotate.py	2011-02-09 08:37:08 +0000
+++ b/bzrlib/tests/blackbox/test_annotate.py	2011-06-13 15:18:27 +0000
@@ -24,9 +24,11 @@
 """
 
 
-from bzrlib import tests
+from bzrlib import (
+    config,
+    tests,
+    )
 
-from bzrlib.config import extract_email_address
 from bzrlib.urlutils import joinpath
 
 
@@ -160,7 +162,6 @@
         tree.add('file')
         tree.commit('add file', committer="test at host", rev_id="rev1")
         self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])
-        tree.branch.get_config().set_user_option('email', 'current at host2')
         return tree
 
     def test_annotate_cmd_revspec_branch(self):
@@ -176,6 +177,7 @@
 
     def test_annotate_edited_file(self):
         tree = self._setup_edited_file()
+        tree.branch.get_config().set_user_option('email', 'current at host2')
         out, err = self.run_bzr('annotate file')
         self.assertEqual(
             '1   test at ho | foo\n'
@@ -183,8 +185,24 @@
             '1   test at ho | gam\n',
             out)
 
+    def test_annotate_edited_file_no_default(self):
+        # Ensure that when no username is available annotate still works.
+        self.overrideEnv('EMAIL', None)
+        self.overrideEnv('BZR_EMAIL', None)
+        # Also, make sure that it's not inferred from mailname.
+        self.overrideAttr(config, '_auto_user_id',
+            lambda: (None, None))
+        tree = self._setup_edited_file()
+        out, err = self.run_bzr('annotate file')
+        self.assertEqual(
+            '1   test at ho | foo\n'
+            '2?  local u | bar\n'
+            '1   test at ho | gam\n',
+            out)
+
     def test_annotate_edited_file_show_ids(self):
         tree = self._setup_edited_file()
+        tree.branch.get_config().set_user_option('email', 'current at host2')
         out, err = self.run_bzr('annotate file --show-ids')
         self.assertEqual(
             '    rev1 | foo\n'
@@ -214,7 +232,7 @@
     def test_annotated_edited_merged_file_revnos(self):
         wt = self._create_merged_file()
         out, err = self.run_bzr(['annotate', 'file'])
-        email = extract_email_address(wt.branch.get_config().username())
+        email = config.extract_email_address(wt.branch.get_config().username())
         self.assertEqual(
             '3?    %-7s | local\n'
             '1     test at ho | foo\n'

=== modified file 'bzrlib/tests/per_repository/test_commit_builder.py'
--- a/bzrlib/tests/per_repository/test_commit_builder.py	2011-05-17 15:19:59 +0000
+++ b/bzrlib/tests/per_repository/test_commit_builder.py	2011-06-13 15:16:17 +0000
@@ -21,7 +21,6 @@
 from bzrlib import (
     config,
     errors,
-    graph,
     inventory,
     osutils,
     repository,

=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt	2011-06-14 08:08:36 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt	2011-06-14 09:56:54 +0000
@@ -37,6 +37,9 @@
 .. Improvements to existing commands, especially improved performance 
    or memory usage, or better results.
 
+* ``bzr annotate`` can be run without setting whoami data first. (Jonathan
+  Riddell, #667408)
+
 Bug Fixes
 *********
 




More information about the bazaar-commits mailing list