##// END OF EJS Templates
convert/svn: handle files/links replaced by dirs (issue2166)
Patrick Mezard -
r11128:a9b427b5 stable
parent child Browse files
Show More
@@ -0,0 +1,241 b''
1 SVN-fs-dump-format-version: 2
2
3 UUID: 4a895937-439c-4e56-b7b0-fa1c8acc0c20
4
5 Revision-number: 0
6 Prop-content-length: 56
7 Content-length: 56
8
9 K 8
10 svn:date
11 V 27
12 2010-05-09T14:57:31.007802Z
13 PROPS-END
14
15 Revision-number: 1
16 Prop-content-length: 108
17 Content-length: 108
18
19 K 7
20 svn:log
21 V 7
22 initial
23 K 10
24 svn:author
25 V 7
26 pmezard
27 K 8
28 svn:date
29 V 27
30 2010-05-09T14:57:32.094732Z
31 PROPS-END
32
33 Node-path: branches
34 Node-kind: dir
35 Node-action: add
36 Prop-content-length: 10
37 Content-length: 10
38
39 PROPS-END
40
41
42 Node-path: trunk
43 Node-kind: dir
44 Node-action: add
45 Prop-content-length: 10
46 Content-length: 10
47
48 PROPS-END
49
50
51 Node-path: trunk/a
52 Node-kind: file
53 Node-action: add
54 Prop-content-length: 10
55 Text-content-length: 2
56 Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3
57 Text-content-sha1: 3f786850e387550fdab836ed7e6dc881de23001b
58 Content-length: 12
59
60 PROPS-END
61 a
62
63
64 Node-path: trunk/d
65 Node-kind: dir
66 Node-action: add
67 Prop-content-length: 10
68 Content-length: 10
69
70 PROPS-END
71
72
73 Node-path: trunk/d/b
74 Node-kind: file
75 Node-action: add
76 Prop-content-length: 10
77 Text-content-length: 2
78 Text-content-md5: 3b5d5c3712955042212316173ccf37be
79 Text-content-sha1: 89e6c98d92887913cadf06b2adb97f26cde4849b
80 Content-length: 12
81
82 PROPS-END
83 b
84
85
86 Node-path: trunk/dlink
87 Node-kind: file
88 Node-action: add
89 Prop-content-length: 33
90 Text-content-length: 6
91 Text-content-md5: cca56829f18345718a4980bb02b6d8c3
92 Text-content-sha1: 7c54cc5d472b78c94a04382df34b0f4f0f4f2d49
93 Content-length: 39
94
95 K 11
96 svn:special
97 V 1
98 *
99 PROPS-END
100 link d
101
102 Node-path: trunk/dlink2
103 Node-kind: file
104 Node-action: add
105 Prop-content-length: 33
106 Text-content-length: 6
107 Text-content-md5: cca56829f18345718a4980bb02b6d8c3
108 Text-content-sha1: 7c54cc5d472b78c94a04382df34b0f4f0f4f2d49
109 Content-length: 39
110
111 K 11
112 svn:special
113 V 1
114 *
115 PROPS-END
116 link d
117
118 Node-path: trunk/dlink3
119 Node-kind: file
120 Node-action: add
121 Prop-content-length: 33
122 Text-content-length: 6
123 Text-content-md5: cca56829f18345718a4980bb02b6d8c3
124 Text-content-sha1: 7c54cc5d472b78c94a04382df34b0f4f0f4f2d49
125 Content-length: 39
126
127 K 11
128 svn:special
129 V 1
130 *
131 PROPS-END
132 link d
133
134 Revision-number: 2
135 Prop-content-length: 117
136 Content-length: 117
137
138 K 7
139 svn:log
140 V 15
141 clobber symlink
142 K 10
143 svn:author
144 V 7
145 pmezard
146 K 8
147 svn:date
148 V 27
149 2010-05-09T14:57:33.071117Z
150 PROPS-END
151
152 Node-path: trunk/dlink3
153 Node-kind: file
154 Node-action: change
155 Prop-content-length: 10
156 Text-content-length: 2
157 Text-content-md5: e29311f6f1bf1af907f9ef9f44b8328b
158 Text-content-sha1: e983f374794de9c64e3d1c1de1d490c0756eeeff
159 Content-length: 12
160
161 PROPS-END
162 d
163
164
165 Revision-number: 3
166 Prop-content-length: 106
167 Content-length: 106
168
169 K 7
170 svn:log
171 V 8
172 clobber1
173 K 10
174 svn:author
175 V 4
176 evil
177 K 8
178 svn:date
179 V 27
180 2010-05-09T14:57:35.268057Z
181 PROPS-END
182
183 Node-path: trunk/a
184 Node-kind: dir
185 Node-action: delete
186
187 Node-path: trunk/a
188 Node-kind: dir
189 Node-action: add
190 Node-copyfrom-rev: 2
191 Node-copyfrom-path: trunk/d
192
193
194
195
196 Node-path: trunk/dlink
197 Node-kind: dir
198 Node-action: delete
199
200 Node-path: trunk/dlink
201 Node-kind: dir
202 Node-action: add
203 Node-copyfrom-rev: 2
204 Node-copyfrom-path: trunk/d
205
206
207
208
209 Revision-number: 4
210 Prop-content-length: 106
211 Content-length: 106
212
213 K 7
214 svn:log
215 V 8
216 clobber2
217 K 10
218 svn:author
219 V 4
220 evil
221 K 8
222 svn:date
223 V 27
224 2010-05-09T14:57:35.521816Z
225 PROPS-END
226
227 Node-path: trunk/dlink3
228 Node-kind: file
229 Node-action: delete
230
231 Node-path: trunk/dlink3
232 Node-kind: file
233 Node-action: add
234 Node-copyfrom-rev: 3
235 Node-copyfrom-path: trunk/dlink2
236 Text-copy-source-md5: cca56829f18345718a4980bb02b6d8c3
237 Text-copy-source-sha1: 7c54cc5d472b78c94a04382df34b0f4f0f4f2d49
238
239
240
241
@@ -0,0 +1,55 b''
1 #!/bin/sh
2
3 RSVN="`pwd`/rsvn.py"
4 export PATH=/bin:/usr/bin
5 mkdir temp
6 cd temp
7
8 svnadmin create repo
9 svn co file://`pwd`/repo wc
10
11 cd wc
12 mkdir trunk branches
13 cd trunk
14 echo a > a
15 mkdir d
16 echo b > d/b
17 ln -s d dlink
18 ln -s d dlink2
19 ln -s d dlink3
20 cd ..
21 svn add *
22 svn ci -m 'initial'
23 # Clobber symlink with file with similar content
24 cd trunk
25 ls -Alh
26 readlink dlink3 > dlink3tmp
27 rm dlink3
28 mv dlink3tmp dlink3
29 svn propdel svn:special dlink3
30 svn ci -m 'clobber symlink'
31 cd ..
32 svn up
33
34 # Clobber files and symlink with directories
35 cd ..
36 cat > clobber.rsvn <<EOF
37 rdelete trunk/a
38 rdelete trunk/dlink
39 rcopy trunk/d trunk/a
40 rcopy trunk/d trunk/dlink
41 EOF
42
43 python $RSVN --message=clobber1 --username=evil `pwd`/repo < clobber.rsvn
44
45 # Clobber non-symlink with symlink with same content (kudos openwrt)
46 cat > clobber.rsvn <<EOF
47 rdelete trunk/dlink3
48 rcopy trunk/dlink2 trunk/dlink3
49 EOF
50
51 python $RSVN --message=clobber2 --username=evil `pwd`/repo < clobber.rsvn
52
53 svn log -v file://`pwd`/repo
54
55 svnadmin dump repo > ../replace.svndump
@@ -645,14 +645,7 b' class svn_source(converter_source):'
645 self.ui.debug("gone from %s\n" % ent.copyfrom_rev)
645 self.ui.debug("gone from %s\n" % ent.copyfrom_rev)
646 pmodule, prevnum = self.revsplit(parents[0])[1:]
646 pmodule, prevnum = self.revsplit(parents[0])[1:]
647 parentpath = pmodule + "/" + entrypath
647 parentpath = pmodule + "/" + entrypath
648 self.ui.debug("entry %s\n" % parentpath)
648 fromkind = self._checkpath(entrypath, prevnum, pmodule)
649
650 # We can avoid the reparent calls if the module has
651 # not changed but it probably does not worth the pain.
652 prevmodule = self.reparent('')
653 fromkind = svn.ra.check_path(self.ra, parentpath.strip('/'),
654 prevnum)
655 self.reparent(prevmodule)
656
649
657 if fromkind == svn.core.svn_node_file:
650 if fromkind == svn.core.svn_node_file:
658 removed.add(self.recode(entrypath))
651 removed.add(self.recode(entrypath))
@@ -668,11 +661,18 b' class svn_source(converter_source):'
668 else:
661 else:
669 self.ui.debug('unknown path in revision %d: %s\n' % \
662 self.ui.debug('unknown path in revision %d: %s\n' % \
670 (revnum, path))
663 (revnum, path))
671 elif kind == svn.core.svn_node_dir:
664 elif kind == svn.core.svn_node_dir:
672 # If the directory just had a prop change,
673 # then we shouldn't need to look for its children.
674 if ent.action == 'M':
665 if ent.action == 'M':
666 # If the directory just had a prop change,
667 # then we shouldn't need to look for its children.
675 continue
668 continue
669 elif ent.action == 'R' and parents:
670 # If a directory is replacing a file, mark the previous
671 # file as deleted
672 pmodule, prevnum = self.revsplit(parents[0])[1:]
673 pkind = self._checkpath(entrypath, prevnum, pmodule)
674 if pkind == svn.core.svn_node_file:
675 removed.add(self.recode(entrypath))
676
676
677 children = sorted(self._find_children(path, revnum))
677 children = sorted(self._find_children(path, revnum))
678 for child in children:
678 for child in children:
@@ -898,11 +898,18 b' class svn_source(converter_source):'
898 self.ui.debug('%r is not under %r, ignoring\n' % (path, module))
898 self.ui.debug('%r is not under %r, ignoring\n' % (path, module))
899 return None
899 return None
900
900
901 def _checkpath(self, path, revnum):
901 def _checkpath(self, path, revnum, module=None):
902 # ra.check_path does not like leading slashes very much, it leads
902 if module is not None:
903 # to PROPFIND subversion errors
903 prevmodule = self.reparent('')
904 return svn.ra.check_path(self.ra, path.strip('/'), revnum)
904 path = module + '/' + path
905
905 try:
906 # ra.check_path does not like leading slashes very much, it leads
907 # to PROPFIND subversion errors
908 return svn.ra.check_path(self.ra, path.strip('/'), revnum)
909 finally:
910 if module is not None:
911 self.reparent(prevmodule)
912
906 def _getlog(self, paths, start, end, limit=0, discover_changed_paths=True,
913 def _getlog(self, paths, start, end, limit=0, discover_changed_paths=True,
907 strict_node_history=False):
914 strict_node_history=False):
908 # Normalize path names, svn >= 1.5 only wants paths relative to
915 # Normalize path names, svn >= 1.5 only wants paths relative to
@@ -33,3 +33,21 b' hg st --rev 12:13 --copies'
33 echo '% check branches'
33 echo '% check branches'
34 hg branches | sed 's/:.*/:/'
34 hg branches | sed 's/:.*/:/'
35 cd ..
35 cd ..
36
37 mkdir test-replace
38 cd test-replace
39 svnadmin create svn-repo
40 cat "$TESTDIR/svn/replace.svndump" | svnadmin load svn-repo > /dev/null
41
42 echo '% convert files being replaced by directories'
43 hg convert svn-repo hg-repo
44 cd hg-repo
45 echo '% manifest before'
46 hg -v manifest -r 1
47 echo '% manifest after clobber1'
48 hg -v manifest -r 2
49 echo '% manifest after clobber2'
50 hg -v manifest -r 3
51 echo '% try updating'
52 hg up -qC default
53 cd ..
@@ -52,3 +52,31 b' R d4old/g'
52 % check branches
52 % check branches
53 default 13:
53 default 13:
54 d1 6:
54 d1 6:
55 % convert files being replaced by directories
56 initializing destination hg-repo repository
57 scanning source...
58 sorting...
59 converting...
60 3 initial
61 2 clobber symlink
62 1 clobber1
63 0 clobber2
64 % manifest before
65 644 a
66 644 d/b
67 644 @ dlink
68 644 @ dlink2
69 644 dlink3
70 % manifest after clobber1
71 644 a/b
72 644 d/b
73 644 dlink/b
74 644 @ dlink2
75 644 dlink3
76 % manifest after clobber2
77 644 a/b
78 644 d/b
79 644 dlink/b
80 644 @ dlink2
81 644 @ dlink3
82 % try updating
General Comments 0
You need to be logged in to leave comments. Login now