Mercurial > hg
comparison mercurial/dispatch.py @ 21572:6c9b7712ac69 stable
alias: change return code of bad definition to 255
We use 255 for general command error.
It can't raise util.Abort because help module executes badalias command to get
error message.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 17 May 2014 15:14:18 +0900 |
parents | c5afb07c33d3 |
children | 57c70d3ad1c9 |
comparison
equal
deleted
inserted
replaced
21571:17da326fd041 | 21572:6c9b7712ac69 |
---|---|
353 self.shadows = False | 353 self.shadows = False |
354 | 354 |
355 if not self.definition: | 355 if not self.definition: |
356 def fn(ui, *args): | 356 def fn(ui, *args): |
357 ui.warn(_("no definition for alias '%s'\n") % self.name) | 357 ui.warn(_("no definition for alias '%s'\n") % self.name) |
358 return 1 | 358 return -1 |
359 self.fn = fn | 359 self.fn = fn |
360 self.badalias = True | 360 self.badalias = True |
361 return | 361 return |
362 | 362 |
363 if self.definition.startswith('!'): | 363 if self.definition.startswith('!'): |
387 args = shlex.split(self.definition) | 387 args = shlex.split(self.definition) |
388 except ValueError, inst: | 388 except ValueError, inst: |
389 def fn(ui, *args): | 389 def fn(ui, *args): |
390 ui.warn(_("error in definition for alias '%s': %s\n") | 390 ui.warn(_("error in definition for alias '%s': %s\n") |
391 % (self.name, inst)) | 391 % (self.name, inst)) |
392 return 1 | 392 return -1 |
393 self.fn = fn | 393 self.fn = fn |
394 self.badalias = True | 394 self.badalias = True |
395 return | 395 return |
396 self.cmdname = cmd = args.pop(0) | 396 self.cmdname = cmd = args.pop(0) |
397 args = map(util.expandpath, args) | 397 args = map(util.expandpath, args) |
400 if _earlygetopt([invalidarg], args): | 400 if _earlygetopt([invalidarg], args): |
401 def fn(ui, *args): | 401 def fn(ui, *args): |
402 ui.warn(_("error in definition for alias '%s': %s may only " | 402 ui.warn(_("error in definition for alias '%s': %s may only " |
403 "be given on the command line\n") | 403 "be given on the command line\n") |
404 % (self.name, invalidarg)) | 404 % (self.name, invalidarg)) |
405 return 1 | 405 return -1 |
406 | 406 |
407 self.fn = fn | 407 self.fn = fn |
408 self.badalias = True | 408 self.badalias = True |
409 return | 409 return |
410 | 410 |
432 try: | 432 try: |
433 # check if the command is in a disabled extension | 433 # check if the command is in a disabled extension |
434 commands.help_(ui, cmd, unknowncmd=True) | 434 commands.help_(ui, cmd, unknowncmd=True) |
435 except error.UnknownCommand: | 435 except error.UnknownCommand: |
436 pass | 436 pass |
437 return 1 | 437 return -1 |
438 self.fn = fn | 438 self.fn = fn |
439 self.badalias = True | 439 self.badalias = True |
440 except error.AmbiguousCommand: | 440 except error.AmbiguousCommand: |
441 def fn(ui, *args): | 441 def fn(ui, *args): |
442 ui.warn(_("alias '%s' resolves to ambiguous command '%s'\n") \ | 442 ui.warn(_("alias '%s' resolves to ambiguous command '%s'\n") \ |
443 % (self.name, cmd)) | 443 % (self.name, cmd)) |
444 return 1 | 444 return -1 |
445 self.fn = fn | 445 self.fn = fn |
446 self.badalias = True | 446 self.badalias = True |
447 | 447 |
448 def __call__(self, ui, *args, **opts): | 448 def __call__(self, ui, *args, **opts): |
449 if self.shadows: | 449 if self.shadows: |