Mercurial > hg > mercurial-crew
comparison mercurial/archival.py @ 18967:88d1b59f6906
archive: raise error.Abort if the file pattern matches no files
Note that we could raise this exception even if no pattern were specified, but
the revision contained no files. However this should not happen in practice
since in that case commands.py/archive would exit earlier with an "no working
directory: please specify a revision" error message instead.
author | Angel Ezquerra <angel.ezquerra@gmail.com> |
---|---|
date | Thu, 21 Mar 2013 22:09:15 +0100 |
parents | 6252b4f1c4b4 |
children | a2f139d25845 |
comparison
equal
deleted
inserted
replaced
18966:5572f688e0a9 | 18967:88d1b59f6906 |
---|---|
11 import cmdutil | 11 import cmdutil |
12 import scmutil, util, encoding | 12 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 |
19 _UNX_IFLNK = 0xa000 | 20 _UNX_IFLNK = 0xa000 |
20 | 21 |
286 | 287 |
287 if matchfn: | 288 if matchfn: |
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'), None) | 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 |