[PATCH 1 of 6] decode and encode text in UTF-8

Andrey grooz-work at gorodok.net
Sun Nov 12 17:49:24 UTC 2006


# HG changeset patch
# User Andrey <grooz at gorodok.net>
# Date 1163269770 -21600
# Node ID 69bafd28ba10981bfc4cb2648a48aad2545fbe70
# Parent  adbf440a81e07f82f5cb1de61ab2931fe920a80b
decode and encode text in UTF-8

diff -r adbf440a81e0 -r 69bafd28ba10 mercurial/changelog.py
--- a/mercurial/changelog.py	Thu Nov 09 14:44:17 2006 -0800
+++ b/mercurial/changelog.py	Sun Nov 12 00:29:30 2006 +0600
@@ -9,6 +9,8 @@ from i18n import gettext as _
 from i18n import gettext as _
 from demandload import demandload
 demandload(globals(), "os time util")
+
+CHANGELOG_ENCODING='UTF-8'
 
 def _string_escape(text):
     """
@@ -60,6 +62,7 @@ class changelog(revlog):
         """
         if not text:
             return (nullid, "", (0, 0), [], "", {})
+        text = unicode(text, CHANGELOG_ENCODING)
         last = text.index("\n\n")
         desc = text[last + 2:]
         l = text[:last].split('\n')
@@ -98,4 +101,4 @@ class changelog(revlog):
         list.sort()
         l = [hex(manifest), user, parseddate] + list + ["", desc]
         text = "\n".join(l)
-        return self.addrevision(text, transaction, self.count(), p1, p2)
+        return self.addrevision(text.encode(CHANGELOG_ENCODING), transaction, self.count(), p1, p2)



More information about the Mercurial-devel mailing list