Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 27728:294037159c64
paths: port to generic templater
Embedded passwords are masked only in plain output because we'll want raw
values in machine-readable format such as JSON. For custom template, we can
add a filter to mask passwords (e.g. "{url|hidepassword}").
path.rawloc field is called as "url" than "path" because we have "pushurl"
sub-option. Also, "name" and "url" are not allowed as sub-options as they
conflict with the field names.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 13 Dec 2015 22:09:57 +0900 |
parents | 1a6fd929056f |
children | a40e2f7fe49d |
line wrap: on
line diff
--- a/mercurial/commands.py Sun Dec 13 23:01:19 2015 +0900 +++ b/mercurial/commands.py Sun Dec 13 22:09:57 2015 +0900 @@ -5365,8 +5365,8 @@ displayer.show(repo[n]) displayer.close() -@command('paths', [], _('[NAME]'), optionalrepo=True) -def paths(ui, repo, search=None): +@command('paths', formatteropts, _('[NAME]'), optionalrepo=True) +def paths(ui, repo, search=None, **opts): """show aliases for remote repositories Show definition of symbolic path name NAME. If no name is given, @@ -5403,6 +5403,11 @@ else: pathitems = sorted(ui.paths.iteritems()) + fm = ui.formatter('paths', opts) + if fm: + hidepassword = str + else: + hidepassword = util.hidepassword if ui.quiet: namefmt = '%s\n' else: @@ -5410,13 +5415,16 @@ showsubopts = not search and not ui.quiet for name, path in pathitems: - if not search: - ui.write(namefmt % name) - if not ui.quiet: - ui.write("%s\n" % util.hidepassword(path.rawloc)) + fm.startitem() + fm.condwrite(not search, 'name', namefmt, name) + fm.condwrite(not ui.quiet, 'url', '%s\n', hidepassword(path.rawloc)) for subopt, value in sorted(path.suboptions.items()): + assert subopt not in ('name', 'url') if showsubopts: - ui.write('%s:%s = %s\n' % (name, subopt, value)) + fm.plain('%s:%s = ' % (name, subopt)) + fm.condwrite(showsubopts, subopt, '%s\n', value) + + fm.end() if search and not pathitems: if not ui.quiet: