Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.4rc2, 0.4rc3, and 0.4rc4

hggtk/vis: dirty hack to import hglib.toutf()

Changeset 7b77b0011641

Parent cb9edf30b6f5

by TK Soh

Changes to one file · Browse files at 7b77b0011641 Showing diff from parent cb9edf30b6f5 Diff from another changeset...

 
13
14
15
 
 
 
 
 
 
 
 
 
 
 
 
 
16
17
18
 
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
42
43
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
46
47
@@ -13,6 +13,19 @@
 from time import (strftime, gmtime)  from mercurial import util   +# FIXME: dirty hack to import toutf() from hggtk.hglib. +# +# Python 2.5's relative imports doesn't seem to work either, +# when running history.py directly. +# +# Besides, we want to be compatible older Python versions. +try: + # when history.py is invoked directly + from hglib import toutf +except ImportError: + # when history.py is imported and called from hgproc.py + from hggtk.hglib import toutf +  # treemodel row enumerated attributes  LINES = 0  NODE = 1 @@ -29,24 +42,6 @@
 MARKED = 12  FGCOLOR = 13   -# FIXME: -# this function is a copy of hglib.touft(), but I've -# trouble importing hglib (resides one dir level above ) -# into this module. -# -# Note: Python 2.5's new import syntax causes problem -# when importing this module from command line. -def toutf(s): - """ - Convert a string to UTF-8 encoding - """ - for e in ('utf-8', util._encoding): - try: - return s.decode(e, 'strict').encode('utf-8') - except UnicodeDecodeError: - pass - return s.decode(util._fallbackencoding, 'replace').encode('utf-8') -  class TreeModel(gtk.GenericTreeModel):     def __init__ (self, repo, graphdata, color_func):