Show More
@@ -523,21 +523,52 b' class cmdalias(object):' | |||
|
523 | 523 | ui.debug("alias '%s' expands to '%s'\n" % (self.name, args)) |
|
524 | 524 | raise |
|
525 | 525 | |
|
526 | class lazyaliasentry(object): | |
|
527 | """like a typical command entry (func, opts, help), but is lazy""" | |
|
528 | ||
|
529 | def __init__(self, name, definition, cmdtable, source): | |
|
530 | self.name = name | |
|
531 | self.definition = definition | |
|
532 | self.cmdtable = cmdtable.copy() | |
|
533 | self.source = source | |
|
534 | ||
|
535 | @util.propertycache | |
|
536 | def _aliasdef(self): | |
|
537 | return cmdalias(self.name, self.definition, self.cmdtable, self.source) | |
|
538 | ||
|
539 | def __getitem__(self, n): | |
|
540 | aliasdef = self._aliasdef | |
|
541 | if n == 0: | |
|
542 | return aliasdef | |
|
543 | elif n == 1: | |
|
544 | return aliasdef.opts | |
|
545 | elif n == 2: | |
|
546 | return aliasdef.help | |
|
547 | else: | |
|
548 | raise IndexError | |
|
549 | ||
|
550 | def __iter__(self): | |
|
551 | for i in range(3): | |
|
552 | yield self[i] | |
|
553 | ||
|
554 | def __len__(self): | |
|
555 | return 3 | |
|
556 | ||
|
526 | 557 | def addaliases(ui, cmdtable): |
|
527 | 558 | # aliases are processed after extensions have been loaded, so they |
|
528 | 559 | # may use extension commands. Aliases can also use other alias definitions, |
|
529 | 560 | # but only if they have been defined prior to the current definition. |
|
530 | 561 | for alias, definition in ui.configitems('alias'): |
|
531 | 562 | try: |
|
532 |
if cmdtable[alias |
|
|
563 | if cmdtable[alias].definition == definition: | |
|
533 | 564 | continue |
|
534 | 565 | except (KeyError, AttributeError): |
|
535 | 566 | # definition might not exist or it might not be a cmdalias |
|
536 | 567 | pass |
|
537 | 568 | |
|
538 | 569 | source = ui.configsource('alias', alias) |
|
539 |
|
|
|
540 | cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help) | |
|
570 | entry = lazyaliasentry(alias, definition, cmdtable, source) | |
|
571 | cmdtable[alias] = entry | |
|
541 | 572 | |
|
542 | 573 | def _parse(ui, args): |
|
543 | 574 | options = {} |
General Comments 0
You need to be logged in to leave comments.
Login now