[qt/hgrepoview] try probable encodings rather than just impose one (author, commit msg)

authorAurelien Campeas <aurelien.campeas@logilab.fr>
changeset3db520bf9455
branchdefault
phasepublic
hiddenno
parent revision#60c0dd913f22 merge stable in default
child revision#4017b4155c6a [TUI] phases support (closes #87899)
files modified by this revision
hgviewlib/qt4/hgrepoview.py
# HG changeset patch
# User Aurelien Campeas <aurelien.campeas@logilab.fr>
# Date 1331802976 -3600
# Thu Mar 15 10:16:16 2012 +0100
# Node ID 3db520bf945535f70771baf07fbb42ac41baeb3b
# Parent 60c0dd913f22a569a78a024273c920f03cabc7d6
[qt/hgrepoview] try probable encodings rather than just impose one (author, commit msg)

diff --git a/hgviewlib/qt4/hgrepoview.py b/hgviewlib/qt4/hgrepoview.py
@@ -29,11 +29,11 @@
1  SIGNAL = QtCore.SIGNAL
2  nullvariant = QtCore.QVariant()
3 
4  from hgviewlib.decorators import timeit
5  from hgviewlib.config import HgConfig
6 -from hgviewlib.util import format_desc, xml_escape
7 +from hgviewlib.util import format_desc, xml_escape, tounicode
8  from hgviewlib.qt4 import icon as geticon
9  from hgviewlib.qt4.hgmanifestdialog import ManifestViewer
10  from hgviewlib.qt4.quickbar import QuickBar
11 
12  # Re-Structured Text support
@@ -444,11 +444,11 @@
13                     '<span class="rev_hash">%s</span></td>'\
14                     '\n' % (ctx.rev(), short_hex(ctx.node()))
15 
16          buf += '<td><b>Author:</b>&nbsp;'\
17                 '%s</td>'\
18 -               '\n' %  unicode(ctx.user(), 'utf-8', 'replace')
19 +               '\n' %  tounicode(ctx.user())
20          buf += '<td><b>Branch:</b>&nbsp;%s</td>' % ctx.branch()
21          buf += '</tr>'
22          buf += "</table>\n"
23          buf += "<table width=100%>\n"
24          parents = [p for p in ctx.parents() if p]
@@ -492,11 +492,11 @@
25                         '<a href="%s" class="rev_hash">%s</a>&nbsp;'\
26                         '<span class="short_desc"><i>%s</i></span></td></tr>'\
27                         '\n' % (p.rev(), p.rev(), short, desc)
28 
29          buf += "</table>\n"
30 -        desc = unicode(ctx.description(), 'utf-8', 'replace')
31 +        desc = tounicode(ctx.description())
32          if self.rst_action is not None  and self.rst_action.isChecked():
33              replace = cfg.getFancyReplace()
34              if replace:
35                  desc = replace(desc)
36              desc = rst2html(desc).decode('utf-8')