Mercurial > hgsubversion
changeset 1014:0ed7cf23e801
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.
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Fri, 26 Apr 2013 11:14:06 -0700 |
parents | d507c1a12dcb |
children | ea6109f5c000 |
files | hgsubversion/layouts/base.py hgsubversion/layouts/single.py hgsubversion/layouts/standard.py hgsubversion/svnmeta.py |
diffstat | 4 files changed, 34 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/layouts/base.py +++ b/hgsubversion/layouts/base.py @@ -16,9 +16,25 @@ class BaseLayout(object): 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')
--- a/hgsubversion/layouts/single.py +++ b/hgsubversion/layouts/single.py @@ -10,3 +10,6 @@ class SingleLayout(base.BaseLayout): def remotename(self, branch): return '' + + def remotepath(self, branch, subdir='/'): + return subdir or '/'
--- a/hgsubversion/layouts/standard.py +++ b/hgsubversion/layouts/standard.py @@ -19,3 +19,13 @@ class StandardLayout(base.BaseLayout): 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)
--- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -235,17 +235,10 @@ class SVNMeta(object): 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,