archive: abort on empty repository. Fixes #624.
authorBrendan Cully <brendan@kublai.com>
Tue, 10 Jul 2007 10:06:24 -0700
changeset 4863 6dc0094c0827
parent 4862 cba10652a901
child 4864 fc389dcc33f5
archive: abort on empty repository. Fixes #624.
mercurial/commands.py
tests/test-archive
tests/test-archive.out
--- a/mercurial/commands.py	Tue Jul 10 09:52:32 2007 -0700
+++ b/mercurial/commands.py	Tue Jul 10 10:06:24 2007 -0700
@@ -142,7 +142,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'))
--- a/tests/test-archive	Tue Jul 10 09:52:32 2007 -0700
+++ b/tests/test-archive	Tue Jul 10 10:06:24 2007 -0700
@@ -63,3 +63,9 @@
 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
--- a/tests/test-archive.out	Tue Jul 10 09:52:32 2007 -0700
+++ b/tests/test-archive.out	Tue Jul 10 10:06:24 2007 -0700
@@ -38,3 +38,5 @@
 test-TIP/bar
 test-TIP/baz/bletch
 test-TIP/foo
+% empty repo
+abort: repository has no revisions