[PATCH] bookmarks: recognize the current bookmark when the local encoding isn't UTF-8

LUO Zheng xmuluo at gmail.com
Wed Jun 8 08:29:45 CDT 2011


# HG changeset patch
# User LUO Zheng <xmuluo at gmail.com>
# Date 1307539518 -28800
# Node ID 4b424f28ab98f2277ca7841dc382656cb27e25e6
# Parent  48ec0763afbbbbb4802fb836ae75256e82e5609c
bookmarks: recognize the current bookmark when the local encoding isn't UTF-8

The current bookmark is stored in bookmark.current, supposingly in UTF-8.
But the call to encoding.fromlocal() is missing, therefore Hg is not able
to recognize the current bookmark in the case that bookmark uses
characters of which the bit stream is different between local encoding
and UTF-8.
For example, the Chinese version of Windows cmd uses gbk(cp936), not UTF-8.
Therefore I won't be able to make a Chinese bookmark current.

R:\ht>hg bookmark ÊéÇ©

R:\ht>hg bookmarks
   ÊéÇ©                      0:1ed88cb32260

By wrapping mark in a encoding.fromlocal() call, the problem is solved.

diff -r 48ec0763afbb -r 4b424f28ab98 mercurial/bookmarks.py
--- a/mercurial/bookmarks.py	Tue Jun 07 17:02:54 2011 -0500
+++ b/mercurial/bookmarks.py	Wed Jun 08 21:25:18 2011 +0800
@@ -114,7 +114,7 @@
     wlock = repo.wlock()
     try:
         file = repo.opener('bookmarks.current', 'w', atomictemp=True)
-        file.write(mark)
+        file.write(encoding.fromlocal(mark))
         file.rename()
     finally:
         wlock.release()


More information about the Mercurial-devel mailing list