--- a/hgext/highlight/highlight.py Fri Apr 03 13:20:52 2009 -0500
+++ b/hgext/highlight/highlight.py Fri Apr 03 14:51:48 2009 -0500
@@ -6,7 +6,7 @@
from mercurial import demandimport
demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__',])
-from mercurial import util
+from mercurial import util, encoding
from mercurial.templatefilters import filters
from pygments import highlight
@@ -30,19 +30,19 @@
return
# avoid UnicodeDecodeError in pygments
- text = util.tolocal(text)
+ text = encoding.tolocal(text)
# To get multi-line strings right, we can't format line-by-line
try:
lexer = guess_lexer_for_filename(fctx.path(), text[:1024],
- encoding=util._encoding)
+ encoding=encoding.encoding)
except (ClassNotFound, ValueError):
try:
- lexer = guess_lexer(text[:1024], encoding=util._encoding)
+ lexer = guess_lexer(text[:1024], encoding=encoding.encoding)
except (ClassNotFound, ValueError):
- lexer = TextLexer(encoding=util._encoding)
+ lexer = TextLexer(encoding=encoding.encoding)
- formatter = HtmlFormatter(style=style, encoding=util._encoding)
+ formatter = HtmlFormatter(style=style, encoding=encoding.encoding)
colorized = highlight(text, lexer, formatter)
# strip wrapping div