[PATCH 1 of 2] archive: raise error.Abort if the file pattern matches no files
Angel Ezquerra
angel.ezquerra at gmail.com
Thu Mar 21 17:44:16 CDT 2013
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1363900155 -3600
# Thu Mar 21 22:09:15 2013 +0100
# Node ID e068221f22216fbddf7f6d54c1d27bf264defe87
# Parent d844e3879f9b1ecac0114ae688093781d5cc3202
archive: raise error.Abort if the file pattern matches no files
diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -13,6 +13,7 @@
import cStringIO, os, tarfile, time, zipfile
import zlib, gzip
import struct
+import error
# from unzip source code:
_UNX_IFREG = 0x8000
@@ -286,8 +287,11 @@
if matchfn:
files = [f for f in ctx.manifest().keys() if matchfn(f)]
+ if not files:
+ raise error.Abort(_('no files match the archive pattern'))
else:
files = ctx.manifest().keys()
+
files.sort()
total = len(files)
repo.ui.progress(_('archiving'), 0, unit=_('files'), total=total)
diff --git a/tests/test-archive.t b/tests/test-archive.t
--- a/tests/test-archive.t
+++ b/tests/test-archive.t
@@ -289,6 +289,16 @@
*-----* (glob)
\s*147\s+2 files (re)
+show an error when a provided pattern matches no files
+
+ $ hg archive -I file_that_does_not_exist.foo ../empty.zip
+ abort: no files match the archive pattern
+ [255]
+
+ $ hg archive -X * ../empty.zip
+ abort: no files match the archive pattern
+ [255]
+
$ cd ..
issue3600: check whether "hg archive" can create archive files which
More information about the Mercurial-devel
mailing list