Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.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 | b37f65b047c7 |
children | d4e026341e16 |
comparison
equal
deleted
inserted
replaced
29805:4891f3b93182 | 29806:142ae01820a3 |
---|---|
3042 ('', 'record-parents', False, | 3042 ('', 'record-parents', False, |
3043 _('record parent information for the precursor')), | 3043 _('record parent information for the precursor')), |
3044 ('r', 'rev', [], _('display markers relevant to REV')), | 3044 ('r', 'rev', [], _('display markers relevant to REV')), |
3045 ('', 'index', False, _('display index of the marker')), | 3045 ('', 'index', False, _('display index of the marker')), |
3046 ('', 'delete', [], _('delete markers specified by indices')), | 3046 ('', 'delete', [], _('delete markers specified by indices')), |
3047 ] + commitopts2, | 3047 ] + commitopts2 + formatteropts, |
3048 _('[OBSOLETED [REPLACEMENT ...]]')) | 3048 _('[OBSOLETED [REPLACEMENT ...]]')) |
3049 def debugobsolete(ui, repo, precursor=None, *successors, **opts): | 3049 def debugobsolete(ui, repo, precursor=None, *successors, **opts): |
3050 """create arbitrary obsolete marker | 3050 """create arbitrary obsolete marker |
3051 | 3051 |
3052 With no arguments, displays the list of obsolescence markers.""" | 3052 With no arguments, displays the list of obsolescence markers.""" |
3130 if opts.get('rev') and opts.get('index'): | 3130 if opts.get('rev') and opts.get('index'): |
3131 markerstoiter = obsolete.getmarkers(repo) | 3131 markerstoiter = obsolete.getmarkers(repo) |
3132 markerset = set(markers) | 3132 markerset = set(markers) |
3133 isrelevant = lambda m: m in markerset | 3133 isrelevant = lambda m: m in markerset |
3134 | 3134 |
3135 fm = ui.formatter('debugobsolete', opts) | |
3135 for i, m in enumerate(markerstoiter): | 3136 for i, m in enumerate(markerstoiter): |
3136 if not isrelevant(m): | 3137 if not isrelevant(m): |
3137 # marker can be irrelevant when we're iterating over a set | 3138 # marker can be irrelevant when we're iterating over a set |
3138 # of markers (markerstoiter) which is bigger than the set | 3139 # of markers (markerstoiter) which is bigger than the set |
3139 # of markers we want to display (markers) | 3140 # of markers we want to display (markers) |
3140 # this can happen if both --index and --rev options are | 3141 # this can happen if both --index and --rev options are |
3141 # provided and thus we need to iterate over all of the markers | 3142 # provided and thus we need to iterate over all of the markers |
3142 # to get the correct indices, but only display the ones that | 3143 # to get the correct indices, but only display the ones that |
3143 # are relevant to --rev value | 3144 # are relevant to --rev value |
3144 continue | 3145 continue |
3146 fm.startitem() | |
3145 ind = i if opts.get('index') else None | 3147 ind = i if opts.get('index') else None |
3146 cmdutil.showmarker(ui, m, index=ind) | 3148 cmdutil.showmarker(fm, m, index=ind) |
3149 fm.end() | |
3147 | 3150 |
3148 @command('debugpathcomplete', | 3151 @command('debugpathcomplete', |
3149 [('f', 'full', None, _('complete an entire path')), | 3152 [('f', 'full', None, _('complete an entire path')), |
3150 ('n', 'normal', None, _('show only normal files')), | 3153 ('n', 'normal', None, _('show only normal files')), |
3151 ('a', 'added', None, _('show only added files')), | 3154 ('a', 'added', None, _('show only added files')), |