Mercurial > hgsubversion
comparison hgsubversion/svnmeta.py @ 1301:9e46dfddd3a9
svnmeta: turn layout into a cached property
It turns out we don't need the fancy checks that were in the layout property
before so we use our new fancy property generator to cache this property.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Mon, 24 Mar 2014 11:20:54 -0500 |
parents | 8b3b456afd5f |
children | 80b57ed92544 |
comparison
equal
deleted
inserted
replaced
1300:5a68a6b44336 | 1301:9e46dfddd3a9 |
---|---|
39 self._revmap = None | 39 self._revmap = None |
40 self._authors = None | 40 self._authors = None |
41 self._branchmap = None | 41 self._branchmap = None |
42 self._tagmap = None | 42 self._tagmap = None |
43 self._filemap = None | 43 self._filemap = None |
44 self._layout = None | |
44 | 45 |
45 # create .hg/svn folder if it doesn't exist | 46 # create .hg/svn folder if it doesn't exist |
46 if not os.path.isdir(self.metapath): | 47 if not os.path.isdir(self.metapath): |
47 os.makedirs(self.metapath) | 48 os.makedirs(self.metapath) |
48 | 49 |
56 self._gen_cachedconfig('caseignoreauthors', False) | 57 self._gen_cachedconfig('caseignoreauthors', False) |
57 self._gen_cachedconfig('defaulthost', self.uuid) | 58 self._gen_cachedconfig('defaulthost', self.uuid) |
58 self._gen_cachedconfig('usebranchnames', True) | 59 self._gen_cachedconfig('usebranchnames', True) |
59 self._gen_cachedconfig('defaultmessage', '') | 60 self._gen_cachedconfig('defaultmessage', '') |
60 self._gen_cachedconfig('branch', '') | 61 self._gen_cachedconfig('branch', '') |
62 self._gen_cachedconfig('layout', 'auto') | |
61 | 63 |
62 # misc | 64 # misc |
63 self.branches = util.load(self.branch_info_file) or {} | 65 self.branches = util.load(self.branch_info_file) or {} |
64 self.prevbranches = dict(self.branches) | 66 self.prevbranches = dict(self.branches) |
65 self._layout = layouts.detect.layout_from_file(self) | |
66 | 67 |
67 def _get_cachedconfig(self, name, filename, configname, default, pre): | 68 def _get_cachedconfig(self, name, filename, configname, default, pre): |
68 """Return a cached value for a config option. If the cache is uninitialized | 69 """Return a cached value for a config option. If the cache is uninitialized |
69 then try to read its value from disk. Option can be overridden by the | 70 then try to read its value from disk. Option can be overridden by the |
70 commandline. | 71 commandline. |
207 | 208 |
208 | 209 |
209 @property | 210 @property |
210 def layout_file(self): | 211 def layout_file(self): |
211 return os.path.join(self.metapath, 'layout') | 212 return os.path.join(self.metapath, 'layout') |
212 | |
213 @property | |
214 def layout(self): | |
215 # this method can't determine the layout, but it needs to be | |
216 # resolved into something other than auto before this ever | |
217 # gets called | |
218 if not self._layout or self._layout == 'auto': | |
219 self._layout = layouts.detect.layout_from_config(self) | |
220 util.dump(self._layout, self.layout_file) | |
221 return self._layout | |
222 | 213 |
223 @property | 214 @property |
224 def layoutobj(self): | 215 def layoutobj(self): |
225 if not self._layoutobj: | 216 if not self._layoutobj: |
226 self._layoutobj = layouts.layout_from_name(self.layout, self) | 217 self._layoutobj = layouts.layout_from_name(self.layout, self) |