##// END OF EJS Templates
test-archive: fix touch datestamps...
Mads Kiilerich -
r12395:cc6d40df stable
parent child Browse files
Show More
@@ -1,150 +1,150 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 cp .hg/hgrc .hg/hgrc-base
15 cp .hg/hgrc .hg/hgrc-base
16
16
17 # check http return codes
17 # check http return codes
18 test_archtype() {
18 test_archtype() {
19 echo "allow_archive = $1" >> .hg/hgrc
19 echo "allow_archive = $1" >> .hg/hgrc
20 hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
20 hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
21 cat hg.pid >> $DAEMON_PIDS
21 cat hg.pid >> $DAEMON_PIDS
22 echo % $1 allowed should give 200
22 echo % $1 allowed should give 200
23 "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$2" | head -n 1
23 "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$2" | head -n 1
24 echo % $3 and $4 disallowed should both give 403
24 echo % $3 and $4 disallowed should both give 403
25 "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$3" | head -n 1
25 "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$3" | head -n 1
26 "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$4" | head -n 1
26 "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$4" | head -n 1
27 "$TESTDIR/killdaemons.py"
27 "$TESTDIR/killdaemons.py"
28 cat errors.log
28 cat errors.log
29 cp .hg/hgrc-base .hg/hgrc
29 cp .hg/hgrc-base .hg/hgrc
30 }
30 }
31
31
32 echo
32 echo
33 test_archtype gz tar.gz tar.bz2 zip
33 test_archtype gz tar.gz tar.bz2 zip
34 test_archtype bz2 tar.bz2 zip tar.gz
34 test_archtype bz2 tar.bz2 zip tar.gz
35 test_archtype zip zip tar.gz tar.bz2
35 test_archtype zip zip tar.gz tar.bz2
36
36
37 echo "allow_archive = gz bz2 zip" >> .hg/hgrc
37 echo "allow_archive = gz bz2 zip" >> .hg/hgrc
38 hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
38 hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
39 cat hg.pid >> $DAEMON_PIDS
39 cat hg.pid >> $DAEMON_PIDS
40
40
41 echo % invalid arch type should give 404
41 echo % invalid arch type should give 404
42 "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.invalid" | head -n 1
42 "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.invalid" | head -n 1
43 echo
43 echo
44
44
45 TIP=`hg id -v | cut -f1 -d' '`
45 TIP=`hg id -v | cut -f1 -d' '`
46 QTIP=`hg id -q`
46 QTIP=`hg id -q`
47 cat > getarchive.py <<EOF
47 cat > getarchive.py <<EOF
48 import os, sys, urllib2
48 import os, sys, urllib2
49 try:
49 try:
50 # Set stdout to binary mode for win32 platforms
50 # Set stdout to binary mode for win32 platforms
51 import msvcrt
51 import msvcrt
52 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
52 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
53 except ImportError:
53 except ImportError:
54 pass
54 pass
55
55
56 node, archive = sys.argv[1:]
56 node, archive = sys.argv[1:]
57 f = urllib2.urlopen('http://127.0.0.1:%s/?cmd=archive;node=%s;type=%s'
57 f = urllib2.urlopen('http://127.0.0.1:%s/?cmd=archive;node=%s;type=%s'
58 % (os.environ['HGPORT'], node, archive))
58 % (os.environ['HGPORT'], node, archive))
59 sys.stdout.write(f.read())
59 sys.stdout.write(f.read())
60 EOF
60 EOF
61 python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/"
61 python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/"
62 python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/"
62 python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/"
63 python getarchive.py "$TIP" zip > archive.zip
63 python getarchive.py "$TIP" zip > archive.zip
64 unzip -t archive.zip | sed "s/$QTIP/TIP/"
64 unzip -t archive.zip | sed "s/$QTIP/TIP/"
65
65
66 "$TESTDIR/killdaemons.py"
66 "$TESTDIR/killdaemons.py"
67
67
68 hg archive -t tar test.tar
68 hg archive -t tar test.tar
69 tar tf test.tar
69 tar tf test.tar
70
70
71 hg archive -t tbz2 -X baz test.tar.bz2
71 hg archive -t tbz2 -X baz test.tar.bz2
72 bunzip2 -dc test.tar.bz2 | tar tf - 2>/dev/null
72 bunzip2 -dc test.tar.bz2 | tar tf - 2>/dev/null
73
73
74 hg archive -t tgz -p %b-%h test-%h.tar.gz
74 hg archive -t tgz -p %b-%h test-%h.tar.gz
75 gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/"
75 gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/"
76
76
77 hg archive autodetected_test.tar
77 hg archive autodetected_test.tar
78 tar tf autodetected_test.tar
78 tar tf autodetected_test.tar
79
79
80 # The '-t' should override autodetection
80 # The '-t' should override autodetection
81 hg archive -t tar autodetect_override_test.zip
81 hg archive -t tar autodetect_override_test.zip
82 tar tf autodetect_override_test.zip
82 tar tf autodetect_override_test.zip
83
83
84 for ext in tar tar.gz tgz tar.bz2 tbz2 zip; do
84 for ext in tar tar.gz tgz tar.bz2 tbz2 zip; do
85 hg archive auto_test.$ext
85 hg archive auto_test.$ext
86 if [ -d auto_test.$ext ]; then
86 if [ -d auto_test.$ext ]; then
87 echo "extension $ext was not autodetected."
87 echo "extension $ext was not autodetected."
88 fi
88 fi
89 done
89 done
90
90
91 cat > md5comp.py <<EOF
91 cat > md5comp.py <<EOF
92 try:
92 try:
93 from hashlib import md5
93 from hashlib import md5
94 except ImportError:
94 except ImportError:
95 from md5 import md5
95 from md5 import md5
96 import sys
96 import sys
97 f1, f2 = sys.argv[1:3]
97 f1, f2 = sys.argv[1:3]
98 h1 = md5(file(f1, 'rb').read()).hexdigest()
98 h1 = md5(file(f1, 'rb').read()).hexdigest()
99 h2 = md5(file(f2, 'rb').read()).hexdigest()
99 h2 = md5(file(f2, 'rb').read()).hexdigest()
100 print h1 == h2 or "md5 differ: " + repr((h1, h2))
100 print h1 == h2 or "md5 differ: " + repr((h1, h2))
101 EOF
101 EOF
102
102
103 # archive name is stored in the archive, so create similar
103 # archive name is stored in the archive, so create similar
104 # archives and rename them afterwards.
104 # archives and rename them afterwards.
105 hg archive -t tgz tip.tar.gz
105 hg archive -t tgz tip.tar.gz
106 mv tip.tar.gz tip1.tar.gz
106 mv tip.tar.gz tip1.tar.gz
107 sleep 1
107 sleep 1
108 hg archive -t tgz tip.tar.gz
108 hg archive -t tgz tip.tar.gz
109 mv tip.tar.gz tip2.tar.gz
109 mv tip.tar.gz tip2.tar.gz
110 python md5comp.py tip1.tar.gz tip2.tar.gz
110 python md5comp.py tip1.tar.gz tip2.tar.gz
111
111
112 hg archive -t zip -p /illegal test.zip
112 hg archive -t zip -p /illegal test.zip
113 hg archive -t zip -p very/../bad test.zip
113 hg archive -t zip -p very/../bad test.zip
114
114
115 hg archive --config ui.archivemeta=false -t zip -r 2 test.zip
115 hg archive --config ui.archivemeta=false -t zip -r 2 test.zip
116 unzip -t test.zip
116 unzip -t test.zip
117
117
118 hg archive -t tar - | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/"
118 hg archive -t tar - | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/"
119
119
120 hg archive -r 0 -t tar rev-%r.tar
120 hg archive -r 0 -t tar rev-%r.tar
121 if [ -f rev-0.tar ]; then
121 if [ -f rev-0.tar ]; then
122 echo 'rev-0.tar created'
122 echo 'rev-0.tar created'
123 fi
123 fi
124
124
125 echo '% test .hg_archival.txt'
125 echo '% test .hg_archival.txt'
126 hg archive ../test-tags
126 hg archive ../test-tags
127 cat ../test-tags/.hg_archival.txt
127 cat ../test-tags/.hg_archival.txt
128 hg tag -r 2 mytag
128 hg tag -r 2 mytag
129 hg tag -r 2 anothertag
129 hg tag -r 2 anothertag
130 hg archive -r 2 ../test-lasttag
130 hg archive -r 2 ../test-lasttag
131 cat ../test-lasttag/.hg_archival.txt
131 cat ../test-lasttag/.hg_archival.txt
132
132
133 hg archive -t bogus test.bogus
133 hg archive -t bogus test.bogus
134
134
135 echo % server errors
135 echo % server errors
136 cat errors.log
136 cat errors.log
137
137
138 echo '% empty repo'
138 echo '% empty repo'
139 hg init ../empty
139 hg init ../empty
140 cd ../empty
140 cd ../empty
141 hg archive ../test-empty
141 hg archive ../test-empty
142
142
143 echo '% old file -- date clamped to 1980'
143 echo '% old file -- date clamped to 1980'
144 touch -d 1975-01-01 old
144 touch -t 197501010000 old
145 hg add old
145 hg add old
146 hg commit -m old
146 hg commit -m old
147 hg archive ../old.zip
147 hg archive ../old.zip
148 unzip -l ../old.zip | grep 80 > /dev/null && echo ok
148 unzip -l ../old.zip | grep 80 > /dev/null && echo ok
149
149
150 exit 0
150 exit 0
General Comments 0
You need to be logged in to leave comments. Login now