Mercurial > hg
changeset 5462:91a522a69c13
convert: svn -- fix tags handling
They were simply not detected.
author | Kirill Smelkov <kirr@landau.phys.spbu.ru> |
---|---|
date | Sat, 13 Oct 2007 15:25:11 +0400 |
parents | ab4d2e9f3b97 |
children | 3b204881f959 |
files | hgext/convert/subversion.py tests/test-convert-svn tests/test-convert-svn.out |
diffstat | 3 files changed, 145 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/subversion.py Sat Oct 13 15:22:03 2007 +0400 +++ b/hgext/convert/subversion.py Sat Oct 13 15:25:11 2007 +0400 @@ -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 @@ 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 @@ 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 @@ 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)
--- a/tests/test-convert-svn Sat Oct 13 15:22:03 2007 +0400 +++ b/tests/test-convert-svn Sat Oct 13 15:25:11 2007 +0400 @@ -58,3 +58,58 @@ 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 ..
--- a/tests/test-convert-svn.out Sat Oct 13 15:22:03 2007 +0400 +++ b/tests/test-convert-svn.out Sat Oct 13 15:25:11 2007 +0400 @@ -42,3 +42,73 @@ | 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