Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
27727:1a6fd929056f | 27728:294037159c64 |
---|---|
5363 for n in p: | 5363 for n in p: |
5364 if n != nullid: | 5364 if n != nullid: |
5365 displayer.show(repo[n]) | 5365 displayer.show(repo[n]) |
5366 displayer.close() | 5366 displayer.close() |
5367 | 5367 |
5368 @command('paths', [], _('[NAME]'), optionalrepo=True) | 5368 @command('paths', formatteropts, _('[NAME]'), optionalrepo=True) |
5369 def paths(ui, repo, search=None): | 5369 def paths(ui, repo, search=None, **opts): |
5370 """show aliases for remote repositories | 5370 """show aliases for remote repositories |
5371 | 5371 |
5372 Show definition of symbolic path name NAME. If no name is given, | 5372 Show definition of symbolic path name NAME. If no name is given, |
5373 show definition of all available names. | 5373 show definition of all available names. |
5374 | 5374 |
5401 pathitems = [(name, path) for name, path in ui.paths.iteritems() | 5401 pathitems = [(name, path) for name, path in ui.paths.iteritems() |
5402 if name == search] | 5402 if name == search] |
5403 else: | 5403 else: |
5404 pathitems = sorted(ui.paths.iteritems()) | 5404 pathitems = sorted(ui.paths.iteritems()) |
5405 | 5405 |
5406 fm = ui.formatter('paths', opts) | |
5407 if fm: | |
5408 hidepassword = str | |
5409 else: | |
5410 hidepassword = util.hidepassword | |
5406 if ui.quiet: | 5411 if ui.quiet: |
5407 namefmt = '%s\n' | 5412 namefmt = '%s\n' |
5408 else: | 5413 else: |
5409 namefmt = '%s = ' | 5414 namefmt = '%s = ' |
5410 showsubopts = not search and not ui.quiet | 5415 showsubopts = not search and not ui.quiet |
5411 | 5416 |
5412 for name, path in pathitems: | 5417 for name, path in pathitems: |
5413 if not search: | 5418 fm.startitem() |
5414 ui.write(namefmt % name) | 5419 fm.condwrite(not search, 'name', namefmt, name) |
5415 if not ui.quiet: | 5420 fm.condwrite(not ui.quiet, 'url', '%s\n', hidepassword(path.rawloc)) |
5416 ui.write("%s\n" % util.hidepassword(path.rawloc)) | |
5417 for subopt, value in sorted(path.suboptions.items()): | 5421 for subopt, value in sorted(path.suboptions.items()): |
5422 assert subopt not in ('name', 'url') | |
5418 if showsubopts: | 5423 if showsubopts: |
5419 ui.write('%s:%s = %s\n' % (name, subopt, value)) | 5424 fm.plain('%s:%s = ' % (name, subopt)) |
5425 fm.condwrite(showsubopts, subopt, '%s\n', value) | |
5426 | |
5427 fm.end() | |
5420 | 5428 |
5421 if search and not pathitems: | 5429 if search and not pathitems: |
5422 if not ui.quiet: | 5430 if not ui.quiet: |
5423 ui.warn(_("not found!\n")) | 5431 ui.warn(_("not found!\n")) |
5424 return 1 | 5432 return 1 |