Show More
@@ -13,6 +13,7 b' import scmutil, util, encoding' | |||
|
13 | 13 | import cStringIO, os, tarfile, time, zipfile |
|
14 | 14 | import zlib, gzip |
|
15 | 15 | import struct |
|
16 | import error | |
|
16 | 17 | |
|
17 | 18 | # from unzip source code: |
|
18 | 19 | _UNX_IFREG = 0x8000 |
@@ -288,20 +289,25 b' def archive(repo, dest, node, kind, deco' | |||
|
288 | 289 | files = [f for f in ctx.manifest().keys() if matchfn(f)] |
|
289 | 290 | else: |
|
290 | 291 | files = ctx.manifest().keys() |
|
291 | files.sort() | |
|
292 | 292 | total = len(files) |
|
293 | repo.ui.progress(_('archiving'), 0, unit=_('files'), total=total) | |
|
294 | for i, f in enumerate(files): | |
|
295 | ff = ctx.flags(f) | |
|
296 | write(f, 'x' in ff and 0755 or 0644, 'l' in ff, ctx[f].data) | |
|
297 | repo.ui.progress(_('archiving'), i + 1, item=f, | |
|
298 | unit=_('files'), total=total) | |
|
299 |
repo.ui.progress(_('archiving'), |
|
|
293 | if total: | |
|
294 | files.sort() | |
|
295 | repo.ui.progress(_('archiving'), 0, unit=_('files'), total=total) | |
|
296 | for i, f in enumerate(files): | |
|
297 | ff = ctx.flags(f) | |
|
298 | write(f, 'x' in ff and 0755 or 0644, 'l' in ff, ctx[f].data) | |
|
299 | repo.ui.progress(_('archiving'), i + 1, item=f, | |
|
300 | unit=_('files'), total=total) | |
|
301 | repo.ui.progress(_('archiving'), None) | |
|
300 | 302 | |
|
301 | 303 | if subrepos: |
|
302 | 304 | for subpath in sorted(ctx.substate): |
|
303 | 305 | sub = ctx.sub(subpath) |
|
304 | 306 | submatch = matchmod.narrowmatcher(subpath, matchfn) |
|
305 | sub.archive(repo.ui, archiver, prefix, submatch) | |
|
307 | total += sub.archive(repo.ui, archiver, prefix, submatch) | |
|
308 | ||
|
309 | if total == 0: | |
|
310 | raise error.Abort(_('no files match the archive pattern')) | |
|
306 | 311 | |
|
307 | 312 | archiver.done() |
|
313 | return total |
@@ -423,6 +423,7 b' class abstractsubrepo(object):' | |||
|
423 | 423 | ui.progress(_('archiving (%s)') % relpath, i + 1, |
|
424 | 424 | unit=_('files'), total=total) |
|
425 | 425 | ui.progress(_('archiving (%s)') % relpath, None) |
|
426 | return total | |
|
426 | 427 | |
|
427 | 428 | def walk(self, match): |
|
428 | 429 | ''' |
@@ -580,14 +581,15 b' class hgsubrepo(abstractsubrepo):' | |||
|
580 | 581 | @annotatesubrepoerror |
|
581 | 582 | def archive(self, ui, archiver, prefix, match=None): |
|
582 | 583 | self._get(self._state + ('hg',)) |
|
583 | abstractsubrepo.archive(self, ui, archiver, prefix, match) | |
|
584 | ||
|
584 | total = abstractsubrepo.archive(self, ui, archiver, prefix, match) | |
|
585 | 585 | rev = self._state[1] |
|
586 | 586 | ctx = self._repo[rev] |
|
587 | 587 | for subpath in ctx.substate: |
|
588 | 588 | s = subrepo(ctx, subpath) |
|
589 | 589 | submatch = matchmod.narrowmatcher(subpath, match) |
|
590 | s.archive(ui, archiver, os.path.join(prefix, self._path), submatch) | |
|
590 | total += s.archive( | |
|
591 | ui, archiver, os.path.join(prefix, self._path), submatch) | |
|
592 | return total | |
|
591 | 593 | |
|
592 | 594 | @annotatesubrepoerror |
|
593 | 595 | def dirty(self, ignoreupdate=False): |
@@ -1383,9 +1385,10 b' class gitsubrepo(abstractsubrepo):' | |||
|
1383 | 1385 | os.remove(path) |
|
1384 | 1386 | |
|
1385 | 1387 | def archive(self, ui, archiver, prefix, match=None): |
|
1388 | total = 0 | |
|
1386 | 1389 | source, revision = self._state |
|
1387 | 1390 | if not revision: |
|
1388 | return | |
|
1391 | return total | |
|
1389 | 1392 | self._fetch(source, revision) |
|
1390 | 1393 | |
|
1391 | 1394 | # Parse git's native archive command. |
@@ -1406,9 +1409,11 b' class gitsubrepo(abstractsubrepo):' | |||
|
1406 | 1409 | data = tar.extractfile(info).read() |
|
1407 | 1410 | archiver.addfile(os.path.join(prefix, self._path, info.name), |
|
1408 | 1411 | info.mode, info.issym(), data) |
|
1412 | total += 1 | |
|
1409 | 1413 | ui.progress(_('archiving (%s)') % relpath, i + 1, |
|
1410 | 1414 | unit=_('files')) |
|
1411 | 1415 | ui.progress(_('archiving (%s)') % relpath, None) |
|
1416 | return total | |
|
1412 | 1417 | |
|
1413 | 1418 | |
|
1414 | 1419 | @annotatesubrepoerror |
@@ -289,6 +289,16 b' old file -- date clamped to 1980' | |||
|
289 | 289 | *-----* (glob) |
|
290 | 290 | \s*147\s+2 files (re) |
|
291 | 291 | |
|
292 | show an error when a provided pattern matches no files | |
|
293 | ||
|
294 | $ hg archive -I file_that_does_not_exist.foo ../empty.zip | |
|
295 | abort: no files match the archive pattern | |
|
296 | [255] | |
|
297 | ||
|
298 | $ hg archive -X * ../empty.zip | |
|
299 | abort: no files match the archive pattern | |
|
300 | [255] | |
|
301 | ||
|
292 | 302 | $ cd .. |
|
293 | 303 | |
|
294 | 304 | issue3600: check whether "hg archive" can create archive files which |
General Comments 0
You need to be logged in to leave comments.
Login now