Merge lp:~vila/bzr-gtk/1132719-dont-expand-commit-message into lp:bzr-gtk

Proposed by Vincent Ladeuil
Status: Merged
Approved by: John A Meinel
Approved revision: 796
Merge reported by: Vincent Ladeuil
Merged at revision: not available
Proposed branch: lp:~vila/bzr-gtk/1132719-dont-expand-commit-message
Merge into: lp:bzr-gtk
Diff against target: 158 lines (+35/-23)
3 files modified
NEWS (+4/-0)
commitmsgs.py (+4/-3)
tests/test_commit.py (+27/-20)
To merge this branch: bzr merge lp:~vila/bzr-gtk/1132719-dont-expand-commit-message
Reviewer Review Type Date Requested Status
John A Meinel Approve
Richard Wilbur Approve
Jelmer Vernooij (community) Approve
Review via email: mp+150521@code.launchpad.net

Description of the change

This fixes bug #1132719 by not trying to expand config options in commit
messages (global or per-file).

The fix is trivial, the tests are not prettier after the fix but provided
enough support and coverage to fix the bug TDD style ;)

Since the expansion was attempted on the values retrieved in branch.conf,
this should work even for users with existing commit messages.

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

Looks good, thanks!

review: Approve
Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

Good fix for an annoying bug! I'm glad it could be so trivial.

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

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

