Mercurial > hg
comparison mercurial/dispatch.py @ 21569:c5afb07c33d3 stable
alias: handle shlex error in command aliases
No command should fail with ValueError just because there is unparseable
alias definition.
It returns 1 like other badalias handlers, but should be changed to 255 in
a later version because we use 255 for general command error.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 17 May 2014 13:06:16 +0900 |
parents | 5e13507a3b4e |
children | 6c9b7712ac69 |
comparison
equal
deleted
inserted
replaced
21568:8dd17b19e722 | 21569:c5afb07c33d3 |
---|---|
381 cmd = util.interpolate(r'\$', replace, cmd, escape_prefix=True) | 381 cmd = util.interpolate(r'\$', replace, cmd, escape_prefix=True) |
382 return util.system(cmd, environ=env, out=ui.fout) | 382 return util.system(cmd, environ=env, out=ui.fout) |
383 self.fn = fn | 383 self.fn = fn |
384 return | 384 return |
385 | 385 |
386 args = shlex.split(self.definition) | 386 try: |
387 args = shlex.split(self.definition) | |
388 except ValueError, inst: | |
389 def fn(ui, *args): | |
390 ui.warn(_("error in definition for alias '%s': %s\n") | |
391 % (self.name, inst)) | |
392 return 1 | |
393 self.fn = fn | |
394 self.badalias = True | |
395 return | |
387 self.cmdname = cmd = args.pop(0) | 396 self.cmdname = cmd = args.pop(0) |
388 args = map(util.expandpath, args) | 397 args = map(util.expandpath, args) |
389 | 398 |
390 for invalidarg in ("--cwd", "-R", "--repository", "--repo", "--config"): | 399 for invalidarg in ("--cwd", "-R", "--repository", "--repo", "--config"): |
391 if _earlygetopt([invalidarg], args): | 400 if _earlygetopt([invalidarg], args): |