comparison mercurial/cmdutil.py @ 4554:9dbabb9d466c

dispatch: use the repo path found by early parsing This lets us simplify things a bit.
author Matt Mackall <mpm@selenic.com>
date Mon, 11 Jun 2007 21:09:24 -0500
parents 741f64dfc04d
children 1843d31bfdbf
comparison
equal deleted inserted replaced
4553:741f64dfc04d 4554:9dbabb9d466c
254 254
255 extensions.loadall(ui) 255 extensions.loadall(ui)
256 ui.addreadhook(extensions.loadall) 256 ui.addreadhook(extensions.loadall)
257 257
258 # read the local extension info into a local ui object 258 # read the local extension info into a local ui object
259 rcpath = earlygetopt(["-R", "--repository"], args) or localrepo.findrepo() 259 path = earlygetopt(["-R", "--repository"], args) or localrepo.findrepo() or ""
260 if rcpath: 260 if path:
261 try: 261 try:
262 lui = commands.ui.ui(parentui=ui) 262 lui = commands.ui.ui(parentui=ui)
263 lui.readconfig(os.path.join(rcpath, ".hg", "hgrc")) 263 lui.readconfig(os.path.join(path, ".hg", "hgrc"))
264 except IOError: 264 except IOError:
265 pass 265 pass
266 266
267 cmd, func, args, options, cmdoptions = parse(ui, args) 267 cmd, func, args, options, cmdoptions = parse(ui, args)
268 268
285 285
286 ui.updateopts(options["verbose"], options["debug"], options["quiet"], 286 ui.updateopts(options["verbose"], options["debug"], options["quiet"],
287 not options["noninteractive"], options["traceback"], 287 not options["noninteractive"], options["traceback"],
288 parseconfig(options["config"])) 288 parseconfig(options["config"]))
289 289
290 path = ui.expandpath(options["repository"]) or ""
291 repo = path and hg.repository(ui, path=path) or None
292 if repo and not repo.local():
293 raise util.Abort(_("repository '%s' is not local") % path)
294
295 if options['help']: 290 if options['help']:
296 return commands.help_(ui, cmd, options['version']) 291 return commands.help_(ui, cmd, options['version'])
297 elif options['version']: 292 elif options['version']:
298 return commands.version_(ui) 293 return commands.version_(ui)
299 elif not cmd: 294 elif not cmd:
300 return commands.help_(ui, 'shortlist') 295 return commands.help_(ui, 'shortlist')
301 296
302 if cmd not in commands.norepo.split(): 297 if cmd not in commands.norepo.split():
298 repo = None
303 try: 299 try:
304 if not repo: 300 repo = hg.repository(ui, path=path)
305 repo = hg.repository(ui, path=path) 301 #ui = repo.ui
306 ui = repo.ui 302 if not repo.local():
303 raise util.Abort(_("repository '%s' is not local") % path)
307 except hg.RepoError: 304 except hg.RepoError:
308 if cmd not in commands.optionalrepo.split(): 305 if cmd not in commands.optionalrepo.split():
309 raise 306 raise
310 d = lambda: func(ui, repo, *args, **cmdoptions) 307 d = lambda: func(ui, repo, *args, **cmdoptions)
311 else: 308 else: