Patchwork [stable] log: fix json-formatted output when file copies are listed (issue4523)

login
register
mail settings
Submitter Augie Fackler
Date Feb. 2, 2015, 7:44 p.m.
Message ID <ec704a2226e9ff749279.1422906291@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/7603/
State Superseded
Commit 942a5a34b2d0611ab284380fbe45b9bb1897af98
Headers show

Comments

Augie Fackler - Feb. 2, 2015, 7:44 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1422905207 18000
#      Mon Feb 02 14:26:47 2015 -0500
# Branch stable
# Node ID ec704a2226e9ff7492797fd4fa0977bd5f34d092
# Parent  3667bc21b8773715d9472a3b4e034b77e62c6451
log: fix json-formatted output when file copies are listed (issue4523)
Gregory Szorc - Feb. 2, 2015, 8:24 p.m.
> On Feb 2, 2015, at 11:44, Augie Fackler <raf@durin42.com> wrote:
> 
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1422905207 18000
> #      Mon Feb 02 14:26:47 2015 -0500
> # Branch stable
> # Node ID ec704a2226e9ff7492797fd4fa0977bd5f34d092
> # Parent  3667bc21b8773715d9472a3b4e034b77e62c6451
> log: fix json-formatted output when file copies are listed (issue4523)
> 
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -1091,8 +1091,8 @@ class jsonchangeset(changeset_printer):
> 
>             if copies:
>                 self.ui.write(',\n  "copies": {%s}' %
> -                              ", ".join('"%s": %s' % (j(k), j(copies[k]))
> -                                                      for k in copies))
> +                              ", ".join('"%s": %s' % (j(k), j(v))
> +                                                      for k, v in copies))
> 
>         matchfn = self.matchfn
>         if matchfn:
> diff --git a/tests/test-log.t b/tests/test-log.t
> --- a/tests/test-log.t
> +++ b/tests/test-log.t
> @@ -494,7 +494,23 @@ log copies with hardcoded style and with
>   e
> 
> 
> -
> +  $ hg log -vC -r4 -Tjson
> +  [
> +   {
> +    "rev": 4,
> +    "node": "7e4639b4691b9f84b81036a8d4fb218ce3c5e3a3",
> +    "branch": "default",
> +    "phase": "draft",
> +    "user": "test",
> +    "date": [5, 0],
> +    "desc": "e",
> +    "bookmarks": [],
> +    "tags": ["tip"],
> +    "parents": ["2ca5ba7019804f1f597249caddf22a64d34df0ba"],
> +    "files": ["dir/b", "e"],
> +    "copies": {"e": dir/b}

Why isn't "dir/b" quoted?

> +   }
> +  ]
> 
> log copies, non-linear manifest
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Augie Fackler - Feb. 3, 2015, 4:17 p.m.
Gooooooooood point. I'll figure that out and send a v2.

On Mon, Feb 2, 2015 at 3:24 PM, Gregory Szorc <gregory.szorc@gmail.com> wrote:
>
>
>> On Feb 2, 2015, at 11:44, Augie Fackler <raf@durin42.com> wrote:
>>
>> # HG changeset patch
>> # User Augie Fackler <augie@google.com>
>> # Date 1422905207 18000
>> #      Mon Feb 02 14:26:47 2015 -0500
>> # Branch stable
>> # Node ID ec704a2226e9ff7492797fd4fa0977bd5f34d092
>> # Parent  3667bc21b8773715d9472a3b4e034b77e62c6451
>> log: fix json-formatted output when file copies are listed (issue4523)
>>
>> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
>> --- a/mercurial/cmdutil.py
>> +++ b/mercurial/cmdutil.py
>> @@ -1091,8 +1091,8 @@ class jsonchangeset(changeset_printer):
>>
>>             if copies:
>>                 self.ui.write(',\n  "copies": {%s}' %
>> -                              ", ".join('"%s": %s' % (j(k), j(copies[k]))
>> -                                                      for k in copies))
>> +                              ", ".join('"%s": %s' % (j(k), j(v))
>> +                                                      for k, v in copies))
>>
>>         matchfn = self.matchfn
>>         if matchfn:
>> diff --git a/tests/test-log.t b/tests/test-log.t
>> --- a/tests/test-log.t
>> +++ b/tests/test-log.t
>> @@ -494,7 +494,23 @@ log copies with hardcoded style and with
>>   e
>>
>>
>> -
>> +  $ hg log -vC -r4 -Tjson
>> +  [
>> +   {
>> +    "rev": 4,
>> +    "node": "7e4639b4691b9f84b81036a8d4fb218ce3c5e3a3",
>> +    "branch": "default",
>> +    "phase": "draft",
>> +    "user": "test",
>> +    "date": [5, 0],
>> +    "desc": "e",
>> +    "bookmarks": [],
>> +    "tags": ["tip"],
>> +    "parents": ["2ca5ba7019804f1f597249caddf22a64d34df0ba"],
>> +    "files": ["dir/b", "e"],
>> +    "copies": {"e": dir/b}
>
> Why isn't "dir/b" quoted?
>
>> +   }
>> +  ]
>>
>> log copies, non-linear manifest
>>
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1091,8 +1091,8 @@  class jsonchangeset(changeset_printer):
 
             if copies:
                 self.ui.write(',\n  "copies": {%s}' %
-                              ", ".join('"%s": %s' % (j(k), j(copies[k]))
-                                                      for k in copies))
+                              ", ".join('"%s": %s' % (j(k), j(v))
+                                                      for k, v in copies))
 
         matchfn = self.matchfn
         if matchfn:
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -494,7 +494,23 @@  log copies with hardcoded style and with
   e
   
   
-
+  $ hg log -vC -r4 -Tjson
+  [
+   {
+    "rev": 4,
+    "node": "7e4639b4691b9f84b81036a8d4fb218ce3c5e3a3",
+    "branch": "default",
+    "phase": "draft",
+    "user": "test",
+    "date": [5, 0],
+    "desc": "e",
+    "bookmarks": [],
+    "tags": ["tip"],
+    "parents": ["2ca5ba7019804f1f597249caddf22a64d34df0ba"],
+    "files": ["dir/b", "e"],
+    "copies": {"e": dir/b}
+   }
+  ]
 
 log copies, non-linear manifest