[PATCH] [issue2653] Invalid branch names after converting from svn with non-standard trunk name

Pavel Boldin boldin.pavel at gmail.com
Thu Feb 24 08:53:46 CST 2011


# HG changeset patch
# User Pavel Boldin <boldin.pavel at gmail.com>
# Date 1298558829 -10800
# Node ID e924d9ea5bd6bbb66f38a357decdcd3040d10c4b
# Parent  643b8212813e631b5525049fc4321a34a4def105
fix for issue2653
check if branch is equals to trunk name specified in config.svn.trunk

diff -r 643b8212813e -r e924d9ea5bd6 hgext/convert/subversion.py
--- a/hgext/convert/subversion.py	Wed Feb 16 15:02:30 2011 +0100
+++ b/hgext/convert/subversion.py	Thu Feb 24 17:47:09 2011 +0300
@@ -761,7 +761,9 @@
             author = author and self.recode(author) or ''
             try:
                 branch = self.module.split("/")[-1]
-                if branch == 'trunk':
+                trunkname = self.ui.config('convert', 'svn.trunk') or 'trunk'
+                trunkname = trunkname.strip('/')
+                if branch == trunkname:
                     branch = ''
             except IndexError:
                 branch = None
diff -r 643b8212813e -r e924d9ea5bd6 tests/test-convert-svn-mytrunk.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-svn-mytrunk.t	Thu Feb 24 17:47:09 2011 +0300
@@ -0,0 +1,53 @@
+
+  $ "$TESTDIR/hghave" svn svn-bindings || exit 80
+
+  $ fixpath()
+  > {
+  >     tr '\\' /
+  > }
+  $ cat > $HGRCPATH <<EOF
+  > [extensions]
+  > convert = 
+  > graphlog =
+  > EOF
+
+  $ svnadmin create svn-repo
+  $ svnpath=`pwd | fixpath`
+
+
+  $ expr "$svnpath" : "\/" > /dev/null
+  > if [ $? -ne 0 ]; then
+  >   svnpath="/$svnpath"
+  > fi
+  > svnurl="file://$svnpath/svn-repo"
+
+Now test that it works with trunk/tags layout, but no branches yet.
+
+Initial svn import
+
+  $ mkdir projB
+  $ cd projB
+  $ mkdir mytrunk
+  $ echo "fileconent" > mytrunk/file
+  $ cd ..
+
+  $ svnurl="file://$svnpath/svn-repo/proj%20B"
+  $ svn import -m "init projB" projB "$svnurl" | fixpath
+  Adding         projB/mytrunk
+  Adding         projB/mytrunk/file
+  
+  Committed revision 1.
+
+Convert trunk and branches
+
+  $ hg convert --config convert.svn.trunk=mytrunk --datesort "$svnurl" B-hg
+  initializing destination B-hg repository
+  scanning source...
+  sorting...
+  converting...
+  0 init projB
+
+Check current branch
+  $ cd B-hg
+  $ hg branches -q
+  default


More information about the Mercurial-devel mailing list