[PATCH 3 of 3 v2] changeset: adjust json output to use new/old

timeless timeless at mozdev.org
Fri Feb 26 13:12:42 EST 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1456455801 0
#      Fri Feb 26 03:03:21 2016 +0000
# Node ID 3e1dbbc6ece30c6207c21bb47b888b39e1052a02
# Parent  d66dc235bd21ed08c5661fd62604d0c1bcfd0f8a
changeset: adjust json output to use new/old

The previous json structure was not friendly to strongly structured parsing.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1395,8 +1395,9 @@
                           ", ".join('"%s"' % j(f) for f in ctx.files()))
 
             if copies:
-                self.ui.write(',\n  "copies": {%s}' %
-                              ", ".join('"%s": "%s"' % (j(k), j(v))
+                self.ui.write(',\n  "copies": [%s]' %
+                              ", ".join('{"new": {"path": "%s"}, '
+                                         '"old": {"path": "%s"}}' % (j(k), j(v))
                                                         for k, v in copies))
 
         matchfn = self.matchfn
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -524,7 +524,7 @@
     "tags": ["tip"],
     "parents": ["2ca5ba7019804f1f597249caddf22a64d34df0ba"],
     "files": ["dir/b", "e"],
-    "copies": {"e": "dir/b"}
+    "copies": [{"new": {"path": "e"}, "old": {"path": "dir/b"}}]
    }
   ]
 


More information about the Mercurial-devel mailing list