##// END OF EJS Templates
tests: work around FreeBSD's unzip having slightly different output...
Augie Fackler -
r30844:b3d2e8cc stable
parent child Browse files
Show More
@@ -1,378 +1,375 b''
1 1 #require serve
2 2
3 3 $ hg init test
4 4 $ cd test
5 5 $ echo foo>foo
6 6 $ hg commit -Am 1 -d '1 0'
7 7 adding foo
8 8 $ echo bar>bar
9 9 $ hg commit -Am 2 -d '2 0'
10 10 adding bar
11 11 $ mkdir baz
12 12 $ echo bletch>baz/bletch
13 13 $ hg commit -Am 3 -d '1000000000 0'
14 14 adding baz/bletch
15 15 $ hg init subrepo
16 16 $ touch subrepo/sub
17 17 $ hg -q -R subrepo ci -Am "init subrepo"
18 18 $ echo "subrepo = subrepo" > .hgsub
19 19 $ hg add .hgsub
20 20 $ hg ci -m "add subrepo"
21 21 $ echo "[web]" >> .hg/hgrc
22 22 $ echo "name = test-archive" >> .hg/hgrc
23 23 $ echo "archivesubrepos = True" >> .hg/hgrc
24 24 $ cp .hg/hgrc .hg/hgrc-base
25 25 > test_archtype() {
26 26 > echo "allow_archive = $1" >> .hg/hgrc
27 27 > hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
28 28 > cat hg.pid >> $DAEMON_PIDS
29 29 > echo % $1 allowed should give 200
30 30 > get-with-headers.py localhost:$HGPORT "archive/tip.$2" | head -n 1
31 31 > echo % $3 and $4 disallowed should both give 403
32 32 > get-with-headers.py localhost:$HGPORT "archive/tip.$3" | head -n 1
33 33 > get-with-headers.py localhost:$HGPORT "archive/tip.$4" | head -n 1
34 34 > killdaemons.py
35 35 > cat errors.log
36 36 > cp .hg/hgrc-base .hg/hgrc
37 37 > }
38 38
39 39 check http return codes
40 40
41 41 $ test_archtype gz tar.gz tar.bz2 zip
42 42 % gz allowed should give 200
43 43 200 Script output follows
44 44 % tar.bz2 and zip disallowed should both give 403
45 45 403 Archive type not allowed: bz2
46 46 403 Archive type not allowed: zip
47 47 $ test_archtype bz2 tar.bz2 zip tar.gz
48 48 % bz2 allowed should give 200
49 49 200 Script output follows
50 50 % zip and tar.gz disallowed should both give 403
51 51 403 Archive type not allowed: zip
52 52 403 Archive type not allowed: gz
53 53 $ test_archtype zip zip tar.gz tar.bz2
54 54 % zip allowed should give 200
55 55 200 Script output follows
56 56 % tar.gz and tar.bz2 disallowed should both give 403
57 57 403 Archive type not allowed: gz
58 58 403 Archive type not allowed: bz2
59 59
60 60 $ echo "allow_archive = gz bz2 zip" >> .hg/hgrc
61 61 $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
62 62 $ cat hg.pid >> $DAEMON_PIDS
63 63
64 64 check archive links' order
65 65
66 66 $ get-with-headers.py localhost:$HGPORT "?revcount=1" | grep '/archive/tip.'
67 67 <a href="/archive/tip.zip">zip</a>
68 68 <a href="/archive/tip.tar.gz">gz</a>
69 69 <a href="/archive/tip.tar.bz2">bz2</a>
70 70
71 71 invalid arch type should give 404
72 72
73 73 $ get-with-headers.py localhost:$HGPORT "archive/tip.invalid" | head -n 1
74 74 404 Unsupported archive type: None
75 75
76 76 $ TIP=`hg id -v | cut -f1 -d' '`
77 77 $ QTIP=`hg id -q`
78 78 $ cat > getarchive.py <<EOF
79 79 > from __future__ import absolute_import
80 80 > import os
81 81 > import sys
82 82 > from mercurial import (
83 83 > util,
84 84 > )
85 85 > try:
86 86 > # Set stdout to binary mode for win32 platforms
87 87 > import msvcrt
88 88 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
89 89 > except ImportError:
90 90 > pass
91 91 > if len(sys.argv) <= 3:
92 92 > node, archive = sys.argv[1:]
93 93 > requeststr = 'cmd=archive;node=%s;type=%s' % (node, archive)
94 94 > else:
95 95 > node, archive, file = sys.argv[1:]
96 96 > requeststr = 'cmd=archive;node=%s;type=%s;file=%s' % (node, archive, file)
97 97 > try:
98 98 > stdout = sys.stdout.buffer
99 99 > except AttributeError:
100 100 > stdout = sys.stdout
101 101 > try:
102 102 > f = util.urlreq.urlopen('http://127.0.0.1:%s/?%s'
103 103 > % (os.environ['HGPORT'], requeststr))
104 104 > stdout.write(f.read())
105 105 > except util.urlerr.httperror as e:
106 106 > sys.stderr.write(str(e) + '\n')
107 107 > EOF
108 108 $ python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null
109 109 test-archive-1701ef1f1510/.hg_archival.txt
110 110 test-archive-1701ef1f1510/.hgsub
111 111 test-archive-1701ef1f1510/.hgsubstate
112 112 test-archive-1701ef1f1510/bar
113 113 test-archive-1701ef1f1510/baz/bletch
114 114 test-archive-1701ef1f1510/foo
115 115 test-archive-1701ef1f1510/subrepo/sub
116 116 $ python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null
117 117 test-archive-1701ef1f1510/.hg_archival.txt
118 118 test-archive-1701ef1f1510/.hgsub
119 119 test-archive-1701ef1f1510/.hgsubstate
120 120 test-archive-1701ef1f1510/bar
121 121 test-archive-1701ef1f1510/baz/bletch
122 122 test-archive-1701ef1f1510/foo
123 123 test-archive-1701ef1f1510/subrepo/sub
124 124 $ python getarchive.py "$TIP" zip > archive.zip
125 125 $ unzip -t archive.zip
126 126 Archive: archive.zip
127 127 testing: test-archive-1701ef1f1510/.hg_archival.txt*OK (glob)
128 128 testing: test-archive-1701ef1f1510/.hgsub*OK (glob)
129 129 testing: test-archive-1701ef1f1510/.hgsubstate*OK (glob)
130 130 testing: test-archive-1701ef1f1510/bar*OK (glob)
131 131 testing: test-archive-1701ef1f1510/baz/bletch*OK (glob)
132 132 testing: test-archive-1701ef1f1510/foo*OK (glob)
133 133 testing: test-archive-1701ef1f1510/subrepo/sub*OK (glob)
134 134 No errors detected in compressed data of archive.zip.
135 135
136 136 test that we can download single directories and files
137 137
138 138 $ python getarchive.py "$TIP" gz baz | gunzip | tar tf - 2>/dev/null
139 139 test-archive-1701ef1f1510/baz/bletch
140 140 $ python getarchive.py "$TIP" gz foo | gunzip | tar tf - 2>/dev/null
141 141 test-archive-1701ef1f1510/foo
142 142
143 143 test that we detect file patterns that match no files
144 144
145 145 $ python getarchive.py "$TIP" gz foobar
146 146 HTTP Error 404: file(s) not found: foobar
147 147
148 148 test that we reject unsafe patterns
149 149
150 150 $ python getarchive.py "$TIP" gz relre:baz
151 151 HTTP Error 404: file(s) not found: relre:baz
152 152
153 153 $ killdaemons.py
154 154
155 155 $ hg archive -t tar test.tar
156 156 $ tar tf test.tar
157 157 test/.hg_archival.txt
158 158 test/.hgsub
159 159 test/.hgsubstate
160 160 test/bar
161 161 test/baz/bletch
162 162 test/foo
163 163
164 164 $ hg archive --debug -t tbz2 -X baz test.tar.bz2 --config progress.debug=true
165 165 archiving: 0/4 files (0.00%)
166 166 archiving: .hgsub 1/4 files (25.00%)
167 167 archiving: .hgsubstate 2/4 files (50.00%)
168 168 archiving: bar 3/4 files (75.00%)
169 169 archiving: foo 4/4 files (100.00%)
170 170 $ bunzip2 -dc test.tar.bz2 | tar tf - 2>/dev/null
171 171 test/.hg_archival.txt
172 172 test/.hgsub
173 173 test/.hgsubstate
174 174 test/bar
175 175 test/foo
176 176
177 177 $ hg archive -t tgz -p %b-%h test-%h.tar.gz
178 178 $ gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null
179 179 test-1701ef1f1510/.hg_archival.txt
180 180 test-1701ef1f1510/.hgsub
181 181 test-1701ef1f1510/.hgsubstate
182 182 test-1701ef1f1510/bar
183 183 test-1701ef1f1510/baz/bletch
184 184 test-1701ef1f1510/foo
185 185
186 186 $ hg archive autodetected_test.tar
187 187 $ tar tf autodetected_test.tar
188 188 autodetected_test/.hg_archival.txt
189 189 autodetected_test/.hgsub
190 190 autodetected_test/.hgsubstate
191 191 autodetected_test/bar
192 192 autodetected_test/baz/bletch
193 193 autodetected_test/foo
194 194
195 195 The '-t' should override autodetection
196 196
197 197 $ hg archive -t tar autodetect_override_test.zip
198 198 $ tar tf autodetect_override_test.zip
199 199 autodetect_override_test.zip/.hg_archival.txt
200 200 autodetect_override_test.zip/.hgsub
201 201 autodetect_override_test.zip/.hgsubstate
202 202 autodetect_override_test.zip/bar
203 203 autodetect_override_test.zip/baz/bletch
204 204 autodetect_override_test.zip/foo
205 205
206 206 $ for ext in tar tar.gz tgz tar.bz2 tbz2 zip; do
207 207 > hg archive auto_test.$ext
208 208 > if [ -d auto_test.$ext ]; then
209 209 > echo "extension $ext was not autodetected."
210 210 > fi
211 211 > done
212 212
213 213 $ cat > md5comp.py <<EOF
214 214 > from __future__ import print_function
215 215 > try:
216 216 > from hashlib import md5
217 217 > except ImportError:
218 218 > from md5 import md5
219 219 > import sys
220 220 > f1, f2 = sys.argv[1:3]
221 221 > h1 = md5(open(f1, 'rb').read()).hexdigest()
222 222 > h2 = md5(open(f2, 'rb').read()).hexdigest()
223 223 > print(h1 == h2 or "md5 differ: " + repr((h1, h2)))
224 224 > EOF
225 225
226 226 archive name is stored in the archive, so create similar archives and
227 227 rename them afterwards.
228 228
229 229 $ hg archive -t tgz tip.tar.gz
230 230 $ mv tip.tar.gz tip1.tar.gz
231 231 $ sleep 1
232 232 $ hg archive -t tgz tip.tar.gz
233 233 $ mv tip.tar.gz tip2.tar.gz
234 234 $ python md5comp.py tip1.tar.gz tip2.tar.gz
235 235 True
236 236
237 237 $ hg archive -t zip -p /illegal test.zip
238 238 abort: archive prefix contains illegal components
239 239 [255]
240 240 $ hg archive -t zip -p very/../bad test.zip
241 241
242 242 $ hg archive --config ui.archivemeta=false -t zip -r 2 test.zip
243 243 $ unzip -t test.zip
244 244 Archive: test.zip
245 245 testing: test/bar*OK (glob)
246 246 testing: test/baz/bletch*OK (glob)
247 247 testing: test/foo*OK (glob)
248 248 No errors detected in compressed data of test.zip.
249 249
250 250 $ hg archive -t tar - | tar tf - 2>/dev/null
251 251 test-1701ef1f1510/.hg_archival.txt
252 252 test-1701ef1f1510/.hgsub
253 253 test-1701ef1f1510/.hgsubstate
254 254 test-1701ef1f1510/bar
255 255 test-1701ef1f1510/baz/bletch
256 256 test-1701ef1f1510/foo
257 257
258 258 $ hg archive -r 0 -t tar rev-%r.tar
259 259 $ [ -f rev-0.tar ]
260 260
261 261 test .hg_archival.txt
262 262
263 263 $ hg archive ../test-tags
264 264 $ cat ../test-tags/.hg_archival.txt
265 265 repo: daa7f7c60e0a224faa4ff77ca41b2760562af264
266 266 node: 1701ef1f151069b8747038e93b5186bb43a47504
267 267 branch: default
268 268 latesttag: null
269 269 latesttagdistance: 4
270 270 changessincelatesttag: 4
271 271 $ hg tag -r 2 mytag
272 272 $ hg tag -r 2 anothertag
273 273 $ hg archive -r 2 ../test-lasttag
274 274 $ cat ../test-lasttag/.hg_archival.txt
275 275 repo: daa7f7c60e0a224faa4ff77ca41b2760562af264
276 276 node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e
277 277 branch: default
278 278 tag: anothertag
279 279 tag: mytag
280 280
281 281 $ hg archive -t bogus test.bogus
282 282 abort: unknown archive type 'bogus'
283 283 [255]
284 284
285 285 enable progress extension:
286 286
287 287 $ cp $HGRCPATH $HGRCPATH.no-progress
288 288 $ cat >> $HGRCPATH <<EOF
289 289 > [progress]
290 290 > assume-tty = 1
291 291 > format = topic bar number
292 292 > delay = 0
293 293 > refresh = 0
294 294 > width = 60
295 295 > EOF
296 296
297 297 $ hg archive ../with-progress
298 298 \r (no-eol) (esc)
299 299 archiving [ ] 0/6\r (no-eol) (esc)
300 300 archiving [======> ] 1/6\r (no-eol) (esc)
301 301 archiving [=============> ] 2/6\r (no-eol) (esc)
302 302 archiving [====================> ] 3/6\r (no-eol) (esc)
303 303 archiving [===========================> ] 4/6\r (no-eol) (esc)
304 304 archiving [==================================> ] 5/6\r (no-eol) (esc)
305 305 archiving [==========================================>] 6/6\r (no-eol) (esc)
306 306 \r (no-eol) (esc)
307 307
308 308 cleanup after progress extension test:
309 309
310 310 $ cp $HGRCPATH.no-progress $HGRCPATH
311 311
312 312 server errors
313 313
314 314 $ cat errors.log
315 315
316 316 empty repo
317 317
318 318 $ hg init ../empty
319 319 $ cd ../empty
320 320 $ hg archive ../test-empty
321 321 abort: no working directory: please specify a revision
322 322 [255]
323 323
324 324 old file -- date clamped to 1980
325 325
326 326 $ touch -t 197501010000 old
327 327 $ hg add old
328 328 $ hg commit -m old
329 329 $ hg archive ../old.zip
330 $ unzip -l ../old.zip
330 $ unzip -l ../old.zip | grep -v -- ----- | egrep -v files$
331 331 Archive: ../old.zip
332 332 \s*Length.* (re)
333 *-----* (glob)
334 333 *172*80*00:00*old/.hg_archival.txt (glob)
335 334 *0*80*00:00*old/old (glob)
336 *-----* (glob)
337 \s*172\s+2 files (re)
338 335
339 336 show an error when a provided pattern matches no files
340 337
341 338 $ hg archive -I file_that_does_not_exist.foo ../empty.zip
342 339 abort: no files match the archive pattern
343 340 [255]
344 341
345 342 $ hg archive -X * ../empty.zip
346 343 abort: no files match the archive pattern
347 344 [255]
348 345
349 346 $ cd ..
350 347
351 348 issue3600: check whether "hg archive" can create archive files which
352 349 are extracted with expected timestamp, even though TZ is not
353 350 configured as GMT.
354 351
355 352 $ mkdir issue3600
356 353 $ cd issue3600
357 354
358 355 $ hg init repo
359 356 $ echo a > repo/a
360 357 $ hg -R repo add repo/a
361 358 $ hg -R repo commit -m '#0' -d '456789012 21600'
362 359 $ cat > show_mtime.py <<EOF
363 360 > from __future__ import print_function
364 361 > import sys, os
365 362 > print(int(os.stat(sys.argv[1]).st_mtime))
366 363 > EOF
367 364
368 365 $ hg -R repo archive --prefix tar-extracted archive.tar
369 366 $ (TZ=UTC-3; export TZ; tar xf archive.tar)
370 367 $ python show_mtime.py tar-extracted/a
371 368 456789012
372 369
373 370 $ hg -R repo archive --prefix zip-extracted archive.zip
374 371 $ (TZ=UTC-3; export TZ; unzip -q archive.zip)
375 372 $ python show_mtime.py zip-extracted/a
376 373 456789012
377 374
378 375 $ cd ..
@@ -1,568 +1,565 b''
1 1 Create test repository:
2 2
3 3 $ hg init repo
4 4 $ cd repo
5 5 $ echo x1 > x.txt
6 6
7 7 $ hg init foo
8 8 $ cd foo
9 9 $ echo y1 > y.txt
10 10
11 11 $ hg init bar
12 12 $ cd bar
13 13 $ echo z1 > z.txt
14 14
15 15 $ cd ..
16 16 $ echo 'bar = bar' > .hgsub
17 17
18 18 $ cd ..
19 19 $ echo 'foo = foo' > .hgsub
20 20
21 21 Add files --- .hgsub files must go first to trigger subrepos:
22 22
23 23 $ hg add -S .hgsub
24 24 $ hg add -S foo/.hgsub
25 25 $ hg add -S foo/bar
26 26 adding foo/bar/z.txt (glob)
27 27 $ hg add -S
28 28 adding x.txt
29 29 adding foo/y.txt (glob)
30 30
31 31 Test recursive status without committing anything:
32 32
33 33 $ hg status -S
34 34 A .hgsub
35 35 A foo/.hgsub
36 36 A foo/bar/z.txt
37 37 A foo/y.txt
38 38 A x.txt
39 39
40 40 Test recursive diff without committing anything:
41 41
42 42 $ hg diff --nodates -S foo
43 43 diff -r 000000000000 foo/.hgsub
44 44 --- /dev/null
45 45 +++ b/foo/.hgsub
46 46 @@ -0,0 +1,1 @@
47 47 +bar = bar
48 48 diff -r 000000000000 foo/y.txt
49 49 --- /dev/null
50 50 +++ b/foo/y.txt
51 51 @@ -0,0 +1,1 @@
52 52 +y1
53 53 diff -r 000000000000 foo/bar/z.txt
54 54 --- /dev/null
55 55 +++ b/foo/bar/z.txt
56 56 @@ -0,0 +1,1 @@
57 57 +z1
58 58
59 59 Commits:
60 60
61 61 $ hg commit -m fails
62 62 abort: uncommitted changes in subrepository 'foo'
63 63 (use --subrepos for recursive commit)
64 64 [255]
65 65
66 66 The --subrepos flag overwrite the config setting:
67 67
68 68 $ hg commit -m 0-0-0 --config ui.commitsubrepos=No --subrepos
69 69 committing subrepository foo
70 70 committing subrepository foo/bar (glob)
71 71
72 72 $ cd foo
73 73 $ echo y2 >> y.txt
74 74 $ hg commit -m 0-1-0
75 75
76 76 $ cd bar
77 77 $ echo z2 >> z.txt
78 78 $ hg commit -m 0-1-1
79 79
80 80 $ cd ..
81 81 $ hg commit -m 0-2-1
82 82
83 83 $ cd ..
84 84 $ hg commit -m 1-2-1
85 85
86 86 Change working directory:
87 87
88 88 $ echo y3 >> foo/y.txt
89 89 $ echo z3 >> foo/bar/z.txt
90 90 $ hg status -S
91 91 M foo/bar/z.txt
92 92 M foo/y.txt
93 93 $ hg diff --nodates -S
94 94 diff -r d254738c5f5e foo/y.txt
95 95 --- a/foo/y.txt
96 96 +++ b/foo/y.txt
97 97 @@ -1,2 +1,3 @@
98 98 y1
99 99 y2
100 100 +y3
101 101 diff -r 9647f22de499 foo/bar/z.txt
102 102 --- a/foo/bar/z.txt
103 103 +++ b/foo/bar/z.txt
104 104 @@ -1,2 +1,3 @@
105 105 z1
106 106 z2
107 107 +z3
108 108
109 109 Status call crossing repository boundaries:
110 110
111 111 $ hg status -S foo/bar/z.txt
112 112 M foo/bar/z.txt
113 113 $ hg status -S -I 'foo/?.txt'
114 114 M foo/y.txt
115 115 $ hg status -S -I '**/?.txt'
116 116 M foo/bar/z.txt
117 117 M foo/y.txt
118 118 $ hg diff --nodates -S -I '**/?.txt'
119 119 diff -r d254738c5f5e foo/y.txt
120 120 --- a/foo/y.txt
121 121 +++ b/foo/y.txt
122 122 @@ -1,2 +1,3 @@
123 123 y1
124 124 y2
125 125 +y3
126 126 diff -r 9647f22de499 foo/bar/z.txt
127 127 --- a/foo/bar/z.txt
128 128 +++ b/foo/bar/z.txt
129 129 @@ -1,2 +1,3 @@
130 130 z1
131 131 z2
132 132 +z3
133 133
134 134 Status from within a subdirectory:
135 135
136 136 $ mkdir dir
137 137 $ cd dir
138 138 $ echo a1 > a.txt
139 139 $ hg status -S
140 140 M foo/bar/z.txt
141 141 M foo/y.txt
142 142 ? dir/a.txt
143 143 $ hg diff --nodates -S
144 144 diff -r d254738c5f5e foo/y.txt
145 145 --- a/foo/y.txt
146 146 +++ b/foo/y.txt
147 147 @@ -1,2 +1,3 @@
148 148 y1
149 149 y2
150 150 +y3
151 151 diff -r 9647f22de499 foo/bar/z.txt
152 152 --- a/foo/bar/z.txt
153 153 +++ b/foo/bar/z.txt
154 154 @@ -1,2 +1,3 @@
155 155 z1
156 156 z2
157 157 +z3
158 158
159 159 Status with relative path:
160 160
161 161 $ hg status -S ..
162 162 M ../foo/bar/z.txt
163 163 M ../foo/y.txt
164 164 ? a.txt
165 165
166 166 XXX: filtering lfilesrepo.status() in 3.3-rc causes these files to be listed as
167 167 added instead of modified.
168 168 $ hg status -S .. --config extensions.largefiles=
169 169 M ../foo/bar/z.txt
170 170 M ../foo/y.txt
171 171 ? a.txt
172 172
173 173 $ hg diff --nodates -S ..
174 174 diff -r d254738c5f5e foo/y.txt
175 175 --- a/foo/y.txt
176 176 +++ b/foo/y.txt
177 177 @@ -1,2 +1,3 @@
178 178 y1
179 179 y2
180 180 +y3
181 181 diff -r 9647f22de499 foo/bar/z.txt
182 182 --- a/foo/bar/z.txt
183 183 +++ b/foo/bar/z.txt
184 184 @@ -1,2 +1,3 @@
185 185 z1
186 186 z2
187 187 +z3
188 188 $ cd ..
189 189
190 190 Cleanup and final commit:
191 191
192 192 $ rm -r dir
193 193 $ hg commit --subrepos -m 2-3-2
194 194 committing subrepository foo
195 195 committing subrepository foo/bar (glob)
196 196
197 197 Test explicit path commands within subrepos: add/forget
198 198 $ echo z1 > foo/bar/z2.txt
199 199 $ hg status -S
200 200 ? foo/bar/z2.txt
201 201 $ hg add foo/bar/z2.txt
202 202 $ hg status -S
203 203 A foo/bar/z2.txt
204 204 $ hg forget foo/bar/z2.txt
205 205 $ hg status -S
206 206 ? foo/bar/z2.txt
207 207 $ hg forget foo/bar/z2.txt
208 208 not removing foo/bar/z2.txt: file is already untracked (glob)
209 209 [1]
210 210 $ hg status -S
211 211 ? foo/bar/z2.txt
212 212 $ rm foo/bar/z2.txt
213 213
214 214 Log with the relationships between repo and its subrepo:
215 215
216 216 $ hg log --template '{rev}:{node|short} {desc}\n'
217 217 2:1326fa26d0c0 2-3-2
218 218 1:4b3c9ff4f66b 1-2-1
219 219 0:23376cbba0d8 0-0-0
220 220
221 221 $ hg -R foo log --template '{rev}:{node|short} {desc}\n'
222 222 3:65903cebad86 2-3-2
223 223 2:d254738c5f5e 0-2-1
224 224 1:8629ce7dcc39 0-1-0
225 225 0:af048e97ade2 0-0-0
226 226
227 227 $ hg -R foo/bar log --template '{rev}:{node|short} {desc}\n'
228 228 2:31ecbdafd357 2-3-2
229 229 1:9647f22de499 0-1-1
230 230 0:4904098473f9 0-0-0
231 231
232 232 Status between revisions:
233 233
234 234 $ hg status -S
235 235 $ hg status -S --rev 0:1
236 236 M .hgsubstate
237 237 M foo/.hgsubstate
238 238 M foo/bar/z.txt
239 239 M foo/y.txt
240 240 $ hg diff --nodates -S -I '**/?.txt' --rev 0:1
241 241 diff -r af048e97ade2 -r d254738c5f5e foo/y.txt
242 242 --- a/foo/y.txt
243 243 +++ b/foo/y.txt
244 244 @@ -1,1 +1,2 @@
245 245 y1
246 246 +y2
247 247 diff -r 4904098473f9 -r 9647f22de499 foo/bar/z.txt
248 248 --- a/foo/bar/z.txt
249 249 +++ b/foo/bar/z.txt
250 250 @@ -1,1 +1,2 @@
251 251 z1
252 252 +z2
253 253
254 254 Enable progress extension for archive tests:
255 255
256 256 $ cp $HGRCPATH $HGRCPATH.no-progress
257 257 $ cat >> $HGRCPATH <<EOF
258 258 > [progress]
259 259 > disable=False
260 260 > assume-tty = 1
261 261 > delay = 0
262 262 > # set changedelay really large so we don't see nested topics
263 263 > changedelay = 30000
264 264 > format = topic bar number
265 265 > refresh = 0
266 266 > width = 60
267 267 > EOF
268 268
269 269 Test archiving to a directory tree (the doubled lines in the output
270 270 only show up in the test output, not in real usage):
271 271
272 272 $ hg archive --subrepos ../archive
273 273 \r (no-eol) (esc)
274 274 archiving [ ] 0/3\r (no-eol) (esc)
275 275 archiving [=============> ] 1/3\r (no-eol) (esc)
276 276 archiving [===========================> ] 2/3\r (no-eol) (esc)
277 277 archiving [==========================================>] 3/3\r (no-eol) (esc)
278 278 \r (no-eol) (esc)
279 279 \r (no-eol) (esc)
280 280 archiving (foo) [ ] 0/3\r (no-eol) (esc)
281 281 archiving (foo) [===========> ] 1/3\r (no-eol) (esc)
282 282 archiving (foo) [=======================> ] 2/3\r (no-eol) (esc)
283 283 archiving (foo) [====================================>] 3/3\r (no-eol) (esc)
284 284 \r (no-eol) (esc)
285 285 \r (no-eol) (esc)
286 286 archiving (foo/bar) [ ] 0/1\r (no-eol) (glob) (esc)
287 287 archiving (foo/bar) [================================>] 1/1\r (no-eol) (glob) (esc)
288 288 \r (no-eol) (esc)
289 289 $ find ../archive | sort
290 290 ../archive
291 291 ../archive/.hg_archival.txt
292 292 ../archive/.hgsub
293 293 ../archive/.hgsubstate
294 294 ../archive/foo
295 295 ../archive/foo/.hgsub
296 296 ../archive/foo/.hgsubstate
297 297 ../archive/foo/bar
298 298 ../archive/foo/bar/z.txt
299 299 ../archive/foo/y.txt
300 300 ../archive/x.txt
301 301
302 302 Test archiving to zip file (unzip output is unstable):
303 303
304 304 $ hg archive --subrepos --prefix '.' ../archive.zip
305 305 \r (no-eol) (esc)
306 306 archiving [ ] 0/3\r (no-eol) (esc)
307 307 archiving [=============> ] 1/3\r (no-eol) (esc)
308 308 archiving [===========================> ] 2/3\r (no-eol) (esc)
309 309 archiving [==========================================>] 3/3\r (no-eol) (esc)
310 310 \r (no-eol) (esc)
311 311 \r (no-eol) (esc)
312 312 archiving (foo) [ ] 0/3\r (no-eol) (esc)
313 313 archiving (foo) [===========> ] 1/3\r (no-eol) (esc)
314 314 archiving (foo) [=======================> ] 2/3\r (no-eol) (esc)
315 315 archiving (foo) [====================================>] 3/3\r (no-eol) (esc)
316 316 \r (no-eol) (esc)
317 317 \r (no-eol) (esc)
318 318 archiving (foo/bar) [ ] 0/1\r (no-eol) (glob) (esc)
319 319 archiving (foo/bar) [================================>] 1/1\r (no-eol) (glob) (esc)
320 320 \r (no-eol) (esc)
321 321
322 322 (unzip date formating is unstable, we do not care about it and glob it out)
323 323
324 $ unzip -l ../archive.zip
324 $ unzip -l ../archive.zip | grep -v -- ----- | egrep -v files$
325 325 Archive: ../archive.zip
326 326 Length [ ]* Date [ ]* Time [ ]* Name (re)
327 [\- ]* (re)
328 327 172 [0-9:\- ]* .hg_archival.txt (re)
329 328 10 [0-9:\- ]* .hgsub (re)
330 329 45 [0-9:\- ]* .hgsubstate (re)
331 330 3 [0-9:\- ]* x.txt (re)
332 331 10 [0-9:\- ]* foo/.hgsub (re)
333 332 45 [0-9:\- ]* foo/.hgsubstate (re)
334 333 9 [0-9:\- ]* foo/y.txt (re)
335 334 9 [0-9:\- ]* foo/bar/z.txt (re)
336 [\- ]* (re)
337 303 [ ]* 8 files (re)
338 335
339 336 Test archiving a revision that references a subrepo that is not yet
340 337 cloned:
341 338
342 339 #if hardlink
343 340 $ hg clone -U . ../empty
344 341 \r (no-eol) (esc)
345 342 linking [ <=> ] 1\r (no-eol) (esc)
346 343 linking [ <=> ] 2\r (no-eol) (esc)
347 344 linking [ <=> ] 3\r (no-eol) (esc)
348 345 linking [ <=> ] 4\r (no-eol) (esc)
349 346 linking [ <=> ] 5\r (no-eol) (esc)
350 347 linking [ <=> ] 6\r (no-eol) (esc)
351 348 linking [ <=> ] 7\r (no-eol) (esc)
352 349 linking [ <=> ] 8\r (no-eol) (esc)
353 350 \r (no-eol) (esc)
354 351 #else
355 352 $ hg clone -U . ../empty
356 353 \r (no-eol) (esc)
357 354 linking [ <=> ] 1 (no-eol)
358 355 #endif
359 356
360 357 $ cd ../empty
361 358 #if hardlink
362 359 $ hg archive --subrepos -r tip --prefix './' ../archive.tar.gz
363 360 \r (no-eol) (esc)
364 361 archiving [ ] 0/3\r (no-eol) (esc)
365 362 archiving [=============> ] 1/3\r (no-eol) (esc)
366 363 archiving [===========================> ] 2/3\r (no-eol) (esc)
367 364 archiving [==========================================>] 3/3\r (no-eol) (esc)
368 365 \r (no-eol) (esc)
369 366 \r (no-eol) (esc)
370 367 linking [ <=> ] 1\r (no-eol) (esc)
371 368 linking [ <=> ] 2\r (no-eol) (esc)
372 369 linking [ <=> ] 3\r (no-eol) (esc)
373 370 linking [ <=> ] 4\r (no-eol) (esc)
374 371 linking [ <=> ] 5\r (no-eol) (esc)
375 372 linking [ <=> ] 6\r (no-eol) (esc)
376 373 linking [ <=> ] 7\r (no-eol) (esc)
377 374 linking [ <=> ] 8\r (no-eol) (esc)
378 375 \r (no-eol) (esc)
379 376 \r (no-eol) (esc)
380 377 archiving (foo) [ ] 0/3\r (no-eol) (esc)
381 378 archiving (foo) [===========> ] 1/3\r (no-eol) (esc)
382 379 archiving (foo) [=======================> ] 2/3\r (no-eol) (esc)
383 380 archiving (foo) [====================================>] 3/3\r (no-eol) (esc)
384 381 \r (no-eol) (esc)
385 382 \r (no-eol) (esc)
386 383 linking [ <=> ] 1\r (no-eol) (esc)
387 384 linking [ <=> ] 2\r (no-eol) (esc)
388 385 linking [ <=> ] 3\r (no-eol) (esc)
389 386 linking [ <=> ] 4\r (no-eol) (esc)
390 387 linking [ <=> ] 5\r (no-eol) (esc)
391 388 linking [ <=> ] 6\r (no-eol) (esc)
392 389 \r (no-eol) (esc)
393 390 \r (no-eol) (esc)
394 391 archiving (foo/bar) [ ] 0/1\r (no-eol) (glob) (esc)
395 392 archiving (foo/bar) [================================>] 1/1\r (no-eol) (glob) (esc)
396 393 \r (no-eol) (esc)
397 394 cloning subrepo foo from $TESTTMP/repo/foo
398 395 cloning subrepo foo/bar from $TESTTMP/repo/foo/bar (glob)
399 396 #else
400 397 Note there's a slight output glitch on non-hardlink systems: the last
401 398 "linking" progress topic never gets closed, leading to slight output corruption on that platform.
402 399 $ hg archive --subrepos -r tip --prefix './' ../archive.tar.gz
403 400 \r (no-eol) (esc)
404 401 archiving [ ] 0/3\r (no-eol) (esc)
405 402 archiving [=============> ] 1/3\r (no-eol) (esc)
406 403 archiving [===========================> ] 2/3\r (no-eol) (esc)
407 404 archiving [==========================================>] 3/3\r (no-eol) (esc)
408 405 \r (no-eol) (esc)
409 406 \r (no-eol) (esc)
410 407 linking [ <=> ] 1\r (no-eol) (esc)
411 408 cloning subrepo foo/bar from $TESTTMP/repo/foo/bar (glob)
412 409 #endif
413 410
414 411 Archive + subrepos uses '/' for all component separators
415 412
416 413 $ tar -tzf ../archive.tar.gz | sort
417 414 .hg_archival.txt
418 415 .hgsub
419 416 .hgsubstate
420 417 foo/.hgsub
421 418 foo/.hgsubstate
422 419 foo/bar/z.txt
423 420 foo/y.txt
424 421 x.txt
425 422
426 423 The newly cloned subrepos contain no working copy:
427 424
428 425 $ hg -R foo summary
429 426 parent: -1:000000000000 (no revision checked out)
430 427 branch: default
431 428 commit: (clean)
432 429 update: 4 new changesets (update)
433 430
434 431 Disable progress extension and cleanup:
435 432
436 433 $ mv $HGRCPATH.no-progress $HGRCPATH
437 434
438 435 Test archiving when there is a directory in the way for a subrepo
439 436 created by archive:
440 437
441 438 $ hg clone -U . ../almost-empty
442 439 $ cd ../almost-empty
443 440 $ mkdir foo
444 441 $ echo f > foo/f
445 442 $ hg archive --subrepos -r tip archive
446 443 cloning subrepo foo from $TESTTMP/empty/foo
447 444 abort: destination '$TESTTMP/almost-empty/foo' is not empty (in subrepo foo) (glob)
448 445 [255]
449 446
450 447 Clone and test outgoing:
451 448
452 449 $ cd ..
453 450 $ hg clone repo repo2
454 451 updating to branch default
455 452 cloning subrepo foo from $TESTTMP/repo/foo
456 453 cloning subrepo foo/bar from $TESTTMP/repo/foo/bar (glob)
457 454 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
458 455 $ cd repo2
459 456 $ hg outgoing -S
460 457 comparing with $TESTTMP/repo (glob)
461 458 searching for changes
462 459 no changes found
463 460 comparing with $TESTTMP/repo/foo
464 461 searching for changes
465 462 no changes found
466 463 comparing with $TESTTMP/repo/foo/bar
467 464 searching for changes
468 465 no changes found
469 466 [1]
470 467
471 468 Make nested change:
472 469
473 470 $ echo y4 >> foo/y.txt
474 471 $ hg diff --nodates -S
475 472 diff -r 65903cebad86 foo/y.txt
476 473 --- a/foo/y.txt
477 474 +++ b/foo/y.txt
478 475 @@ -1,3 +1,4 @@
479 476 y1
480 477 y2
481 478 y3
482 479 +y4
483 480 $ hg commit --subrepos -m 3-4-2
484 481 committing subrepository foo
485 482 $ hg outgoing -S
486 483 comparing with $TESTTMP/repo (glob)
487 484 searching for changes
488 485 changeset: 3:2655b8ecc4ee
489 486 tag: tip
490 487 user: test
491 488 date: Thu Jan 01 00:00:00 1970 +0000
492 489 summary: 3-4-2
493 490
494 491 comparing with $TESTTMP/repo/foo
495 492 searching for changes
496 493 changeset: 4:e96193d6cb36
497 494 tag: tip
498 495 user: test
499 496 date: Thu Jan 01 00:00:00 1970 +0000
500 497 summary: 3-4-2
501 498
502 499 comparing with $TESTTMP/repo/foo/bar
503 500 searching for changes
504 501 no changes found
505 502
506 503
507 504 Switch to original repo and setup default path:
508 505
509 506 $ cd ../repo
510 507 $ echo '[paths]' >> .hg/hgrc
511 508 $ echo 'default = ../repo2' >> .hg/hgrc
512 509
513 510 Test incoming:
514 511
515 512 $ hg incoming -S
516 513 comparing with $TESTTMP/repo2 (glob)
517 514 searching for changes
518 515 changeset: 3:2655b8ecc4ee
519 516 tag: tip
520 517 user: test
521 518 date: Thu Jan 01 00:00:00 1970 +0000
522 519 summary: 3-4-2
523 520
524 521 comparing with $TESTTMP/repo2/foo
525 522 searching for changes
526 523 changeset: 4:e96193d6cb36
527 524 tag: tip
528 525 user: test
529 526 date: Thu Jan 01 00:00:00 1970 +0000
530 527 summary: 3-4-2
531 528
532 529 comparing with $TESTTMP/repo2/foo/bar
533 530 searching for changes
534 531 no changes found
535 532
536 533 $ hg incoming -S --bundle incoming.hg
537 534 abort: cannot combine --bundle and --subrepos
538 535 [255]
539 536
540 537 Test missing subrepo:
541 538
542 539 $ rm -r foo
543 540 $ hg status -S
544 541 warning: error "unknown revision '65903cebad86f1a84bd4f1134f62fa7dcb7a1c98'" in subrepository "foo"
545 542
546 543 Issue2619: IndexError: list index out of range on hg add with subrepos
547 544 The subrepo must sorts after the explicit filename.
548 545
549 546 $ cd ..
550 547 $ hg init test
551 548 $ cd test
552 549 $ hg init x
553 550 $ echo abc > abc.txt
554 551 $ hg ci -Am "abc"
555 552 adding abc.txt
556 553 $ echo "x = x" >> .hgsub
557 554 $ hg add .hgsub
558 555 $ touch a x/a
559 556 $ hg add a x/a
560 557
561 558 $ hg ci -Sm "added x"
562 559 committing subrepository x
563 560 $ echo abc > x/a
564 561 $ hg revert --rev '.^' "set:subrepo('glob:x*')"
565 562 abort: subrepository 'x' does not exist in 25ac2c9b3180!
566 563 [255]
567 564
568 565 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now