[MERGE][Take three] Show the diff in the commit messages

Goffredo Baroncelli kreijack at tiscalinet.it
Tue Jul 17 18:23:51 BST 2007


On Tuesday 17 July 2007, Martin Pool wrote:
> Martin Pool has voted -1.
> Status is now: Vetoed
> Comment:
> Thankyou for updating this Goffredo,
> 
>   def edit_commit_message(infotext, ignoreline=DEFAULT_IGNORE_LINE,
> -                        start_message=None):
> +                        start_message=None, 
> user_encoding=bzrlib.user_encoding):
>       """Let the user edit a commit message in a temp file.
> 
> Putting variables into the default parameters is not a good idea because
> the value is saved at the time the function is defined.  It's better to
> say user_encoding=None, then inside the function
> 
> I would probably call those parameters 'output_encoding' or something,
> just to be clear that they're not necessarily the same as the global
> variable output_encoding.
> 
>    if user_encoding is None:
>      user_encoding = bzrlib.user_encoding
Ok, I tought that the values was evaluated at the interpretation time and not 
at the definition time...

>      >  
> +        stream.seek(0,0)
> +        for l in stream.readlines():
> +            if ( l.startswith("===") or l.startswith("---") or
> +                 l.startswith("+++") ):
> +                    # the header are utf8 encoded
> +                    status_tmp.write(l.decode("utf8","replace"))
> +            else:
> +                    status_tmp.write(l.decode(user_encoding, 
> "replace"))
> 
> Parsing out the diff really does not seem like a good idea to me either.
> 
> Given John's message, I'm not sure what encoding we should be using for
> the diff.  But I am pretty sure that it's not the job of the commit code
> to rewrite it.  
[...]
>  At any rate I would be ok to
> bring that in as a first version of this feature.
I updated my patch


> It should ask for a diff already encoded to bytes, and 
> just put that into the commit template.
The diff is generated both on the basis of the file contents ( which is 8-bit 
data ) and on the basis of the repository metadata (which are unicode).
Assuming that during the IO operation python encode the file path as the user 
encoding [*], a possible solution is to encode the file path in the diff code 
in the user encoding. Instead now the encoding is UTF8.

> 
> 
> For details, see: 
> 
http://bundlebuggy.aaronbentley.com/request/%3C200707162159.31326.kreijack%40tiscalinet.it%3E
> 
> 


[*] http://www.amk.ca/python/howto/unicode, section "Unicode filenames"
-- 
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack at inwind.it>
Key fingerprint = CE3C 7E01 6782 30A3 5B87  87C0 BB86 505C 6B2A CFF9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bzr-ci-diff.bundle.diff
Type: text/x-diff
Size: 58585 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070717/3f0dc535/attachment-0001.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070717/3f0dc535/attachment-0001.pgp 


More information about the bazaar mailing list