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