# HG changeset patch # User Brendan Cully # Date 1184087184 25200 # Node ID a49f2a4d5ff73dfde8e4d18a0f59f7f63c801504 # Parent 8d9bdcbb2b1852d2507cbb7e5d922f549f73f19d archive: abort on empty repository. Fixes #624. diff -r 8d9bdcbb2b18 -r a49f2a4d5ff7 mercurial/commands.py --- a/mercurial/commands.py Thu Aug 02 12:29:10 2007 -0500 +++ b/mercurial/commands.py Tue Jul 10 10:06:24 2007 -0700 @@ -133,7 +133,10 @@ The default is the basename of the archive, with suffixes removed. ''' - node = repo.changectx(opts['rev']).node() + ctx = repo.changectx(opts['rev']) + if not ctx: + raise util.Abort(_('repository has no revisions')) + node = ctx.node() dest = cmdutil.make_filename(repo, dest, node) if os.path.realpath(dest) == repo.root: raise util.Abort(_('repository root cannot be destination')) diff -r 8d9bdcbb2b18 -r a49f2a4d5ff7 tests/test-archive --- a/tests/test-archive Thu Aug 02 12:29:10 2007 -0500 +++ b/tests/test-archive Tue Jul 10 10:06:24 2007 -0700 @@ -67,3 +67,9 @@ if [ -f rev-0.tar ]; then echo 'rev-0.tar created' fi + +echo '% empty repo' +hg init ../empty +cd ../empty +hg archive ../test-empty +exit 0 diff -r 8d9bdcbb2b18 -r a49f2a4d5ff7 tests/test-archive.out --- a/tests/test-archive.out Thu Aug 02 12:29:10 2007 -0500 +++ b/tests/test-archive.out Tue Jul 10 10:06:24 2007 -0700 @@ -39,3 +39,5 @@ test-TIP/baz/bletch test-TIP/foo rev-0.tar created +% empty repo +abort: repository has no revisions