# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 2009-01-19 22:19:09
# Node ID 523c7816c33a57a196ffd2d2d948e94b37e2ebca
# Parent  06cf09c822c47244be2549c616a1d0b04724d642

Give a useful message about PYTHONPATH if startup fails

diff --git a/hg b/hg
--- a/hg
+++ b/hg
@@ -8,7 +8,14 @@
 # of the GNU General Public License, incorporated herein by reference.
 
 # enable importing on demand to reduce startup time
-from mercurial import demandimport; demandimport.enable()
+try:
+    from mercurial import demandimport; demandimport.enable()
+except ImportError:
+    import sys
+    sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
+                     ' '.join(sys.path))
+    sys.stderr.write("(check your install and PYTHONPATH)\n")
+    sys.exit(-1)
 
 import sys
 import mercurial.util