[Svnmerge] Encoding problem in svnmerge commit message file

Romulo A. Ceccon romuloceccon at gmail.com
Fri Dec 7 08:56:47 PST 2007


Raman,

On Dec 6, 2007 11:14 PM, Raman Gupta <rocketraman at fastmail.fm> wrote:
> Basically, what we need to be sure about is which encoding svn commit
> defaults to when it reads log message files, and which python method
> returns that same encoding on every platform.

I found what looks like the correct way to get the encodings used in
the Windows platform: locale.getdefaultlocale()
<http://docs.python.org/lib/module-locale.html>. Below is the new
patch.

Romulo

P.S.: Fot those trying my initial test-case script, svnmergebug.cmd,
please make sure svn and svnmerge are in your path and PATHEXT
contains .PY.


Index: svnmerge.py
===================================================================
--- svnmerge.py (revision 28275)
+++ svnmerge.py (working copy)
@@ -68,7 +68,7 @@
 #  A "target" is generally user-specified, and may be a working copy or
 #  a URL.

-import sys, os, getopt, re, types, tempfile, time, popen2
+import sys, os, getopt, re, types, tempfile, time, popen2, locale
 from bisect import bisect
 from xml.dom import pulldom

@@ -208,6 +208,10 @@
     assert lines[-1] == "\n"
     return prefix + lines[:-1].replace("\n", "\n"+prefix) + "\n"

+def recode_stdout_to_file(s):
+    u = s.decode(sys.stdout.encoding)
+    return u.encode(locale.getdefaultlocale()[1])
+
 class LaunchError(Exception):
     """Signal a failure in execution of an external command. Parameters are the
     exit code of the process, the original command line, and the output of the
@@ -933,7 +937,7 @@
     """Return the log message for a specific integer revision
     number."""
     out = launchsvn("log --incremental -r%d %s" % (revnum, url))
-    return "".join(out[1:])
+    return recode_stdout_to_file("".join(out[1:]))

 def construct_merged_log_message(url, revnums):
     """Return a commit log message containing all the commit messages



More information about the Svnmerge mailing list