changeset 18:2fd3e1e3783f

Give a friendlier message when repo isn't found
author mpm@selenic.com
date Wed, 04 May 2005 11:01:17 -0800
parents ffe6a5ca1a89
children 12360c04fa48
files hg
diffstat 1 files changed, 30 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/hg	Wed May 04 10:50:21 2005 -0800
+++ b/hg	Wed May 04 11:01:17 2005 -0800
@@ -18,6 +18,26 @@
 import sys, os
 from mercurial import hg, mdiff, fancyopts
 
+def help():
+        print """\
+ commands:
+
+ init                  create a new repository in this directory
+ branch <path>         create a branch of <path> in this directory
+ merge <path>          merge changes from <path> into local repository
+ checkout [changeset]  checkout the latest or given changeset
+ status                show new, missing, and changed files in working dir
+ add [files...]        add the given files in the next commit
+ remove [files...]     remove the given files in the next commit
+ addremove             add all new files, delete all missing files
+ commit                commit all changes to the repository
+ history               show changeset history
+ log <file>            show revision history of a single file
+ dump <file> [rev]     dump the latest or given revision of a file
+ dumpmanifest [rev]    dump the latest or given revision of the manifest
+"""
+
+
 options = {}
 opts = [('v', 'verbose', None, 'verbose'),
         ('d', 'debug', None, 'debug')]
@@ -39,8 +59,15 @@
 elif cmd == "branch" or cmd == "clone":
     os.system("cp -al %s/.hg .hg" % args[0])
     sys.exit(0)
+elif cmd == "help":
+    help()
+    sys.exit(0)
 else:
-    repo = hg.repository(ui=ui)
+    try:
+        repo = hg.repository(ui=ui)
+    except:
+        print "Unable to open repository"
+        sys.exit(0)
 
 if cmd == "checkout" or cmd == "co":
     node = repo.changelog.tip()
@@ -256,24 +283,6 @@
                                                            revisions)
     
 else:
-    if cmd != "help":
-        print "unknown command\n"
-
-    print """\
- commands:
-
- init                  create a new repository in this directory
- branch <path>         create a branch of <path> in this directory
- merge <path>          merge changes from <path> into local repository
- checkout [changeset]  checkout the latest or given changeset
- status                show new, missing, and changed files in working dir
- add [files...]        add the given files in the next commit
- remove [files...]     remove the given files in the next commit
- addremove             add all new files, delete all missing files
- commit                commit all changes to the repository
- history               show changeset history
- log <file>            show revision history of a single file
- dump <file> [rev]     dump the latest or given revision of a file
- dumpmanifest [rev]    dump the latest or given revision of the manifest
-"""
+    print "unknown command\n"
+    help()
     sys.exit(1)