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

Andrey grooz-work at gorodok.net
Mon Nov 20 04:29:58 CST 2006


# HG changeset patch
# User Andrey <grooz-work at gorodok.net>
# Date 1164020121 -21600
# Node ID 73709ef70e679d50117c25b7d632b7d1068ecf7b
# Parent  02aa0b1fd22e78ab0697637cdc840aaccb4c2539
changed logmessage() to encode/decode commit messages properly

diff -r 02aa0b1fd22e -r 73709ef70e67 hgext/fetch.py
--- a/hgext/fetch.py	Mon Nov 20 16:35:24 2006 +0600
+++ b/hgext/fetch.py	Mon Nov 20 16:55:21 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(ui, opts) or
                        (_('Automated merge with %s') % other.url()))
             n = repo.commit(mod + add + rem, message,
                             opts['user'], opts['date'], lock=lock, wlock=wlock,
diff -r 02aa0b1fd22e -r 73709ef70e67 hgext/mq.py
--- a/hgext/mq.py	Mon Nov 20 16:35:24 2006 +0600
+++ b/hgext/mq.py	Mon Nov 20 16:55:21 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(ui, opts)
     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(ui, opts)
     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(ui, opts)
     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(ui, opts)
     ret = q.save(repo, msg=message)
     if ret:
         return ret
diff -r 02aa0b1fd22e -r 73709ef70e67 mercurial/commands.py
--- a/mercurial/commands.py	Mon Nov 20 16:35:24 2006 +0600
+++ b/mercurial/commands.py	Mon Nov 20 16:55:21 2006 +0600
@@ -24,9 +24,9 @@ def bail_if_changed(repo):
     if modified or added or removed or deleted:
         raise util.Abort(_("outstanding uncommitted changes"))
 
-def logmessage(opts):
+def logmessage(ui, opts):
     """ 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:
@@ -35,9 +35,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))
@@ -412,7 +412,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(ui, opts)
 
     if opts['addremove']:
         cmdutil.addremove(repo, pats, opts)
@@ -1754,7 +1754,7 @@ def rawcommit(ui, repo, *pats, **opts):
 
     ui.warn(_("(the rawcommit command is deprecated)\n"))
 
-    message = logmessage(opts)
+    message = logmessage(ui, opts)
 
     files, match, anypats = cmdutil.matchpats(repo, pats, opts)
     if opts['files']:


More information about the Mercurial-devel mailing list