[RFC] Ask for confirmation if the commit message is a file name

Martin Pool mbp at canonical.com
Thu Nov 12 02:09:59 GMT 2009


2009/11/12 Gioele Barabucci <gioele at svario.it>:
> Hello,
>
> sometimes I mistakenly type "commit -m file1 file2", i.e. I forget to add a
> commit message and bzr uses "file1" as the commit message. With the attached
> tiny patch, bzr will ask the user for a confirmation in cases like that.

That'd be nice to fix, thanks!

I think there may be a bug number for this too.

> This patch lacks a test case. What variation of run_bzr should I use to
> assert "and now a boolean prompt with a text like this should appear"?

A good place to put this would be into
bzrlib.tests.commands.test_commit and the other tests there should
give you an example.

So there is the question of whether this should prompt interactively,
or just fail unless you give --force.  And if you are going to do this
interactively, you need to decide what to do when there is no ui, eg
when running from cron, in which case I think the UIFactory returns
None (check), and you need a more explanatory message than 'commit
aborted.'

> Other code questions:
>  * what is the correct way to abort a command in "peaceful" way?

Raise a BzrCommandError.

>  * is "return 0" OK?

I think you should return non-zero if the commit was not actually made.

>  * are the strings correctly split? I can see that in the code, the inter-
> word space is sometimes kept at the end of a string, other times at the
> start.

I don't think we care.  However, we do normally use doublequotes not
single around filenames.  (Or there was a thread that agreed we
should.)

> Messages questions:
>  * should a strong verb like "abort" be used in the user interface?

'cancel'?

>  * doesn't the forced addition of a "?" to boolean questions create
> problems for future translations in languages where questions are not
> created in that way?

Good point!

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



More information about the bazaar mailing list