Merge lp:~gioele/bzr/forgot-commit-message into lp:bzr

Proposed by Gioele Barabucci
Status: Merged
Merged at revision: not available
Proposed branch: lp:~gioele/bzr/forgot-commit-message
Merge into: lp:bzr
Diff against target: 37 lines (+16/-0)
2 files modified
bzrlib/builtins.py (+8/-0)
bzrlib/tests/blackbox/test_commit.py (+8/-0)
To merge this branch: bzr merge lp:~gioele/bzr/forgot-commit-message
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Ian Clatworthy Approve
John A Meinel Needs Information
Review via email: mp+14985@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Gioele Barabucci (gioele) wrote :

This patch adds a check to the commit command to catch the common mistake of passing a file name instead of a commit message to the '-m' option.

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

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

Gioele Barabucci wrote:
> Gioele Barabucci has proposed merging lp:~gioele/bzr/forgot-commit-message into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> #73073 warn when commit -m argument is omitted
> https://bugs.launchpad.net/bugs/73073
>
>
> This patch adds a check to the commit command to catch the common mistake of passing a file name instead of a commit message to the '-m' option.
>

So *I* would prefer if this would only warn and not actually prompt. A
user can generally "bzr uncommit" if they have a problem.

The main issue that comes to mind is that something like 'qcommit' will
fail if you gave the commit the same message as a filename. As it will
spawn commit under-the-covers which may block waiting for user input. I
see you do handle if they have a ui_factory that doesn't allow a boolean
to be requested.

Given that the only interactive commands are:

1) shelve
2) uncommit, which has had pretty much unanimous support for removing
the 'y' prompt by default.

Now, we could always have 'commit --interactive' though I think people
would expect that to also prompt for hunk-by-hunk changes that you chose
whether or not you actually want to commit.

I'm not going to block this if someone else really wants this, but I
don't prefer it.

John
=:->

 review: abstain

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

iEYEARECAAYFAksEB34ACgkQJdeBCYSNAANykACgx8GTxpJ+U0pknx0DWB+NwRYk
vBoAoJkVSV5DO5CK1T+tZGk5CuPCHEtv
=b3iI
-----END PGP SIGNATURE-----

review: Abstain
Revision history for this message
Martin Pool (mbp) wrote :

2009/11/19 John A Meinel <email address hidden>:
> Review: Abstain
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Gioele Barabucci wrote:
>> Gioele Barabucci has proposed merging lp:~gioele/bzr/forgot-commit-message into lp:bzr.
>>
>>     Requested reviews:
>>     bzr-core (bzr-core)
>> Related bugs:
>>   #73073 warn when commit -m argument is omitted
>>   https://bugs.launchpad.net/bugs/73073
>>
>>
>> This patch adds a check to the commit command to catch the common mistake of passing a file name instead of a commit message to the '-m' option.
>>
>
> So *I* would prefer if this would only warn and not actually prompt. A
> user can generally "bzr uncommit" if they have a problem.

I agree.

Also, can I suggest you please put both lines in one call to
ui_factory.warning, with a \n? For the current textui it makes no
difference, but if it was displayed in eg a dialog box it is obviously
just one logical warning.

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Gioele Barabucci (gioele) wrote :

> 2009/11/19 John A Meinel <email address hidden>:
> Also, can I suggest you please put both lines in one call to
> ui_factory.warning, with a \n? For the current textui it makes no
> difference, but if it was displayed in eg a dialog box it is obviously
> just one logical warning.
Done.

Revision history for this message
Gioele Barabucci (gioele) wrote :

> So *I* would prefer if this would only warn and not actually prompt. A
> user can generally "bzr uncommit" if they have a problem.

People on the mailing list have pointed out that there could be problems with that approach.

For example Jelmer Vernooij commented
    FWIW bzr-svn does support uncommit, the main issue would be
    that Subversion still shows the original commit with the typo
    when running "svn log" on the repository root.

> The main issue that comes to mind is that something like 'qcommit' will
> fail if you gave the commit the same message as a filename. As it will
> spawn commit under-the-covers which may block waiting for user input.

Doesn't qcommit provide a new ui_factory implementation that overrides the textual ui interface? A correctly implemented qbzr ui_factory should show you a graphical warning message with the same GUI used by qcommit. Or did I misunderstand the purpose of UIFactory?

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

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

