diff tests/test-evolve-obshistory.t @ 2342:e28026b4d3c1

obshistory: use formatter instead of ui.write in the debugobshistory command Replace ui.write with a formater to have template support and json output. Update tests to assert json outputs.
author Boris Feld <boris.feld@octobus.net>
date Wed, 10 May 2017 11:52:11 +0200
parents 93a37e13424f
children 521a18a10a06
line wrap: on
line diff
--- a/tests/test-evolve-obshistory.t	Wed May 10 13:04:31 2017 +0200
+++ b/tests/test-evolve-obshistory.t	Wed May 10 11:52:11 2017 +0200
@@ -57,9 +57,57 @@
   4ae3a4151de9 (3) A1
   471f378eab4c (1) A0
     rewritten by test (*20*) as 4ae3a4151de9 (glob)
+  $ hg debugobshistory 4ae3a4151de9 -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [],
+          "debugobshistory.node": "4ae3a4151de9",
+          "debugobshistory.rev": 3,
+          "debugobshistory.shortdescription": "A1"
+      },
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "4ae3a4151de9"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "471f378eab4c",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg debugobshistory --hidden 471f378eab4c
   471f378eab4c (1) A0
     rewritten by test (*20*) as 4ae3a4151de9 (glob)
+  $ hg debugobshistory --hidden 471f378eab4c -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "4ae3a4151de9"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "471f378eab4c",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg update 471f378eab4c
   abort: hidden revision '471f378eab4c'!
   (use --hidden to access hidden revisions; successor: 4ae3a4151de9)
@@ -125,8 +173,35 @@
   $ hg debugobshistory 'desc(B0)' --hidden
   0dec01379d3b (2) B0
     pruned by test (*20*) (glob)
+  $ hg debugobshistory 'desc(B0)' --hidden -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.verb": "pruned"
+              }
+          ],
+          "debugobshistory.node": "0dec01379d3b",
+          "debugobshistory.rev": 2,
+          "debugobshistory.shortdescription": "B0"
+      }
+  ]
   $ hg debugobshistory 'desc(A0)'
   471f378eab4c (1) A0
+  $ hg debugobshistory 'desc(A0)' -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [],
+          "debugobshistory.node": "471f378eab4c",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg up 1
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg up 0dec01379d3b
@@ -228,14 +303,92 @@
   $ hg debugobshistory 471597cad322 --hidden
   471597cad322 (1) A0
     rewritten by test (*20*) as 337fec4d2edc, f257fde29c7a (glob)
+  $ hg debugobshistory 471597cad322 --hidden -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "337fec4d2edc",
+                      "f257fde29c7a"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "471597cad322",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg debugobshistory 337fec4d2edc
   337fec4d2edc (2) A0
   471597cad322 (1) A0
     rewritten by test (*20*) as 337fec4d2edc, f257fde29c7a (glob)
+  $ hg debugobshistory 337fec4d2edc -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [],
+          "debugobshistory.node": "337fec4d2edc",
+          "debugobshistory.rev": 2,
+          "debugobshistory.shortdescription": "A0"
+      },
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "337fec4d2edc",
+                      "f257fde29c7a"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "471597cad322",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg debugobshistory f257fde29c7a
   f257fde29c7a (3) A0
   471597cad322 (1) A0
     rewritten by test (*20*) as 337fec4d2edc, f257fde29c7a (glob)
+  $ hg debugobshistory f257fde29c7a -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [],
+          "debugobshistory.node": "f257fde29c7a",
+          "debugobshistory.rev": 3,
+          "debugobshistory.shortdescription": "A0"
+      },
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "337fec4d2edc",
+                      "f257fde29c7a"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "471597cad322",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg update 471597cad322
   abort: hidden revision '471597cad322'!
   (use --hidden to access hidden revisions; successors: 337fec4d2edc, f257fde29c7a)
@@ -401,10 +554,64 @@
   $ hg debugobshistory de7290d8b885 --hidden
   de7290d8b885 (1) A0
     rewritten by test (*20*) as 1ae8bc733a14, 337fec4d2edc, c7f044602e9b, f257fde29c7a (glob)
+  $ hg debugobshistory de7290d8b885 --hidden -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "1ae8bc733a14",
+                      "337fec4d2edc",
+                      "c7f044602e9b",
+                      "f257fde29c7a"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "de7290d8b885",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg debugobshistory c7f044602e9b
   c7f044602e9b (5) A0
   de7290d8b885 (1) A0
     rewritten by test (*20*) as 1ae8bc733a14, 337fec4d2edc, c7f044602e9b, f257fde29c7a (glob)
+  $ hg debugobshistory c7f044602e9b -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [],
+          "debugobshistory.node": "c7f044602e9b",
+          "debugobshistory.rev": 5,
+          "debugobshistory.shortdescription": "A0"
+      },
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "1ae8bc733a14",
+                      "337fec4d2edc",
+                      "c7f044602e9b",
+                      "f257fde29c7a"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "de7290d8b885",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg update de7290d8b885
   abort: hidden revision 'de7290d8b885'!
   (use --hidden to access hidden revisions; successors: 337fec4d2edc, f257fde29c7a and 2 more)
@@ -474,15 +681,102 @@
   $ hg debugobshistory --hidden 471f378eab4c
   471f378eab4c (1) A0
     rewritten by test (*20*) as eb5a0daa2192 (glob)
