diff mercurial/commands.py @ 32672:7a209737f01c

annotate: restructure formatter output to be nested list (BC) Annotate data should be in [(file, [line...])...] form, but there was no API to represent such data structure when I ported it to formatter. Now we have fm.nested() and the -T option is still experimental, so we can fix the data format.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Jun 2017 00:25:24 +0900
parents d3d262ff42c0
children 723de0ad3d8b
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Jun 03 00:05:12 2017 +0900
+++ b/mercurial/commands.py	Sat Jun 03 00:25:24 2017 +0900
@@ -377,15 +377,18 @@
 
     for abs in ctx.walk(m):
         fctx = ctx[abs]
+        rootfm.startitem()
+        rootfm.data(abspath=abs, path=m.rel(abs))
         if not opts.get('text') and fctx.isbinary():
             rootfm.plain(_("%s: binary file\n")
                          % ((pats and m.rel(abs)) or abs))
             continue
 
-        fm = rootfm
+        fm = rootfm.nested('lines')
         lines = fctx.annotate(follow=follow, linenumber=linenumber,
                               skiprevs=skiprevs, diffopts=diffopts)
         if not lines:
+            fm.end()
             continue
         formats = []
         pieces = []
@@ -407,6 +410,7 @@
 
         if not lines[-1][1].endswith('\n'):
             fm.plain('\n')
+        fm.end()
 
     rootfm.end()