Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmdutil.py @ 29806:142ae01820a3
debugobsolete: add formatter support (issue5134)
It appears that computing index isn't cheap if --rev is specified. That's
why "index" field is available only if --index is specified.
I've named marker.flags() as "flag" because "flags" implies a list or dict
in template world.
Thanks to Piotr Listkiewicz for the initial implementation of this patch.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 15 Aug 2016 16:07:55 +0900 |
parents | 2372182e505b |
children | 35560189677c |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Mon Aug 15 12:58:33 2016 +0900 +++ b/mercurial/cmdutil.py Mon Aug 15 16:07:55 2016 +0900 @@ -1611,25 +1611,26 @@ return changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile, buffered) -def showmarker(ui, marker, index=None): +def showmarker(fm, marker, index=None): """utility function to display obsolescence marker in a readable way To be used by debug function.""" if index is not None: - ui.write("%i " % index) - ui.write(hex(marker.precnode())) - for repl in marker.succnodes(): - ui.write(' ') - ui.write(hex(repl)) - ui.write(' %X ' % marker.flags()) + fm.write('index', '%i ', index) + fm.write('precnode', '%s ', hex(marker.precnode())) + succs = marker.succnodes() + fm.condwrite(succs, 'succnodes', '%s ', + fm.formatlist(map(hex, succs), name='node')) + fm.write('flag', '%X ', marker.flags()) parents = marker.parentnodes() if parents is not None: - ui.write('{%s} ' % ', '.join(hex(p) for p in parents)) - ui.write('(%s) ' % util.datestr(marker.date())) - ui.write('{%s}' % (', '.join('%r: %r' % t for t in - sorted(marker.metadata().items()) - if t[0] != 'date'))) - ui.write('\n') + fm.write('parentnodes', '{%s} ', + fm.formatlist(map(hex, parents), name='node', sep=', ')) + fm.write('date', '(%s) ', fm.formatdate(marker.date())) + meta = marker.metadata().copy() + meta.pop('date', None) + fm.write('metadata', '{%s}', fm.formatdict(meta, fmt='%r: %r', sep=', ')) + fm.plain('\n') def finddate(ui, repo, date): """Find the tipmost changeset that matches the given date spec"""