Mercurial > hg > mercurial-source
changeset 43205:9803323048b6
root: add support for -Tformatter option
It's useless right now, but it should just work and I want to add a few more
fields.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 04 Jun 2019 20:58:39 +0900 (2019-06-04) |
parents | a97b12f726e4 |
children | 69883775b27d |
files | mercurial/commands.py tests/test-alias.t tests/test-basic.t tests/test-completion.t tests/test-help.t |
diffstat | 5 files changed, 21 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5225,16 +5225,19 @@ force=opts.get(r'force')) @command( - 'root', [], intents={INTENT_READONLY}, + 'root', [] + formatteropts, intents={INTENT_READONLY}, helpcategory=command.CATEGORY_WORKING_DIRECTORY) -def root(ui, repo): +def root(ui, repo, **opts): """print the root (top) of the current working directory Print the root directory of the current repository. Returns 0 on success. """ - ui.write(repo.root + "\n") + opts = pycompat.byteskwargs(opts) + with ui.formatter('root', opts) as fm: + fm.startitem() + fm.write('reporoot', '%s\n', repo.root) @command('serve', [('A', 'accesslog', '', _('name of access log file to write to'),
--- a/tests/test-alias.t +++ b/tests/test-alias.t @@ -645,6 +645,10 @@ alias for: hg root + options: + + -T --template TEMPLATE display with template + (use 'hg rt -h' to show more help) [255]
--- a/tests/test-basic.t +++ b/tests/test-basic.t @@ -98,6 +98,12 @@ $TESTTMP/t $ hg log -l1 -T '{reporoot}\n' $TESTTMP/t + $ hg root -Tjson | sed 's|\\\\|\\|g' + [ + { + "reporoot": "$TESTTMP/t" + } + ] At the end...
--- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -338,7 +338,7 @@ resolve: all, list, mark, unmark, no-status, re-merge, tool, include, exclude, template revert: all, date, rev, no-backup, interactive, include, exclude, dry-run rollback: dry-run, force - root: + root: template serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, print-url, subrepos status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template summary: remote