comparison hg @ 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 54a57a5ebcb1
comparison
equal deleted inserted replaced
17:ffe6a5ca1a89 18:2fd3e1e3783f
16 pass 16 pass
17 17
18 import sys, os 18 import sys, os
19 from mercurial import hg, mdiff, fancyopts 19 from mercurial import hg, mdiff, fancyopts
20 20
21 def help():
22 print """\
23 commands:
24
25 init create a new repository in this directory
26 branch <path> create a branch of <path> in this directory
27 merge <path> merge changes from <path> into local repository
28 checkout [changeset] checkout the latest or given changeset
29 status show new, missing, and changed files in working dir
30 add [files...] add the given files in the next commit
31 remove [files...] remove the given files in the next commit
32 addremove add all new files, delete all missing files
33 commit commit all changes to the repository
34 history show changeset history
35 log <file> show revision history of a single file
36 dump <file> [rev] dump the latest or given revision of a file
37 dumpmanifest [rev] dump the latest or given revision of the manifest
38 """
39
40
21 options = {} 41 options = {}
22 opts = [('v', 'verbose', None, 'verbose'), 42 opts = [('v', 'verbose', None, 'verbose'),
23 ('d', 'debug', None, 'debug')] 43 ('d', 'debug', None, 'debug')]
24 44
25 args = fancyopts.fancyopts(sys.argv[1:], opts, options, 45 args = fancyopts.fancyopts(sys.argv[1:], opts, options,
37 repo = hg.repository(ui, ".", create=1) 57 repo = hg.repository(ui, ".", create=1)
38 sys.exit(0) 58 sys.exit(0)
39 elif cmd == "branch" or cmd == "clone": 59 elif cmd == "branch" or cmd == "clone":
40 os.system("cp -al %s/.hg .hg" % args[0]) 60 os.system("cp -al %s/.hg .hg" % args[0])
41 sys.exit(0) 61 sys.exit(0)
62 elif cmd == "help":
63 help()
64 sys.exit(0)
42 else: 65 else:
43 repo = hg.repository(ui=ui) 66 try:
67 repo = hg.repository(ui=ui)
68 except:
69 print "Unable to open repository"
70 sys.exit(0)
44 71
45 if cmd == "checkout" or cmd == "co": 72 if cmd == "checkout" or cmd == "co":
46 node = repo.changelog.tip() 73 node = repo.changelog.tip()
47 if len(args): 74 if len(args):
48 if len(args[0]) < 40: 75 if len(args[0]) < 40:
254 281
255 print "%d files, %d changesets, %d total revisions" % (files, changesets, 282 print "%d files, %d changesets, %d total revisions" % (files, changesets,
256 revisions) 283 revisions)
257 284
258 else: 285 else:
259 if cmd != "help": 286 print "unknown command\n"
260 print "unknown command\n" 287 help()
261
262 print """\
263 commands:
264
265 init create a new repository in this directory
266 branch <path> create a branch of <path> in this directory
267 merge <path> merge changes from <path> into local repository
268 checkout [changeset] checkout the latest or given changeset
269 status show new, missing, and changed files in working dir
270 add [files...] add the given files in the next commit
271 remove [files...] remove the given files in the next commit
272 addremove add all new files, delete all missing files
273 commit commit all changes to the repository
274 history show changeset history
275 log <file> show revision history of a single file
276 dump <file> [rev] dump the latest or given revision of a file
277 dumpmanifest [rev] dump the latest or given revision of the manifest
278 """
279 sys.exit(1) 288 sys.exit(1)