Changeset - 927b7934b867
[Not reviewed]
default
0 1 0
Mads Kiilerich - 7 years ago 2019-03-19 03:05:11
mads@kiilerich.com
utils: let make_ui return an empty ui.ui() object if the requested hgrc file isn't present

89c30b145bb8 lost an "if repoui" in simplehg, and Kallithea would thus fail on
serving repos without a .hg/hgrc :

File ".../kallithea/lib/middleware/simplehg.py", line 285, in _augment_hgrc
for k, v in repoui.configitems(section):
AttributeError: 'bool' object has no attribute 'configitems'

It is *only* simplehg that invoke make_ui with read_from 'file'. In this case
it could return False if the requested file wasn't present.

It was odd and inconsistent that make_ui with read_from 'file' either returned
an ui object or the value False.

To fix the problem, just let make_ui return the empty ui.ui() if no .hg/hgrc is
present. An ui object that just doesn't have any config sections is much better
than any alternative.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/utils.py
Show inline comments
 
@@ -334,7 +334,7 @@ def make_ui(read_from='file', path=None,
 
    if read_from == 'file':
 
        if not os.path.isfile(path):
 
            log.debug('hgrc file is not present at %s, skipping...', path)
 
            return False
 
            return baseui
 
        log.debug('reading hgrc from %s', path)
 
        cfg = config.config()
 
        cfg.read(path)
0 comments (0 inline, 0 general)