[MERGE] Defer prompting for commit message until commit is mostly done [was: Fix commit --strict regression]

Aaron Bentley aaron.bentley at utoronto.ca
Mon Nov 27 16:18:41 GMT 2006

Hash: SHA1

Robert Collins wrote:

> Specifically, I dont think we want to deprecate the 'message'
> parameter to commit : its just too useful as a direct library api

I disagree.  There's very little it can do that mutabletree.commit
can't, and AFAIK, no one uses it directly except baz-import.  Still,
I'll revert the deprecation as I don't feel strongly about it.

> - and the friction is clear where you have mutabletree having to adapt the interface.

I don't see that.  I see a nice, convenient high-level interface and a
simple low-level interface, and that seems like the right approach to me.

> I wonder if we can make commit faster with this patch as well - 
> make_commit_message_template does a status, which is now unneeded
> as commit knows what files it has found as altered. That is a
> different change and can be done as a separate step if needed.

We could make the callback take the commit builder as a parameter, for
now.  Does that make sense to you?

> Lastly, I think the callback should be defined as 'must return unicode',

Sure, that makes sense.

> and that way we can put the onus on decoding etc to the supplier of
> the callback, and change the logic for upcasting the message parameter
> to use 'osutils.safe_unicode'.

I'm not sure what you're saying.

I would be happy with "callback must return unicode".  But
osutils.safe_unicode also does conversion from utf-8 to unicode.  So
this would suggest that the callback may return utf-8 as well as unicode.

The current API says that if a message is supplied as a string, it's in
the user encoding.

So if I change it to use safe_unicode, I think we get
1. callback must be unicode or utf-8
2. message must be unicode or user_encoding.

I think that's a confusing API.  It's regrettable that Commit cares
about the user_encoding.  The obvious way to fix it is to provide a
'utf8_encoded' parameter and emit a deprecation warning if it's not True.

But essentially everything in the test suite calls commit with a string
parameter, so that would mean changing the whole test suite. I don't
think it's worth it.

So I propose avoiding the safe_unicode, and just asserting that the
commit callback result is unicode, which means the rules are:
1. callback must return unicode
2. message must be unicode or user_encoding.

Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: commit-callback-2.patch
Type: text/x-patch
Size: 25239 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061127/0d76ddf5/attachment.bin 

More information about the bazaar mailing list