Mercurial > hgsubversion
comparison hgsubversion/svnmeta.py @ 1005:5bba4d1becde
layouts: refactor layout loading based on config into function
Refactor the logic for loading the layout based on config, and for
validating that config is sane into a single function.
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Wed, 17 Apr 2013 15:00:33 -0700 |
parents | 1bdd075a490a |
children | 7a3b938825cd |
comparison
equal
deleted
inserted
replaced
1004:b2d89ba6b871 | 1005:5bba4d1becde |
---|---|
8 from mercurial import revlog | 8 from mercurial import revlog |
9 from mercurial import node | 9 from mercurial import node |
10 | 10 |
11 import util | 11 import util |
12 import maps | 12 import maps |
13 import layouts | |
13 import editor | 14 import editor |
14 | 15 |
15 | 16 |
16 def pickle_atomic(data, file_path): | 17 def pickle_atomic(data, file_path): |
17 """pickle some data to a path atomically. | 18 """pickle some data to a path atomically. |
105 def layout(self): | 106 def layout(self): |
106 # this method can't determine the layout, but it needs to be | 107 # this method can't determine the layout, but it needs to be |
107 # resolved into something other than auto before this ever | 108 # resolved into something other than auto before this ever |
108 # gets called | 109 # gets called |
109 if not self._layout or self._layout == 'auto': | 110 if not self._layout or self._layout == 'auto': |
110 lo = self.repo.ui.config('hgsubversion', 'layout', default='auto') | 111 self._layout = layouts.detect.layout_from_config(self.repo.ui) |
111 if lo == 'auto': | |
112 raise hgutil.Abort('layout not yet determined') | |
113 elif not lo in ('single', 'standard'): | |
114 raise hgutil.Abort("unknown layout '%s'" % lo) | |
115 self._layout = lo | |
116 f = open(self.layoutfile, 'w') | 112 f = open(self.layoutfile, 'w') |
117 f.write(self._layout) | 113 f.write(self._layout) |
118 f.close() | 114 f.close() |
119 return self._layout | 115 return self._layout |
120 | 116 |