Mercurial > public > mercurial-scm > hg-stable
diff hgext/highlight/highlight.py @ 7948:de377b1a9a84
move encoding bits from util to encoding
In addition to cleaning up util, this gets rid of some circular dependencies.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 03 Apr 2009 14:51:48 -0500 |
parents | db7557359636 |
children | 7fc30044b514 |
line wrap: on
line diff
--- 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