Show More
@@ -1,365 +1,369 b'' | |||||
1 | #require serve |
|
1 | #require serve | |
2 |
|
2 | |||
3 | $ hg init test |
|
3 | $ hg init test | |
4 | $ cd test |
|
4 | $ cd test | |
5 | $ echo foo>foo |
|
5 | $ echo foo>foo | |
6 | $ hg commit -Am 1 -d '1 0' |
|
6 | $ hg commit -Am 1 -d '1 0' | |
7 | adding foo |
|
7 | adding foo | |
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 | adding bar |
|
10 | adding bar | |
11 | $ mkdir baz |
|
11 | $ mkdir baz | |
12 | $ echo bletch>baz/bletch |
|
12 | $ echo bletch>baz/bletch | |
13 | $ hg commit -Am 3 -d '1000000000 0' |
|
13 | $ hg commit -Am 3 -d '1000000000 0' | |
14 | adding baz/bletch |
|
14 | adding baz/bletch | |
15 | $ hg init subrepo |
|
15 | $ hg init subrepo | |
16 | $ touch subrepo/sub |
|
16 | $ touch subrepo/sub | |
17 | $ hg -q -R subrepo ci -Am "init subrepo" |
|
17 | $ hg -q -R subrepo ci -Am "init subrepo" | |
18 | $ echo "subrepo = subrepo" > .hgsub |
|
18 | $ echo "subrepo = subrepo" > .hgsub | |
19 | $ hg add .hgsub |
|
19 | $ hg add .hgsub | |
20 | $ hg ci -m "add subrepo" |
|
20 | $ hg ci -m "add subrepo" | |
21 | $ echo "[web]" >> .hg/hgrc |
|
21 | $ echo "[web]" >> .hg/hgrc | |
22 | $ echo "name = test-archive" >> .hg/hgrc |
|
22 | $ echo "name = test-archive" >> .hg/hgrc | |
23 | $ echo "archivesubrepos = True" >> .hg/hgrc |
|
23 | $ echo "archivesubrepos = True" >> .hg/hgrc | |
24 | $ cp .hg/hgrc .hg/hgrc-base |
|
24 | $ cp .hg/hgrc .hg/hgrc-base | |
25 | > test_archtype() { |
|
25 | > test_archtype() { | |
26 | > echo "allow_archive = $1" >> .hg/hgrc |
|
26 | > echo "allow_archive = $1" >> .hg/hgrc | |
27 | > hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log |
|
27 | > hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log | |
28 | > cat hg.pid >> $DAEMON_PIDS |
|
28 | > cat hg.pid >> $DAEMON_PIDS | |
29 | > echo % $1 allowed should give 200 |
|
29 | > echo % $1 allowed should give 200 | |
30 | > get-with-headers.py localhost:$HGPORT "archive/tip.$2" | head -n 1 |
|
30 | > get-with-headers.py localhost:$HGPORT "archive/tip.$2" | head -n 1 | |
31 | > echo % $3 and $4 disallowed should both give 403 |
|
31 | > echo % $3 and $4 disallowed should both give 403 | |
32 | > get-with-headers.py localhost:$HGPORT "archive/tip.$3" | head -n 1 |
|
32 | > get-with-headers.py localhost:$HGPORT "archive/tip.$3" | head -n 1 | |
33 | > get-with-headers.py localhost:$HGPORT "archive/tip.$4" | head -n 1 |
|
33 | > get-with-headers.py localhost:$HGPORT "archive/tip.$4" | head -n 1 | |
34 | > killdaemons.py |
|
34 | > killdaemons.py | |
35 | > cat errors.log |
|
35 | > cat errors.log | |
36 | > cp .hg/hgrc-base .hg/hgrc |
|
36 | > cp .hg/hgrc-base .hg/hgrc | |
37 | > } |
|
37 | > } | |
38 |
|
38 | |||
39 | check http return codes |
|
39 | check http return codes | |
40 |
|
40 | |||
41 | $ test_archtype gz tar.gz tar.bz2 zip |
|
41 | $ test_archtype gz tar.gz tar.bz2 zip | |
42 | % gz allowed should give 200 |
|
42 | % gz allowed should give 200 | |
43 | 200 Script output follows |
|
43 | 200 Script output follows | |
44 | % tar.bz2 and zip disallowed should both give 403 |
|
44 | % tar.bz2 and zip disallowed should both give 403 | |
45 | 403 Archive type not allowed: bz2 |
|
45 | 403 Archive type not allowed: bz2 | |
46 | 403 Archive type not allowed: zip |
|
46 | 403 Archive type not allowed: zip | |
47 | $ test_archtype bz2 tar.bz2 zip tar.gz |
|
47 | $ test_archtype bz2 tar.bz2 zip tar.gz | |
48 | % bz2 allowed should give 200 |
|
48 | % bz2 allowed should give 200 | |
49 | 200 Script output follows |
|
49 | 200 Script output follows | |
50 | % zip and tar.gz disallowed should both give 403 |
|
50 | % zip and tar.gz disallowed should both give 403 | |
51 | 403 Archive type not allowed: zip |
|
51 | 403 Archive type not allowed: zip | |
52 | 403 Archive type not allowed: gz |
|
52 | 403 Archive type not allowed: gz | |
53 | $ test_archtype zip zip tar.gz tar.bz2 |
|
53 | $ test_archtype zip zip tar.gz tar.bz2 | |
54 | % zip allowed should give 200 |
|
54 | % zip allowed should give 200 | |
55 | 200 Script output follows |
|
55 | 200 Script output follows | |
56 | % tar.gz and tar.bz2 disallowed should both give 403 |
|
56 | % tar.gz and tar.bz2 disallowed should both give 403 | |
57 | 403 Archive type not allowed: gz |
|
57 | 403 Archive type not allowed: gz | |
58 | 403 Archive type not allowed: bz2 |
|
58 | 403 Archive type not allowed: bz2 | |
59 |
|
59 | |||
60 | $ echo "allow_archive = gz bz2 zip" >> .hg/hgrc |
|
60 | $ echo "allow_archive = gz bz2 zip" >> .hg/hgrc | |
61 | $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log |
|
61 | $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log | |
62 | $ cat hg.pid >> $DAEMON_PIDS |
|
62 | $ cat hg.pid >> $DAEMON_PIDS | |
63 |
|
63 | |||
64 | invalid arch type should give 404 |
|
64 | invalid arch type should give 404 | |
65 |
|
65 | |||
66 | $ get-with-headers.py localhost:$HGPORT "archive/tip.invalid" | head -n 1 |
|
66 | $ get-with-headers.py localhost:$HGPORT "archive/tip.invalid" | head -n 1 | |
67 | 404 Unsupported archive type: None |
|
67 | 404 Unsupported archive type: None | |
68 |
|
68 | |||
69 | $ TIP=`hg id -v | cut -f1 -d' '` |
|
69 | $ TIP=`hg id -v | cut -f1 -d' '` | |
70 | $ QTIP=`hg id -q` |
|
70 | $ QTIP=`hg id -q` | |
71 | $ cat > getarchive.py <<EOF |
|
71 | $ cat > getarchive.py <<EOF | |
72 | > from __future__ import absolute_import |
|
72 | > from __future__ import absolute_import | |
73 | > import os |
|
73 | > import os | |
74 | > import sys |
|
74 | > import sys | |
75 | > import urllib2 |
|
75 | > import urllib2 | |
76 | > try: |
|
76 | > try: | |
77 | > # Set stdout to binary mode for win32 platforms |
|
77 | > # Set stdout to binary mode for win32 platforms | |
78 | > import msvcrt |
|
78 | > import msvcrt | |
79 | > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
|
79 | > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) | |
80 | > except ImportError: |
|
80 | > except ImportError: | |
81 | > pass |
|
81 | > pass | |
82 | > if len(sys.argv) <= 3: |
|
82 | > if len(sys.argv) <= 3: | |
83 | > node, archive = sys.argv[1:] |
|
83 | > node, archive = sys.argv[1:] | |
84 | > requeststr = 'cmd=archive;node=%s;type=%s' % (node, archive) |
|
84 | > requeststr = 'cmd=archive;node=%s;type=%s' % (node, archive) | |
85 | > else: |
|
85 | > else: | |
86 | > node, archive, file = sys.argv[1:] |
|
86 | > node, archive, file = sys.argv[1:] | |
87 | > requeststr = 'cmd=archive;node=%s;type=%s;file=%s' % (node, archive, file) |
|
87 | > requeststr = 'cmd=archive;node=%s;type=%s;file=%s' % (node, archive, file) | |
88 | > try: |
|
88 | > try: | |
|
89 | > stdout = sys.stdout.buffer | |||
|
90 | > except AttributeError: | |||
|
91 | > stdout = sys.stdout | |||
|
92 | > try: | |||
89 | > f = urllib2.urlopen('http://127.0.0.1:%s/?%s' |
|
93 | > f = urllib2.urlopen('http://127.0.0.1:%s/?%s' | |
90 | > % (os.environ['HGPORT'], requeststr)) |
|
94 | > % (os.environ['HGPORT'], requeststr)) | |
91 |
> |
|
95 | > stdout.write(f.read()) | |
92 | > except urllib2.HTTPError, e: |
|
96 | > except urllib2.HTTPError, e: | |
93 | > sys.stderr.write(str(e) + '\n') |
|
97 | > sys.stderr.write(str(e) + '\n') | |
94 | > EOF |
|
98 | > EOF | |
95 | $ python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null |
|
99 | $ python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null | |
96 | test-archive-1701ef1f1510/.hg_archival.txt |
|
100 | test-archive-1701ef1f1510/.hg_archival.txt | |
97 | test-archive-1701ef1f1510/.hgsub |
|
101 | test-archive-1701ef1f1510/.hgsub | |
98 | test-archive-1701ef1f1510/.hgsubstate |
|
102 | test-archive-1701ef1f1510/.hgsubstate | |
99 | test-archive-1701ef1f1510/bar |
|
103 | test-archive-1701ef1f1510/bar | |
100 | test-archive-1701ef1f1510/baz/bletch |
|
104 | test-archive-1701ef1f1510/baz/bletch | |
101 | test-archive-1701ef1f1510/foo |
|
105 | test-archive-1701ef1f1510/foo | |
102 | test-archive-1701ef1f1510/subrepo/sub |
|
106 | test-archive-1701ef1f1510/subrepo/sub | |
103 | $ python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null |
|
107 | $ python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null | |
104 | test-archive-1701ef1f1510/.hg_archival.txt |
|
108 | test-archive-1701ef1f1510/.hg_archival.txt | |
105 | test-archive-1701ef1f1510/.hgsub |
|
109 | test-archive-1701ef1f1510/.hgsub | |
106 | test-archive-1701ef1f1510/.hgsubstate |
|
110 | test-archive-1701ef1f1510/.hgsubstate | |
107 | test-archive-1701ef1f1510/bar |
|
111 | test-archive-1701ef1f1510/bar | |
108 | test-archive-1701ef1f1510/baz/bletch |
|
112 | test-archive-1701ef1f1510/baz/bletch | |
109 | test-archive-1701ef1f1510/foo |
|
113 | test-archive-1701ef1f1510/foo | |
110 | test-archive-1701ef1f1510/subrepo/sub |
|
114 | test-archive-1701ef1f1510/subrepo/sub | |
111 | $ python getarchive.py "$TIP" zip > archive.zip |
|
115 | $ python getarchive.py "$TIP" zip > archive.zip | |
112 | $ unzip -t archive.zip |
|
116 | $ unzip -t archive.zip | |
113 | Archive: archive.zip |
|
117 | Archive: archive.zip | |
114 | testing: test-archive-1701ef1f1510/.hg_archival.txt OK |
|
118 | testing: test-archive-1701ef1f1510/.hg_archival.txt OK | |
115 | testing: test-archive-1701ef1f1510/.hgsub OK |
|
119 | testing: test-archive-1701ef1f1510/.hgsub OK | |
116 | testing: test-archive-1701ef1f1510/.hgsubstate OK |
|
120 | testing: test-archive-1701ef1f1510/.hgsubstate OK | |
117 | testing: test-archive-1701ef1f1510/bar OK |
|
121 | testing: test-archive-1701ef1f1510/bar OK | |
118 | testing: test-archive-1701ef1f1510/baz/bletch OK |
|
122 | testing: test-archive-1701ef1f1510/baz/bletch OK | |
119 | testing: test-archive-1701ef1f1510/foo OK |
|
123 | testing: test-archive-1701ef1f1510/foo OK | |
120 | testing: test-archive-1701ef1f1510/subrepo/sub OK |
|
124 | testing: test-archive-1701ef1f1510/subrepo/sub OK | |
121 | No errors detected in compressed data of archive.zip. |
|
125 | No errors detected in compressed data of archive.zip. | |
122 |
|
126 | |||
123 | test that we can download single directories and files |
|
127 | test that we can download single directories and files | |
124 |
|
128 | |||
125 | $ python getarchive.py "$TIP" gz baz | gunzip | tar tf - 2>/dev/null |
|
129 | $ python getarchive.py "$TIP" gz baz | gunzip | tar tf - 2>/dev/null | |
126 | test-archive-1701ef1f1510/baz/bletch |
|
130 | test-archive-1701ef1f1510/baz/bletch | |
127 | $ python getarchive.py "$TIP" gz foo | gunzip | tar tf - 2>/dev/null |
|
131 | $ python getarchive.py "$TIP" gz foo | gunzip | tar tf - 2>/dev/null | |
128 | test-archive-1701ef1f1510/foo |
|
132 | test-archive-1701ef1f1510/foo | |
129 |
|
133 | |||
130 | test that we detect file patterns that match no files |
|
134 | test that we detect file patterns that match no files | |
131 |
|
135 | |||
132 | $ python getarchive.py "$TIP" gz foobar |
|
136 | $ python getarchive.py "$TIP" gz foobar | |
133 | HTTP Error 404: file(s) not found: foobar |
|
137 | HTTP Error 404: file(s) not found: foobar | |
134 |
|
138 | |||
135 | test that we reject unsafe patterns |
|
139 | test that we reject unsafe patterns | |
136 |
|
140 | |||
137 | $ python getarchive.py "$TIP" gz relre:baz |
|
141 | $ python getarchive.py "$TIP" gz relre:baz | |
138 | HTTP Error 404: file(s) not found: relre:baz |
|
142 | HTTP Error 404: file(s) not found: relre:baz | |
139 |
|
143 | |||
140 | $ killdaemons.py |
|
144 | $ killdaemons.py | |
141 |
|
145 | |||
142 | $ hg archive -t tar test.tar |
|
146 | $ hg archive -t tar test.tar | |
143 | $ tar tf test.tar |
|
147 | $ tar tf test.tar | |
144 | test/.hg_archival.txt |
|
148 | test/.hg_archival.txt | |
145 | test/.hgsub |
|
149 | test/.hgsub | |
146 | test/.hgsubstate |
|
150 | test/.hgsubstate | |
147 | test/bar |
|
151 | test/bar | |
148 | test/baz/bletch |
|
152 | test/baz/bletch | |
149 | test/foo |
|
153 | test/foo | |
150 |
|
154 | |||
151 | $ hg archive --debug -t tbz2 -X baz test.tar.bz2 --config progress.debug=true |
|
155 | $ hg archive --debug -t tbz2 -X baz test.tar.bz2 --config progress.debug=true | |
152 | archiving: 0/4 files (0.00%) |
|
156 | archiving: 0/4 files (0.00%) | |
153 | archiving: .hgsub 1/4 files (25.00%) |
|
157 | archiving: .hgsub 1/4 files (25.00%) | |
154 | archiving: .hgsubstate 2/4 files (50.00%) |
|
158 | archiving: .hgsubstate 2/4 files (50.00%) | |
155 | archiving: bar 3/4 files (75.00%) |
|
159 | archiving: bar 3/4 files (75.00%) | |
156 | archiving: foo 4/4 files (100.00%) |
|
160 | archiving: foo 4/4 files (100.00%) | |
157 | $ bunzip2 -dc test.tar.bz2 | tar tf - 2>/dev/null |
|
161 | $ bunzip2 -dc test.tar.bz2 | tar tf - 2>/dev/null | |
158 | test/.hg_archival.txt |
|
162 | test/.hg_archival.txt | |
159 | test/.hgsub |
|
163 | test/.hgsub | |
160 | test/.hgsubstate |
|
164 | test/.hgsubstate | |
161 | test/bar |
|
165 | test/bar | |
162 | test/foo |
|
166 | test/foo | |
163 |
|
167 | |||
164 | $ hg archive -t tgz -p %b-%h test-%h.tar.gz |
|
168 | $ hg archive -t tgz -p %b-%h test-%h.tar.gz | |
165 | $ gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null |
|
169 | $ gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null | |
166 | test-1701ef1f1510/.hg_archival.txt |
|
170 | test-1701ef1f1510/.hg_archival.txt | |
167 | test-1701ef1f1510/.hgsub |
|
171 | test-1701ef1f1510/.hgsub | |
168 | test-1701ef1f1510/.hgsubstate |
|
172 | test-1701ef1f1510/.hgsubstate | |
169 | test-1701ef1f1510/bar |
|
173 | test-1701ef1f1510/bar | |
170 | test-1701ef1f1510/baz/bletch |
|
174 | test-1701ef1f1510/baz/bletch | |
171 | test-1701ef1f1510/foo |
|
175 | test-1701ef1f1510/foo | |
172 |
|
176 | |||
173 | $ hg archive autodetected_test.tar |
|
177 | $ hg archive autodetected_test.tar | |
174 | $ tar tf autodetected_test.tar |
|
178 | $ tar tf autodetected_test.tar | |
175 | autodetected_test/.hg_archival.txt |
|
179 | autodetected_test/.hg_archival.txt | |
176 | autodetected_test/.hgsub |
|
180 | autodetected_test/.hgsub | |
177 | autodetected_test/.hgsubstate |
|
181 | autodetected_test/.hgsubstate | |
178 | autodetected_test/bar |
|
182 | autodetected_test/bar | |
179 | autodetected_test/baz/bletch |
|
183 | autodetected_test/baz/bletch | |
180 | autodetected_test/foo |
|
184 | autodetected_test/foo | |
181 |
|
185 | |||
182 | The '-t' should override autodetection |
|
186 | The '-t' should override autodetection | |
183 |
|
187 | |||
184 | $ hg archive -t tar autodetect_override_test.zip |
|
188 | $ hg archive -t tar autodetect_override_test.zip | |
185 | $ tar tf autodetect_override_test.zip |
|
189 | $ tar tf autodetect_override_test.zip | |
186 | autodetect_override_test.zip/.hg_archival.txt |
|
190 | autodetect_override_test.zip/.hg_archival.txt | |
187 | autodetect_override_test.zip/.hgsub |
|
191 | autodetect_override_test.zip/.hgsub | |
188 | autodetect_override_test.zip/.hgsubstate |
|
192 | autodetect_override_test.zip/.hgsubstate | |
189 | autodetect_override_test.zip/bar |
|
193 | autodetect_override_test.zip/bar | |
190 | autodetect_override_test.zip/baz/bletch |
|
194 | autodetect_override_test.zip/baz/bletch | |
191 | autodetect_override_test.zip/foo |
|
195 | autodetect_override_test.zip/foo | |
192 |
|
196 | |||
193 | $ for ext in tar tar.gz tgz tar.bz2 tbz2 zip; do |
|
197 | $ for ext in tar tar.gz tgz tar.bz2 tbz2 zip; do | |
194 | > hg archive auto_test.$ext |
|
198 | > hg archive auto_test.$ext | |
195 | > if [ -d auto_test.$ext ]; then |
|
199 | > if [ -d auto_test.$ext ]; then | |
196 | > echo "extension $ext was not autodetected." |
|
200 | > echo "extension $ext was not autodetected." | |
197 | > fi |
|
201 | > fi | |
198 | > done |
|
202 | > done | |
199 |
|
203 | |||
200 | $ cat > md5comp.py <<EOF |
|
204 | $ cat > md5comp.py <<EOF | |
201 | > from __future__ import print_function |
|
205 | > from __future__ import print_function | |
202 | > try: |
|
206 | > try: | |
203 | > from hashlib import md5 |
|
207 | > from hashlib import md5 | |
204 | > except ImportError: |
|
208 | > except ImportError: | |
205 | > from md5 import md5 |
|
209 | > from md5 import md5 | |
206 | > import sys |
|
210 | > import sys | |
207 | > f1, f2 = sys.argv[1:3] |
|
211 | > f1, f2 = sys.argv[1:3] | |
208 | > h1 = md5(open(f1, 'rb').read()).hexdigest() |
|
212 | > h1 = md5(open(f1, 'rb').read()).hexdigest() | |
209 | > h2 = md5(open(f2, 'rb').read()).hexdigest() |
|
213 | > h2 = md5(open(f2, 'rb').read()).hexdigest() | |
210 | > print(h1 == h2 or "md5 differ: " + repr((h1, h2))) |
|
214 | > print(h1 == h2 or "md5 differ: " + repr((h1, h2))) | |
211 | > EOF |
|
215 | > EOF | |
212 |
|
216 | |||
213 | archive name is stored in the archive, so create similar archives and |
|
217 | archive name is stored in the archive, so create similar archives and | |
214 | rename them afterwards. |
|
218 | rename them afterwards. | |
215 |
|
219 | |||
216 | $ hg archive -t tgz tip.tar.gz |
|
220 | $ hg archive -t tgz tip.tar.gz | |
217 | $ mv tip.tar.gz tip1.tar.gz |
|
221 | $ mv tip.tar.gz tip1.tar.gz | |
218 | $ sleep 1 |
|
222 | $ sleep 1 | |
219 | $ hg archive -t tgz tip.tar.gz |
|
223 | $ hg archive -t tgz tip.tar.gz | |
220 | $ mv tip.tar.gz tip2.tar.gz |
|
224 | $ mv tip.tar.gz tip2.tar.gz | |
221 | $ python md5comp.py tip1.tar.gz tip2.tar.gz |
|
225 | $ python md5comp.py tip1.tar.gz tip2.tar.gz | |
222 | True |
|
226 | True | |
223 |
|
227 | |||
224 | $ hg archive -t zip -p /illegal test.zip |
|
228 | $ hg archive -t zip -p /illegal test.zip | |
225 | abort: archive prefix contains illegal components |
|
229 | abort: archive prefix contains illegal components | |
226 | [255] |
|
230 | [255] | |
227 | $ hg archive -t zip -p very/../bad test.zip |
|
231 | $ hg archive -t zip -p very/../bad test.zip | |
228 |
|
232 | |||
229 | $ hg archive --config ui.archivemeta=false -t zip -r 2 test.zip |
|
233 | $ hg archive --config ui.archivemeta=false -t zip -r 2 test.zip | |
230 | $ unzip -t test.zip |
|
234 | $ unzip -t test.zip | |
231 | Archive: test.zip |
|
235 | Archive: test.zip | |
232 | testing: test/bar OK |
|
236 | testing: test/bar OK | |
233 | testing: test/baz/bletch OK |
|
237 | testing: test/baz/bletch OK | |
234 | testing: test/foo OK |
|
238 | testing: test/foo OK | |
235 | No errors detected in compressed data of test.zip. |
|
239 | No errors detected in compressed data of test.zip. | |
236 |
|
240 | |||
237 | $ hg archive -t tar - | tar tf - 2>/dev/null |
|
241 | $ hg archive -t tar - | tar tf - 2>/dev/null | |
238 | test-1701ef1f1510/.hg_archival.txt |
|
242 | test-1701ef1f1510/.hg_archival.txt | |
239 | test-1701ef1f1510/.hgsub |
|
243 | test-1701ef1f1510/.hgsub | |
240 | test-1701ef1f1510/.hgsubstate |
|
244 | test-1701ef1f1510/.hgsubstate | |
241 | test-1701ef1f1510/bar |
|
245 | test-1701ef1f1510/bar | |
242 | test-1701ef1f1510/baz/bletch |
|
246 | test-1701ef1f1510/baz/bletch | |
243 | test-1701ef1f1510/foo |
|
247 | test-1701ef1f1510/foo | |
244 |
|
248 | |||
245 | $ hg archive -r 0 -t tar rev-%r.tar |
|
249 | $ hg archive -r 0 -t tar rev-%r.tar | |
246 | $ [ -f rev-0.tar ] |
|
250 | $ [ -f rev-0.tar ] | |
247 |
|
251 | |||
248 | test .hg_archival.txt |
|
252 | test .hg_archival.txt | |
249 |
|
253 | |||
250 | $ hg archive ../test-tags |
|
254 | $ hg archive ../test-tags | |
251 | $ cat ../test-tags/.hg_archival.txt |
|
255 | $ cat ../test-tags/.hg_archival.txt | |
252 | repo: daa7f7c60e0a224faa4ff77ca41b2760562af264 |
|
256 | repo: daa7f7c60e0a224faa4ff77ca41b2760562af264 | |
253 | node: 1701ef1f151069b8747038e93b5186bb43a47504 |
|
257 | node: 1701ef1f151069b8747038e93b5186bb43a47504 | |
254 | branch: default |
|
258 | branch: default | |
255 | latesttag: null |
|
259 | latesttag: null | |
256 | latesttagdistance: 4 |
|
260 | latesttagdistance: 4 | |
257 | changessincelatesttag: 4 |
|
261 | changessincelatesttag: 4 | |
258 | $ hg tag -r 2 mytag |
|
262 | $ hg tag -r 2 mytag | |
259 | $ hg tag -r 2 anothertag |
|
263 | $ hg tag -r 2 anothertag | |
260 | $ hg archive -r 2 ../test-lasttag |
|
264 | $ hg archive -r 2 ../test-lasttag | |
261 | $ cat ../test-lasttag/.hg_archival.txt |
|
265 | $ cat ../test-lasttag/.hg_archival.txt | |
262 | repo: daa7f7c60e0a224faa4ff77ca41b2760562af264 |
|
266 | repo: daa7f7c60e0a224faa4ff77ca41b2760562af264 | |
263 | node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e |
|
267 | node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e | |
264 | branch: default |
|
268 | branch: default | |
265 | tag: anothertag |
|
269 | tag: anothertag | |
266 | tag: mytag |
|
270 | tag: mytag | |
267 |
|
271 | |||
268 | $ hg archive -t bogus test.bogus |
|
272 | $ hg archive -t bogus test.bogus | |
269 | abort: unknown archive type 'bogus' |
|
273 | abort: unknown archive type 'bogus' | |
270 | [255] |
|
274 | [255] | |
271 |
|
275 | |||
272 | enable progress extension: |
|
276 | enable progress extension: | |
273 |
|
277 | |||
274 | $ cp $HGRCPATH $HGRCPATH.no-progress |
|
278 | $ cp $HGRCPATH $HGRCPATH.no-progress | |
275 | $ cat >> $HGRCPATH <<EOF |
|
279 | $ cat >> $HGRCPATH <<EOF | |
276 | > [progress] |
|
280 | > [progress] | |
277 | > assume-tty = 1 |
|
281 | > assume-tty = 1 | |
278 | > format = topic bar number |
|
282 | > format = topic bar number | |
279 | > delay = 0 |
|
283 | > delay = 0 | |
280 | > refresh = 0 |
|
284 | > refresh = 0 | |
281 | > width = 60 |
|
285 | > width = 60 | |
282 | > EOF |
|
286 | > EOF | |
283 |
|
287 | |||
284 | $ hg archive ../with-progress |
|
288 | $ hg archive ../with-progress | |
285 | \r (no-eol) (esc) |
|
289 | \r (no-eol) (esc) | |
286 | archiving [ ] 0/6\r (no-eol) (esc) |
|
290 | archiving [ ] 0/6\r (no-eol) (esc) | |
287 | archiving [======> ] 1/6\r (no-eol) (esc) |
|
291 | archiving [======> ] 1/6\r (no-eol) (esc) | |
288 | archiving [=============> ] 2/6\r (no-eol) (esc) |
|
292 | archiving [=============> ] 2/6\r (no-eol) (esc) | |
289 | archiving [====================> ] 3/6\r (no-eol) (esc) |
|
293 | archiving [====================> ] 3/6\r (no-eol) (esc) | |
290 | archiving [===========================> ] 4/6\r (no-eol) (esc) |
|
294 | archiving [===========================> ] 4/6\r (no-eol) (esc) | |
291 | archiving [==================================> ] 5/6\r (no-eol) (esc) |
|
295 | archiving [==================================> ] 5/6\r (no-eol) (esc) | |
292 | archiving [==========================================>] 6/6\r (no-eol) (esc) |
|
296 | archiving [==========================================>] 6/6\r (no-eol) (esc) | |
293 | \r (no-eol) (esc) |
|
297 | \r (no-eol) (esc) | |
294 |
|
298 | |||
295 | cleanup after progress extension test: |
|
299 | cleanup after progress extension test: | |
296 |
|
300 | |||
297 | $ cp $HGRCPATH.no-progress $HGRCPATH |
|
301 | $ cp $HGRCPATH.no-progress $HGRCPATH | |
298 |
|
302 | |||
299 | server errors |
|
303 | server errors | |
300 |
|
304 | |||
301 | $ cat errors.log |
|
305 | $ cat errors.log | |
302 |
|
306 | |||
303 | empty repo |
|
307 | empty repo | |
304 |
|
308 | |||
305 | $ hg init ../empty |
|
309 | $ hg init ../empty | |
306 | $ cd ../empty |
|
310 | $ cd ../empty | |
307 | $ hg archive ../test-empty |
|
311 | $ hg archive ../test-empty | |
308 | abort: no working directory: please specify a revision |
|
312 | abort: no working directory: please specify a revision | |
309 | [255] |
|
313 | [255] | |
310 |
|
314 | |||
311 | old file -- date clamped to 1980 |
|
315 | old file -- date clamped to 1980 | |
312 |
|
316 | |||
313 | $ touch -t 197501010000 old |
|
317 | $ touch -t 197501010000 old | |
314 | $ hg add old |
|
318 | $ hg add old | |
315 | $ hg commit -m old |
|
319 | $ hg commit -m old | |
316 | $ hg archive ../old.zip |
|
320 | $ hg archive ../old.zip | |
317 | $ unzip -l ../old.zip |
|
321 | $ unzip -l ../old.zip | |
318 | Archive: ../old.zip |
|
322 | Archive: ../old.zip | |
319 | \s*Length.* (re) |
|
323 | \s*Length.* (re) | |
320 | *-----* (glob) |
|
324 | *-----* (glob) | |
321 | *172*80*00:00*old/.hg_archival.txt (glob) |
|
325 | *172*80*00:00*old/.hg_archival.txt (glob) | |
322 | *0*80*00:00*old/old (glob) |
|
326 | *0*80*00:00*old/old (glob) | |
323 | *-----* (glob) |
|
327 | *-----* (glob) | |
324 | \s*172\s+2 files (re) |
|
328 | \s*172\s+2 files (re) | |
325 |
|
329 | |||
326 | show an error when a provided pattern matches no files |
|
330 | show an error when a provided pattern matches no files | |
327 |
|
331 | |||
328 | $ hg archive -I file_that_does_not_exist.foo ../empty.zip |
|
332 | $ hg archive -I file_that_does_not_exist.foo ../empty.zip | |
329 | abort: no files match the archive pattern |
|
333 | abort: no files match the archive pattern | |
330 | [255] |
|
334 | [255] | |
331 |
|
335 | |||
332 | $ hg archive -X * ../empty.zip |
|
336 | $ hg archive -X * ../empty.zip | |
333 | abort: no files match the archive pattern |
|
337 | abort: no files match the archive pattern | |
334 | [255] |
|
338 | [255] | |
335 |
|
339 | |||
336 | $ cd .. |
|
340 | $ cd .. | |
337 |
|
341 | |||
338 | issue3600: check whether "hg archive" can create archive files which |
|
342 | issue3600: check whether "hg archive" can create archive files which | |
339 | are extracted with expected timestamp, even though TZ is not |
|
343 | are extracted with expected timestamp, even though TZ is not | |
340 | configured as GMT. |
|
344 | configured as GMT. | |
341 |
|
345 | |||
342 | $ mkdir issue3600 |
|
346 | $ mkdir issue3600 | |
343 | $ cd issue3600 |
|
347 | $ cd issue3600 | |
344 |
|
348 | |||
345 | $ hg init repo |
|
349 | $ hg init repo | |
346 | $ echo a > repo/a |
|
350 | $ echo a > repo/a | |
347 | $ hg -R repo add repo/a |
|
351 | $ hg -R repo add repo/a | |
348 | $ hg -R repo commit -m '#0' -d '456789012 21600' |
|
352 | $ hg -R repo commit -m '#0' -d '456789012 21600' | |
349 | $ cat > show_mtime.py <<EOF |
|
353 | $ cat > show_mtime.py <<EOF | |
350 | > from __future__ import print_function |
|
354 | > from __future__ import print_function | |
351 | > import sys, os |
|
355 | > import sys, os | |
352 | > print(int(os.stat(sys.argv[1]).st_mtime)) |
|
356 | > print(int(os.stat(sys.argv[1]).st_mtime)) | |
353 | > EOF |
|
357 | > EOF | |
354 |
|
358 | |||
355 | $ hg -R repo archive --prefix tar-extracted archive.tar |
|
359 | $ hg -R repo archive --prefix tar-extracted archive.tar | |
356 | $ (TZ=UTC-3; export TZ; tar xf archive.tar) |
|
360 | $ (TZ=UTC-3; export TZ; tar xf archive.tar) | |
357 | $ python show_mtime.py tar-extracted/a |
|
361 | $ python show_mtime.py tar-extracted/a | |
358 | 456789012 |
|
362 | 456789012 | |
359 |
|
363 | |||
360 | $ hg -R repo archive --prefix zip-extracted archive.zip |
|
364 | $ hg -R repo archive --prefix zip-extracted archive.zip | |
361 | $ (TZ=UTC-3; export TZ; unzip -q archive.zip) |
|
365 | $ (TZ=UTC-3; export TZ; unzip -q archive.zip) | |
362 | $ python show_mtime.py zip-extracted/a |
|
366 | $ python show_mtime.py zip-extracted/a | |
363 | 456789012 |
|
367 | 456789012 | |
364 |
|
368 | |||
365 | $ cd .. |
|
369 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now