Show More
@@ -32,7 +32,6 b' from mercurial.node import (' | |||||
32 | from mercurial import ( |
|
32 | from mercurial import ( | |
33 | logexchange, |
|
33 | logexchange, | |
34 | namespaces, |
|
34 | namespaces, | |
35 | pycompat, |
|
|||
36 | registrar, |
|
35 | registrar, | |
37 | revsetlang, |
|
36 | revsetlang, | |
38 | smartset, |
|
37 | smartset, | |
@@ -225,11 +224,11 b' def reposetup(ui, repo):' | |||||
225 | repo._remotenames.nodetobranch().get(node, [])) |
|
224 | repo._remotenames.nodetobranch().get(node, [])) | |
226 | repo.names.addnamespace(remotebranchns) |
|
225 | repo.names.addnamespace(remotebranchns) | |
227 |
|
226 | |||
228 | @templatekeyword('remotenames') |
|
227 | @templatekeyword('remotenames', requires={'repo', 'ctx', 'templ'}) | |
229 |
def remotenameskw( |
|
228 | def remotenameskw(context, mapping): | |
230 | """List of strings. Remote names associated with the changeset.""" |
|
229 | """List of strings. Remote names associated with the changeset.""" | |
231 | args = pycompat.byteskwargs(args) |
|
230 | repo = context.resource(mapping, 'repo') | |
232 | repo, ctx = args['repo'], args['ctx'] |
|
231 | ctx = context.resource(mapping, 'ctx') | |
233 |
|
232 | |||
234 | remotenames = [] |
|
233 | remotenames = [] | |
235 | if 'remotebookmarks' in repo.names: |
|
234 | if 'remotebookmarks' in repo.names: | |
@@ -238,34 +237,34 b' def remotenameskw(**args):' | |||||
238 | if 'remotebranches' in repo.names: |
|
237 | if 'remotebranches' in repo.names: | |
239 | remotenames += repo.names['remotebranches'].names(repo, ctx.node()) |
|
238 | remotenames += repo.names['remotebranches'].names(repo, ctx.node()) | |
240 |
|
239 | |||
241 |
return templatekw. |
|
240 | return templatekw.compatlist(context, mapping, 'remotename', remotenames, | |
242 | plural='remotenames') |
|
241 | plural='remotenames') | |
243 |
|
242 | |||
244 | @templatekeyword('remotebookmarks') |
|
243 | @templatekeyword('remotebookmarks', requires={'repo', 'ctx', 'templ'}) | |
245 |
def remotebookmarkskw( |
|
244 | def remotebookmarkskw(context, mapping): | |
246 | """List of strings. Remote bookmarks associated with the changeset.""" |
|
245 | """List of strings. Remote bookmarks associated with the changeset.""" | |
247 | args = pycompat.byteskwargs(args) |
|
246 | repo = context.resource(mapping, 'repo') | |
248 | repo, ctx = args['repo'], args['ctx'] |
|
247 | ctx = context.resource(mapping, 'ctx') | |
249 |
|
248 | |||
250 | remotebmarks = [] |
|
249 | remotebmarks = [] | |
251 | if 'remotebookmarks' in repo.names: |
|
250 | if 'remotebookmarks' in repo.names: | |
252 | remotebmarks = repo.names['remotebookmarks'].names(repo, ctx.node()) |
|
251 | remotebmarks = repo.names['remotebookmarks'].names(repo, ctx.node()) | |
253 |
|
252 | |||
254 |
return templatekw. |
|
253 | return templatekw.compatlist(context, mapping, 'remotebookmark', | |
255 | plural='remotebookmarks') |
|
254 | remotebmarks, plural='remotebookmarks') | |
256 |
|
255 | |||
257 | @templatekeyword('remotebranches') |
|
256 | @templatekeyword('remotebranches', requires={'repo', 'ctx', 'templ'}) | |
258 |
def remotebrancheskw( |
|
257 | def remotebrancheskw(context, mapping): | |
259 | """List of strings. Remote branches associated with the changeset.""" |
|
258 | """List of strings. Remote branches associated with the changeset.""" | |
260 | args = pycompat.byteskwargs(args) |
|
259 | repo = context.resource(mapping, 'repo') | |
261 | repo, ctx = args['repo'], args['ctx'] |
|
260 | ctx = context.resource(mapping, 'ctx') | |
262 |
|
261 | |||
263 | remotebranches = [] |
|
262 | remotebranches = [] | |
264 | if 'remotebranches' in repo.names: |
|
263 | if 'remotebranches' in repo.names: | |
265 | remotebranches = repo.names['remotebranches'].names(repo, ctx.node()) |
|
264 | remotebranches = repo.names['remotebranches'].names(repo, ctx.node()) | |
266 |
|
265 | |||
267 |
return templatekw. |
|
266 | return templatekw.compatlist(context, mapping, 'remotebranch', | |
268 | plural='remotebranches') |
|
267 | remotebranches, plural='remotebranches') | |
269 |
|
268 | |||
270 | def _revsetutil(repo, subset, x, rtypes): |
|
269 | def _revsetutil(repo, subset, x, rtypes): | |
271 | """utility function to return a set of revs based on the rtypes""" |
|
270 | """utility function to return a set of revs based on the rtypes""" |
@@ -385,17 +385,18 b' def showbranch(context, mapping):' | |||||
385 | ctx = context.resource(mapping, 'ctx') |
|
385 | ctx = context.resource(mapping, 'ctx') | |
386 | return ctx.branch() |
|
386 | return ctx.branch() | |
387 |
|
387 | |||
388 | @templatekeyword('branches') |
|
388 | @templatekeyword('branches', requires={'ctx', 'templ'}) | |
389 |
def showbranches( |
|
389 | def showbranches(context, mapping): | |
390 | """List of strings. The name of the branch on which the |
|
390 | """List of strings. The name of the branch on which the | |
391 | changeset was committed. Will be empty if the branch name was |
|
391 | changeset was committed. Will be empty if the branch name was | |
392 | default. (DEPRECATED) |
|
392 | default. (DEPRECATED) | |
393 | """ |
|
393 | """ | |
394 | args = pycompat.byteskwargs(args) |
|
394 | ctx = context.resource(mapping, 'ctx') | |
395 |
branch = |
|
395 | branch = ctx.branch() | |
396 | if branch != 'default': |
|
396 | if branch != 'default': | |
397 |
return |
|
397 | return compatlist(context, mapping, 'branch', [branch], | |
398 | return showlist('branch', [], args, plural='branches') |
|
398 | plural='branches') | |
|
399 | return compatlist(context, mapping, 'branch', [], plural='branches') | |||
399 |
|
400 | |||
400 | @templatekeyword('bookmarks') |
|
401 | @templatekeyword('bookmarks') | |
401 | def showbookmarks(**args): |
|
402 | def showbookmarks(**args): | |
@@ -482,18 +483,19 b' def showextras(**args):' | |||||
482 | return _hybrid(f, extras, makemap, |
|
483 | return _hybrid(f, extras, makemap, | |
483 | lambda k: '%s=%s' % (k, util.escapestr(extras[k]))) |
|
484 | lambda k: '%s=%s' % (k, util.escapestr(extras[k]))) | |
484 |
|
485 | |||
485 |
def _showfilesbystat( |
|
486 | def _showfilesbystat(context, mapping, name, index): | |
486 | repo, ctx, revcache = args['repo'], args['ctx'], args['revcache'] |
|
487 | repo = context.resource(mapping, 'repo') | |
|
488 | ctx = context.resource(mapping, 'ctx') | |||
|
489 | revcache = context.resource(mapping, 'revcache') | |||
487 | if 'files' not in revcache: |
|
490 | if 'files' not in revcache: | |
488 | revcache['files'] = repo.status(ctx.p1(), ctx)[:3] |
|
491 | revcache['files'] = repo.status(ctx.p1(), ctx)[:3] | |
489 | files = revcache['files'][index] |
|
492 | files = revcache['files'][index] | |
490 |
return |
|
493 | return compatlist(context, mapping, name, files, element='file') | |
491 |
|
494 | |||
492 | @templatekeyword('file_adds') |
|
495 | @templatekeyword('file_adds', requires={'repo', 'ctx', 'revcache', 'templ'}) | |
493 |
def showfileadds( |
|
496 | def showfileadds(context, mapping): | |
494 | """List of strings. Files added by this changeset.""" |
|
497 | """List of strings. Files added by this changeset.""" | |
495 | args = pycompat.byteskwargs(args) |
|
498 | return _showfilesbystat(context, mapping, 'file_add', 1) | |
496 | return _showfilesbystat(args, 'file_add', 1) |
|
|||
497 |
|
499 | |||
498 | @templatekeyword('file_copies', |
|
500 | @templatekeyword('file_copies', | |
499 | requires={'repo', 'ctx', 'cache', 'revcache', 'templ'}) |
|
501 | requires={'repo', 'ctx', 'cache', 'revcache', 'templ'}) | |
@@ -534,25 +536,23 b' def showfilecopiesswitch(context, mappin' | |||||
534 | key='name', value='source', fmt='%s (%s)', |
|
536 | key='name', value='source', fmt='%s (%s)', | |
535 | plural='file_copies') |
|
537 | plural='file_copies') | |
536 |
|
538 | |||
537 | @templatekeyword('file_dels') |
|
539 | @templatekeyword('file_dels', requires={'repo', 'ctx', 'revcache', 'templ'}) | |
538 |
def showfiledels( |
|
540 | def showfiledels(context, mapping): | |
539 | """List of strings. Files removed by this changeset.""" |
|
541 | """List of strings. Files removed by this changeset.""" | |
540 | args = pycompat.byteskwargs(args) |
|
542 | return _showfilesbystat(context, mapping, 'file_del', 2) | |
541 | return _showfilesbystat(args, 'file_del', 2) |
|
|||
542 |
|
543 | |||
543 | @templatekeyword('file_mods') |
|
544 | @templatekeyword('file_mods', requires={'repo', 'ctx', 'revcache', 'templ'}) | |
544 |
def showfilemods( |
|
545 | def showfilemods(context, mapping): | |
545 | """List of strings. Files modified by this changeset.""" |
|
546 | """List of strings. Files modified by this changeset.""" | |
546 | args = pycompat.byteskwargs(args) |
|
547 | return _showfilesbystat(context, mapping, 'file_mod', 0) | |
547 | return _showfilesbystat(args, 'file_mod', 0) |
|
|||
548 |
|
548 | |||
549 | @templatekeyword('files') |
|
549 | @templatekeyword('files', requires={'ctx', 'templ'}) | |
550 |
def showfiles( |
|
550 | def showfiles(context, mapping): | |
551 | """List of strings. All files modified, added, or removed by this |
|
551 | """List of strings. All files modified, added, or removed by this | |
552 | changeset. |
|
552 | changeset. | |
553 | """ |
|
553 | """ | |
554 | args = pycompat.byteskwargs(args) |
|
554 | ctx = context.resource(mapping, 'ctx') | |
555 |
return |
|
555 | return compatlist(context, mapping, 'file', ctx.files()) | |
556 |
|
556 | |||
557 | @templatekeyword('graphnode', requires={'repo', 'ctx'}) |
|
557 | @templatekeyword('graphnode', requires={'repo', 'ctx'}) | |
558 | def showgraphnode(context, mapping): |
|
558 | def showgraphnode(context, mapping): | |
@@ -913,14 +913,13 b' def showrevslist(name, revs, **args):' | |||||
913 | lambda x: {name: x, 'ctx': repo[x], 'revcache': {}}, |
|
913 | lambda x: {name: x, 'ctx': repo[x], 'revcache': {}}, | |
914 | pycompat.identity, keytype=int) |
|
914 | pycompat.identity, keytype=int) | |
915 |
|
915 | |||
916 | @templatekeyword('subrepos') |
|
916 | @templatekeyword('subrepos', requires={'ctx', 'templ'}) | |
917 |
def showsubrepos( |
|
917 | def showsubrepos(context, mapping): | |
918 | """List of strings. Updated subrepositories in the changeset.""" |
|
918 | """List of strings. Updated subrepositories in the changeset.""" | |
919 | args = pycompat.byteskwargs(args) |
|
919 | ctx = context.resource(mapping, 'ctx') | |
920 | ctx = args['ctx'] |
|
|||
921 | substate = ctx.substate |
|
920 | substate = ctx.substate | |
922 | if not substate: |
|
921 | if not substate: | |
923 |
return |
|
922 | return compatlist(context, mapping, 'subrepo', []) | |
924 | psubstate = ctx.parents()[0].substate or {} |
|
923 | psubstate = ctx.parents()[0].substate or {} | |
925 | subrepos = [] |
|
924 | subrepos = [] | |
926 | for sub in substate: |
|
925 | for sub in substate: | |
@@ -929,7 +928,7 b' def showsubrepos(**args):' | |||||
929 | for sub in psubstate: |
|
928 | for sub in psubstate: | |
930 | if sub not in substate: |
|
929 | if sub not in substate: | |
931 | subrepos.append(sub) # removed in ctx |
|
930 | subrepos.append(sub) # removed in ctx | |
932 |
return |
|
931 | return compatlist(context, mapping, 'subrepo', sorted(subrepos)) | |
933 |
|
932 | |||
934 | # don't remove "showtags" definition, even though namespaces will put |
|
933 | # don't remove "showtags" definition, even though namespaces will put | |
935 | # a helper function for "tags" keyword into "keywords" map automatically, |
|
934 | # a helper function for "tags" keyword into "keywords" map automatically, | |
@@ -945,13 +944,13 b' def showtermwidth(context, mapping):' | |||||
945 | ui = context.resource(mapping, 'ui') |
|
944 | ui = context.resource(mapping, 'ui') | |
946 | return ui.termwidth() |
|
945 | return ui.termwidth() | |
947 |
|
946 | |||
948 | @templatekeyword('instabilities') |
|
947 | @templatekeyword('instabilities', requires={'ctx', 'templ'}) | |
949 |
def showinstabilities( |
|
948 | def showinstabilities(context, mapping): | |
950 | """List of strings. Evolution instabilities affecting the changeset. |
|
949 | """List of strings. Evolution instabilities affecting the changeset. | |
951 | (EXPERIMENTAL) |
|
950 | (EXPERIMENTAL) | |
952 | """ |
|
951 | """ | |
953 | args = pycompat.byteskwargs(args) |
|
952 | ctx = context.resource(mapping, 'ctx') | |
954 |
return |
|
953 | return compatlist(context, mapping, 'instability', ctx.instabilities(), | |
955 | plural='instabilities') |
|
954 | plural='instabilities') | |
956 |
|
955 | |||
957 | @templatekeyword('verbosity', requires={'ui'}) |
|
956 | @templatekeyword('verbosity', requires={'ui'}) |
@@ -722,10 +722,7 b' def files(context, mapping, args):' | |||||
722 | ctx = context.resource(mapping, 'ctx') |
|
722 | ctx = context.resource(mapping, 'ctx') | |
723 | m = ctx.match([raw]) |
|
723 | m = ctx.match([raw]) | |
724 | files = list(ctx.matches(m)) |
|
724 | files = list(ctx.matches(m)) | |
725 | # TODO: pass (context, mapping) pair to keyword function |
|
725 | return templatekw.compatlist(context, mapping, "file", files) | |
726 | props = context._resources.copy() |
|
|||
727 | props.update(mapping) |
|
|||
728 | return templatekw.showlist("file", files, props) |
|
|||
729 |
|
726 | |||
730 | @templatefunc('fill(text[, width[, initialident[, hangindent]]])') |
|
727 | @templatefunc('fill(text[, width[, initialident[, hangindent]]])') | |
731 | def fill(context, mapping, args): |
|
728 | def fill(context, mapping, args): |
General Comments 0
You need to be logged in to leave comments.
Login now