Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 39396:34ba47117164
formatter: rename {abspath}/{file} to {path}, and drop relative {path} (BC)
Note that {path} in status is either relative-to-cwd or repository-absolute
depending on the command argument and config knob, which can't be reproduced
by using the {path|relpath} filter. The default template is updated to always
use a relative path.
.. bc::
``{abspath}`` and ``{file}`` in generic templates are renamed to ``{path}``.
Any ``{path}`` is a repository-absolute path. Use ``{path|relpath}`` to
convert it to a filesystem path.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 05 Aug 2018 16:44:16 +0900 |
parents | 3fec8aa9b454 |
children | 46f3ff64bea7 |
line wrap: on
line diff
--- a/mercurial/commands.py Sun Aug 05 16:27:09 2018 +0900 +++ b/mercurial/commands.py Sun Aug 05 16:44:16 2018 +0900 @@ -337,10 +337,10 @@ ('rev', ' ', lambda x: x.fctx.rev(), formatrev), ('node', ' ', lambda x: hexfn(x.fctx.node()), formathex), ('date', ' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)), - ('file', ' ', lambda x: x.fctx.path(), pycompat.bytestr), + ('path', ' ', lambda x: x.fctx.path(), pycompat.bytestr), ('line_number', ':', lambda x: x.lineno, pycompat.bytestr), ] - opnamemap = {'rev': 'number', 'node': 'changeset'} + opnamemap = {'rev': 'number', 'node': 'changeset', 'path': 'file'} if (not opts.get('user') and not opts.get('changeset') and not opts.get('date') and not opts.get('file')): @@ -380,7 +380,7 @@ for abs in ctx.walk(m): fctx = ctx[abs] rootfm.startitem() - rootfm.data(abspath=abs, path=m.rel(abs)) + rootfm.data(path=abs) if not opts.get('text') and fctx.isbinary(): rootfm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs)) @@ -2660,7 +2660,7 @@ except error.WdirUnsupported: return ctx[fn].isbinary() - fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'} + fieldnamemap = {'filename': 'path', 'linenumber': 'line_number'} if diff: iter = difflinestates(pstates, states) else: @@ -5187,10 +5187,12 @@ for f in files: fm.startitem() fm.context(ctx=ctx2) + fm.data(path=f) fm.condwrite(showchar, 'status', '%s ', char, label=label) - fm.write('path', fmt, repo.pathto(f, cwd), label=label) + fm.plain(fmt % repo.pathto(f, cwd), label=label) if f in copy: - fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd), + fm.data(copy=copy[f]) + fm.plain((' %s' + end) % repo.pathto(copy[f], cwd), label='status.copied') if ((ui.verbose or ui.configbool('commands', 'status.verbose'))