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.
--- a/hgext/convert/__init__.py Fri Feb 25 23:26:24 2011 -0600
+++ 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
--- a/hgext/convert/subversion.py Fri Feb 25 23:26:24 2011 -0600
+++ b/hgext/convert/subversion.py Fri Feb 25 21:01:30 2011 +0300
@@ -311,6 +311,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))
@@ -758,7 +761,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
--- a/tests/test-convert-svn-source.t Fri Feb 25 23:26:24 2011 -0600
+++ 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@1 (re)
+ extra: convert_revision=svn:........-....-....-....-............/proj B/mytrunk@1 (re)
$ cd ..
--- a/tests/test-convert.t Fri Feb 25 23:26:24 2011 -0600
+++ b/tests/test-convert.t Fri Feb 25 21:01:30 2011 +0300
@@ -204,12 +204,12 @@
The following options can be set with "--config":
convert.svn.branches
- specify the directory containing branches. The defaults is
+ specify the directory containing 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".
+ 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 conversions are