[PATCH 3 of 3] hgweb: add diffs to the json changeset template
Augie Fackler
raf at durin42.com
Mon Nov 18 16:24:33 EST 2019
queued, thanks
> On Nov 15, 2019, at 16:02, Jordi GutiƩrrez Hermoso <jordigh at octave.org> wrote:
>
> # HG changeset patch
> # User Jordi GutiƩrrez Hermoso <jordigh at octave.org>
> # Date 1573851536 18000
> # Fri Nov 15 15:58:56 2019 -0500
> # Node ID df8d762ab0683fb2fe337952b906e2944f89aaa2
> # Parent 6a9122d3cd3639ddacb8768c573ea9eaeb9a6a33
> hgweb: add diffs to the json changeset template
>
> While it's possible to get the diff for each file individually via an
> obscure url that I'm not even sure is documented, (e.g.
> diff/{rev}/{filename}?style=json ), it is more convenient to provide
> the full diff from the changeset view. This is already normally
> computed for other non-JSON templates, so it seems like an oversight
> to omit it for the JSON one.
>
> The output format is a bit unwieldy but it's consistent with the
> existing format output by the aforementioned obscure url.
>
> diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
> --- a/mercurial/templates/json/map
> +++ b/mercurial/templates/json/map
> @@ -66,6 +66,7 @@ changeset = '\{
> "user": {author|utf8|json},
> "parents": [{join(parent%changesetparent, ", ")}],
> "files": [{join(files, ", ")}],
> + "diff": [{join(diff, ", ")}],
> "phase": {phase|json}
> }'
> changesetbranch = '{name|utf8|json}'
> diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
> --- a/tests/test-hgweb-json.t
> +++ b/tests/test-hgweb-json.t
> @@ -782,6 +782,7 @@ changeset/ renders the tip changeset
> 0
> ],
> "desc": "merge test-branch into default",
> + "diff": [],
> "files": [
> {
> "file": "foo-new",
> @@ -813,6 +814,58 @@ changeset/{revision} shows tags
> 0
> ],
> "desc": "move foo",
> + "diff": [
> + {
> + "blockno": 1,
> + "lines": [
> + {
> + "l": "--- a/foo\tThu Jan 01 00:00:00 1970 +0000\n",
> + "n": 1,
> + "t": "-"
> + },
> + {
> + "l": "+++ /dev/null\tThu Jan 01 00:00:00 1970 +0000\n",
> + "n": 2,
> + "t": "+"
> + },
> + {
> + "l": "@@ -1,1 +0,0 @@\n",
> + "n": 3,
> + "t": "@"
> + },
> + {
> + "l": "-bar\n",
> + "n": 4,
> + "t": "-"
> + }
> + ]
> + },
> + {
> + "blockno": 2,
> + "lines": [
> + {
> + "l": "--- /dev/null\tThu Jan 01 00:00:00 1970 +0000\n",
> + "n": 1,
> + "t": "-"
> + },
> + {
> + "l": "+++ b/foo-new\tThu Jan 01 00:00:00 1970 +0000\n",
> + "n": 2,
> + "t": "+"
> + },
> + {
> + "l": "@@ -0,0 +1,1 @@\n",
> + "n": 3,
> + "t": "@"
> + },
> + {
> + "l": "+bar\n",
> + "n": 4,
> + "t": "+"
> + }
> + ]
> + }
> + ],
> "files": [
> {
> "file": "foo",
> @@ -849,6 +902,38 @@ changeset/{revision} shows bookmarks
> 0
> ],
> "desc": "modify da/foo",
> + "diff": [
> + {
> + "blockno": 1,
> + "lines": [
> + {
> + "l": "--- a/da/foo\tThu Jan 01 00:00:00 1970 +0000\n",
> + "n": 1,
> + "t": "-"
> + },
> + {
> + "l": "+++ b/da/foo\tThu Jan 01 00:00:00 1970 +0000\n",
> + "n": 2,
> + "t": "+"
> + },
> + {
> + "l": "@@ -1,1 +1,1 @@\n",
> + "n": 3,
> + "t": "@"
> + },
> + {
> + "l": "-foo\n",
> + "n": 4,
> + "t": "-"
> + },
> + {
> + "l": "+bar\n",
> + "n": 5,
> + "t": "+"
> + }
> + ]
> + }
> + ],
> "files": [
> {
> "file": "da/foo",
> @@ -877,6 +962,38 @@ changeset/{revision} shows branches
> 0
> ],
> "desc": "create test branch",
> + "diff": [
> + {
> + "blockno": 1,
> + "lines": [
> + {
> + "l": "--- a/foo\tThu Jan 01 00:00:00 1970 +0000\n",
> + "n": 1,
> + "t": "-"
> + },
> + {
> + "l": "+++ b/foo\tThu Jan 01 00:00:00 1970 +0000\n",
> + "n": 2,
> + "t": "+"
> + },
> + {
> + "l": "@@ -1,1 +1,1 @@\n",
> + "n": 3,
> + "t": "@"
> + },
> + {
> + "l": "-foo\n",
> + "n": 4,
> + "t": "-"
> + },
> + {
> + "l": "+branch\n",
> + "n": 5,
> + "t": "+"
> + }
> + ]
> + }
> + ],
> "files": [
> {
> "file": "foo",
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list