[nested] be robust against .hgguestrepo parse errors (closes #234670)

The config files may be corrupted. But HgView can help fixing the config file problem.

authorAlain Leufroy <alain.leufroy@logilab.fr>
changesetc1cc5c806c53
branchdefault
phasepublic
hiddenno
parent revision#99478d1b5b30 setup: be compatible with newer setuptools
child revision#66055b7bdfbc [application] allow to retrieve version using command line option
files modified by this revision
hgviewlib/util.py
# HG changeset patch
# User Alain Leufroy <alain.leufroy@logilab.fr>
# Date 1396893161 -7200
# Mon Apr 07 19:52:41 2014 +0200
# Node ID c1cc5c806c530bf2531dd2225a81c3ce256da7ae
# Parent 99478d1b5b30fa92a6b74ff30dab050c4c1c92b8
[nested] be robust against .hgguestrepo parse errors (closes #234670)

The config files may be corrupted. But HgView can help fixing the config file problem.

diff --git a/hgviewlib/util.py b/hgviewlib/util.py
@@ -10,11 +10,11 @@
1  """
2  import os
3  import os.path as osp
4  import string
5  from functools import partial
6 -from mercurial import hg, config
7 +from mercurial import hg, config, error
8 
9  from hgviewlib.hgpatches.scmutil import match
10  from hgviewlib.hgpatches import precursorsmarkers, successorsmarkers
11 
12  def tounicode(text):
@@ -237,13 +237,16 @@
13      # folder in rc-style.
14      confpath = osp.join(repo_path, conf_file)
15      if not osp.exists(confpath):
16          return None
17      conf = config.config()
18 -    conf.read(confpath)
19 -    return conf
20 -
21 +    try:
22 +        conf.read(confpath)
23 +        out = conf
24 +    except error.ParseError:
25 +        out = None
26 +    return out
27 
28  def _get_subrepo(repo_path):
29      """Get subrepo style nested repo"""
30      config = _get_conf(repo_path, '.hgsub')
31      if config is None: