Mercurial > hgsubversion
changeset 1260:7993379b9956
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.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Mon, 24 Mar 2014 11:20:49 -0500 |
parents | b7b0ed1e1455 |
children | 51f88d3aa4dd |
files | hgsubversion/layouts/detect.py |
diffstat | 1 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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):