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