equal
deleted
inserted
replaced
227 if len(inst.args) > 1: |
227 if len(inst.args) > 1: |
228 return _('at %s: %s') % (inst.args[1], inst.args[0]) |
228 return _('at %s: %s') % (inst.args[1], inst.args[0]) |
229 else: |
229 else: |
230 return inst.args[0] |
230 return inst.args[0] |
231 |
231 |
|
232 class alias(object): |
|
233 """Parsed result of alias""" |
|
234 |
|
235 def __init__(self, name, tree, args, err, replacement): |
|
236 self.name = name |
|
237 self.tree = tree |
|
238 self.args = args |
|
239 self.error = err |
|
240 self.replacement = replacement |
|
241 # whether own `error` information is already shown or not. |
|
242 # this avoids showing same warning multiple times at each `findaliases`. |
|
243 self.warned = False |
|
244 |
232 class basealiasrules(object): |
245 class basealiasrules(object): |
233 """Parsing and expansion rule set of aliases |
246 """Parsing and expansion rule set of aliases |
234 |
247 |
235 This is a helper for fileset/revset/template aliases. A concrete rule set |
248 This is a helper for fileset/revset/template aliases. A concrete rule set |
236 should be made by sub-classing this and implementing class/static methods. |
249 should be made by sub-classing this and implementing class/static methods. |
428 if args: |
441 if args: |
429 args = set(args) |
442 args = set(args) |
430 else: |
443 else: |
431 args = set() |
444 args = set() |
432 return cls._relabelargs(tree, args) |
445 return cls._relabelargs(tree, args) |
|
446 |
|
447 @classmethod |
|
448 def build(cls, decl, defn): |
|
449 """Parse an alias declaration and definition into an alias object""" |
|
450 repl = efmt = None |
|
451 name, tree, args, err = cls._builddecl(decl) |
|
452 if err: |
|
453 efmt = _('failed to parse the declaration of %(section)s ' |
|
454 '"%(name)s": %(error)s') |
|
455 else: |
|
456 try: |
|
457 repl = cls._builddefn(defn, args) |
|
458 except error.ParseError as inst: |
|
459 err = parseerrordetail(inst) |
|
460 efmt = _('failed to parse the definition of %(section)s ' |
|
461 '"%(name)s": %(error)s') |
|
462 if err: |
|
463 err = efmt % {'section': cls._section, 'name': name, 'error': err} |
|
464 return alias(name, tree, args, err, repl) |