##// END OF EJS Templates
python-2.6: md5 import in test-archive helper
Dirkjan Ochtman -
r6496:118720f8 default
parent child Browse files
Show More
@@ -1,82 +1,83 b''
1 #!/bin/sh
1 #!/bin/sh
2
2
3 mkdir test
3 mkdir test
4 cd test
4 cd test
5 hg init
5 hg init
6 echo foo>foo
6 echo foo>foo
7 hg commit -Am 1 -d '1 0'
7 hg commit -Am 1 -d '1 0'
8 echo bar>bar
8 echo bar>bar
9 hg commit -Am 2 -d '2 0'
9 hg commit -Am 2 -d '2 0'
10 mkdir baz
10 mkdir baz
11 echo bletch>baz/bletch
11 echo bletch>baz/bletch
12 hg commit -Am 3 -d '1000000000 0'
12 hg commit -Am 3 -d '1000000000 0'
13 echo "[web]" >> .hg/hgrc
13 echo "[web]" >> .hg/hgrc
14 echo "name = test-archive" >> .hg/hgrc
14 echo "name = test-archive" >> .hg/hgrc
15 echo "allow_archive = gz bz2, zip" >> .hg/hgrc
15 echo "allow_archive = gz bz2, zip" >> .hg/hgrc
16 hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
16 hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
17 cat hg.pid >> $DAEMON_PIDS
17 cat hg.pid >> $DAEMON_PIDS
18
18
19 TIP=`hg id -v | cut -f1 -d' '`
19 TIP=`hg id -v | cut -f1 -d' '`
20 QTIP=`hg id -q`
20 QTIP=`hg id -q`
21 cat > getarchive.py <<EOF
21 cat > getarchive.py <<EOF
22 import os, sys, urllib2
22 import os, sys, urllib2
23 node, archive = sys.argv[1:]
23 node, archive = sys.argv[1:]
24 f = urllib2.urlopen('http://127.0.0.1:%s/?cmd=archive;node=%s;type=%s'
24 f = urllib2.urlopen('http://127.0.0.1:%s/?cmd=archive;node=%s;type=%s'
25 % (os.environ['HGPORT'], node, archive))
25 % (os.environ['HGPORT'], node, archive))
26 sys.stdout.write(f.read())
26 sys.stdout.write(f.read())
27 EOF
27 EOF
28 http_proxy= python getarchive.py "$TIP" gz | gunzip | tar tf - | sed "s/$QTIP/TIP/"
28 http_proxy= python getarchive.py "$TIP" gz | gunzip | tar tf - | sed "s/$QTIP/TIP/"
29 http_proxy= python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - | sed "s/$QTIP/TIP/"
29 http_proxy= python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - | sed "s/$QTIP/TIP/"
30 http_proxy= python getarchive.py "$TIP" zip > archive.zip
30 http_proxy= python getarchive.py "$TIP" zip > archive.zip
31 unzip -t archive.zip | sed "s/$QTIP/TIP/"
31 unzip -t archive.zip | sed "s/$QTIP/TIP/"
32
32
33 hg archive -t tar test.tar
33 hg archive -t tar test.tar
34 tar tf test.tar
34 tar tf test.tar
35
35
36 hg archive -t tbz2 -X baz test.tar.bz2
36 hg archive -t tbz2 -X baz test.tar.bz2
37 bunzip2 -dc test.tar.bz2 | tar tf -
37 bunzip2 -dc test.tar.bz2 | tar tf -
38
38
39 hg archive -t tgz -p %b-%h test-%h.tar.gz
39 hg archive -t tgz -p %b-%h test-%h.tar.gz
40 gzip -dc test-$QTIP.tar.gz | tar tf - | sed "s/$QTIP/TIP/"
40 gzip -dc test-$QTIP.tar.gz | tar tf - | sed "s/$QTIP/TIP/"
41
41
42 cat > md5comp.py <<EOF
42 cat > md5comp.py <<EOF
43 import md5, sys
43 from mercurial.util import md5
44 import sys
44 f1, f2 = sys.argv[1:3]
45 f1, f2 = sys.argv[1:3]
45 h1 = md5.md5(file(f1, 'rb').read()).hexdigest()
46 h1 = md5(file(f1, 'rb').read()).hexdigest()
46 h2 = md5.md5(file(f2, 'rb').read()).hexdigest()
47 h2 = md5(file(f2, 'rb').read()).hexdigest()
47 print h1 == h2 or "md5 differ: " + repr((h1, h2))
48 print h1 == h2 or "md5 differ: " + repr((h1, h2))
48 EOF
49 EOF
49
50
50 # archive name is stored in the archive, so create similar
51 # archive name is stored in the archive, so create similar
51 # archives and rename them afterwards.
52 # archives and rename them afterwards.
52 hg archive -t tgz tip.tar.gz
53 hg archive -t tgz tip.tar.gz
53 mv tip.tar.gz tip1.tar.gz
54 mv tip.tar.gz tip1.tar.gz
54 sleep 1
55 sleep 1
55 hg archive -t tgz tip.tar.gz
56 hg archive -t tgz tip.tar.gz
56 mv tip.tar.gz tip2.tar.gz
57 mv tip.tar.gz tip2.tar.gz
57 python md5comp.py tip1.tar.gz tip2.tar.gz
58 python md5comp.py tip1.tar.gz tip2.tar.gz
58
59
59 hg archive -t zip -p /illegal test.zip
60 hg archive -t zip -p /illegal test.zip
60 hg archive -t zip -p very/../bad test.zip
61 hg archive -t zip -p very/../bad test.zip
61
62
62 hg archive --config ui.archivemeta=false -t zip -r 2 test.zip
63 hg archive --config ui.archivemeta=false -t zip -r 2 test.zip
63 unzip -t test.zip
64 unzip -t test.zip
64
65
65 hg archive -t tar - | tar tf - | sed "s/$QTIP/TIP/"
66 hg archive -t tar - | tar tf - | sed "s/$QTIP/TIP/"
66
67
67 hg archive -r 0 -t tar rev-%r.tar
68 hg archive -r 0 -t tar rev-%r.tar
68 if [ -f rev-0.tar ]; then
69 if [ -f rev-0.tar ]; then
69 echo 'rev-0.tar created'
70 echo 'rev-0.tar created'
70 fi
71 fi
71
72
72 hg archive -t bogus test.bogus
73 hg archive -t bogus test.bogus
73
74
74 echo % server errors
75 echo % server errors
75 cat errors.log
76 cat errors.log
76
77
77 echo '% empty repo'
78 echo '% empty repo'
78 hg init ../empty
79 hg init ../empty
79 cd ../empty
80 cd ../empty
80 hg archive ../test-empty
81 hg archive ../test-empty
81
82
82 exit 0
83 exit 0
General Comments 0
You need to be logged in to leave comments. Login now