Mercurial > hg
comparison mercurial/dispatch.py @ 6217:fe8dbbe9520d
Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
author | Joel Rosdahl <joel@rosdahl.net> |
---|---|
date | Thu, 06 Mar 2008 22:51:16 +0100 |
parents | f89fd07fc51d |
children | 5cf3bf3c19ba b9d012ce8578 |
comparison
equal
deleted
inserted
replaced
6216:a88259018f79 | 6217:fe8dbbe9520d |
---|---|
4 # | 4 # |
5 # This software may be used and distributed according to the terms | 5 # This software may be used and distributed according to the terms |
6 # of the GNU General Public License, incorporated herein by reference. | 6 # of the GNU General Public License, incorporated herein by reference. |
7 | 7 |
8 from i18n import _ | 8 from i18n import _ |
9 from repo import RepoError | |
9 import os, sys, atexit, signal, pdb, traceback, socket, errno, shlex, time | 10 import os, sys, atexit, signal, pdb, traceback, socket, errno, shlex, time |
10 import util, commands, hg, lock, fancyopts, revlog, version, extensions, hook | 11 import util, commands, hg, lock, fancyopts, revlog, version, extensions, hook |
11 import cmdutil | 12 import cmdutil |
12 import ui as _ui | 13 import ui as _ui |
13 | 14 |
62 ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") % | 63 ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") % |
63 (inst.args[0], " ".join(inst.args[1]))) | 64 (inst.args[0], " ".join(inst.args[1]))) |
64 except cmdutil.UnknownCommand, inst: | 65 except cmdutil.UnknownCommand, inst: |
65 ui.warn(_("hg: unknown command '%s'\n") % inst.args[0]) | 66 ui.warn(_("hg: unknown command '%s'\n") % inst.args[0]) |
66 commands.help_(ui, 'shortlist') | 67 commands.help_(ui, 'shortlist') |
67 except hg.RepoError, inst: | 68 except RepoError, inst: |
68 ui.warn(_("abort: %s!\n") % inst) | 69 ui.warn(_("abort: %s!\n") % inst) |
69 except lock.LockHeld, inst: | 70 except lock.LockHeld, inst: |
70 if inst.errno == errno.ETIMEDOUT: | 71 if inst.errno == errno.ETIMEDOUT: |
71 reason = _('timed out waiting for lock held by %s') % inst.locker | 72 reason = _('timed out waiting for lock held by %s') % inst.locker |
72 else: | 73 else: |
339 repo = hg.repository(ui, path=path) | 340 repo = hg.repository(ui, path=path) |
340 ui = repo.ui | 341 ui = repo.ui |
341 if not repo.local(): | 342 if not repo.local(): |
342 raise util.Abort(_("repository '%s' is not local") % path) | 343 raise util.Abort(_("repository '%s' is not local") % path) |
343 ui.setconfig("bundle", "mainreporoot", repo.root) | 344 ui.setconfig("bundle", "mainreporoot", repo.root) |
344 except hg.RepoError: | 345 except RepoError: |
345 if cmd not in commands.optionalrepo.split(): | 346 if cmd not in commands.optionalrepo.split(): |
346 if args and not path: # try to infer -R from command args | 347 if args and not path: # try to infer -R from command args |
347 repos = map(_findrepo, args) | 348 repos = map(_findrepo, args) |
348 guess = repos[0] | 349 guess = repos[0] |
349 if guess and repos.count(guess) == len(repos): | 350 if guess and repos.count(guess) == len(repos): |
350 return _dispatch(ui, ['--repository', guess] + fullargs) | 351 return _dispatch(ui, ['--repository', guess] + fullargs) |
351 if not path: | 352 if not path: |
352 raise hg.RepoError(_("There is no Mercurial repository here" | 353 raise RepoError(_("There is no Mercurial repository here" |
353 " (.hg not found)")) | 354 " (.hg not found)")) |
354 raise | 355 raise |
355 d = lambda: func(ui, repo, *args, **cmdoptions) | 356 d = lambda: func(ui, repo, *args, **cmdoptions) |
356 else: | 357 else: |
357 d = lambda: func(ui, *args, **cmdoptions) | 358 d = lambda: func(ui, *args, **cmdoptions) |
358 | 359 |