[PATCH 2 of 2] convert: svn -- fix tags handling
Kirill Smelkov
kirr at landau.phys.spbu.ru
Sat Oct 13 11:31:17 UTC 2007
# HG changeset patch
# User Kirill Smelkov <kirr at landau.phys.spbu.ru>
# Date 1192274711 -14400
# Node ID 91a522a69c13b62b4388765a0370155ea7ac75e9
# Parent ab4d2e9f3b97a0a1cd4898c5fba0d409b0077a96
convert: svn -- fix tags handling
They were simply not detected.
diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -8,6 +8,8 @@
# Relative path to the trunk (default: "trunk")
# convert.svn.branches
# Relative path to tree of branches (default: "branches")
+# convert.svn.tags
+# Relative path to tree of tags (default: "tags")
#
# Set these in a hgrc, or on the command line as follows:
#
@@ -170,11 +172,13 @@ class svn_source(converter_source):
rpath = self.url.strip('/')
cfgtrunk = self.ui.config('convert', 'svn.trunk')
cfgbranches = self.ui.config('convert', 'svn.branches')
+ cfgtags = self.ui.config('convert', 'svn.tags')
trunk = (cfgtrunk or 'trunk').strip('/')
branches = (cfgbranches or 'branches').strip('/')
- if self.exists(trunk, rev) and self.exists(branches, rev):
- self.ui.note('found trunk at %r and branches at %r\n' %
- (trunk, branches))
+ tags = (cfgtags or 'tags').strip('/')
+ if self.exists(trunk, rev) and self.exists(branches, rev) and self.exists(tags, rev):
+ self.ui.note('found trunk at %r, branches at %r and tags at %r\n' %
+ (trunk, branches, tags))
oldmodule = self.module
self.module += '/' + trunk
lt = self.latest(self.module, self.last_changed)
@@ -184,18 +188,25 @@ class svn_source(converter_source):
self.ctx)
for branch in branchnames.keys():
if oldmodule:
- module = '/' + oldmodule + '/' + branches + '/' + branch
+ module = oldmodule + '/' + branches + '/' + branch
else:
module = '/' + branches + '/' + branch
brevnum = self.latest(module, self.last_changed)
brev = self.revid(brevnum, module)
self.ui.note('found branch %s at %d\n' % (branch, brevnum))
self.heads.append(brev)
- elif cfgtrunk or cfgbranches:
- raise util.Abort('trunk/branch layout expected, but not found')
+
+ if oldmodule:
+ self.tags = '%s/%s' % (oldmodule, tags)
+ else:
+ self.tags = '/%s' % tags
+
+ elif cfgtrunk or cfgbranches or cfgtags:
+ raise util.Abort('trunk/branch/tags layout expected, but not found')
else:
self.ui.note('working with one branch\n')
self.heads = [self.head]
+ self.tags = tags
return self.heads
def getfile(self, file, rev):
@@ -268,15 +279,15 @@ class svn_source(converter_source):
tags = {}
start = self.revnum(self.head)
try:
- for entry in self.get_log(['/tags'], 0, start):
+ for entry in self.get_log([self.tags], 0, start):
orig_paths, revnum, author, date, message = entry
for path in orig_paths:
- if not path.startswith('/tags/'):
+ if not path.startswith(self.tags+'/'):
continue
ent = orig_paths[path]
source = ent.copyfrom_path
rev = ent.copyfrom_rev
- tag = path.split('/', 2)[2]
+ tag = path.split('/')[-1]
tags[tag] = self.revid(rev, module=source)
except SubversionException, (inst, num):
self.ui.note('no tags found at revision %d\n' % start)
diff --git a/tests/test-convert-svn b/tests/test-convert-svn
--- a/tests/test-convert-svn
+++ b/tests/test-convert-svn
@@ -58,3 +58,58 @@ echo 'hgext.graphlog =' >> $HGRCPATH
echo 'hgext.graphlog =' >> $HGRCPATH
hg glog -R fmap --template '#rev# #desc|firstline# files: #files#\n'
+########################################
+
+echo "# now tests that it works with trunk/branches/tags layout"
+echo
+echo % initial svn import
+mkdir projA
+cd projA
+mkdir trunk
+mkdir branches
+mkdir tags
+cd ..
+
+svnurl=file://$svnpath/svn-repo/projA
+svn import -m "init projA" projA $svnurl | fix_path
+
+
+echo % update svn repository
+svn co $svnurl/trunk A | fix_path
+cd A
+echo hello > letter.txt
+svn add letter.txt
+svn ci -m hello
+
+echo world >> letter.txt
+svn ci -m world
+
+svn copy -m "tag v0.1" $svnurl/trunk $svnurl/tags/v0.1
+
+echo 'nice day today!' >> letter.txt
+svn ci -m "nice day"
+cd ..
+
+echo % convert to hg once
+hg convert $svnurl A-hg
+
+echo % update svn repository again
+cd A
+echo "see second letter" >> letter.txt
+echo "nice to meet you" > letter2.txt
+svn add letter2.txt
+svn ci -m "second letter"
+
+svn copy -m "tag v0.2" $svnurl/trunk $svnurl/tags/v0.2
+
+echo "blah-blah-blah" >> letter2.txt
+svn ci -m "work in progress"
+cd ..
+
+echo % test incremental conversion
+hg convert $svnurl A-hg
+
+cd A-hg
+hg glog --template '#rev# #desc|firstline# files: #files#\n'
+hg tags -q
+cd ..
diff --git a/tests/test-convert-svn.out b/tests/test-convert-svn.out
--- a/tests/test-convert-svn.out
+++ b/tests/test-convert-svn.out
@@ -42,3 +42,73 @@ o 1 changeb files: b
|
o 0 changea files: b
+# now tests that it works with trunk/branches/tags layout
+
+% initial svn import
+Adding projA/trunk
+Adding projA/branches
+Adding projA/tags
+
+Committed revision 4.
+% update svn repository
+Checked out revision 4.
+A letter.txt
+Adding letter.txt
+Transmitting file data .
+Committed revision 5.
+Sending letter.txt
+Transmitting file data .
+Committed revision 6.
+
+Committed revision 7.
+Sending letter.txt
+Transmitting file data .
+Committed revision 8.
+% convert to hg once
+initializing destination A-hg repository
+scanning source...
+sorting...
+converting...
+3 init projA
+2 hello
+1 world
+0 nice day
+updating tags
+% update svn repository again
+A letter2.txt
+Sending letter.txt
+Adding letter2.txt
+Transmitting file data ..
+Committed revision 9.
+
+Committed revision 10.
+Sending letter2.txt
+Transmitting file data .
+Committed revision 11.
+% test incremental conversion
+destination A-hg is a Mercurial repository
+scanning source...
+sorting...
+converting...
+1 second letter
+0 work in progress
+updating tags
+o 7 update tags files: .hgtags
+|
+o 6 work in progress files: letter2.txt
+|
+o 5 second letter files: letter.txt letter2.txt
+|
+o 4 update tags files: .hgtags
+|
+o 3 nice day files: letter.txt
+|
+o 2 world files: letter.txt
+|
+o 1 hello files: letter.txt
+|
+o 0 init projA files:
+
+tip
+v0.2
+v0.1
More information about the Mercurial-devel
mailing list