Patchwork [1,of,3] debugformat: flush formatter output per item

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 10, 2017, 10:58 a.m.
Message ID <85a8d0279d24d039a4f1.1512903495@mimosa>
Download mbox | patch
Permalink /patch/26195/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 10, 2017, 10:58 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1512902379 -32400
#      Sun Dec 10 19:39:39 2017 +0900
# Node ID 85a8d0279d24d039a4f113179dcafac44a3eb93c
# Parent  ea645c6c6d4609a8beedee97610ce27cb4d18a6c
debugformat: flush formatter output per item
Gregory Szorc - Dec. 10, 2017, 5:32 p.m.
On Sun, Dec 10, 2017 at 2:58 AM, Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1512902379 -32400
> #      Sun Dec 10 19:39:39 2017 +0900
> # Node ID 85a8d0279d24d039a4f113179dcafac44a3eb93c
> # Parent  ea645c6c6d4609a8beedee97610ce27cb4d18a6c
> debugformat: flush formatter output per item
>

Queued. Thanks.


>
> diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
> --- a/mercurial/debugcommands.py
> +++ b/mercurial/debugcommands.py
> @@ -888,8 +888,8 @@ def debugformat(ui, repo, **opts):
>      if ui.verbose:
>          fm.plain(' config default')
>      fm.plain('\n')
> -    fm.startitem()
>      for fv in upgrade.allformatvariant:
> +        fm.startitem()
>          repovalue = fv.fromrepo(repo)
>          configvalue = fv.fromconfig(repo)
>
> @@ -916,6 +916,7 @@ def debugformat(ui, repo, **opts):
>          fm.condwrite(ui.verbose, 'default', ' %7s',
> formatvalue(fv.default),
>                       label='formatvariant.default')
>          fm.plain('\n')
> +    fm.end()
>
>  @command('debugfsinfo', [], _('[PATH]'), norepo=True)
>  def debugfsinfo(ui, path="."):
> diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
> --- a/tests/test-upgrade-repo.t
> +++ b/tests/test-upgrade-repo.t
> @@ -82,6 +82,39 @@ An upgrade of a repository created with
>    [formatvariant.name.uptodate|generaldelta:
> ][formatvariant.repo.uptodate| yes][formatvariant.config.default|
> yes][formatvariant.default|     yes]
>    [formatvariant.name.uptodate|plain-cl-delta:][formatvariant.repo.uptodate|
> yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
>    [formatvariant.name.uptodate|compression:
>  ][formatvariant.repo.uptodate| zlib][formatvariant.config.default|
>  zlib][formatvariant.default|    zlib]
> +  $ hg debugformat -Tjson
> +  [
> +   {
> +    "config": "yes",
> +    "default": "yes",
> +    "name": "fncache",
> +    "repo": "yes"
> +   },
> +   {
> +    "config": "yes",
> +    "default": "yes",
> +    "name": "dotencode",
> +    "repo": "yes"
> +   },
> +   {
> +    "config": "yes",
> +    "default": "yes",
> +    "name": "generaldelta",
> +    "repo": "yes"
> +   },
> +   {
> +    "config": "yes",
> +    "default": "yes",
> +    "name": "plain-cl-delta",
> +    "repo": "yes"
> +   },
> +   {
> +    "config": "zlib",
> +    "default": "zlib",
> +    "name": "compression",
> +    "repo": "zlib"
> +   }
> +  ]
>    $ hg debugupgraderepo
>    (no feature deficiencies found in existing repository)
>    performing an upgrade with "--run" will make the following changes:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -888,8 +888,8 @@  def debugformat(ui, repo, **opts):
     if ui.verbose:
         fm.plain(' config default')
     fm.plain('\n')
-    fm.startitem()
     for fv in upgrade.allformatvariant:
+        fm.startitem()
         repovalue = fv.fromrepo(repo)
         configvalue = fv.fromconfig(repo)
 
@@ -916,6 +916,7 @@  def debugformat(ui, repo, **opts):
         fm.condwrite(ui.verbose, 'default', ' %7s', formatvalue(fv.default),
                      label='formatvariant.default')
         fm.plain('\n')
+    fm.end()
 
 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
 def debugfsinfo(ui, path="."):
diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -82,6 +82,39 @@  An upgrade of a repository created with 
   [formatvariant.name.uptodate|generaldelta:  ][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
   [formatvariant.name.uptodate|plain-cl-delta:][formatvariant.repo.uptodate| yes][formatvariant.config.default|    yes][formatvariant.default|     yes]
   [formatvariant.name.uptodate|compression:   ][formatvariant.repo.uptodate| zlib][formatvariant.config.default|   zlib][formatvariant.default|    zlib]
+  $ hg debugformat -Tjson
+  [
+   {
+    "config": "yes",
+    "default": "yes",
+    "name": "fncache",
+    "repo": "yes"
+   },
+   {
+    "config": "yes",
+    "default": "yes",
+    "name": "dotencode",
+    "repo": "yes"
+   },
+   {
+    "config": "yes",
+    "default": "yes",
+    "name": "generaldelta",
+    "repo": "yes"
+   },
+   {
+    "config": "yes",
+    "default": "yes",
+    "name": "plain-cl-delta",
+    "repo": "yes"
+   },
+   {
+    "config": "zlib",
+    "default": "zlib",
+    "name": "compression",
+    "repo": "zlib"
+   }
+  ]
   $ hg debugupgraderepo
   (no feature deficiencies found in existing repository)
   performing an upgrade with "--run" will make the following changes: