diff util.py @ 223:330f0b15d417

issue67: mercurial 1.3 util incompatibility with encoding swap
author Luke Opperman <luke@loppear.com>
date Tue, 07 Apr 2009 13:30:05 -0500
parents ced45b753ba7
children a065bf61caa1
line wrap: on
line diff
--- a/util.py
+++ b/util.py
@@ -4,6 +4,10 @@ import shutil
 from mercurial import hg
 from mercurial import node
 from mercurial import util
+try:
+    from mercurial import encoding
+except ImportError:
+    encoding = None
 
 svn_subcommands = { }
 def register_subcommand(name):
@@ -135,3 +139,14 @@ def describe_revision(ui, r):
 
 def describe_commit(ui, h, b):
     ui.note(' committed to "%s" as %s\n' % ((b or 'default'), node.short(h)))
+
+
+def swap_out_encoding(new_encoding="UTF-8"):
+    """ Utility for mercurial incompatibility changes, can be removed after 1.3"""
+    if encoding is None:
+        old = util._encoding
+        util._encoding = new_encoding
+    else:
+        old = encoding.encoding
+        encoding.encoding = new_encoding
+    return old