Mercurial > hgsubversion
comparison util.py @ 249:a065bf61caa1
encoding: fix encoding swap to work with demandimport enabled (#67)
| author | Daniel Tang <dytang@cs.purdue.edu> |
|---|---|
| date | Fri, 10 Apr 2009 15:43:47 -0500 |
| parents | 330f0b15d417 |
| children | 79349fd04836 |
comparison
equal
deleted
inserted
replaced
| 248:a9134fa28d15 | 249:a065bf61caa1 |
|---|---|
| 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 | |
| 11 | 7 |
| 12 svn_subcommands = { } | 8 svn_subcommands = { } |
| 13 def register_subcommand(name): | 9 def register_subcommand(name): |
| 14 def inner(fn): | 10 def inner(fn): |
| 15 svn_subcommands[name] = fn | 11 svn_subcommands[name] = fn |
| 141 ui.note(' committed to "%s" as %s\n' % ((b or 'default'), node.short(h))) | 137 ui.note(' committed to "%s" as %s\n' % ((b or 'default'), node.short(h))) |
| 142 | 138 |
| 143 | 139 |
| 144 def swap_out_encoding(new_encoding="UTF-8"): | 140 def swap_out_encoding(new_encoding="UTF-8"): |
| 145 """ Utility for mercurial incompatibility changes, can be removed after 1.3""" | 141 """ Utility for mercurial incompatibility changes, can be removed after 1.3""" |
| 146 if encoding is None: | 142 try: |
| 143 from mercurial import encoding | |
| 144 old = encoding.encoding | |
| 145 encoding.encoding = new_encoding | |
| 146 except ImportError: | |
| 147 old = util._encoding | 147 old = util._encoding |
| 148 util._encoding = new_encoding | 148 util._encoding = new_encoding |
| 149 else: | |
| 150 old = encoding.encoding | |
| 151 encoding.encoding = new_encoding | |
| 152 return old | 149 return old |
