# HG changeset patch # User Daniel Tang # Date 1239396227 18000 # Node ID a065bf61caa16e359822727a21a15ac5a3c30f75 # Parent a9134fa28d150d3e40bc4d3df9c04bbda026752e encoding: fix encoding swap to work with demandimport enabled (#67) diff --git a/util.py b/util.py --- a/util.py +++ b/util.py @@ -4,10 +4,6 @@ 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): @@ -143,10 +139,11 @@ def describe_commit(ui, h, b): 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: + try: + from mercurial import encoding old = encoding.encoding encoding.encoding = new_encoding + except ImportError: + old = util._encoding + util._encoding = new_encoding return old