[PATCH] [mq]: branchmap
Michael J. Pedersen
m.pedersen at icelus.org
Wed May 13 14:08:18 CDT 2009
# HG changeset patch
# User Michael J. Pedersen <m.pedersen at icelus.org>
# Date 1242241411 14400
# Node ID d4b60909e511e99833cbcc1572975ad564ab65eb
# Parent 45ed015b524e44184c92cbe099454190ff4c6049
[mq]: branchmap
diff -r 45ed015b524e -r d4b60909e511 hgext/convert/__init__.py
--- a/hgext/convert/__init__.py Wed May 13 13:07:43 2009 -0500
+++ 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 45ed015b524e -r d4b60909e511 hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py Wed May 13 13:07:43 2009 -0500
+++ 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
@@ -230,6 +231,9 @@
def copy(self, rev):
commit = self.commitcache[rev]
+ replbranch = self.branchmap.get(commit.branch, commit.branch)
+ if replbranch:
+ commit.branch = replbranch.replace(',', ' ').split()[0]
changes = self.source.getchanges(rev)
if isinstance(changes, basestring):
diff -r 45ed015b524e -r d4b60909e511 tests/test-convert-svn-branches
--- a/tests/test-convert-svn-branches Wed May 13 13:07:43 2009 -0500
+++ 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'
diff -r 45ed015b524e -r d4b60909e511 tests/test-convert-svn-branches.out
--- a/tests/test-convert-svn-branches.out Wed May 13 13:07:43 2009 -0500
+++ b/tests/test-convert-svn-branches.out Wed May 13 15:03:31 2009 -0400
@@ -19,7 +19,7 @@
sorting...
converting...
0 branch trunk at 1 into old3
-o branch=old3 11 branch trunk at 1 into old3 files:
+o branch=newbranch 11 branch trunk at 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:
diff -r 45ed015b524e -r d4b60909e511 tests/test-convert.out
--- a/tests/test-convert.out Wed May 13 13:07:43 2009 -0500
+++ 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
More information about the Mercurial-devel
mailing list