changeset 1013:d507c1a12dcb

layouts: refactor mercurial branch to svn path mapping out of svnmeta This leaves the existing svnmeta.remotename as a proxy to the new layout objects rather than updating any of the callsites.
author David Schleimer <dschleimer@fb.com>
date Wed, 24 Apr 2013 15:23:33 -0700
parents e8cd211684c4
children 0ed7cf23e801
files hgsubversion/layouts/base.py hgsubversion/layouts/single.py hgsubversion/layouts/standard.py hgsubversion/svnmeta.py
diffstat 4 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/layouts/base.py
+++ b/hgsubversion/layouts/base.py
@@ -18,3 +18,7 @@ class BaseLayout(object):
         """Compute the local name for a branch located at path.
         """
         self.__unimplemented('localname')
+
+    def remotename(self, branch):
+        """Compute a subversion path for a mercurial branch name"""
+        self.__unimplemented('remotename')
--- a/hgsubversion/layouts/single.py
+++ b/hgsubversion/layouts/single.py
@@ -7,3 +7,6 @@ class SingleLayout(base.BaseLayout):
 
     def localname(self, path):
         return 'default'
+
+    def remotename(self, branch):
+        return ''
--- a/hgsubversion/layouts/standard.py
+++ b/hgsubversion/layouts/standard.py
@@ -12,3 +12,10 @@ class StandardLayout(base.BaseLayout):
         elif path.startswith('branches/'):
             return path[len('branches/'):]
         return  '../%s' % path
+
+    def remotename(self, branch):
+        if branch == 'default' or branch is None:
+            return 'trunk'
+        elif branch.startswith('../'):
+            return branch[3:]
+        return 'branches/%s' % branch
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -225,13 +225,7 @@ class SVNMeta(object):
         return self.layoutobj.localname(path)
 
     def remotename(self, branch):
-        if self.layout == 'single':
-            return ''
-        if branch == 'default' or branch is None:
-            return 'trunk'
-        elif branch.startswith('../'):
-            return branch[3:]
-        return 'branches/%s' % branch
+        return self.layoutobj.remotename(branch)
 
     def genextra(self, revnum, branch):
         extra = {}