Mercurial > hg
changeset 8377:29f4f0d66cd5
convert: adding branchmap functionality to convert extension
author | Michael J. Pedersen <m.pedersen@icelus.org> |
---|---|
date | Wed, 13 May 2009 15:03:31 -0400 |
parents | 04f9253906bb |
children | 59acf64995d2 |
files | hgext/convert/__init__.py hgext/convert/convcmd.py tests/test-convert-svn-branches tests/test-convert-svn-branches.out tests/test-convert.out |
diffstat | 5 files changed, 33 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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":
--- 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
--- 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 <<EOF +old3 newbranch +EOF +hg convert --branchmap=branchmap --datesort -r 10 $svnurl A-hg echo % convert again -hg convert --datesort $svnurl A-hg +hg convert --branchmap=branchmap --datesort $svnurl A-hg cd A-hg hg glog --template 'branch=#branches# #rev# #desc|firstline# files: #files#\n'
--- a/tests/test-convert-svn-branches.out Wed May 13 22:42:40 2009 +0200 +++ b/tests/test-convert-svn-branches.out Wed May 13 15:03:31 2009 -0400 @@ -19,7 +19,7 @@ sorting... converting... 0 branch trunk@1 into old3 -o branch=old3 11 branch trunk@1 into old3 files: +o branch=newbranch 11 branch trunk@1 into old3 files: | | o branch= 10 last change to a files: a | | @@ -43,7 +43,7 @@ |/ o branch= 0 init projA files: -old3 11: +newbranch 11: default 10: old 9: old2 8:
--- a/tests/test-convert.out Wed May 13 22:42:40 2009 +0200 +++ b/tests/test-convert.out Wed May 13 15:03:31 2009 -0400 @@ -70,6 +70,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 ----------------- @@ -197,6 +208,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 try to sort changesets by date use "hg -v help convert" to show global options