Show More
@@ -0,0 +1,51 b'' | |||||
|
1 | # Read the output of a "svn log --xml" command on stdin, parse it and | |||
|
2 | # print a subset of attributes common to all svn versions tested by | |||
|
3 | # hg. | |||
|
4 | import xml.dom.minidom, sys | |||
|
5 | ||||
|
6 | def xmltext(e): | |||
|
7 | return ''.join(c.data for c | |||
|
8 | in e.childNodes | |||
|
9 | if c.nodeType == c.TEXT_NODE) | |||
|
10 | ||||
|
11 | def parseentry(entry): | |||
|
12 | e = {} | |||
|
13 | e['revision'] = entry.getAttribute('revision') | |||
|
14 | e['author'] = xmltext(entry.getElementsByTagName('author')[0]) | |||
|
15 | e['msg'] = xmltext(entry.getElementsByTagName('msg')[0]) | |||
|
16 | e['paths'] = [] | |||
|
17 | paths = entry.getElementsByTagName('paths') | |||
|
18 | if paths: | |||
|
19 | paths = paths[0] | |||
|
20 | for p in paths.getElementsByTagName('path'): | |||
|
21 | action = p.getAttribute('action') | |||
|
22 | path = xmltext(p) | |||
|
23 | frompath = p.getAttribute('copyfrom-path') | |||
|
24 | fromrev = p.getAttribute('copyfrom-rev') | |||
|
25 | e['paths'].append((path, action, frompath, fromrev)) | |||
|
26 | return e | |||
|
27 | ||||
|
28 | def parselog(data): | |||
|
29 | entries = [] | |||
|
30 | doc = xml.dom.minidom.parseString(data) | |||
|
31 | for e in doc.getElementsByTagName('logentry'): | |||
|
32 | entries.append(parseentry(e)) | |||
|
33 | return entries | |||
|
34 | ||||
|
35 | def printentries(entries): | |||
|
36 | fp = sys.stdout | |||
|
37 | for e in entries: | |||
|
38 | for k in ('revision', 'author', 'msg'): | |||
|
39 | fp.write(('%s: %s\n' % (k, e[k])).encode('utf-8')) | |||
|
40 | for path, action, fpath, frev in sorted(e['paths']): | |||
|
41 | frominfo = '' | |||
|
42 | if frev: | |||
|
43 | frominfo = ' (from %s@%s)' % (fpath, frev) | |||
|
44 | p = ' %s %s%s\n' % (action, path, frominfo) | |||
|
45 | fp.write(p.encode('utf-8')) | |||
|
46 | ||||
|
47 | if __name__ == '__main__': | |||
|
48 | data = sys.stdin.read() | |||
|
49 | entries = parselog(data) | |||
|
50 | printentries(entries) | |||
|
51 |
@@ -8,16 +8,13 b'' | |||||
8 | > { |
|
8 | > { | |
9 | > ( |
|
9 | > ( | |
10 | > cd $1; |
|
10 | > cd $1; | |
11 | > svn up; |
|
11 | > svn up -q; | |
12 | > svn st -v | fixpath | sed 's/ */ /g' |
|
12 | > svn st -v | fixpath | sed 's/ */ /g' | sort | |
13 | > limit='' |
|
13 | > limit='' | |
14 | > if [ $2 -gt 0 ]; then |
|
14 | > if [ $2 -gt 0 ]; then | |
15 | > limit="--limit=$2" |
|
15 | > limit="--limit=$2" | |
16 | > fi |
|
16 | > fi | |
17 |
> svn log --xml -v $limit |
|
17 | > svn log --xml -v $limit | python "$TESTDIR/svnxml.py" | |
18 | > | fixpath \ |
|
|||
19 | > | sed 's,<date>.*,<date/>,' \ |
|
|||
20 | > | grep -v 'kind="' |
|
|||
21 | > ) |
|
18 | > ) | |
22 | > } |
|
19 | > } | |
23 |
|
20 | |||
@@ -57,44 +54,24 b' Modify' | |||||
57 | 1 add a file |
|
54 | 1 add a file | |
58 | 0 modify a file |
|
55 | 0 modify a file | |
59 | $ svnupanddisplay a-hg-wc 2 |
|
56 | $ svnupanddisplay a-hg-wc 2 | |
60 | At revision 2. |
|
|||
61 | 2 2 test . |
|
|||
62 | 2 2 test a |
|
|||
63 | 2 1 test d1 |
|
57 | 2 1 test d1 | |
64 | 2 1 test d1/d2 |
|
58 | 2 1 test d1/d2 | |
65 | 2 1 test d1/d2/b |
|
59 | 2 1 test d1/d2/b | |
66 | 2 1 test link |
|
60 | 2 1 test link | |
67 | <?xml version="1.0"?> |
|
61 | 2 2 test . | |
68 | <log> |
|
62 | 2 2 test a | |
69 | <logentry |
|
63 | revision: 2 | |
70 | revision="2"> |
|
64 | author: test | |
71 | <author>test</author> |
|
65 | msg: modify a file | |
72 | <date/> |
|
66 | M /a | |
73 | <paths> |
|
67 | revision: 1 | |
74 | <path |
|
68 | author: test | |
75 | action="M">/a</path> |
|
69 | msg: add a file | |
76 | </paths> |
|
70 | A /a | |
77 | <msg>modify a file</msg> |
|
71 | A /d1 | |
78 | </logentry> |
|
72 | A /d1/d2 | |
79 | <logentry |
|
73 | A /d1/d2/b | |
80 | revision="1"> |
|
74 | A /link | |
81 | <author>test</author> |
|
|||
82 | <date/> |
|
|||
83 | <paths> |
|
|||
84 | <path |
|
|||
85 | action="A">/a</path> |
|
|||
86 | <path |
|
|||
87 | action="A">/d1</path> |
|
|||
88 | <path |
|
|||
89 | action="A">/d1/d2</path> |
|
|||
90 | <path |
|
|||
91 | action="A">/d1/d2/b</path> |
|
|||
92 | <path |
|
|||
93 | action="A">/link</path> |
|
|||
94 | </paths> |
|
|||
95 | <msg>add a file</msg> |
|
|||
96 | </logentry> |
|
|||
97 | </log> |
|
|||
98 | $ ls a a-hg-wc |
|
75 | $ ls a a-hg-wc | |
99 | a: |
|
76 | a: | |
100 | a |
|
77 | a | |
@@ -124,36 +101,19 b' Rename' | |||||
124 | converting... |
|
101 | converting... | |
125 | 0 rename a file |
|
102 | 0 rename a file | |
126 | $ svnupanddisplay a-hg-wc 1 |
|
103 | $ svnupanddisplay a-hg-wc 1 | |
127 | At revision 3. |
|
|||
128 | 3 3 test . |
|
|||
129 | 3 3 test b |
|
|||
130 | 3 1 test d1 |
|
104 | 3 1 test d1 | |
131 | 3 1 test d1/d2 |
|
105 | 3 1 test d1/d2 | |
132 | 3 1 test d1/d2/b |
|
106 | 3 1 test d1/d2/b | |
|
107 | 3 3 test . | |||
|
108 | 3 3 test b | |||
133 | 3 3 test newlink |
|
109 | 3 3 test newlink | |
134 | <?xml version="1.0"?> |
|
110 | revision: 3 | |
135 | <log> |
|
111 | author: test | |
136 | <logentry |
|
112 | msg: rename a file | |
137 | revision="3"> |
|
113 | D /a | |
138 | <author>test</author> |
|
114 | A /b (from /a@2) | |
139 | <date/> |
|
115 | D /link | |
140 | <paths> |
|
116 | A /newlink (from /link@2) | |
141 | <path |
|
|||
142 | action="D">/a</path> |
|
|||
143 | <path |
|
|||
144 | copyfrom-path="/a" |
|
|||
145 | copyfrom-rev="2" |
|
|||
146 | action="A">/b</path> |
|
|||
147 | <path |
|
|||
148 | copyfrom-path="/link" |
|
|||
149 | copyfrom-rev="2" |
|
|||
150 | action="A">/newlink</path> |
|
|||
151 | <path |
|
|||
152 | action="D">/link</path> |
|
|||
153 | </paths> |
|
|||
154 | <msg>rename a file</msg> |
|
|||
155 | </logentry> |
|
|||
156 | </log> |
|
|||
157 | $ ls a a-hg-wc |
|
117 | $ ls a a-hg-wc | |
158 | a: |
|
118 | a: | |
159 | b |
|
119 | b | |
@@ -181,29 +141,17 b' Copy' | |||||
181 | converting... |
|
141 | converting... | |
182 | 0 copy a file |
|
142 | 0 copy a file | |
183 | $ svnupanddisplay a-hg-wc 1 |
|
143 | $ svnupanddisplay a-hg-wc 1 | |
184 | At revision 4. |
|
|||
185 | 4 4 test . |
|
|||
186 | 4 3 test b |
|
|||
187 | 4 4 test c |
|
|||
188 | 4 1 test d1 |
|
144 | 4 1 test d1 | |
189 | 4 1 test d1/d2 |
|
145 | 4 1 test d1/d2 | |
190 | 4 1 test d1/d2/b |
|
146 | 4 1 test d1/d2/b | |
|
147 | 4 3 test b | |||
191 | 4 3 test newlink |
|
148 | 4 3 test newlink | |
192 | <?xml version="1.0"?> |
|
149 | 4 4 test . | |
193 | <log> |
|
150 | 4 4 test c | |
194 | <logentry |
|
151 | revision: 4 | |
195 | revision="4"> |
|
152 | author: test | |
196 | <author>test</author> |
|
153 | msg: copy a file | |
197 | <date/> |
|
154 | A /c (from /b@3) | |
198 | <paths> |
|
|||
199 | <path |
|
|||
200 | copyfrom-path="/b" |
|
|||
201 | copyfrom-rev="3" |
|
|||
202 | action="A">/c</path> |
|
|||
203 | </paths> |
|
|||
204 | <msg>copy a file</msg> |
|
|||
205 | </logentry> |
|
|||
206 | </log> |
|
|||
207 | $ ls a a-hg-wc |
|
155 | $ ls a a-hg-wc | |
208 | a: |
|
156 | a: | |
209 | b |
|
157 | b | |
@@ -233,26 +181,16 b' Remove' | |||||
233 | converting... |
|
181 | converting... | |
234 | 0 remove a file |
|
182 | 0 remove a file | |
235 | $ svnupanddisplay a-hg-wc 1 |
|
183 | $ svnupanddisplay a-hg-wc 1 | |
236 | At revision 5. |
|
|||
237 | 5 5 test . |
|
|||
238 | 5 4 test c |
|
|||
239 | 5 1 test d1 |
|
184 | 5 1 test d1 | |
240 | 5 1 test d1/d2 |
|
185 | 5 1 test d1/d2 | |
241 | 5 1 test d1/d2/b |
|
186 | 5 1 test d1/d2/b | |
242 | 5 3 test newlink |
|
187 | 5 3 test newlink | |
243 | <?xml version="1.0"?> |
|
188 | 5 4 test c | |
244 | <log> |
|
189 | 5 5 test . | |
245 | <logentry |
|
190 | revision: 5 | |
246 | revision="5"> |
|
191 | author: test | |
247 | <author>test</author> |
|
192 | msg: remove a file | |
248 | <date/> |
|
193 | D /b | |
249 | <paths> |
|
|||
250 | <path |
|
|||
251 | action="D">/b</path> |
|
|||
252 | </paths> |
|
|||
253 | <msg>remove a file</msg> |
|
|||
254 | </logentry> |
|
|||
255 | </log> |
|
|||
256 | $ ls a a-hg-wc |
|
194 | $ ls a a-hg-wc | |
257 | a: |
|
195 | a: | |
258 | c |
|
196 | c | |
@@ -279,26 +217,16 b' Exectutable' | |||||
279 | converting... |
|
217 | converting... | |
280 | 0 make a file executable |
|
218 | 0 make a file executable | |
281 | $ svnupanddisplay a-hg-wc 1 |
|
219 | $ svnupanddisplay a-hg-wc 1 | |
282 | At revision 6. |
|
|||
283 | 6 6 test . |
|
|||
284 | 6 6 test c |
|
|||
285 | 6 1 test d1 |
|
220 | 6 1 test d1 | |
286 | 6 1 test d1/d2 |
|
221 | 6 1 test d1/d2 | |
287 | 6 1 test d1/d2/b |
|
222 | 6 1 test d1/d2/b | |
288 | 6 3 test newlink |
|
223 | 6 3 test newlink | |
289 | <?xml version="1.0"?> |
|
224 | 6 6 test . | |
290 | <log> |
|
225 | 6 6 test c | |
291 | <logentry |
|
226 | revision: 6 | |
292 | revision="6"> |
|
227 | author: test | |
293 | <author>test</author> |
|
228 | msg: make a file executable | |
294 | <date/> |
|
229 | M /c | |
295 | <paths> |
|
|||
296 | <path |
|
|||
297 | action="M">/c</path> |
|
|||
298 | </paths> |
|
|||
299 | <msg>make a file executable</msg> |
|
|||
300 | </logentry> |
|
|||
301 | </log> |
|
|||
302 | $ test -x a-hg-wc/c |
|
230 | $ test -x a-hg-wc/c | |
303 |
|
231 | |||
304 | Executable in new directory |
|
232 | Executable in new directory | |
@@ -321,25 +249,14 b' Executable in new directory' | |||||
321 | converting... |
|
249 | converting... | |
322 | 0 add executable file in new directory |
|
250 | 0 add executable file in new directory | |
323 | $ svnupanddisplay a-hg-wc 1 |
|
251 | $ svnupanddisplay a-hg-wc 1 | |
324 | At revision 1. |
|
|||
325 | 1 1 test . |
|
252 | 1 1 test . | |
326 | 1 1 test d1 |
|
253 | 1 1 test d1 | |
327 | 1 1 test d1/a |
|
254 | 1 1 test d1/a | |
328 | <?xml version="1.0"?> |
|
255 | revision: 1 | |
329 | <log> |
|
256 | author: test | |
330 | <logentry |
|
257 | msg: add executable file in new directory | |
331 | revision="1"> |
|
258 | A /d1 | |
332 | <author>test</author> |
|
259 | A /d1/a | |
333 | <date/> |
|
|||
334 | <paths> |
|
|||
335 | <path |
|
|||
336 | action="A">/d1</path> |
|
|||
337 | <path |
|
|||
338 | action="A">/d1/a</path> |
|
|||
339 | </paths> |
|
|||
340 | <msg>add executable file in new directory</msg> |
|
|||
341 | </logentry> |
|
|||
342 | </log> |
|
|||
343 | $ test -x a-hg-wc/d1/a |
|
260 | $ test -x a-hg-wc/d1/a | |
344 |
|
261 | |||
345 | Copy to new directory |
|
262 | Copy to new directory | |
@@ -356,29 +273,16 b' Copy to new directory' | |||||
356 | converting... |
|
273 | converting... | |
357 | 0 copy file to new directory |
|
274 | 0 copy file to new directory | |
358 | $ svnupanddisplay a-hg-wc 1 |
|
275 | $ svnupanddisplay a-hg-wc 1 | |
359 | At revision 2. |
|
|||
360 | 2 2 test . |
|
|||
361 | 2 1 test d1 |
|
276 | 2 1 test d1 | |
362 | 2 1 test d1/a |
|
277 | 2 1 test d1/a | |
|
278 | 2 2 test . | |||
363 | 2 2 test d2 |
|
279 | 2 2 test d2 | |
364 | 2 2 test d2/a |
|
280 | 2 2 test d2/a | |
365 | <?xml version="1.0"?> |
|
281 | revision: 2 | |
366 | <log> |
|
282 | author: test | |
367 | <logentry |
|
283 | msg: copy file to new directory | |
368 | revision="2"> |
|
284 | A /d2 | |
369 | <author>test</author> |
|
285 | A /d2/a (from /d1/a@1) | |
370 | <date/> |
|
|||
371 | <paths> |
|
|||
372 | <path |
|
|||
373 | action="A">/d2</path> |
|
|||
374 | <path |
|
|||
375 | copyfrom-path="/d1/a" |
|
|||
376 | copyfrom-rev="1" |
|
|||
377 | action="A">/d2/a</path> |
|
|||
378 | </paths> |
|
|||
379 | <msg>copy file to new directory</msg> |
|
|||
380 | </logentry> |
|
|||
381 | </log> |
|
|||
382 |
|
286 | |||
383 | Branchy history |
|
287 | Branchy history | |
384 |
|
288 | |||
@@ -441,62 +345,31 b' Expect 4 changes' | |||||
441 | 0 merge |
|
345 | 0 merge | |
442 |
|
346 | |||
443 | $ svnupanddisplay b-hg-wc 0 |
|
347 | $ svnupanddisplay b-hg-wc 0 | |
444 | At revision 4. |
|
348 | 4 2 test left-1 | |
445 | 4 4 test . |
|
|||
446 | 4 3 test b |
|
349 | 4 3 test b | |
447 | 4 2 test left-1 |
|
|||
448 | 4 3 test left-2 |
|
350 | 4 3 test left-2 | |
|
351 | 4 4 test . | |||
449 | 4 4 test right-1 |
|
352 | 4 4 test right-1 | |
450 | 4 4 test right-2 |
|
353 | 4 4 test right-2 | |
451 | <?xml version="1.0"?> |
|
354 | revision: 4 | |
452 | <log> |
|
355 | author: test | |
453 | <logentry |
|
356 | msg: merge | |
454 | revision="4"> |
|
357 | A /right-1 | |
455 | <author>test</author> |
|
358 | A /right-2 | |
456 | <date/> |
|
359 | revision: 3 | |
457 | <paths> |
|
360 | author: test | |
458 | <path |
|
361 | msg: left-2 | |
459 | action="A">/right-1</path> |
|
362 | M /b | |
460 | <path |
|
363 | A /left-2 | |
461 | action="A">/right-2</path> |
|
364 | revision: 2 | |
462 | </paths> |
|
365 | author: test | |
463 | <msg>merge</msg> |
|
366 | msg: left-1 | |
464 | </logentry> |
|
367 | M /b | |
465 | <logentry |
|
368 | A /left-1 | |
466 |
|
|
369 | revision: 1 | |
467 |
|
|
370 | author: test | |
468 | <date/> |
|
371 | msg: base | |
469 | <paths> |
|
372 | A /b | |
470 | <path |
|
|||
471 | action="M">/b</path> |
|
|||
472 | <path |
|
|||
473 | action="A">/left-2</path> |
|
|||
474 | </paths> |
|
|||
475 | <msg>left-2</msg> |
|
|||
476 | </logentry> |
|
|||
477 | <logentry |
|
|||
478 | revision="2"> |
|
|||
479 | <author>test</author> |
|
|||
480 | <date/> |
|
|||
481 | <paths> |
|
|||
482 | <path |
|
|||
483 | action="M">/b</path> |
|
|||
484 | <path |
|
|||
485 | action="A">/left-1</path> |
|
|||
486 | </paths> |
|
|||
487 | <msg>left-1</msg> |
|
|||
488 | </logentry> |
|
|||
489 | <logentry |
|
|||
490 | revision="1"> |
|
|||
491 | <author>test</author> |
|
|||
492 | <date/> |
|
|||
493 | <paths> |
|
|||
494 | <path |
|
|||
495 | action="A">/b</path> |
|
|||
496 | </paths> |
|
|||
497 | <msg>base</msg> |
|
|||
498 | </logentry> |
|
|||
499 | </log> |
|
|||
500 |
|
373 | |||
501 | Tags are not supported, but must not break conversion |
|
374 | Tags are not supported, but must not break conversion | |
502 |
|
375 | |||
@@ -518,31 +391,15 b' Tags are not supported, but must not bre' | |||||
518 | 0 Tagged as v1.0 |
|
391 | 0 Tagged as v1.0 | |
519 | writing Subversion tags is not yet implemented |
|
392 | writing Subversion tags is not yet implemented | |
520 | $ svnupanddisplay a-hg-wc 2 |
|
393 | $ svnupanddisplay a-hg-wc 2 | |
521 | At revision 2. |
|
394 | 2 1 test a | |
522 | 2 2 test . |
|
395 | 2 2 test . | |
523 | 2 1 test a |
|
|||
524 | 2 2 test .hgtags |
|
396 | 2 2 test .hgtags | |
525 | <?xml version="1.0"?> |
|
397 | revision: 2 | |
526 | <log> |
|
398 | author: test | |
527 | <logentry |
|
399 | msg: Tagged as v1.0 | |
528 | revision="2"> |
|
400 | A /.hgtags | |
529 | <author>test</author> |
|
401 | revision: 1 | |
530 | <date/> |
|
402 | author: test | |
531 | <paths> |
|
403 | msg: Add file a | |
532 | <path |
|
404 | A /a | |
533 | action="A">/.hgtags</path> |
|
|||
534 | </paths> |
|
|||
535 | <msg>Tagged as v1.0</msg> |
|
|||
536 | </logentry> |
|
|||
537 | <logentry |
|
|||
538 | revision="1"> |
|
|||
539 | <author>test</author> |
|
|||
540 | <date/> |
|
|||
541 | <paths> |
|
|||
542 | <path |
|
|||
543 | action="A">/a</path> |
|
|||
544 | </paths> |
|
|||
545 | <msg>Add file a</msg> |
|
|||
546 | </logentry> |
|
|||
547 | </log> |
|
|||
548 | $ rm -rf a a-hg a-hg-wc |
|
405 | $ rm -rf a a-hg a-hg-wc |
General Comments 0
You need to be logged in to leave comments.
Login now