Merge lp:~jr/bzr/667408-bzr-blame-no-whoami into lp:bzr

Proposed by Jonathan Riddell
Status: Merged
Approved by: Jonathan Riddell
Approved revision: no longer in the source branch.
Merged at revision: 5971
Proposed branch: lp:~jr/bzr/667408-bzr-blame-no-whoami
Merge into: lp:bzr
Diff against target: 130 lines (+30/-9)
5 files modified
bzrlib/annotate.py (+5/-1)
bzrlib/tests/blackbox/test_ancestry.py (+0/-3)
bzrlib/tests/blackbox/test_annotate.py (+22/-4)
bzrlib/tests/per_repository/test_commit_builder.py (+0/-1)
doc/en/release-notes/bzr-2.4.txt (+3/-0)
To merge this branch: bzr merge lp:~jr/bzr/667408-bzr-blame-no-whoami
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) code Approve
Review via email: mp+64375@code.launchpad.net

Commit message

``bzr annotate`` can be run without setting whoami data first. (Jonathan Riddell, LP: #667408)

Description of the change

simple fix to allow for bzr annotate without whoami being set

Another slightly more generic way to do this might be to alter config.username() to take a allow_no_email paramater that means it returns only the username if it can't find an e-mail.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Thanks, I'm surprised it's as simple as this..

Please merge lp:~jelmer/bzr/667408-bzr-blame-no-whoami which adds a test for this behaviour.

Please add a entry to the release notes.

review: Approve (code)
Revision history for this message
Jonathan Riddell (jr) wrote :

sent to pqm by email

Revision history for this message
Jonathan Riddell (jr) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/annotate.py'
--- bzrlib/annotate.py 2011-05-03 15:04:00 +0000
+++ bzrlib/annotate.py 2011-06-14 09:08:42 +0000
@@ -38,6 +38,7 @@
38from bzrlib import (38from bzrlib import (
39 errors,39 errors,
40 osutils,40 osutils,
41 i18n,
41 )42 )
42from bzrlib.config import extract_email_address43from bzrlib.config import extract_email_address
43from bzrlib.repository import _strip_NULL_ghosts44from bzrlib.repository import _strip_NULL_ghosts
@@ -104,7 +105,10 @@
104 # bugfixes etc.105 # bugfixes etc.
105 current_rev = Revision(CURRENT_REVISION)106 current_rev = Revision(CURRENT_REVISION)
106 current_rev.parent_ids = tree.get_parent_ids()107 current_rev.parent_ids = tree.get_parent_ids()
107 current_rev.committer = branch.get_config().username()108 try:
109 current_rev.committer = branch.get_config().username()
110 except errors.NoWhoami:
111 current_rev.committer = i18n.gettext("local user")
108 current_rev.message = "?"112 current_rev.message = "?"
109 current_rev.timestamp = round(time.time(), 3)113 current_rev.timestamp = round(time.time(), 3)
110 current_rev.timezone = osutils.local_time_offset()114 current_rev.timezone = osutils.local_time_offset()
111115
=== modified file 'bzrlib/tests/blackbox/test_ancestry.py'
--- bzrlib/tests/blackbox/test_ancestry.py 2009-08-18 16:53:50 +0000
+++ bzrlib/tests/blackbox/test_ancestry.py 2011-06-14 09:08:42 +0000
@@ -17,9 +17,6 @@
17import os17import os
1818
19from bzrlib.tests import TestCaseWithTransport19from bzrlib.tests import TestCaseWithTransport
20from bzrlib.workingtree import WorkingTree
21from bzrlib.branch import Branch
22
2320
24class TestAncestry(TestCaseWithTransport):21class TestAncestry(TestCaseWithTransport):
2522
2623
=== modified file 'bzrlib/tests/blackbox/test_annotate.py'
--- bzrlib/tests/blackbox/test_annotate.py 2011-02-09 08:37:08 +0000
+++ bzrlib/tests/blackbox/test_annotate.py 2011-06-14 09:08:42 +0000
@@ -24,9 +24,11 @@
24"""24"""
2525
2626
27from bzrlib import tests27from bzrlib import (
28 config,
29 tests,
30 )
2831
29from bzrlib.config import extract_email_address
30from bzrlib.urlutils import joinpath32from bzrlib.urlutils import joinpath
3133
3234
@@ -160,7 +162,6 @@
160 tree.add('file')162 tree.add('file')
161 tree.commit('add file', committer="test@host", rev_id="rev1")163 tree.commit('add file', committer="test@host", rev_id="rev1")
162 self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])164 self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])
163 tree.branch.get_config().set_user_option('email', 'current@host2')
164 return tree165 return tree
165166
166 def test_annotate_cmd_revspec_branch(self):167 def test_annotate_cmd_revspec_branch(self):
@@ -176,6 +177,7 @@
176177
177 def test_annotate_edited_file(self):178 def test_annotate_edited_file(self):
178 tree = self._setup_edited_file()179 tree = self._setup_edited_file()
180 tree.branch.get_config().set_user_option('email', 'current@host2')
179 out, err = self.run_bzr('annotate file')181 out, err = self.run_bzr('annotate file')
180 self.assertEqual(182 self.assertEqual(
181 '1 test@ho | foo\n'183 '1 test@ho | foo\n'
@@ -183,8 +185,24 @@
183 '1 test@ho | gam\n',185 '1 test@ho | gam\n',
184 out)186 out)
185187
188 def test_annotate_edited_file_no_default(self):
189 # Ensure that when no username is available annotate still works.
190 self.overrideEnv('EMAIL', None)
191 self.overrideEnv('BZR_EMAIL', None)
192 # Also, make sure that it's not inferred from mailname.
193 self.overrideAttr(config, '_auto_user_id',
194 lambda: (None, None))
195 tree = self._setup_edited_file()
196 out, err = self.run_bzr('annotate file')
197 self.assertEqual(
198 '1 test@ho | foo\n'
199 '2? local u | bar\n'
200 '1 test@ho | gam\n',
201 out)
202
186 def test_annotate_edited_file_show_ids(self):203 def test_annotate_edited_file_show_ids(self):
187 tree = self._setup_edited_file()204 tree = self._setup_edited_file()
205 tree.branch.get_config().set_user_option('email', 'current@host2')
188 out, err = self.run_bzr('annotate file --show-ids')206 out, err = self.run_bzr('annotate file --show-ids')
189 self.assertEqual(207 self.assertEqual(
190 ' rev1 | foo\n'208 ' rev1 | foo\n'
@@ -214,7 +232,7 @@
214 def test_annotated_edited_merged_file_revnos(self):232 def test_annotated_edited_merged_file_revnos(self):
215 wt = self._create_merged_file()233 wt = self._create_merged_file()
216 out, err = self.run_bzr(['annotate', 'file'])234 out, err = self.run_bzr(['annotate', 'file'])
217 email = extract_email_address(wt.branch.get_config().username())235 email = config.extract_email_address(wt.branch.get_config().username())
218 self.assertEqual(236 self.assertEqual(
219 '3? %-7s | local\n'237 '3? %-7s | local\n'
220 '1 test@ho | foo\n'238 '1 test@ho | foo\n'
221239
=== modified file 'bzrlib/tests/per_repository/test_commit_builder.py'
--- bzrlib/tests/per_repository/test_commit_builder.py 2011-05-17 15:19:59 +0000
+++ bzrlib/tests/per_repository/test_commit_builder.py 2011-06-14 09:08:42 +0000
@@ -21,7 +21,6 @@
21from bzrlib import (21from bzrlib import (
22 config,22 config,
23 errors,23 errors,
24 graph,
25 inventory,24 inventory,
26 osutils,25 osutils,
27 repository,26 repository,
2827
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- doc/en/release-notes/bzr-2.4.txt 2011-06-14 08:08:36 +0000
+++ doc/en/release-notes/bzr-2.4.txt 2011-06-14 09:08:42 +0000
@@ -37,6 +37,9 @@
37.. Improvements to existing commands, especially improved performance 37.. Improvements to existing commands, especially improved performance
38 or memory usage, or better results.38 or memory usage, or better results.
3939
40* ``bzr annotate`` can be run without setting whoami data first. (Jonathan
41 Riddell, #667408)
42
40Bug Fixes43Bug Fixes
41*********44*********
4245