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