+  $ hg debugobshistory --hidden 471f378eab4c -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "eb5a0daa2192"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "471f378eab4c",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg debugobshistory --hidden 0dec01379d3b
   0dec01379d3b (2) B0
     rewritten by test (*20*) as eb5a0daa2192 (glob)
+  $ hg debugobshistory --hidden 0dec01379d3b -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "eb5a0daa2192"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "0dec01379d3b",
+          "debugobshistory.rev": 2,
+          "debugobshistory.shortdescription": "B0"
+      }
+  ]
   $ hg debugobshistory eb5a0daa2192
   eb5a0daa2192 (3) C0
   471f378eab4c (1) A0
     rewritten by test (*20*) as eb5a0daa2192 (glob)
   0dec01379d3b (2) B0
     rewritten by test (*20*) as eb5a0daa2192 (glob)
+  $ hg debugobshistory eb5a0daa2192 -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [],
+          "debugobshistory.node": "eb5a0daa2192",
+          "debugobshistory.rev": 3,
+          "debugobshistory.shortdescription": "C0"
+      },
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "eb5a0daa2192"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "471f378eab4c",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      },
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "eb5a0daa2192"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "0dec01379d3b",
+          "debugobshistory.rev": 2,
+          "debugobshistory.shortdescription": "B0"
+      }
+  ]
   $ hg update 471f378eab4c
   abort: hidden revision '471f378eab4c'!
   (use --hidden to access hidden revisions; successor: eb5a0daa2192)
@@ -570,16 +864,124 @@
   471f378eab4c (1) A0
     rewritten by test (*20*) as 65b757b745b9 (glob)
     rewritten by test (*20*) as fdf9bde5129a (glob)
+  $ hg debugobshistory --hidden 471f378eab4c -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "65b757b745b9"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              },
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "fdf9bde5129a"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "471f378eab4c",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg debugobshistory fdf9bde5129a
   fdf9bde5129a (2) A1
   471f378eab4c (1) A0
     rewritten by test (*20*) as 65b757b745b9 (glob)
     rewritten by test (*20*) as fdf9bde5129a (glob)
+  $ hg debugobshistory fdf9bde5129a -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [],
+          "debugobshistory.node": "fdf9bde5129a",
+          "debugobshistory.rev": 2,
+          "debugobshistory.shortdescription": "A1"
+      },
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "65b757b745b9"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              },
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "fdf9bde5129a"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "471f378eab4c",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg debugobshistory 65b757b745b9
   65b757b745b9 (3) A2
   471f378eab4c (1) A0
     rewritten by test (*20*) as 65b757b745b9 (glob)
     rewritten by test (*20*) as fdf9bde5129a (glob)
+  $ hg debugobshistory 65b757b745b9 -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [],
+          "debugobshistory.node": "65b757b745b9",
+          "debugobshistory.rev": 3,
+          "debugobshistory.shortdescription": "A2"
+      },
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "65b757b745b9"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              },
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "fdf9bde5129a"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "471f378eab4c",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg update 471f378eab4c
   abort: hidden revision '471f378eab4c'!
   (use --hidden to access hidden revisions; diverged)
@@ -662,9 +1064,51 @@
   $ hg debugobshistory --hidden 471f378eab4c
   471f378eab4c (1) A0
     rewritten by test (*20*) as eb5a0daa2192 (glob)
+  $ hg debugobshistory --hidden 471f378eab4c -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "eb5a0daa2192"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "471f378eab4c",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg debugobshistory --hidden 0dec01379d3b
   0dec01379d3b (2) B0
     rewritten by test (*20*) as b7ea6d14e664 (glob)
+  $ hg debugobshistory --hidden 0dec01379d3b -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "b7ea6d14e664"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "0dec01379d3b",
+          "debugobshistory.rev": 2,
+          "debugobshistory.shortdescription": "B0"
+      }
+  ]
   $ hg debugobshistory eb5a0daa2192
   eb5a0daa2192 (4) C0
   b7ea6d14e664 (3) B1
@@ -673,6 +1117,69 @@
     rewritten by test (*20*) as b7ea6d14e664 (glob)
   471f378eab4c (1) A0
     rewritten by test (*20*) as eb5a0daa2192 (glob)
+  $ hg debugobshistory eb5a0daa2192 -Tjson | python -m json.tool
+  [
+      {
+          "debugobshistory.markers": [],
+          "debugobshistory.node": "eb5a0daa2192",
+          "debugobshistory.rev": 4,
+          "debugobshistory.shortdescription": "C0"
+      },
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "eb5a0daa2192"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "b7ea6d14e664",
+          "debugobshistory.rev": 3,
+          "debugobshistory.shortdescription": "B1"
+      },
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "b7ea6d14e664"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "0dec01379d3b",
+          "debugobshistory.rev": 2,
+          "debugobshistory.shortdescription": "B0"
+      },
+      {
+          "debugobshistory.markers": [
+              {
+                  "debugobshistory.marker_date": [
+                      *, (glob)
+                      0 (glob)
+                  ],
+                  "debugobshistory.marker_user": "test",
+                  "debugobshistory.succnodes": [
+                      "eb5a0daa2192"
+                  ],
+                  "debugobshistory.verb": "rewritten"
+              }
+          ],
+          "debugobshistory.node": "471f378eab4c",
+          "debugobshistory.rev": 1,
+          "debugobshistory.shortdescription": "A0"
+      }
+  ]
   $ hg update 471f378eab4c
   abort: hidden revision '471f378eab4c'!
   (use --hidden to access hidden revisions; successor: eb5a0daa2192)