# HG changeset patch # User Brendan Cully # Date 1184087184 25200 # Node ID 6dc0094c0827641189eb46e9447255c925a392f1 # Parent cba10652a9018b10d68925a5b7a986cfc7c9f928 archive: abort on empty repository. Fixes #624. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -142,7 +142,10 @@ def archive(ui, repo, dest, **opts): 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 --git a/tests/test-archive b/tests/test-archive --- a/tests/test-archive +++ b/tests/test-archive @@ -63,3 +63,9 @@ hg archive -t zip -r 2 test.zip unzip -t test.zip hg archive -t tar - | tar tf - | sed "s/$QTIP/TIP/" + +echo '% empty repo' +hg init ../empty +cd ../empty +hg archive ../test-empty +exit 0 \ No newline at end of file diff --git a/tests/test-archive.out b/tests/test-archive.out --- a/tests/test-archive.out +++ b/tests/test-archive.out @@ -38,3 +38,5 @@ test-TIP/.hg_archival.txt test-TIP/bar test-TIP/baz/bletch test-TIP/foo +% empty repo +abort: repository has no revisions