# HG changeset patch # User Michael J. Pedersen # Date 1242241411 14400 # Node ID 29f4f0d66cd53fad7493e5e3b90017024fbbcb2a # Parent 04f9253906bbc20ae71ef19997efed4274b7c450 convert: adding branchmap functionality to convert extension diff -r 04f9253906bb -r 29f4f0d66cd5 hgext/convert/__init__.py --- a/hgext/convert/__init__.py Wed May 13 22:42:40 2009 +0200 +++ b/hgext/convert/__init__.py Wed May 13 15:03:31 2009 -0400 @@ -86,6 +86,17 @@ (in either the source or destination revision control system) that should be used as the new parents for that node. + The branchmap is a file that allows you to rename a branch when it is + being brought in from whatever external repository. When used in + conjunction with a splicemap, it allows for a powerful combination + to help fix even the most badly mismanaged repositories and turn them + into nicely structured Mercurial repositories. The branchmap contains + lines of the form "original_branch_name new_branch_name". + "original_branch_name" is the name of the branch in the source + repository, and "new_branch_name" is the name of the branch is the + destination repository. This can be used to (for instance) move code + in one repository from "default" to a named branch. + Mercurial Source ----------------- @@ -235,6 +246,7 @@ ('r', 'rev', '', _('import up to target revision REV')), ('s', 'source-type', '', _('source repository type')), ('', 'splicemap', '', _('splice synthesized history into place')), + ('', 'branchmap', '', _('change branch names while converting')), ('', 'datesort', None, _('try to sort changesets by date'))], _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]')), "debugsvnlog": diff -r 04f9253906bb -r 29f4f0d66cd5 hgext/convert/convcmd.py --- a/hgext/convert/convcmd.py Wed May 13 22:42:40 2009 +0200 +++ b/hgext/convert/convcmd.py Wed May 13 15:03:31 2009 -0400 @@ -91,6 +91,7 @@ self.authorfile = self.dest.authorfile() self.splicemap = mapfile(ui, opts.get('splicemap')) + self.branchmap = mapfile(ui, opts.get('branchmap')) def walktree(self, heads): '''Return a mapping that identifies the uncommitted parents of every @@ -225,6 +226,7 @@ def cachecommit(self, rev): commit = self.source.getcommit(rev) commit.author = self.authors.get(commit.author, commit.author) + commit.branch = self.branchmap.get(commit.branch, commit.branch) self.commitcache[rev] = commit return commit diff -r 04f9253906bb -r 29f4f0d66cd5 tests/test-convert-svn-branches --- a/tests/test-convert-svn-branches Wed May 13 22:42:40 2009 +0200 +++ b/tests/test-convert-svn-branches Wed May 13 15:03:31 2009 -0400 @@ -24,10 +24,13 @@ svnurl=file://$svnpath/svn-repo echo % convert trunk and branches -hg convert --datesort -r 10 $svnurl A-hg +cat >branchmap <