equal
deleted
inserted
replaced
83 |
83 |
84 data.update((k, evalfuncarg(context, mapping, v)) |
84 data.update((k, evalfuncarg(context, mapping, v)) |
85 for k, v in args['kwargs'].iteritems()) |
85 for k, v in args['kwargs'].iteritems()) |
86 return templateutil.hybriddict(data) |
86 return templateutil.hybriddict(data) |
87 |
87 |
88 @templatefunc('diff([includepattern [, excludepattern]])') |
88 @templatefunc('diff([includepattern [, excludepattern]])', requires={'ctx'}) |
89 def diff(context, mapping, args): |
89 def diff(context, mapping, args): |
90 """Show a diff, optionally |
90 """Show a diff, optionally |
91 specifying files to include or exclude.""" |
91 specifying files to include or exclude.""" |
92 if len(args) > 2: |
92 if len(args) > 2: |
93 # i18n: "diff" is a keyword |
93 # i18n: "diff" is a keyword |
103 ctx = context.resource(mapping, 'ctx') |
103 ctx = context.resource(mapping, 'ctx') |
104 chunks = ctx.diff(match=ctx.match([], getpatterns(0), getpatterns(1))) |
104 chunks = ctx.diff(match=ctx.match([], getpatterns(0), getpatterns(1))) |
105 |
105 |
106 return ''.join(chunks) |
106 return ''.join(chunks) |
107 |
107 |
108 @templatefunc('extdata(source)', argspec='source') |
108 @templatefunc('extdata(source)', argspec='source', requires={'ctx', 'cache'}) |
109 def extdata(context, mapping, args): |
109 def extdata(context, mapping, args): |
110 """Show a text read from the specified extdata source. (EXPERIMENTAL)""" |
110 """Show a text read from the specified extdata source. (EXPERIMENTAL)""" |
111 if 'source' not in args: |
111 if 'source' not in args: |
112 # i18n: "extdata" is a keyword |
112 # i18n: "extdata" is a keyword |
113 raise error.ParseError(_('extdata expects one argument')) |
113 raise error.ParseError(_('extdata expects one argument')) |
126 data = cache[source] |
126 data = cache[source] |
127 else: |
127 else: |
128 data = cache[source] = scmutil.extdatasource(ctx.repo(), source) |
128 data = cache[source] = scmutil.extdatasource(ctx.repo(), source) |
129 return data.get(ctx.rev(), '') |
129 return data.get(ctx.rev(), '') |
130 |
130 |
131 @templatefunc('files(pattern)') |
131 @templatefunc('files(pattern)', requires={'ctx'}) |
132 def files(context, mapping, args): |
132 def files(context, mapping, args): |
133 """All files of the current changeset matching the pattern. See |
133 """All files of the current changeset matching the pattern. See |
134 :hg:`help patterns`.""" |
134 :hg:`help patterns`.""" |
135 if not len(args) == 1: |
135 if not len(args) == 1: |
136 # i18n: "files" is a keyword |
136 # i18n: "files" is a keyword |
164 except IndexError: |
164 except IndexError: |
165 pass |
165 pass |
166 |
166 |
167 return templatefilters.fill(text, width, initindent, hangindent) |
167 return templatefilters.fill(text, width, initindent, hangindent) |
168 |
168 |
169 @templatefunc('formatnode(node)') |
169 @templatefunc('formatnode(node)', requires={'ui'}) |
170 def formatnode(context, mapping, args): |
170 def formatnode(context, mapping, args): |
171 """Obtain the preferred form of a changeset hash. (DEPRECATED)""" |
171 """Obtain the preferred form of a changeset hash. (DEPRECATED)""" |
172 if len(args) != 1: |
172 if len(args) != 1: |
173 # i18n: "formatnode" is a keyword |
173 # i18n: "formatnode" is a keyword |
174 raise error.ParseError(_("formatnode expects one argument")) |
174 raise error.ParseError(_("formatnode expects one argument")) |
177 node = evalstring(context, mapping, args[0]) |
177 node = evalstring(context, mapping, args[0]) |
178 if ui.debugflag: |
178 if ui.debugflag: |
179 return node |
179 return node |
180 return templatefilters.short(node) |
180 return templatefilters.short(node) |
181 |
181 |
182 @templatefunc('mailmap(author)') |
182 @templatefunc('mailmap(author)', requires={'repo', 'cache'}) |
183 def mailmap(context, mapping, args): |
183 def mailmap(context, mapping, args): |
184 """Return the author, updated according to the value |
184 """Return the author, updated according to the value |
185 set in the .mailmap file""" |
185 set in the .mailmap file""" |
186 if len(args) != 1: |
186 if len(args) != 1: |
187 raise error.ParseError(_("mailmap expects one argument")) |
187 raise error.ParseError(_("mailmap expects one argument")) |
329 joiner = " " |
329 joiner = " " |
330 if len(args) > 1: |
330 if len(args) > 1: |
331 joiner = evalstring(context, mapping, args[1]) |
331 joiner = evalstring(context, mapping, args[1]) |
332 return joinset.join(context, mapping, joiner) |
332 return joinset.join(context, mapping, joiner) |
333 |
333 |
334 @templatefunc('label(label, expr)') |
334 @templatefunc('label(label, expr)', requires={'ui'}) |
335 def label(context, mapping, args): |
335 def label(context, mapping, args): |
336 """Apply a label to generated content. Content with |
336 """Apply a label to generated content. Content with |
337 a label applied can result in additional post-processing, such as |
337 a label applied can result in additional post-processing, such as |
338 automatic colorization.""" |
338 automatic colorization.""" |
339 if len(args) != 2: |
339 if len(args) != 2: |
502 except TypeError: |
502 except TypeError: |
503 # i18n: "obsfateverb" is a keyword |
503 # i18n: "obsfateverb" is a keyword |
504 errmsg = _("obsfateverb first argument should be countable") |
504 errmsg = _("obsfateverb first argument should be countable") |
505 raise error.ParseError(errmsg) |
505 raise error.ParseError(errmsg) |
506 |
506 |
507 @templatefunc('relpath(path)') |
507 @templatefunc('relpath(path)', requires={'repo'}) |
508 def relpath(context, mapping, args): |
508 def relpath(context, mapping, args): |
509 """Convert a repository-absolute path into a filesystem path relative to |
509 """Convert a repository-absolute path into a filesystem path relative to |
510 the current working directory.""" |
510 the current working directory.""" |
511 if len(args) != 1: |
511 if len(args) != 1: |
512 # i18n: "relpath" is a keyword |
512 # i18n: "relpath" is a keyword |
514 |
514 |
515 repo = context.resource(mapping, 'repo') |
515 repo = context.resource(mapping, 'repo') |
516 path = evalstring(context, mapping, args[0]) |
516 path = evalstring(context, mapping, args[0]) |
517 return repo.pathto(path) |
517 return repo.pathto(path) |
518 |
518 |
519 @templatefunc('revset(query[, formatargs...])') |
519 @templatefunc('revset(query[, formatargs...])', requires={'repo', 'cache'}) |
520 def revset(context, mapping, args): |
520 def revset(context, mapping, args): |
521 """Execute a revision set query. See |
521 """Execute a revision set query. See |
522 :hg:`help revset`.""" |
522 :hg:`help revset`.""" |
523 if not len(args) > 0: |
523 if not len(args) > 0: |
524 # i18n: "revset" is a keyword |
524 # i18n: "revset" is a keyword |
575 first = False |
575 first = False |
576 else: |
576 else: |
577 yield sep |
577 yield sep |
578 yield argstr |
578 yield argstr |
579 |
579 |
580 @templatefunc('shortest(node, minlength=4)') |
580 @templatefunc('shortest(node, minlength=4)', requires={'repo'}) |
581 def shortest(context, mapping, args): |
581 def shortest(context, mapping, args): |
582 """Obtain the shortest representation of |
582 """Obtain the shortest representation of |
583 a node.""" |
583 a node.""" |
584 if not (1 <= len(args) <= 2): |
584 if not (1 <= len(args) <= 2): |
585 # i18n: "shortest" is a keyword |
585 # i18n: "shortest" is a keyword |