honor the [diff] section of hgrc (closes #20866)

The opts argument in patch.diff appears to exist as of mercurial 0.9.2.

authorDenis Laxalde <denis.laxalde@logilab.fr>
changeset1e90c4932c68
branchdefault
phasepublic
hiddenno
parent revision#ff2553e3e37d Added tag hgview-debian-version-1.7.0-1 for changeset 941c4a14903a
child revision#8666454e29f6 handle various diff header format
files modified by this revision
hgviewlib/hggraph.py
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1353331348 -3600
# Mon Nov 19 14:22:28 2012 +0100
# Node ID 1e90c4932c68779e03147f6ae5708fd4072906b0
# Parent ff2553e3e37de0911e685c78832286166b47509c
honor the [diff] section of hgrc (closes #20866)

The opts argument in patch.diff appears to exist as of mercurial 0.9.2.

diff --git a/hgviewlib/hggraph.py b/hgviewlib/hggraph.py
@@ -56,17 +56,19 @@
1          matchfn = match.always(repo.root, repo.getcwd())
2      else:
3          matchfn = match.exact(repo.root, repo.getcwd(), files)
4      # try/except for the sake of hg compatibility (API changes between
5      # 1.0 and 1.1)
6 +    diffopts = patch.diffopts(repo.ui)
7      try:
8          out = StringIO()
9 -        patch.diff(repo, ctx2.node(), ctx1.node(), match=matchfn, fp=out)
10 +        patch.diff(repo, ctx2.node(), ctx1.node(), match=matchfn, fp=out,
11 +                   opts=diffopts)
12          diffdata = out.getvalue()
13      except:
14          diffdata = '\n'.join(patch.diff(repo, ctx2.node(), ctx1.node(),
15 -                                        match=matchfn))
16 +                                        match=matchfn, opts=diffopts))
17      # XXX how to deal diff encodings?
18      try:
19          diffdata = unicode(diffdata, "utf-8")
20      except UnicodeError:
21          # XXX use a default encoding from config?