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