comparison 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
comparison
equal deleted inserted replaced
222:f2c65dd3d5c0 223:330f0b15d417
2 import shutil 2 import shutil
3 3
4 from mercurial import hg 4 from mercurial import hg
5 from mercurial import node 5 from mercurial import node
6 from mercurial import util 6 from mercurial import util
7 try:
8 from mercurial import encoding
9 except ImportError:
10 encoding = None
7 11
8 svn_subcommands = { } 12 svn_subcommands = { }
9 def register_subcommand(name): 13 def register_subcommand(name):
10 def inner(fn): 14 def inner(fn):
11 svn_subcommands[name] = fn 15 svn_subcommands[name] = fn
133 137
134 ui.status(('[r%d] %s: %s' % (r.revnum, r.author, msg))[:80] + '\n') 138 ui.status(('[r%d] %s: %s' % (r.revnum, r.author, msg))[:80] + '\n')
135 139
136 def describe_commit(ui, h, b): 140 def describe_commit(ui, h, b):
137 ui.note(' committed to "%s" as %s\n' % ((b or 'default'), node.short(h))) 141 ui.note(' committed to "%s" as %s\n' % ((b or 'default'), node.short(h)))
142
143
144 def swap_out_encoding(new_encoding="UTF-8"):
145 """ Utility for mercurial incompatibility changes, can be removed after 1.3"""
146 if encoding is None:
147 old = util._encoding
148 util._encoding = new_encoding
149 else:
150 old = encoding.encoding
151 encoding.encoding = new_encoding
152 return old