# HG changeset patch # User Sean Farley # Date 1395678049 18000 # Node ID 7993379b99562334c7112846dc15ee5d38c86ede # Parent b7b0ed1e1455e3c292821b08f2b9435f881bcef6 layouts: use util.load in layout_from_config This is a temporary move to make refactoring easier. Later patches will use util.dump for writing layout_from_config, so we need to use util.load first (since it provides a safe fallback to reading plain text). In later patches, all 'from hgext_hgsubversion' statements will be removed. diff --git a/hgsubversion/layouts/detect.py b/hgsubversion/layouts/detect.py --- a/hgsubversion/layouts/detect.py +++ b/hgsubversion/layouts/detect.py @@ -66,14 +66,16 @@ def layout_from_file(metapath, ui=None): """ - layout = None + # import late to avoid trouble when running the test suite + try: + from hgext_hgsubversion import util + except ImportError: + from hgsubversion import util + layoutfile = os.path.join(metapath, 'layout') - if os.path.exists(layoutfile): - f = open(layoutfile) - layout = f.read().strip() - f.close() - if ui: - ui.setconfig('hgsubversion', 'layout', layout) + layout = util.load(layoutfile) + if layout is not None and ui: + ui.setconfig('hgsubversion', 'layout', layout) return layout def layout_from_commit(subdir, revpath, branch, ui):