Mercurial > hgsubversion
changeset 701:3b8088de027d
clone: replace the --singlebranch with overloading for --branch
Instead of adding yet another option, we take the --branch option to
mean the resulting branch name. It's stored in the branch map.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Thu, 23 Sep 2010 16:54:27 +0200 |
parents | 04b3f476e2c3 |
children | 841399d10c79 |
files | hgsubversion/__init__.py hgsubversion/help/subversion.rst hgsubversion/svnmeta.py hgsubversion/wrappers.py tests/test_single_dir_clone.py |
diffstat | 5 files changed, 65 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/__init__.py +++ b/hgsubversion/__init__.py @@ -75,7 +75,6 @@ wrapcmds = { # cmd: generic, target, fix ('', 'layout', 'auto', ('import standard layout or single ' 'directory? Can be standard, single, or auto.')), ('', 'branchmap', '', 'file containing rules for branch conversion'), - ('', 'singlebranch', '', 'branch name to use for local svn commits'), ('', 'startrev', '', ('convert Subversion revisions starting at the one ' 'specified, either an integer revision or HEAD; ' 'HEAD causes only the latest revision to be '
--- a/hgsubversion/help/subversion.rst +++ b/hgsubversion/help/subversion.rst @@ -38,7 +38,9 @@ If you instead want to clone just a sing specific directory path. In the example above, to get *only* trunk, you would issue :hg:`clone http://python-nose.googlecode.com/svn/trunk nose-trunk`. This works with any directory with a Subversion repository, and is know as a single -directory clone. +directory clone. Normally, converted changesets will be marked as belonging to +the ``default`` branch, but this can be changed by using the ``-b/--branch`` +option. Pulling new revisions into an already-converted repo is the same as from any other Mercurial source. Within the first example above, the following three @@ -140,6 +142,11 @@ settings: Setting this boolean option to false will cause hgsubversion to abort a conversion if a revision has an author not listed in the author map. + hgsubversion.branch + Mark converted changesets as belonging to this branch or, if unspecifed, + `default`. Please note that this option is not supported for standard + layout clones. + hgsubversion.branchmap Path to a file for changing branch names during the conversion from Subversion to Mercurial.
--- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -54,7 +54,6 @@ class SVNMeta(object): self.usebranchnames = self.ui.configbool('hgsubversion', 'usebranchnames', True) branchmap = self.ui.config('hgsubversion', 'branchmap') - singlebranch = self.ui.config('hgsubversion', 'singlebranch') # FIXME: test that this hasn't changed! defer & compare? if subdir: @@ -94,8 +93,6 @@ class SVNMeta(object): self.branchmap = maps.BranchMap(self.ui, self.branchmapfile) if branchmap: self.branchmap.load(branchmap) - if singlebranch: - self.branchmap['default'] = singlebranch self.lastdate = '1970-01-01 00:00:00 -0000' self.filemap = maps.FileMap(repo)
--- a/hgsubversion/wrappers.py +++ b/hgsubversion/wrappers.py @@ -246,6 +246,15 @@ def pull(repo, source, heads=[], force=F repo.ui.setconfig('hgsubversion', 'layout', layout) repo.ui.note('using %s layout\n' % layout) + branch = repo.ui.config('hgsubversion', 'branch') + if branch: + if layout != 'single': + msg = ('branch cannot be specified for Subversion clones using ' + 'standard directory layout') + raise hgutil.Abort(msg) + + meta.branchmap['default'] = branch + ui = repo.ui start = meta.revmap.youngest origrevcount = len(meta.revmap) @@ -390,7 +399,6 @@ optionmap = { 'authors': ('hgsubversion', 'authormap'), 'filemap': ('hgsubversion', 'filemap'), 'branchmap': ('hgsubversion', 'branchmap'), - 'singlebranch': ('hgsubversion', 'singlebranch'), 'stupid': ('hgsubversion', 'stupid'), 'defaulthost': ('hgsubversion', 'defaulthost'), 'defaultauthors': ('hgsubversion', 'defaultauthors'), @@ -408,6 +416,10 @@ def clone(orig, ui, source, dest=None, * them as well as other ways of customising the conversion process. """ + branch = opts.get('branch', None) + if branch: + ui.setconfig('hgsubversion', 'branch', branch[-1]) + for opt, (section, name) in optionmap.iteritems(): if opt in opts and opts[opt]: ui.setconfig(section, name, str(opts.pop(opt))) @@ -436,6 +448,11 @@ def generic(orig, ui, repo, *args, **opt Subversion %(target)s can be used for %(command)s. See 'hg help %(extension)s' for more on the conversion process. """ + + branch = opts.get('branch', None) + if branch: + ui.setconfig('hgsubversion', 'branch', branch[-1]) + for opt, (section, name) in optionmap.iteritems(): if opt in opts and opts[opt]: if isinstance(repo, str):
--- a/tests/test_single_dir_clone.py +++ b/tests/test_single_dir_clone.py @@ -4,6 +4,7 @@ import errno import shutil import unittest +from mercurial import dispatch from mercurial import commands from mercurial import context from mercurial import hg @@ -212,6 +213,44 @@ class TestSingleDir(test_util.TestBase): self.assertTrue('default' in self.svnls('')) self.assertEquals(len(self.repo.branchheads('default')), 1) + def test_push_single_dir_renamed_branch(self, stupid=False): + # Tests pulling and pushing with a renamed branch + # Based on test_push_single_dir + test_util.load_svndump_fixture(self.repo_path, + 'branch_from_tag.svndump') + cmd = ['clone', '--layout=single', '--branch=flaf'] + if stupid: + cmd.append('--stupid') + cmd += [test_util.fileurl(self.repo_path), self.wc_path] + dispatch.dispatch(cmd) + + def file_callback(repo, memctx, path): + if path == 'adding_file': + return context.memfilectx(path=path, + data='foo', + islink=False, + isexec=False, + copied=False) + raise IOError(errno.EINVAL, 'Invalid operation: ' + path) + ctx = context.memctx(self.repo, + (self.repo['tip'].node(), node.nullid), + 'automated test', + ['adding_file'], + file_callback, + 'an_author', + '2009-10-19 18:49:30 -0500', + {'branch': 'default',}) + self.repo.commitctx(ctx) + hg.update(self.repo, self.repo['tip'].node()) + self.pushrevisions() + self.assertTrue('adding_file' in self.svnls('')) + + self.assertEquals(set(['flaf']), + set(self.repo[i].branch() for i in self.repo)) + + def test_push_single_dir_renamed_branch_stupid(self): + self.test_push_single_dir_renamed_branch(True) + def suite(): all = [unittest.TestLoader().loadTestsFromTestCase(TestSingleDir)] return unittest.TestSuite(all)