##// END OF EJS Templates
convert: prevent svn branches to leave the root module tree
Patrick Mezard -
r5957:971a17af default
parent child Browse files
Show More
@@ -182,6 +182,7 b' class svn_source(converter_source):'
182 182 self.ctx = self.transport.client
183 183 self.base = svn.ra.get_repos_root(self.ra)
184 184 self.module = self.url[len(self.base):]
185 self.rootmodule = self.module
185 186 self.commits = {}
186 187 self.paths = {}
187 188 self.uuid = svn.ra.get_uuid(self.ra).decode(self.encoding)
@@ -201,6 +202,9 b' class svn_source(converter_source):'
201 202 pass
202 203
203 204 self.head = self.latest(self.module, latest)
205 if not self.head:
206 raise util.Abort(_('no revision found in module %s') %
207 self.module.encode(self.encoding))
204 208 self.last_changed = self.revnum(self.head)
205 209
206 210 self._changescache = None
@@ -253,6 +257,9 b' class svn_source(converter_source):'
253 257 oldmodule = self.module or ''
254 258 self.module += '/' + trunk
255 259 self.head = self.latest(self.module, self.last_changed)
260 if not self.head:
261 raise util.Abort(_('no revision found in module %s') %
262 self.module.encode(self.encoding))
256 263
257 264 # First head in the list is the module's head
258 265 self.heads = [self.head]
@@ -266,6 +273,10 b' class svn_source(converter_source):'
266 273 for branch in branchnames.keys():
267 274 module = '%s/%s/%s' % (oldmodule, branches, branch)
268 275 brevid = self.latest(module, self.last_changed)
276 if not brevid:
277 self.ui.note(_('ignoring empty branch %s\n') %
278 branch.encode(self.encoding))
279 continue
269 280 self.ui.note('found branch %s at %d\n' %
270 281 (branch, self.revnum(brevid)))
271 282 self.heads.append(brevid)
@@ -380,7 +391,8 b' class svn_source(converter_source):'
380 391 def latest(self, path, stop=0):
381 392 """Find the latest revid affecting path, up to stop. It may return
382 393 a revision in a different module, since a branch may be moved without
383 a change being reported.
394 a change being reported. Return None if computed module does not
395 belong to rootmodule subtree.
384 396 """
385 397 if not stop:
386 398 stop = svn.ra.get_latest_revnum(self.ra)
@@ -414,6 +426,9 b' class svn_source(converter_source):'
414 426 finally:
415 427 stream.close()
416 428
429 if not path.startswith(self.rootmodule):
430 self.ui.debug(_('ignoring foreign branch %r\n') % path)
431 return None
417 432 return self.revid(dirent.created_rev, path)
418 433
419 434 def get_blacklist(self):
@@ -645,19 +660,22 b' class svn_source(converter_source):'
645 660 self.ui.debug("parsing revision %d (%d changes)\n" %
646 661 (revnum, len(orig_paths)))
647 662
663 branched = False
648 664 rev = self.revid(revnum)
649 665 # branch log might return entries for a parent we already have
650 666
651 667 if (rev in self.commits or revnum < to_revnum):
652 return None, False
668 return None, branched
653 669
654 670 parents = []
655 671 # check whether this revision is the start of a branch
656 672 if self.module in orig_paths:
657 673 ent = orig_paths[self.module]
658 674 if ent.copyfrom_path:
675 branched = True
659 676 # ent.copyfrom_rev may not be the actual last revision
660 677 previd = self.latest(ent.copyfrom_path, ent.copyfrom_rev)
678 if previd is not None:
661 679 parents = [previd]
662 680 prevmodule, prevnum = self.revsplit(previd)[1:]
663 681 self.ui.note('found parent of branch %s at %d: %s\n' %
@@ -703,13 +721,14 b' class svn_source(converter_source):'
703 721 if self.child_cset and not self.child_cset.parents:
704 722 self.child_cset.parents[:] = [rev]
705 723 self.child_cset = cset
706 return cset, len(parents) > 0
724 return cset, branched
707 725
708 726 self.ui.note('fetching revision log for "%s" from %d to %d\n' %
709 727 (self.module, from_revnum, to_revnum))
710 728
711 729 try:
712 730 firstcset = None
731 branched = False
713 732 stream = get_log(self.url, [self.module], from_revnum, to_revnum)
714 733 try:
715 734 for entry in stream:
@@ -730,7 +749,7 b' class svn_source(converter_source):'
730 749 finally:
731 750 stream.close()
732 751
733 if firstcset and not firstcset.parents:
752 if not branched and firstcset and not firstcset.parents:
734 753 # The first revision of the sequence (the last fetched one)
735 754 # has invalid parents if not a branch root. Find the parent
736 755 # revision now, if any.
@@ -738,6 +757,7 b' class svn_source(converter_source):'
738 757 firstrevnum = self.revnum(firstcset.rev)
739 758 if firstrevnum > 1:
740 759 latest = self.latest(self.module, firstrevnum - 1)
760 if latest:
741 761 firstcset.parents.append(latest)
742 762 except util.Abort:
743 763 pass
@@ -25,8 +25,10 b' echo % initial svn import'
25 25 mkdir projA
26 26 cd projA
27 27 mkdir trunk
28 echo a > trunk/a
28 29 mkdir trunk/d1
29 30 echo b > trunk/d1/b
31 echo c > trunk/d1/c
30 32 cd ..
31 33
32 34 svnurl=file://$svnpath/svn-repo/projA
@@ -36,6 +38,9 b' svn import -m "init projA" projA $svnurl'
36 38 echo % update svn repository
37 39 svn co $svnurl A | fix_path
38 40 cd A
41 echo a >> trunk/a
42 echo c >> trunk/d1/c
43 svn ci -m commitbeforemove
39 44 svn mv $svnurl/trunk $svnurl/subproject -m movedtrunk
40 45 svn up
41 46 mkdir subproject/trunk
@@ -1,46 +1,56 b''
1 1 % initial svn import
2 2 Adding projA/trunk
3 Adding projA/trunk/a
3 4 Adding projA/trunk/d1
4 5 Adding projA/trunk/d1/b
6 Adding projA/trunk/d1/c
5 7
6 8 Committed revision 1.
7 9 % update svn repository
8 10 A A/trunk
11 A A/trunk/a
9 12 A A/trunk/d1
10 13 A A/trunk/d1/b
14 A A/trunk/d1/c
11 15 Checked out revision 1.
16 Sending trunk/a
17 Sending trunk/d1/c
18 Transmitting file data ..
19 Committed revision 2.
12 20
13 Committed revision 2.
21 Committed revision 3.
14 22 D trunk
15 23 A subproject
24 A subproject/a
16 25 A subproject/d1
17 26 A subproject/d1/b
18 Updated to revision 2.
27 A subproject/d1/c
28 Updated to revision 3.
19 29 A subproject/trunk
20 30 Adding subproject/trunk
21 31
22 Committed revision 3.
32 Committed revision 4.
23 33 A subproject/branches
24 34 Adding subproject/branches
25 35
26 Committed revision 4.
36 Committed revision 5.
27 37
28 Committed revision 5.
38 Committed revision 6.
29 39 A subproject/trunk/d1
30 40 A subproject/trunk/d1/b
41 A subproject/trunk/d1/c
31 42 D subproject/d1
32 Updated to revision 5.
43 Updated to revision 6.
33 44 Sending subproject/trunk/d1/b
34 45 Transmitting file data .
35 Committed revision 6.
46 Committed revision 7.
36 47
37 Committed revision 7.
48 Committed revision 8.
38 49 % convert trunk and branches
39 50 initializing destination A-hg repository
40 51 scanning source...
41 52 sorting...
42 53 converting...
43 7 init projA
44 54 6 createtrunk
45 55 5 moved1
46 56 4 moved1
@@ -48,21 +58,19 b' 3 changeb'
48 58 2 changeb
49 59 1 moved1again
50 60 0 moved1again
51 o 7 moved1again files: d1/b
61 o 6 moved1again files: d1/b d1/c
52 62 |
53 | o 6 moved1again files:
63 | o 5 moved1again files:
54 64 | |
55 o | 5 changeb files: d1/b
65 o | 4 changeb files: d1/b
56 66 | |
57 | o 4 changeb files: b
67 | o 3 changeb files: b
58 68 | |
59 o | 3 moved1 files: d1/b
60 | |
61 | o 2 moved1 files:
69 o | 2 moved1 files: d1/b d1/c
62 70 | |
63 o | 1 createtrunk files:
64 /
65 o 0 init projA files: b
71 | o 1 moved1 files: b c
72 |
73 o 0 createtrunk files:
66 74
67 default 7:
68 d1 6:
75 default 6:
76 d1 5:
General Comments 0
You need to be logged in to leave comments. Login now