On 2013-02-26 14:42, Vincent Ladeuil wrote:
> Vincent Ladeuil has proposed merging
> lp:~vila/bzr-gtk/1132719-dont-expand-commit-message into
> lp:bzr-gtk.
>
> Requested reviews: Bazaar GTK maintainers (bzr-gtk) Related bugs:
> Bug #1132719 in Bazaar GTK+ Frontends: "bzr-gtk should not try to
> expand config options where none are expected"
> https://bugs.launchpad.net/bzr-gtk/+bug/1132719
>
> For more details, see:
> https://code.launchpad.net/~vila/bzr-gtk/1132719-dont-expand-commit-message/+merge/150521
>
> This fixes bug #1132719 by not trying to expand config options in
> commit messages (global or per-file).
>
> The fix is trivial, the tests are not prettier after the fix but
> provided enough support and coverage to fix the bug TDD style ;)
>
> Since the expansion was attempted on the values retrieved in
> branch.conf, this should work even for users with existing commit
> messages.
>

 status: approve

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlEvQd4ACgkQJdeBCYSNAAO8rwCeL9T7AoBKxcAWLpJcyRkjn99H
V3IAnRgUMqAST/54JzKvBv7nCOoZqGIC
=Cmuk
-----END PGP SIGNATURE-----

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 2012-07-09 15:23:26 +0000
3+++ NEWS 2013-02-26 10:41:21 +0000
4@@ -13,6 +13,10 @@
5
6 * Fix searching in tree views. (Jelmer Vernooij, #928301)
7
8+ * Don't try to expand options in commit messages. They've been saved from
9+ previous commits and won't ever contain option references.
10+ (Vincent Ladeuil, #1132719)
11+
12 CHANGES
13
14 * bzr-notify has been removed, as it was causing regressions
15
16=== modified file 'commitmsgs.py'
17--- commitmsgs.py 2011-12-20 16:47:38 +0000
18+++ commitmsgs.py 2013-02-26 10:41:21 +0000
19@@ -1,4 +1,4 @@
20-# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
21+# Copyright (C) 2011, 2013 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
22 #
23 # This program is free software; you can redistribute it and/or modify
24 # it under the terms of the GNU General Public License as published by
25@@ -35,10 +35,11 @@
26 else:
27 config = branch.get_config()
28 self.global_message = config.get_user_option(
29- 'gtk_global_commit_message')
30+ 'gtk_global_commit_message', expand=False)
31 if self.global_message is None:
32 self.global_message = u''
33- file_messages = config.get_user_option('gtk_file_commit_messages')
34+ file_messages = config.get_user_option(
35+ 'gtk_file_commit_messages' , expand=False)
36 if file_messages: # unicode and B-encoded:
37 self.file_messages = bencode.bdecode(
38 file_messages.encode('UTF-8'))
39
40=== modified file 'tests/test_commit.py'
41--- tests/test_commit.py 2012-03-22 17:14:22 +0000
42+++ tests/test_commit.py 2013-02-26 10:41:21 +0000
43@@ -1,4 +1,4 @@
44-# Copyright (C) 2007, 2008 John Arbash Meinel <john@arbash-meinel.com>
45+# Copyright (C) 2007, 2008, 2009, 2011, 2012, 2013 John Arbash Meinel <john@arbash-meinel.com>
46 #
47 # This program is free software; you can redistribute it and/or modify
48 # it under the terms of the GNU General Public License as published by
49@@ -1185,8 +1185,10 @@
50 'post_uncommit', commitmsgs.save_commit_messages, None)
51
52 def _get_file_info_dict(self, rank):
53- file_info = [dict(path='a', file_id='a-id', message='a msg %d' % rank),
54- dict(path='b', file_id='b-id', message='b msg %d' % rank)]
55+ file_info = [dict(path='a', file_id='a-id',
56+ message='a {msg} %d' % rank),
57+ dict(path='b', file_id='b-id',
58+ message='b msg %d' % rank)]
59 return file_info
60
61 def _get_file_info_revprops(self, rank):
62@@ -1194,10 +1196,12 @@
63 return {'file-info': bencode.bencode(file_info_prop).decode('UTF-8')}
64
65 def _get_commit_message(self):
66- return self.config.get_user_option('gtk_global_commit_message')
67+ return self.config.get_user_option(
68+ 'gtk_global_commit_message', expand=False)
69
70 def _get_file_commit_messages(self):
71- return self.config.get_user_option('gtk_file_commit_messages')
72+ return self.config.get_user_option(
73+ 'gtk_file_commit_messages', expand=False)
74
75
76 class TestUncommitHook(TestSavedCommitMessages):
77@@ -1219,29 +1223,31 @@
78 def test_uncommit_one_by_one(self):
79 uncommit.uncommit(self.tree.branch, tree=self.tree)
80 self.assertEquals(u'three', self._get_commit_message())
81- self.assertEquals(u'd4:a-id7:a msg 34:b-id7:b msg 3e',
82+ self.assertEquals(u'd4:a-id9:a {msg} 34:b-id7:b msg 3e',
83 self._get_file_commit_messages())
84
85 uncommit.uncommit(self.tree.branch, tree=self.tree)
86 self.assertEquals(u'two\n******\nthree', self._get_commit_message())
87- self.assertEquals(u'd4:a-id22:a msg 2\n******\na msg 3'
88+ self.assertEquals(u'd4:a-id26:a {msg} 2\n******\na {msg} 3'
89 '4:b-id22:b msg 2\n******\nb msg 3e',
90 self._get_file_commit_messages())
91
92 uncommit.uncommit(self.tree.branch, tree=self.tree)
93 self.assertEquals(u'one\n******\ntwo\n******\nthree',
94 self._get_commit_message())
95- self.assertEquals(u'd4:a-id37:a msg 1\n******\na msg 2\n******\na msg 3'
96- '4:b-id37:b msg 1\n******\nb msg 2\n******\nb msg 3e',
97- self._get_file_commit_messages())
98+ self.assertEquals(
99+ u'd4:a-id43:a {msg} 1\n******\na {msg} 2\n******\na {msg} 3'
100+ '4:b-id37:b msg 1\n******\nb msg 2\n******\nb msg 3e',
101+ self._get_file_commit_messages())
102
103 def test_uncommit_all_at_once(self):
104 uncommit.uncommit(self.tree.branch, tree=self.tree, revno=1)
105 self.assertEquals(u'one\n******\ntwo\n******\nthree',
106 self._get_commit_message())
107- self.assertEquals(u'd4:a-id37:a msg 1\n******\na msg 2\n******\na msg 3'
108- '4:b-id37:b msg 1\n******\nb msg 2\n******\nb msg 3e',
109- self._get_file_commit_messages())
110+ self.assertEquals(
111+ u'd4:a-id43:a {msg} 1\n******\na {msg} 2\n******\na {msg} 3'
112+ '4:b-id37:b msg 1\n******\nb msg 2\n******\nb msg 3e',
113+ self._get_file_commit_messages())
114
115
116 class TestReusingSavedCommitMessages(TestSavedCommitMessages, QuestionHelpers):
117@@ -1255,7 +1261,8 @@
118 self.tree.add(['a'], ['a-id'])
119 self.tree.add(['b'], ['b-id'])
120 rev1 = self.tree.commit('one', revprops=self._get_file_info_revprops(1))
121- rev2 = self.tree.commit('two', revprops=self._get_file_info_revprops(2))
122+ rev2 = self.tree.commit('two{x}',
123+ revprops=self._get_file_info_revprops(2))
124 uncommit.uncommit(self.tree.branch, tree=self.tree)
125 self.build_tree_contents([('tree/a', 'new a content\n'),
126 ('tree/b', 'new b content'),])
127@@ -1270,16 +1277,16 @@
128
129 def test_setup_saved_messages(self):
130 # Check the initial setup
131- self.assertEquals(u'two', self._get_commit_message())
132- self.assertEquals(u'd4:a-id7:a msg 24:b-id7:b msg 2e',
133+ self.assertEquals(u'two{x}', self._get_commit_message())
134+ self.assertEquals(u'd4:a-id9:a {msg} 24:b-id7:b msg 2e',
135 self._get_file_commit_messages())
136
137 def test_messages_are_reloaded(self):
138 dlg = self._get_commit_dialog(self.tree)
139- self.assertEquals(u'two', dlg._get_global_commit_message())
140+ self.assertEquals(u'two{x}', dlg._get_global_commit_message())
141 self.assertEquals(([u'a', u'b'],
142 [{ 'path': 'a',
143- 'file_id': 'a-id', 'message': 'a msg 2',},
144+ 'file_id': 'a-id', 'message': 'a {msg} 2',},
145 {'path': 'b',
146 'file_id': 'b-id', 'message': 'b msg 2',}],),
147 dlg._get_specific_files())
148@@ -1294,8 +1301,8 @@
149 dlg = self._get_commit_dialog(self.tree)
150 self._set_question_yes(dlg) # Save messages
151 dlg._do_cancel()
152- self.assertEquals(u'two', self._get_commit_message())
153- self.assertEquals(u'd4:a-id7:a msg 24:b-id7:b msg 2e',
154+ self.assertEquals(u'two{x}', self._get_commit_message())
155+ self.assertEquals(u'd4:a-id9:a {msg} 24:b-id7:b msg 2e',
156 self._get_file_commit_messages())
157
158 def test_messages_are_cleared_on_cancel_if_required(self):

Subscribers

People subscribed via source and target branches

to all changes: