[PATCH 6 of 6] changed logmessage() to encode/decode commit messages properly

Andrey grooz-work at gorodok.net
Sun Nov 12 11:49:29 CST 2006


# HG changeset patch
# User Andrey <grooz-work at gorodok.net>
# Date 1163353873 -21600
# Node ID c936fe25df64ff4f4cee1cf9d372550f9a5d0477
# Parent  8f8a0670762c144c809904f50a3f8cdc1a012568
changed logmessage() to encode/decode commit messages properly

diff -r 8f8a0670762c -r c936fe25df64 hgext/fetch.py
--- a/hgext/fetch.py	Sun Nov 12 22:28:53 2006 +0600
+++ b/hgext/fetch.py	Sun Nov 12 23:51:13 2006 +0600
@@ -43,7 +43,7 @@ def fetch(ui, repo, source='default', **
                       (len(newheads) - 1))
         if not err:
             mod, add, rem = repo.status(wlock=wlock)[:3]
-            message = (commands.logmessage(opts) or
+            message = (commands.logmessage(opts, ui) or
                        (_('Automated merge with %s') % other.url()))
             n = repo.commit(mod + add + rem, message,
                             opts['user'], opts['date'], lock=lock, wlock=wlock,
diff -r 8f8a0670762c -r c936fe25df64 hgext/mq.py
--- a/hgext/mq.py	Sun Nov 12 22:28:53 2006 +0600
+++ b/hgext/mq.py	Sun Nov 12 23:51:13 2006 +0600
@@ -1551,7 +1551,7 @@ def new(ui, repo, patch, **opts):
     If none is specified, the patch header is empty and the
     commit message is 'New patch: PATCH'"""
     q = repo.mq
-    message = commands.logmessage(opts)
+    message = commands.logmessage(opts, ui)
     if opts['edit']:
         message = ui.edit(message, ui.username())
     q.new(repo, patch, msg=message, force=opts['force'])
@@ -1566,7 +1566,7 @@ def refresh(ui, repo, *pats, **opts):
     will remain in the working directory.
     """
     q = repo.mq
-    message = commands.logmessage(opts)
+    message = commands.logmessage(opts, ui)
     if opts['edit']:
         if message:
             raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
@@ -1602,7 +1602,7 @@ def fold(ui, repo, *files, **opts):
     if not q.check_toppatch(repo):
         raise util.Abort(_('No patches applied'))
 
-    message = commands.logmessage(opts)
+    message = commands.logmessage(opts, ui)
     if opts['edit']:
         if message:
             raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
@@ -1826,7 +1826,7 @@ def save(ui, repo, **opts):
 def save(ui, repo, **opts):
     """save current queue state"""
     q = repo.mq
-    message = commands.logmessage(opts)
+    message = commands.logmessage(opts, ui)
     ret = q.save(repo, msg=message)
     if ret:
         return ret
diff -r 8f8a0670762c -r c936fe25df64 mercurial/commands.py
--- a/mercurial/commands.py	Sun Nov 12 22:28:53 2006 +0600
+++ b/mercurial/commands.py	Sun Nov 12 23:51:13 2006 +0600
@@ -31,9 +31,9 @@ def relpath(repo, args):
         return [util.normpath(os.path.join(cwd, x)) for x in args]
     return args
 
-def logmessage(opts):
+def logmessage(opts, ui):
     """ get the log message according to -m and -l option """
-    message = opts['message']
+    message = ui.decode(opts['message'])
     logfile = opts['logfile']
 
     if message and logfile:
@@ -42,9 +42,9 @@ def logmessage(opts):
     if not message and logfile:
         try:
             if logfile == '-':
-                message = sys.stdin.read()
+                message = ui.decode(sys.stdin.read(), 'stdio')
             else:
-                message = open(logfile).read()
+                message = ui.decode(open(logfile).read())
         except IOError, inst:
             raise util.Abort(_("can't read commit message '%s': %s") %
                              (logfile, inst.strerror))
@@ -937,7 +937,7 @@ def commit(ui, repo, *pats, **opts):
     If no commit message is specified, the editor configured in your hgrc
     or in the EDITOR environment variable is started to enter a message.
     """
-    message = logmessage(opts)
+    message = logmessage(opts, ui)
 
     if opts['addremove']:
         cmdutil.addremove(repo, pats, opts)


More information about the Mercurial-devel mailing list