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

Martin Pool mbp at canonical.com
Tue Jul 17 04:53:42 BST 2007


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

+        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.  It should ask for a diff already encoded to bytes, and
just put that into the commit template.  At any rate I would be ok to
bring that in as a first version of this feature.


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



More information about the bazaar mailing list