comparison 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
comparison
equal deleted inserted replaced
29805:4891f3b93182 29806:142ae01820a3
1609 if not tmpl and not mapfile: 1609 if not tmpl and not mapfile:
1610 return changeset_printer(ui, repo, matchfn, opts, buffered) 1610 return changeset_printer(ui, repo, matchfn, opts, buffered)
1611 1611
1612 return changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile, buffered) 1612 return changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile, buffered)
1613 1613
1614 def showmarker(ui, marker, index=None): 1614 def showmarker(fm, marker, index=None):
1615 """utility function to display obsolescence marker in a readable way 1615 """utility function to display obsolescence marker in a readable way
1616 1616
1617 To be used by debug function.""" 1617 To be used by debug function."""
1618 if index is not None: 1618 if index is not None:
1619 ui.write("%i " % index) 1619 fm.write('index', '%i ', index)
1620 ui.write(hex(marker.precnode())) 1620 fm.write('precnode', '%s ', hex(marker.precnode()))
1621 for repl in marker.succnodes(): 1621 succs = marker.succnodes()
1622 ui.write(' ') 1622 fm.condwrite(succs, 'succnodes', '%s ',
1623 ui.write(hex(repl)) 1623 fm.formatlist(map(hex, succs), name='node'))
1624 ui.write(' %X ' % marker.flags()) 1624 fm.write('flag', '%X ', marker.flags())
1625 parents = marker.parentnodes() 1625 parents = marker.parentnodes()
1626 if parents is not None: 1626 if parents is not None:
1627 ui.write('{%s} ' % ', '.join(hex(p) for p in parents)) 1627 fm.write('parentnodes', '{%s} ',
1628 ui.write('(%s) ' % util.datestr(marker.date())) 1628 fm.formatlist(map(hex, parents), name='node', sep=', '))
1629 ui.write('{%s}' % (', '.join('%r: %r' % t for t in 1629 fm.write('date', '(%s) ', fm.formatdate(marker.date()))
1630 sorted(marker.metadata().items()) 1630 meta = marker.metadata().copy()
1631 if t[0] != 'date'))) 1631 meta.pop('date', None)
1632 ui.write('\n') 1632 fm.write('metadata', '{%s}', fm.formatdict(meta, fmt='%r: %r', sep=', '))
1633 fm.plain('\n')
1633 1634
1634 def finddate(ui, repo, date): 1635 def finddate(ui, repo, date):
1635 """Find the tipmost changeset that matches the given date spec""" 1636 """Find the tipmost changeset that matches the given date spec"""
1636 1637
1637 df = util.matchdate(date) 1638 df = util.matchdate(date)