[PATCH] convert.svn: branch name which equals trunk means `default' branch (issue2653)

Pavel Boldin boldin.pavel at gmail.com
Fri Feb 25 12:05:03 CST 2011


# HG changeset patch
# User Pavel Boldin <boldin.pavel at gmail.com>
# Date 1298656890 -10800
# Node ID f542beea01457430d45230629746a8834374faca
# Parent  643b8212813e631b5525049fc4321a34a4def105
convert.svn: branch name which equals trunk means `default' branch (issue2653)

Converting from subversion specifying config.svn.trunk results
in storing trunk under branch named as config.svn.trunk, where `default'
brunch is expected. Submission contains patch and test.

diff -r 643b8212813e -r f542beea0145 hgext/convert/__init__.py
--- a/hgext/convert/__init__.py	Wed Feb 16 15:02:30 2011 +0100
+++ b/hgext/convert/__init__.py	Fri Feb 25 21:01:30 2011 +0300
@@ -221,13 +221,13 @@
     The following options can be set with ``--config``:
 
     :convert.svn.branches: specify the directory containing branches.
-        The defaults is ``branches``.
+        The default is ``branches``.
 
     :convert.svn.tags: specify the directory containing tags. The
         default is ``tags``.
 
-    :convert.svn.trunk: specify the name of the trunk branch The
-        defauls is ``trunk``.
+    :convert.svn.trunk: specify the name of the trunk branch. The
+        default is ``trunk``.
 
     Source history can be retrieved starting at a specific revision,
     instead of being integrally converted. Only single branch
diff -r 643b8212813e -r f542beea0145 hgext/convert/subversion.py
--- a/hgext/convert/subversion.py	Wed Feb 16 15:02:30 2011 +0100
+++ b/hgext/convert/subversion.py	Fri Feb 25 21:01:30 2011 +0300
@@ -314,6 +314,9 @@
                 return None
             path = (cfgpath or name).strip('/')
             if not self.exists(path, rev):
+                if self.module.endswith(path) and name == 'trunk':
+                    # we are converting from inside this directory
+                    return None
                 if cfgpath:
                     raise util.Abort(_('expected %s to be at %r, but not found')
                                  % (name, path))
@@ -761,7 +764,8 @@
             author = author and self.recode(author) or ''
             try:
                 branch = self.module.split("/")[-1]
-                if branch == 'trunk':
+                trunkname = self.ui.config('convert', 'svn.trunk', 'trunk')
+                if branch == trunkname.strip('/'):
                     branch = ''
             except IndexError:
                 branch = None
diff -r 643b8212813e -r f542beea0145 tests/test-convert-svn-source.t
--- a/tests/test-convert-svn-source.t	Wed Feb 16 15:02:30 2011 +0100
+++ b/tests/test-convert-svn-source.t	Fri Feb 25 21:01:30 2011 +0300
@@ -9,6 +9,8 @@
   > [extensions]
   > convert = 
   > graphlog =
+  > [convert]
+  > svn.trunk = mytrunk
   > EOF
 
   $ svnadmin create svn-repo
@@ -27,20 +29,20 @@
 
   $ mkdir projB
   $ cd projB
-  $ mkdir trunk
+  $ mkdir mytrunk
   $ mkdir tags
   $ cd ..
 
   $ svnurl="file://$svnpath/svn-repo/proj%20B"
   $ svn import -m "init projB" projB "$svnurl" | fixpath
-  Adding         projB/trunk
+  Adding         projB/mytrunk
   Adding         projB/tags
   
   Committed revision 1.
 
 Update svn repository
 
-  $ svn co "$svnurl"/trunk B | fixpath
+  $ svn co "$svnurl"/mytrunk B | fixpath
   Checked out revision 1.
   $ cd B
   $ echo hello > 'letter .txt'
@@ -57,7 +59,7 @@
   Transmitting file data .
   Committed revision 3.
 
-  $ svn copy -m "tag v0.1" "$svnurl"/trunk "$svnurl"/tags/v0.1
+  $ svn copy -m "tag v0.1" "$svnurl"/mytrunk "$svnurl"/tags/v0.1
   
   Committed revision 4.
 
@@ -94,7 +96,7 @@
   Transmitting file data ..
   Committed revision 6.
 
-  $ svn copy -m "tag v0.2" "$svnurl"/trunk "$svnurl"/tags/v0.2
+  $ svn copy -m "tag v0.2" "$svnurl"/mytrunk "$svnurl"/tags/v0.2
   
   Committed revision 7.
 
@@ -143,7 +145,7 @@
 
 Test filemap
   $ echo 'include letter2.txt' > filemap
-  $ hg convert --filemap filemap "$svnurl"/trunk fmap
+  $ hg convert --filemap filemap "$svnurl"/mytrunk fmap
   initializing destination fmap repository
   scanning source...
   sorting...
@@ -154,6 +156,8 @@
   2 nice day
   1 second letter
   0 work in progress
+  $ hg -R fmap branch -q
+  default
   $ hg glog -R fmap --template '{rev} {desc|firstline} files: {files}\n'
   o  1 work in progress files: letter2.txt
   |
@@ -161,12 +165,14 @@
   
 
 Test stop revision
-  $ hg convert --rev 1 "$svnurl"/trunk stoprev
+  $ hg convert --rev 1 "$svnurl"/mytrunk stoprev
   initializing destination stoprev repository
   scanning source...
   sorting...
   converting...
   0 init projB
+  $ hg -R stoprev branch -q
+  default
 
 Check convert_revision extra-records.
 This is also the only place testing more than one extra field in a revision.
@@ -174,5 +180,5 @@
   $ cd stoprev
   $ hg tip --debug | grep extra
   extra:       branch=default
-  extra:       convert_revision=svn:........-....-....-....-............/proj B/trunk at 1 (re)
+  extra:       convert_revision=svn:........-....-....-....-............/proj B/mytrunk at 1 (re)
   $ cd ..


More information about the Mercurial-devel mailing list