Mercurial > hg
comparison mercurial/cmdutil.py @ 4556:30bc57094bfc
dispatch: move findrepo to cmdutil
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 11 Jun 2007 21:09:24 -0500 |
parents | 1843d31bfdbf |
children | 050fa240db9c |
comparison
equal
deleted
inserted
replaced
4555:1843d31bfdbf | 4556:30bc57094bfc |
---|---|
7 | 7 |
8 from node import * | 8 from node import * |
9 from i18n import _ | 9 from i18n import _ |
10 import os, sys, mdiff, bdiff, util, templater, patch, commands | 10 import os, sys, mdiff, bdiff, util, templater, patch, commands |
11 import atexit, signal, pdb, hg, lock, fancyopts, traceback | 11 import atexit, signal, pdb, hg, lock, fancyopts, traceback |
12 import socket, revlog, version, extensions, errno, localrepo | 12 import socket, revlog, version, extensions, errno |
13 | 13 |
14 revrangesep = ':' | 14 revrangesep = ':' |
15 | 15 |
16 class UnknownCommand(Exception): | 16 class UnknownCommand(Exception): |
17 """Exception raised if command is not in the command table.""" | 17 """Exception raised if command is not in the command table.""" |
184 if choice: | 184 if choice: |
185 return choice.values()[0] | 185 return choice.values()[0] |
186 | 186 |
187 raise UnknownCommand(cmd) | 187 raise UnknownCommand(cmd) |
188 | 188 |
189 def findrepo(): | |
190 p = os.getcwd() | |
191 while not os.path.isdir(os.path.join(p, ".hg")): | |
192 oldp, p = p, os.path.dirname(p) | |
193 if p == oldp: | |
194 return None | |
195 | |
196 return p | |
197 | |
189 def parse(ui, args): | 198 def parse(ui, args): |
190 options = {} | 199 options = {} |
191 cmdoptions = {} | 200 cmdoptions = {} |
192 | 201 |
193 try: | 202 try: |
257 | 266 |
258 # read the local repository .hgrc into a local ui object | 267 # read the local repository .hgrc into a local ui object |
259 # this will trigger its extensions to load | 268 # this will trigger its extensions to load |
260 path = earlygetopt(["-R", "--repository"], args) | 269 path = earlygetopt(["-R", "--repository"], args) |
261 if not path: | 270 if not path: |
262 path = localrepo.findrepo() or "" | 271 path = findrepo() or "" |
263 if path: | 272 if path: |
264 try: | 273 try: |
265 lui = commands.ui.ui(parentui=ui) | 274 lui = commands.ui.ui(parentui=ui) |
266 lui.readconfig(os.path.join(path, ".hg", "hgrc")) | 275 lui.readconfig(os.path.join(path, ".hg", "hgrc")) |
267 except IOError: | 276 except IOError: |