Mercurial > hgsubversion
changeset 422:6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Fri, 12 Jun 2009 08:37:39 +0200 |
parents | 8277113036f1 |
children | 021bdbf391bb |
files | hgsubversion/editor.py hgsubversion/stupid.py hgsubversion/svnmeta.py hgsubversion/util.py |
diffstat | 4 files changed, 24 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/editor.py +++ b/hgsubversion/editor.py @@ -173,7 +173,7 @@ class HgEditor(delta.Editor): revlog.nullid) if parents[0] in closedrevs and branch in self.meta.closebranches: continue - extra = util.build_extra(rev.revnum, branch, self.meta.uuid, self.meta.subdir) + extra = self.meta.genextra(rev.revnum, branch) if branch is not None: if (branch not in self.meta.branches and branch not in self.repo.branchtags()): @@ -233,7 +233,7 @@ class HgEditor(delta.Editor): if self.current.emptybranches[branch]: #pragma: no cover raise hgutil.Abort('Empty commit to an open branch attempted. ' 'Please report this issue.') - extra = util.build_extra(rev.revnum, branch, self.meta.uuid, self.meta.subdir) + extra = self.meta.genextra(rev.revnum, branch) if not self.meta.usebranchnames: extra.pop('branch', None) current_ctx = context.memctx(self.repo,
--- a/hgsubversion/stupid.py +++ b/hgsubversion/stupid.py @@ -599,7 +599,7 @@ def convert_rev(ui, meta, svn, r, tbdelt # something is very wrong assert f[0] != '/' - extra = util.build_extra(r.revnum, b, svn.uuid, svn.subdir) + extra = meta.genextra(r.revnum, b) if not meta.usebranchnames: extra.pop('branch', None)
--- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -159,6 +159,26 @@ class SVNMeta(object): return branch[3:] return 'branches/%s' % branch + def genextra(self, revnum, branch): + extra = {} + branchpath = 'trunk' + if branch: + extra['branch'] = branch + branchpath = 'branches/%s' % branch + + subdir = self.subdir + if subdir and subdir[-1] == '/': + subdir = subdir[:-1] + if subdir and subdir[0] != '/': + subdir = '/' + subdir + + extra['convert_revision'] = 'svn:%(uuid)s%(path)s@%(rev)s' % { + 'uuid': self.uuid, + 'path': '%s/%s' % (subdir , branchpath), + 'rev': revnum, + } + return extra + def normalize(self, path): '''Normalize a path to strip of leading slashes and our subdir if we have one. @@ -410,7 +430,7 @@ class SVNMeta(object): return context.memfilectx(path='.hgtags', data=src, islink=False, isexec=False, copied=None) - extra = util.build_extra(rev.revnum, b, self.uuid, self.subdir) + extra = self.genextra(rev.revnum, b) if not self.usebranchnames: extra.pop('branch', None) if b in endbranches:
--- a/hgsubversion/util.py +++ b/hgsubversion/util.py @@ -59,24 +59,6 @@ def outgoing_revisions(repo, reverse_map if sourcerev.node() != node.nullid: return outgoing_rev_hashes -def build_extra(revnum, branch, uuid, subdir): - extra = {} - branchpath = 'trunk' - if branch: - extra['branch'] = branch - branchpath = 'branches/%s' % branch - if subdir and subdir[-1] == '/': - subdir = subdir[:-1] - if subdir and subdir[0] != '/': - subdir = '/' + subdir - extra['convert_revision'] = 'svn:%(uuid)s%(path)s@%(rev)s' % { - 'uuid': uuid, - 'path': '%s/%s' % (subdir , branchpath), - 'rev': revnum, - } - return extra - - def is_svn_repo(repo): return os.path.exists(os.path.join(repo.path, 'svn', 'uuid'))