Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

hglib: bypass encoding conversion for None

We sometimes use None for special case for string value.

Changeset b08681105532

Parent 15e45503d567

by Yuya Nishihara

Changes to one file · Browse files at b08681105532 Showing diff from parent 15e45503d567 Diff from another changeset...

 
28
29
30
 
 
31
32
33
 
46
47
48
 
 
49
50
51
 
61
62
63
 
 
64
65
66
 
69
70
71
 
 
72
73
74
 
28
29
30
31
32
33
34
35
 
48
49
50
51
52
53
54
55
 
65
66
67
68
69
70
71
72
 
75
76
77
78
79
80
81
82
@@ -28,6 +28,8 @@
  Based on mercurial.util.tolocal().   Return 'unicode' type string.   """ + if s is None: + return None   if isinstance(s, unicode):   return s   for e in ('utf-8', _encoding): @@ -46,6 +48,8 @@
  If you don't want an exception for conversion failure,   specify errors='replace'.   """ + if s is None: + return None   s = unicode(s) # s can be QtCore.QString   for enc in (_encoding, _fallbackencoding):   try: @@ -61,6 +65,8 @@
    Return 'str' type string.   """ + if s is None: + return None   return tounicode(s).encode('utf-8').replace('\0','')    def fromutf(s): @@ -69,6 +75,8 @@
    Return 'str' type string.   """ + if s is None: + return None   try:   return s.decode('utf-8').encode(_encoding)   except (UnicodeDecodeError, UnicodeEncodeError):