Mercurial > hgsubversion
diff hgsubversion/svnmeta.py @ 1012:e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
This pulls the logic for mapping from svn path to mercurial branch
name out of svnmeta.py and into the new layouts library. It also sets
up the structure for that library. This diff does not modify any call
to svnmeta.localname, rather leaving it in place as a simple proxy to
the new layout object.
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Wed, 24 Apr 2013 15:07:11 -0700 |
parents | 7a3b938825cd |
children | d507c1a12dcb |
line wrap: on
line diff
--- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -72,6 +72,7 @@ class SVNMeta(object): self.tag_locations = tag_locations self._layout = layouts.detect.layout_from_file(self.meta_data_dir, ui=self.repo.ui) + self._layoutobj = None pickle_atomic(self.tag_locations, self.tag_locations_file) # ensure nested paths are handled properly self.tag_locations.sort() @@ -107,6 +108,12 @@ class SVNMeta(object): layouts.persist.layout_to_file(self.meta_data_dir, self._layout) return self._layout + @property + def layoutobj(self): + if not self._layoutobj: + self._layoutobj = layouts.layout_from_name(self.layout) + return self._layoutobj + @property def editor(self): if not hasattr(self, '_editor'): @@ -215,13 +222,7 @@ class SVNMeta(object): def localname(self, path): """Compute the local name for a branch located at path. """ - if self.layout == 'single': - return 'default' - if path == 'trunk': - return None - elif path.startswith('branches/'): - return path[len('branches/'):] - return '../%s' % path + return self.layoutobj.localname(path) def remotename(self, branch): if self.layout == 'single':