Gioele Barabucci wrote:
>> So *I* would prefer if this would only warn and not actually prompt. A
>> user can generally "bzr uncommit" if they have a problem.
>
> People on the mailing list have pointed out that there could be problems with that approach.
>
> For example Jelmer Vernooij commented
> FWIW bzr-svn does support uncommit, the main issue would be
> that Subversion still shows the original commit with the typo
> when running "svn log" on the repository root.
>
>
>> The main issue that comes to mind is that something like 'qcommit' will
>> fail if you gave the commit the same message as a filename. As it will
>> spawn commit under-the-covers which may block waiting for user input.
>
> Doesn't qcommit provide a new ui_factory implementation that overrides the textual ui interface? A correctly implemented qbzr ui_factory should show you a graphical warning message with the same GUI used by qcommit. Or did I misunderstand the purpose of UIFactory?

I still would prefer a warning to a prompt. I realize this may have some
implications for bzr-svn, but it doesn't for bzr-hg and bzr-git. I'd
rather not become interactive for the least-common-denominator here. We
can revisit it later, but I don't think bzr-svn is sufficient to cause
all 'bzr commit' actions to become potentially interactive. (Hang in
scripts, etc.)

John
=:->

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

iEYEARECAAYFAksFYGcACgkQJdeBCYSNAAM/fwCglK4KQ1Ib33QTkJmttIA++6Qh
isgAn0xJsusUbOKJbK09iKiB/kc1doTa
=Qc7/
-----END PGP SIGNATURE-----

Revision history for this message
Gioele Barabucci (gioele) wrote :

I implemented your suggestions: now "bzr commit -m a_file" only generates a warning.

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

Do we still need the is_interactive check on this?

I think it is useful to add is_interactive as a general design thing, but I don't see it benefiting us here. (Since you aren't actually prompting anymore.)

review: Needs Information
Revision history for this message
Gioele Barabucci (gioele) wrote :

The default UI factor will not log this warning for non interactive tasks like cron jobs.

If it is OK to print the message without explicitly logging it with trace, then it can be removed.

Isn't is_interactive an useful method anyway? Subject for another branch?

Revision history for this message
Martin Pool (mbp) wrote :

2009/12/3 Gioele Barabucci <email address hidden>:
> The default UI factor will not log this warning for non interactive tasks like cron jobs.
>
> If it is OK to print the message without explicitly logging it with trace, then it can be removed.
>
> Isn't is_interactive an useful method anyway? Subject for another branch?

I think it would be good for another branch. Possibly we actually
want to split this into a separate one, say .wants_confirmations().

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Gioele Barabucci (gioele) wrote :

Changed the patch yet again to emit the warning regardless of the interactivity status.

Revision history for this message
Ian Clatworthy (ian-clatworthy) :
review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

I'll add a NEWS entry and merge.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/builtins.py'
2--- bzrlib/builtins.py 2009-12-03 20:56:18 +0000
3+++ bzrlib/builtins.py 2009-12-04 10:29:12 +0000
4@@ -3069,6 +3069,14 @@
5 if local and not tree.branch.get_bound_location():
6 raise errors.LocalRequiresBoundBranch()
7
8+ if message is not None:
9+ if osutils.lexists(message):
10+ warning_msg = ("The commit message is a file"
11+ " name: \"%(filename)s\".\n"
12+ "(use --file \"%(filename)s\" to take commit message from"
13+ " that file)" % { 'filename': message })
14+ ui.ui_factory.show_warning(warning_msg)
15+
16 def get_message(commit_obj):
17 """Callback to get commit message"""
18 my_message = message
19
20=== modified file 'bzrlib/tests/blackbox/test_commit.py'
21--- bzrlib/tests/blackbox/test_commit.py 2009-11-19 06:28:13 +0000
22+++ bzrlib/tests/blackbox/test_commit.py 2009-12-04 10:29:12 +0000
23@@ -107,6 +107,14 @@
24 'modified hello\.txt\n'
25 'Committed revision 2\.\n$')
26
27+ def test_warn_about_forgotten_commit_message(self):
28+ """Test that the lack of -m parameter is caught"""
29+ wt = self.make_branch_and_tree('.')
30+ self.build_tree(['one', 'two'])
31+ wt.add(['two'])
32+ out, err = self.run_bzr('commit -m one two')
33+ self.assertContainsRe(err, "The commit message is a file name")
34+
35 def test_verbose_commit_renamed(self):
36 # Verbose commit of renamed file should say so
37 wt = self.prepare_simple_history()