Merge lp:~abentley/bzr/revision-id-from-committer into lp:bzr/2.2

Proposed by Aaron Bentley on 2010-08-10
Status: Merged
Approved by: Jelmer Vernooij on 2010-08-11
Approved revision: 5072
Merged at revision: 5072
Proposed branch: lp:~abentley/bzr/revision-id-from-committer
Merge into: lp:bzr/2.2
Diff against target: 103 lines (+57/-6)
4 files modified
NEWS (+28/-0)
bzrlib/generate_ids.py (+4/-4)
bzrlib/repository.py (+1/-2)
bzrlib/tests/per_repository/test_commit_builder.py (+24/-0)
To merge this branch: bzr merge lp:~abentley/bzr/revision-id-from-committer
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) 2010-08-10 Approve on 2010-08-11
Review via email: mp+32246@code.launchpad.net

Commit Message

CommitBuilder user committer, not username in revision-id.

Description of the Change

This change fixes bug #614404 by using the committer, rather than the
config.username, to determine the revision id. The provided test ensures that
1. NoWhoami is raised if the committer is not supplied
2. The commit succeeds if the committer is supplied.

I also tweaked the documentation of gen_revision_id to reflect the new
preferred usage.

To post a comment you must log in.
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-08-06 19:16:16 +0000
3+++ NEWS 2010-08-10 19:25:06 +0000
4@@ -5,6 +5,34 @@
5 .. contents:: List of Releases
6 :depth: 1
7
8+bzr 2.2.1
9+#########
10+
11+:Codename: ??
12+:2.2.1: NOT RELEASED YET
13+
14+Compatibility Breaks
15+********************
16+
17+Bug Fixes
18+*********
19+
20+* CommitBuilder now uses the committer instead of _config.username to generate
21+ the revision-id. (Aaron Bentley, #614404)
22+
23+Improvements
24+************
25+
26+Documentation
27+*************
28+
29+
30+API Changes
31+***********
32+
33+Testing
34+*******
35+
36 bzr 2.2
37 #######
38
39
40=== modified file 'bzrlib/generate_ids.py'
41--- bzrlib/generate_ids.py 2009-03-23 14:59:43 +0000
42+++ bzrlib/generate_ids.py 2010-08-10 19:25:06 +0000
43@@ -93,10 +93,10 @@
44 def gen_revision_id(username, timestamp=None):
45 """Return new revision-id.
46
47- :param username: This is the value returned by config.username(), which is
48- typically a real name, followed by an email address. If found, we will
49- use just the email address portion. Otherwise we flatten the real name,
50- and use that.
51+ :param username: The username of the committer, in the format returned by
52+ config.username(). This is typically a real name, followed by an
53+ email address. If found, we will use just the email address portion.
54+ Otherwise we flatten the real name, and use that.
55 :return: A new revision id.
56 """
57 try:
58
59=== modified file 'bzrlib/repository.py'
60--- bzrlib/repository.py 2010-05-25 17:27:52 +0000
61+++ bzrlib/repository.py 2010-08-10 19:25:06 +0000
62@@ -242,8 +242,7 @@
63
64 def _gen_revision_id(self):
65 """Return new revision-id."""
66- return generate_ids.gen_revision_id(self._config.username(),
67- self._timestamp)
68+ return generate_ids.gen_revision_id(self._committer, self._timestamp)
69
70 def _generate_revision_if_needed(self):
71 """Create a revision id if None was supplied.
72
73=== modified file 'bzrlib/tests/per_repository/test_commit_builder.py'
74--- bzrlib/tests/per_repository/test_commit_builder.py 2010-05-11 13:31:31 +0000
75+++ bzrlib/tests/per_repository/test_commit_builder.py 2010-08-10 19:25:06 +0000
76@@ -1303,3 +1303,27 @@
77 self.addCleanup(repo_local.unlock)
78 self.assertRaises(errors.BzrError, repo_local.get_commit_builder,
79 branch, [], branch.get_config())
80+
81+ def test_committer_no_username(self):
82+ # Ensure that when no username is available but a committer is
83+ # supplied, commit works.
84+ del os.environ['EMAIL']
85+ tree = self.make_branch_and_tree(".")
86+ tree.lock_write()
87+ try:
88+ # Make sure no username is available.
89+ self.assertRaises(errors.NoWhoami, tree.branch.get_commit_builder,
90+ [])
91+ builder = tree.branch.get_commit_builder(
92+ [], committer='me@example.com')
93+ try:
94+ list(builder.record_iter_changes(tree, tree.last_revision(),
95+ tree.iter_changes(tree.basis_tree())))
96+ builder.finish_inventory()
97+ except:
98+ builder.abort()
99+ raise
100+ repo = tree.branch.repository
101+ repo.commit_write_group()
102+ finally:
103+ tree.unlock()

Subscribers

People subscribed via source and target branches