Show More
@@ -357,12 +357,13 b' class cmdalias(object):' | |||
|
357 | 357 | self.name = self.cmd = name |
|
358 | 358 | self.cmdname = '' |
|
359 | 359 | self.definition = definition |
|
360 | self.fn = None | |
|
360 | 361 | self.args = [] |
|
361 | 362 | self.opts = [] |
|
362 | 363 | self.help = '' |
|
363 | 364 | self.norepo = True |
|
364 | 365 | self.optionalrepo = False |
|
365 |
self.badalias = |
|
|
366 | self.badalias = None | |
|
366 | 367 | |
|
367 | 368 | try: |
|
368 | 369 | aliases, entry = cmdutil.findcmd(self.name, cmdtable) |
@@ -375,11 +376,7 b' class cmdalias(object):' | |||
|
375 | 376 | self.shadows = False |
|
376 | 377 | |
|
377 | 378 | if not self.definition: |
|
378 | def fn(ui, *args): | |
|
379 | ui.warn(_("no definition for alias '%s'\n") % self.name) | |
|
380 | return -1 | |
|
381 | self.fn = fn | |
|
382 | self.badalias = True | |
|
379 | self.badalias = _("no definition for alias '%s'") % self.name | |
|
383 | 380 | return |
|
384 | 381 | |
|
385 | 382 | if self.definition.startswith('!'): |
@@ -405,26 +402,17 b' class cmdalias(object):' | |||
|
405 | 402 | try: |
|
406 | 403 | args = shlex.split(self.definition) |
|
407 | 404 | except ValueError, inst: |
|
408 | def fn(ui, *args): | |
|
409 | ui.warn(_("error in definition for alias '%s': %s\n") | |
|
405 | self.badalias = (_("error in definition for alias '%s': %s") | |
|
410 | 406 | % (self.name, inst)) |
|
411 | return -1 | |
|
412 | self.fn = fn | |
|
413 | self.badalias = True | |
|
414 | 407 | return |
|
415 | 408 | self.cmdname = cmd = args.pop(0) |
|
416 | 409 | args = map(util.expandpath, args) |
|
417 | 410 | |
|
418 | 411 | for invalidarg in ("--cwd", "-R", "--repository", "--repo", "--config"): |
|
419 | 412 | if _earlygetopt([invalidarg], args): |
|
420 | def fn(ui, *args): | |
|
421 | ui.warn(_("error in definition for alias '%s': %s may only " | |
|
422 | "be given on the command line\n") | |
|
413 | self.badalias = (_("error in definition for alias '%s': %s may " | |
|
414 | "only be given on the command line") | |
|
423 | 415 | % (self.name, invalidarg)) |
|
424 | return -1 | |
|
425 | ||
|
426 | self.fn = fn | |
|
427 | self.badalias = True | |
|
428 | 416 | return |
|
429 | 417 | |
|
430 | 418 | try: |
@@ -446,8 +434,6 b' class cmdalias(object):' | |||
|
446 | 434 | |
|
447 | 435 | except error.UnknownCommand: |
|
448 | 436 | def fn(ui, *args): |
|
449 | ui.warn(_("alias '%s' resolves to unknown command '%s'\n") \ | |
|
450 | % (self.name, cmd)) | |
|
451 | 437 | try: |
|
452 | 438 | # check if the command is in a disabled extension |
|
453 | 439 | commands.help_(ui, cmd, unknowncmd=True) |
@@ -455,16 +441,18 b' class cmdalias(object):' | |||
|
455 | 441 | pass |
|
456 | 442 | return -1 |
|
457 | 443 | self.fn = fn |
|
458 | self.badalias = True | |
|
444 | self.badalias = (_("alias '%s' resolves to unknown command '%s'") | |
|
445 | % (self.name, cmd)) | |
|
459 | 446 | except error.AmbiguousCommand: |
|
460 | def fn(ui, *args): | |
|
461 | ui.warn(_("alias '%s' resolves to ambiguous command '%s'\n") \ | |
|
447 | self.badalias = (_("alias '%s' resolves to ambiguous command '%s'") | |
|
462 | 448 | % (self.name, cmd)) |
|
463 | return -1 | |
|
464 | self.fn = fn | |
|
465 | self.badalias = True | |
|
466 | 449 | |
|
467 | 450 | def __call__(self, ui, *args, **opts): |
|
451 | if self.badalias: | |
|
452 | ui.warn(self.badalias + '\n') | |
|
453 | if self.fn: | |
|
454 | return self.fn(ui, *args, **opts) | |
|
455 | return -1 | |
|
468 | 456 | if self.shadows: |
|
469 | 457 | ui.debug("alias '%s' shadows command '%s'\n" % |
|
470 | 458 | (self.name, self.cmdname)) |
@@ -235,7 +235,7 b' def help_(ui, name, unknowncmd=False, fu' | |||
|
235 | 235 | rst = [] |
|
236 | 236 | |
|
237 | 237 | # check if it's an invalid alias and display its error if it is |
|
238 |
if getattr(entry[0], 'badalias', |
|
|
238 | if getattr(entry[0], 'badalias', None): | |
|
239 | 239 | if not unknowncmd: |
|
240 | 240 | ui.pushbuffer() |
|
241 | 241 | entry[0](ui) |
General Comments 0
You need to be logged in to leave comments.
Login now