##// END OF EJS Templates
archive: drop the leading '.' path component from the prefix (issue4634)...
Matt Harbison -
r24953:5115d034 default
parent child Browse files
Show More
@@ -37,6 +37,10 b' def tidyprefix(dest, kind, prefix):'
37 prefix = util.pconvert(lpfx)
37 prefix = util.pconvert(lpfx)
38 if not prefix.endswith('/'):
38 if not prefix.endswith('/'):
39 prefix += '/'
39 prefix += '/'
40 # Drop the leading '.' path component if present, so Windows can read the
41 # zip files (issue4634)
42 if prefix.startswith('./'):
43 prefix = prefix[2:]
40 if prefix.startswith('../') or os.path.isabs(lpfx) or '/../' in prefix:
44 if prefix.startswith('../') or os.path.isabs(lpfx) or '/../' in prefix:
41 raise util.Abort(_('archive prefix contains illegal components'))
45 raise util.Abort(_('archive prefix contains illegal components'))
42 return prefix
46 return prefix
@@ -309,17 +309,17 b' Exclude large files from main and sub-su'
309
309
310 Exclude normal files from main and sub-sub repo
310 Exclude normal files from main and sub-sub repo
311
311
312 $ hg --config extensions.largefiles= archive -S -X '**.txt' ../archive_lf.tgz
312 $ hg --config extensions.largefiles= archive -S -X '**.txt' -p '.' ../archive_lf.tgz
313 $ tar -tzf ../archive_lf.tgz | sort
313 $ tar -tzf ../archive_lf.tgz | sort
314 archive_lf/.hgsub
314 .hgsub
315 archive_lf/.hgsubstate
315 .hgsubstate
316 archive_lf/large.bin
316 large.bin
317 archive_lf/main
317 main
318 archive_lf/sub1/.hgsub
318 sub1/.hgsub
319 archive_lf/sub1/.hgsubstate
319 sub1/.hgsubstate
320 archive_lf/sub1/sub1
320 sub1/sub1
321 archive_lf/sub1/sub2/large.bin
321 sub1/sub2/large.bin
322 archive_lf/sub1/sub2/sub2
322 sub1/sub2/sub2
323
323
324 Include normal files from within a largefiles subrepo
324 Include normal files from within a largefiles subrepo
325
325
@@ -325,13 +325,13 b' archive subrepos'
325 ../archive_x/s
325 ../archive_x/s
326 ../archive_x/s/g
326 ../archive_x/s/g
327
327
328 $ hg -R ../tc archive -S ../archive.tgz 2>/dev/null
328 $ hg -R ../tc archive -S ../archive.tgz --prefix '.' 2>/dev/null
329 $ tar -tzf ../archive.tgz | sort
329 $ tar -tzf ../archive.tgz | sort
330 archive/.hg_archival.txt
330 .hg_archival.txt
331 archive/.hgsub
331 .hgsub
332 archive/.hgsubstate
332 .hgsubstate
333 archive/a
333 a
334 archive/s/g
334 s/g
335
335
336 create nested repo
336 create nested repo
337
337
@@ -312,7 +312,7 b' only show up in the test output, not in '
312
312
313 Test archiving to zip file (unzip output is unstable):
313 Test archiving to zip file (unzip output is unstable):
314
314
315 $ hg archive --subrepos ../archive.zip
315 $ hg archive --subrepos --prefix '.' ../archive.zip
316 \r (no-eol) (esc)
316 \r (no-eol) (esc)
317 archiving [ ] 0/3\r (no-eol) (esc)
317 archiving [ ] 0/3\r (no-eol) (esc)
318 archiving [ ] 0/3\r (no-eol) (esc)
318 archiving [ ] 0/3\r (no-eol) (esc)
@@ -339,6 +339,20 b' Test archiving to zip file (unzip output'
339 archiving (foo/bar) [================================>] 1/1\r (no-eol) (glob) (esc)
339 archiving (foo/bar) [================================>] 1/1\r (no-eol) (glob) (esc)
340 archiving (foo/bar) [================================>] 1/1\r (no-eol) (glob) (esc)
340 archiving (foo/bar) [================================>] 1/1\r (no-eol) (glob) (esc)
341 \r (no-eol) (esc)
341 \r (no-eol) (esc)
342 $ unzip -l ../archive.zip
343 Archive: ../archive.zip
344 Length Date Time Name
345 --------- ---------- ----- ----
346 172 01-01-1980 00:00 .hg_archival.txt
347 10 01-01-1980 00:00 .hgsub
348 45 01-01-1980 00:00 .hgsubstate
349 3 01-01-1980 00:00 x.txt
350 10 01-01-1980 00:00 foo/.hgsub
351 45 01-01-1980 00:00 foo/.hgsubstate
352 9 01-01-1980 00:00 foo/y.txt
353 9 01-01-1980 00:00 foo/bar/z.txt
354 --------- -------
355 303 8 files
342
356
343 Test archiving a revision that references a subrepo that is not yet
357 Test archiving a revision that references a subrepo that is not yet
344 cloned:
358 cloned:
@@ -363,7 +377,7 b' cloned:'
363
377
364 $ cd ../empty
378 $ cd ../empty
365 #if hardlink
379 #if hardlink
366 $ hg archive --subrepos -r tip ../archive.tar.gz
380 $ hg archive --subrepos -r tip --prefix './' ../archive.tar.gz
367 \r (no-eol) (esc)
381 \r (no-eol) (esc)
368 archiving [ ] 0/3\r (no-eol) (esc)
382 archiving [ ] 0/3\r (no-eol) (esc)
369 archiving [ ] 0/3\r (no-eol) (esc)
383 archiving [ ] 0/3\r (no-eol) (esc)
@@ -413,7 +427,7 b' cloned:'
413 #else
427 #else
414 Note there's a slight output glitch on non-hardlink systems: the last
428 Note there's a slight output glitch on non-hardlink systems: the last
415 "linking" progress topic never gets closed, leading to slight output corruption on that platform.
429 "linking" progress topic never gets closed, leading to slight output corruption on that platform.
416 $ hg archive --subrepos -r tip ../archive.tar.gz
430 $ hg archive --subrepos -r tip --prefix './' ../archive.tar.gz
417 \r (no-eol) (esc)
431 \r (no-eol) (esc)
418 archiving [ ] 0/3\r (no-eol) (esc)
432 archiving [ ] 0/3\r (no-eol) (esc)
419 archiving [ ] 0/3\r (no-eol) (esc)
433 archiving [ ] 0/3\r (no-eol) (esc)
@@ -437,14 +451,14 b" Note there's a slight output glitch on n"
437 Archive + subrepos uses '/' for all component separators
451 Archive + subrepos uses '/' for all component separators
438
452
439 $ tar -tzf ../archive.tar.gz | sort
453 $ tar -tzf ../archive.tar.gz | sort
440 archive/.hg_archival.txt
454 .hg_archival.txt
441 archive/.hgsub
455 .hgsub
442 archive/.hgsubstate
456 .hgsubstate
443 archive/foo/.hgsub
457 foo/.hgsub
444 archive/foo/.hgsubstate
458 foo/.hgsubstate
445 archive/foo/bar/z.txt
459 foo/bar/z.txt
446 archive/foo/y.txt
460 foo/y.txt
447 archive/x.txt
461 x.txt
448
462
449 The newly cloned subrepos contain no working copy:
463 The newly cloned subrepos contain no working copy:
450
464
General Comments 0
You need to be logged in to leave comments. Login now