Commits

David Schleimer committed 0ed7cf2

layouts: refactor path component of convinfo generation into layouts lib

This adds code responsible for producing an absolute path within the
subversion repository to the new layout objects. It also uses that
code to generate the path component of the conversion info we stick
into extra.

Comments (0)

Files changed (4)

hgsubversion/layouts/base.py

 
     def localname(self, path):
         """Compute the local name for a branch located at path.
+
+        path should be relative to the repo url.
+
         """
         self.__unimplemented('localname')
 
     def remotename(self, branch):
-        """Compute a subversion path for a mercurial branch name"""
+        """Compute a subversion path for a mercurial branch name
+
+        This should return a path relative to the repo url
+
+        """
         self.__unimplemented('remotename')
+
+    def remotepath(self, branch, subdir='/'):
+        """Compute a  subversion path for a mercurial branch name.
+
+        This should return an absolute path, assuming our repo root is at subdir
+        A false subdir shall be taken to mean /.
+
+        """
+        self.__unimplemented('remotepath')

hgsubversion/layouts/single.py

 
     def remotename(self, branch):
         return ''
+
+    def remotepath(self, branch, subdir='/'):
+        return subdir or '/'

hgsubversion/layouts/standard.py

         elif branch.startswith('../'):
             return branch[3:]
         return 'branches/%s' % branch
+
+    def remotepath(self, branch, subdir='/'):
+        branchpath = 'trunk'
+        if branch:
+            if branch.startswith('../'):
+                branchpath = branch[3:]
+            else:
+                branchpath = 'branches/%s' % branch
+
+        return '%s/%s' % (subdir or '', branchpath)

hgsubversion/svnmeta.py

         if subdir and subdir[0] != '/':
             subdir = '/' + subdir
 
-        if self.layout == 'single':
-            path = subdir or '/'
-        else:
-            branchpath = 'trunk'
-            if branch:
-                extra['branch'] = branch
-                if branch.startswith('../'):
-                    branchpath = branch[3:]
-                else:
-                    branchpath = 'branches/%s' % branch
-            path = '%s/%s' % (subdir, branchpath)
+        path = self.layoutobj.remotepath(branch, subdir)
+
+        if branch:
+            extra['branch'] = branch
 
         extra['convert_revision'] = 'svn:%(uuid)s%(path)s@%(rev)s' % {
             'uuid': self.uuid,