Show More
@@ -0,0 +1,60 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | "$TESTDIR/hghave" svn svn-bindings || exit 80 | |||
|
4 | ||||
|
5 | fix_path() | |||
|
6 | { | |||
|
7 | tr '\\' / | |||
|
8 | } | |||
|
9 | ||||
|
10 | echo "[extensions]" >> $HGRCPATH | |||
|
11 | echo "convert = " >> $HGRCPATH | |||
|
12 | echo "hgext.graphlog =" >> $HGRCPATH | |||
|
13 | ||||
|
14 | svnadmin create svn-repo | |||
|
15 | ||||
|
16 | svnpath=`pwd | fix_path` | |||
|
17 | # SVN wants all paths to start with a slash. Unfortunately, | |||
|
18 | # Windows ones don't. Handle that. | |||
|
19 | expr $svnpath : "\/" > /dev/null | |||
|
20 | if [ $? -ne 0 ]; then | |||
|
21 | svnpath='/'$svnpath | |||
|
22 | fi | |||
|
23 | ||||
|
24 | echo % initial svn import | |||
|
25 | mkdir projA | |||
|
26 | cd projA | |||
|
27 | mkdir trunk | |||
|
28 | mkdir trunk/d1 | |||
|
29 | echo b > trunk/d1/b | |||
|
30 | cd .. | |||
|
31 | ||||
|
32 | svnurl=file://$svnpath/svn-repo/projA | |||
|
33 | svn import -m "init projA" projA $svnurl | fix_path | |||
|
34 | ||||
|
35 | # Build a module renaming chain which used to confuse the converter. | |||
|
36 | echo % update svn repository | |||
|
37 | svn co $svnurl A | fix_path | |||
|
38 | cd A | |||
|
39 | svn mv $svnurl/trunk $svnurl/subproject -m movedtrunk | |||
|
40 | svn up | |||
|
41 | mkdir subproject/trunk | |||
|
42 | svn add subproject/trunk | |||
|
43 | svn ci -m createtrunk | |||
|
44 | mkdir subproject/branches | |||
|
45 | svn add subproject/branches | |||
|
46 | svn ci -m createbranches | |||
|
47 | svn mv $svnurl/subproject/d1 $svnurl/subproject/trunk/d1 -m moved1 | |||
|
48 | svn up | |||
|
49 | echo b >> subproject/trunk/d1/b | |||
|
50 | svn ci -m changeb | |||
|
51 | svn mv $svnurl/subproject/trunk/d1 $svnurl/subproject/branches/d1 -m moved1again | |||
|
52 | cd .. | |||
|
53 | ||||
|
54 | echo % convert trunk and branches | |||
|
55 | hg convert --datesort $svnurl/subproject A-hg | |||
|
56 | ||||
|
57 | cd A-hg | |||
|
58 | hg glog --template '#rev# #desc|firstline# files: #files#\n' | |||
|
59 | hg branches | sed 's/:.*/:/' | |||
|
60 | cd .. |
@@ -0,0 +1,68 b'' | |||||
|
1 | % initial svn import | |||
|
2 | Adding projA/trunk | |||
|
3 | Adding projA/trunk/d1 | |||
|
4 | Adding projA/trunk/d1/b | |||
|
5 | ||||
|
6 | Committed revision 1. | |||
|
7 | % update svn repository | |||
|
8 | A A/trunk | |||
|
9 | A A/trunk/d1 | |||
|
10 | A A/trunk/d1/b | |||
|
11 | Checked out revision 1. | |||
|
12 | ||||
|
13 | Committed revision 2. | |||
|
14 | D trunk | |||
|
15 | A subproject | |||
|
16 | A subproject/d1 | |||
|
17 | A subproject/d1/b | |||
|
18 | Updated to revision 2. | |||
|
19 | A subproject/trunk | |||
|
20 | Adding subproject/trunk | |||
|
21 | ||||
|
22 | Committed revision 3. | |||
|
23 | A subproject/branches | |||
|
24 | Adding subproject/branches | |||
|
25 | ||||
|
26 | Committed revision 4. | |||
|
27 | ||||
|
28 | Committed revision 5. | |||
|
29 | A subproject/trunk/d1 | |||
|
30 | A subproject/trunk/d1/b | |||
|
31 | D subproject/d1 | |||
|
32 | Updated to revision 5. | |||
|
33 | Sending subproject/trunk/d1/b | |||
|
34 | Transmitting file data . | |||
|
35 | Committed revision 6. | |||
|
36 | ||||
|
37 | Committed revision 7. | |||
|
38 | % convert trunk and branches | |||
|
39 | initializing destination A-hg repository | |||
|
40 | scanning source... | |||
|
41 | sorting... | |||
|
42 | converting... | |||
|
43 | 7 init projA | |||
|
44 | 6 createtrunk | |||
|
45 | 5 moved1 | |||
|
46 | 4 moved1 | |||
|
47 | 3 changeb | |||
|
48 | 2 changeb | |||
|
49 | 1 moved1again | |||
|
50 | 0 moved1again | |||
|
51 | o 7 moved1again files: d1/b | |||
|
52 | | | |||
|
53 | | o 6 moved1again files: | |||
|
54 | | | | |||
|
55 | o | 5 changeb files: d1/b | |||
|
56 | | | | |||
|
57 | | o 4 changeb files: b | |||
|
58 | | | | |||
|
59 | o | 3 moved1 files: d1/b | |||
|
60 | | | | |||
|
61 | | o 2 moved1 files: | |||
|
62 | | | | |||
|
63 | o | 1 createtrunk files: | |||
|
64 | / | |||
|
65 | o 0 init projA files: b | |||
|
66 | ||||
|
67 | default 7: | |||
|
68 | d1 6: |
@@ -200,9 +200,9 b' class svn_source(converter_source):' | |||||
200 | except IOError, e: |
|
200 | except IOError, e: | |
201 | pass |
|
201 | pass | |
202 |
|
202 | |||
203 |
self. |
|
203 | self.head = self.latest(self.module, latest) | |
|
204 | self.last_changed = self.revnum(self.head) | |||
204 |
|
205 | |||
205 | self.head = self.revid(self.last_changed) |
|
|||
206 | self._changescache = None |
|
206 | self._changescache = None | |
207 |
|
207 | |||
208 | if os.path.exists(os.path.join(url, '.svn/entries')): |
|
208 | if os.path.exists(os.path.join(url, '.svn/entries')): | |
@@ -252,8 +252,7 b' class svn_source(converter_source):' | |||||
252 | if trunk: |
|
252 | if trunk: | |
253 | oldmodule = self.module or '' |
|
253 | oldmodule = self.module or '' | |
254 | self.module += '/' + trunk |
|
254 | self.module += '/' + trunk | |
255 |
|
|
255 | self.head = self.latest(self.module, self.last_changed) | |
256 | self.head = self.revid(lt) |
|
|||
257 |
|
256 | |||
258 | # First head in the list is the module's head |
|
257 | # First head in the list is the module's head | |
259 | self.heads = [self.head] |
|
258 | self.heads = [self.head] | |
@@ -266,10 +265,10 b' class svn_source(converter_source):' | |||||
266 | self.ctx) |
|
265 | self.ctx) | |
267 | for branch in branchnames.keys(): |
|
266 | for branch in branchnames.keys(): | |
268 | module = '%s/%s/%s' % (oldmodule, branches, branch) |
|
267 | module = '%s/%s/%s' % (oldmodule, branches, branch) | |
269 |
brev |
|
268 | brevid = self.latest(module, self.last_changed) | |
270 | brev = self.revid(brevnum, module) |
|
269 | self.ui.note('found branch %s at %d\n' % | |
271 | self.ui.note('found branch %s at %d\n' % (branch, brevnum)) |
|
270 | (branch, self.revnum(brevid))) | |
272 | self.heads.append(brev) |
|
271 | self.heads.append(brevid) | |
273 |
|
272 | |||
274 | return self.heads |
|
273 | return self.heads | |
275 |
|
274 | |||
@@ -369,7 +368,10 b' class svn_source(converter_source):' | |||||
369 | return uuid, mod, revnum |
|
368 | return uuid, mod, revnum | |
370 |
|
369 | |||
371 | def latest(self, path, stop=0): |
|
370 | def latest(self, path, stop=0): | |
372 |
|
|
371 | """Find the latest revid affecting path, up to stop. It may return | |
|
372 | a revision in a different module, since a branch may be moved without | |||
|
373 | a change being reported. | |||
|
374 | """ | |||
373 | if not stop: |
|
375 | if not stop: | |
374 | stop = svn.ra.get_latest_revnum(self.ra) |
|
376 | stop = svn.ra.get_latest_revnum(self.ra) | |
375 | try: |
|
377 | try: | |
@@ -381,7 +383,28 b' class svn_source(converter_source):' | |||||
381 | if not dirent: |
|
383 | if not dirent: | |
382 | raise util.Abort('%s not found up to revision %d' % (path, stop)) |
|
384 | raise util.Abort('%s not found up to revision %d' % (path, stop)) | |
383 |
|
385 | |||
384 | return dirent.created_rev |
|
386 | # stat() gives us the previous revision on this line of development, but | |
|
387 | # it might be in *another module*. Fetch the log and detect renames down | |||
|
388 | # to the latest revision. | |||
|
389 | stream = get_log(self.url, [path], stop, dirent.created_rev) | |||
|
390 | try: | |||
|
391 | for entry in stream: | |||
|
392 | paths, revnum, author, date, message = entry | |||
|
393 | if revnum <= dirent.created_rev: | |||
|
394 | break | |||
|
395 | ||||
|
396 | for p in paths: | |||
|
397 | if not path.startswith(p) or not paths[p].copyfrom_path: | |||
|
398 | continue | |||
|
399 | newpath = paths[p].copyfrom_path + path[len(p):] | |||
|
400 | self.ui.debug("branch renamed from %s to %s at %d\n" % | |||
|
401 | (path, newpath, revnum)) | |||
|
402 | path = newpath | |||
|
403 | break | |||
|
404 | finally: | |||
|
405 | stream.close() | |||
|
406 | ||||
|
407 | return self.revid(dirent.created_rev, path) | |||
385 |
|
408 | |||
386 | def get_blacklist(self): |
|
409 | def get_blacklist(self): | |
387 | """Avoid certain revision numbers. |
|
410 | """Avoid certain revision numbers. | |
@@ -624,10 +647,11 b' class svn_source(converter_source):' | |||||
624 | ent = orig_paths[self.module] |
|
647 | ent = orig_paths[self.module] | |
625 | if ent.copyfrom_path: |
|
648 | if ent.copyfrom_path: | |
626 | # ent.copyfrom_rev may not be the actual last revision |
|
649 | # ent.copyfrom_rev may not be the actual last revision | |
627 | prev = self.latest(ent.copyfrom_path, ent.copyfrom_rev) |
|
650 | previd = self.latest(ent.copyfrom_path, ent.copyfrom_rev) | |
628 |
parents = [ |
|
651 | parents = [previd] | |
629 | self.ui.note('found parent of branch %s at %d: %s\n' % \ |
|
652 | prevmodule, prevnum = self.revsplit(previd)[1:] | |
630 | (self.module, prev, ent.copyfrom_path)) |
|
653 | self.ui.note('found parent of branch %s at %d: %s\n' % | |
|
654 | (self.module, prevnum, prevmodule)) | |||
631 | else: |
|
655 | else: | |
632 | self.ui.debug("No copyfrom path, don't know what to do.\n") |
|
656 | self.ui.debug("No copyfrom path, don't know what to do.\n") | |
633 |
|
657 | |||
@@ -704,7 +728,7 b' class svn_source(converter_source):' | |||||
704 | firstrevnum = self.revnum(firstcset.rev) |
|
728 | firstrevnum = self.revnum(firstcset.rev) | |
705 | if firstrevnum > 1: |
|
729 | if firstrevnum > 1: | |
706 | latest = self.latest(self.module, firstrevnum - 1) |
|
730 | latest = self.latest(self.module, firstrevnum - 1) | |
707 |
firstcset.parents.append( |
|
731 | firstcset.parents.append(latest) | |
708 | except util.Abort: |
|
732 | except util.Abort: | |
709 | pass |
|
733 | pass | |
710 | except SubversionException, (inst, num): |
|
734 | except SubversionException, (inst, num): |
General Comments 0
You need to be logged in to leave comments.
Login now