Show More
@@ -248,12 +248,28 b' def parseconfig(config):' | |||||
248 | return parsed |
|
248 | return parsed | |
249 |
|
249 | |||
250 | def earlygetopt(aliases, args): |
|
250 | def earlygetopt(aliases, args): | |
251 | if "--" in args: |
|
251 | """Return list of values for a option (with aliases) in given order""" | |
252 | args = args[:args.index("--")] |
|
252 | try: | |
253 | for opt in aliases: |
|
253 | argcount = args.index("--") | |
254 | if opt in args: |
|
254 | except ValueError: | |
255 | return args[args.index(opt) + 1] |
|
255 | argcount = len(args) | |
256 | return None |
|
256 | values = [] | |
|
257 | pos = 0 | |||
|
258 | while pos < argcount: | |||
|
259 | valuepos = argcount | |||
|
260 | for opt in aliases: | |||
|
261 | # find next occurance of current alias | |||
|
262 | try: | |||
|
263 | candidate = args.index(opt, pos, argcount) + 1 | |||
|
264 | # ignore and let getopt report an error if there is no value | |||
|
265 | if candidate < valuepos: | |||
|
266 | valuepos = candidate | |||
|
267 | except ValueError: | |||
|
268 | pass | |||
|
269 | if valuepos < argcount: | |||
|
270 | values.append(args[valuepos]) | |||
|
271 | pos = valuepos | |||
|
272 | return values | |||
257 |
|
273 | |||
258 | def dispatch(ui, args, argv0=None): |
|
274 | def dispatch(ui, args, argv0=None): | |
259 | # remember how to call 'hg' before changing the working dir |
|
275 | # remember how to call 'hg' before changing the working dir | |
@@ -262,7 +278,7 b' def dispatch(ui, args, argv0=None):' | |||||
262 | # check for cwd first |
|
278 | # check for cwd first | |
263 | cwd = earlygetopt(['--cwd'], args) |
|
279 | cwd = earlygetopt(['--cwd'], args) | |
264 | if cwd: |
|
280 | if cwd: | |
265 | os.chdir(cwd) |
|
281 | os.chdir(cwd[-1]) | |
266 |
|
282 | |||
267 | # read the local repository .hgrc into a local ui object |
|
283 | # read the local repository .hgrc into a local ui object | |
268 | path = findrepo() or "" |
|
284 | path = findrepo() or "" | |
@@ -278,7 +294,7 b' def dispatch(ui, args, argv0=None):' | |||||
278 | # now we can expand paths, even ones in .hg/hgrc |
|
294 | # now we can expand paths, even ones in .hg/hgrc | |
279 | rpath = earlygetopt(["-R", "--repository", "--repo"], args) |
|
295 | rpath = earlygetopt(["-R", "--repository", "--repo"], args) | |
280 | if rpath: |
|
296 | if rpath: | |
281 | path = lui.expandpath(rpath) |
|
297 | path = lui.expandpath(rpath[-1]) | |
282 | lui = commands.ui.ui(parentui=ui) |
|
298 | lui = commands.ui.ui(parentui=ui) | |
283 | lui.readconfig(os.path.join(path, ".hg", "hgrc")) |
|
299 | lui.readconfig(os.path.join(path, ".hg", "hgrc")) | |
284 |
|
300 |
General Comments 0
You need to be logged in to leave comments.
Login now