1. Augie Fackler
  2. hgsubversion

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.

  • Participants
  • Parent commits d507c1a
  • Branches default

Comments (0)

Files changed (4)

File hgsubversion/layouts/base.py

View file
 
     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')

File hgsubversion/layouts/single.py

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

File hgsubversion/layouts/standard.py

View file
         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)

File hgsubversion/svnmeta.py

View file
         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,