[BUNDLE] save commit messages

Martin Pool mbp at canonical.com
Wed Aug 23 03:56:13 BST 2006

On 22 Aug 2006, John Arbash Meinel <john at arbash-meinel.com> wrote:

> Which brings up other encoding headaches. In that you can right now use
> 'tree.commit(message=X)' to commit any Unicode message you desire. But
> since we are serializing it out to a file, it now is possible that it
> will not fit in user_encoding. So we have to decide what we want to do.
> It seems bogus to fail just because we can't write the Unicode message
> to the file. So we could either not create the file if we can't write it
> correctly, or we could use encode('replace') which changes un-encodable
> characters with '?'.
> Perhaps do a plain encode(), and trap an exception, that you will only
> report if the commit fails, so that the user knows there may be some
> information lost in the commit. This is an edge case, though. So more
> important is that we don't abort the test suite because of user_encoding.
> I believe the current test suite actually depends on this ability under
> Windows, so we will probably see bugs pop up if we don't handle it. At
> the very least, we need to do something, so that

To me it would seem reasonable to use encode(user_encoding, 'replace').
Using a message not representable in your encoding is a bit of an edge
case, and losing those characters is better than losing the whole

I suppose ideally we would get:

  bzr: warning: some characters in commit message are not representable 
     in user encoding 'ascii'

svn allows you to set the encoding used for editing the message to
something different to your default encoding; this seems only slightly
useful but someone could add it someday.  For the moment just replace
would do.

> I'm not sure if it is better to write the temporary file to '.'. Or if
> it would be better to write it to tree.basedir.
> I probably would go for 'tree.basedir' especially when you consider that
> commit might be being called as part of an api, and '.' is somewhere
> completely unrelated.

I think either basedir or even just $TMP, which is what svn does.  In
general we feel OK about writing e.g. merge results into the working

> I think it would be good to say:
> 'Commit message saved. Use bzr commit --file %s to re-use the commit
> message' % (msgfilename,)
> You probably should trap the mkstemp() call, in case the user is in a
> readonly directory.
> There are people who version /etc, and only have .bzr/ as writeable. it
> would be nice if they still could commit there. So maybe we should have
> a 2-level mkstemp call. First try tree.basedir, and if that fails, use
> no pre-specified dir, so that it goes into $TMP.
> Sorry to make this so complex. Unfortunately, that is what we get when
> we chose to support Unicode, even on platforms that are not 100% unicode
> compliant.

That would be good.

Thanks for explaining it so well John.  Metze, if you need tips on
testing any of this just ask on irc or here.  These interactive things
can be tricky.


More information about the bazaar mailing list