diff 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
line wrap: on
line diff
--- a/mercurial/commands.py	Mon Aug 15 12:58:33 2016 +0900
+++ b/mercurial/commands.py	Mon Aug 15 16:07:55 2016 +0900
@@ -3044,7 +3044,7 @@
          ('r', 'rev', [], _('display markers relevant to REV')),
          ('', 'index', False, _('display index of the marker')),
          ('', 'delete', [], _('delete markers specified by indices')),
-        ] + commitopts2,
+        ] + commitopts2 + formatteropts,
          _('[OBSOLETED [REPLACEMENT ...]]'))
 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
     """create arbitrary obsolete marker
@@ -3132,6 +3132,7 @@
             markerset = set(markers)
             isrelevant = lambda m: m in markerset
 
+        fm = ui.formatter('debugobsolete', opts)
         for i, m in enumerate(markerstoiter):
             if not isrelevant(m):
                 # marker can be irrelevant when we're iterating over a set
@@ -3142,8 +3143,10 @@
                 # to get the correct indices, but only display the ones that
                 # are relevant to --rev value
                 continue
+            fm.startitem()
             ind = i if opts.get('index') else None
-            cmdutil.showmarker(ui, m, index=ind)
+            cmdutil.showmarker(fm, m, index=ind)
+        fm.end()
 
 @command('debugpathcomplete',
          [('f', 'full', None, _('complete an entire path')),