[PATCH 2 of 3] json: implement {changeset} template
Gregory Szorc
gregory.szorc at gmail.com
Wed Apr 1 06:02:09 UTC 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1427866512 25200
# Tue Mar 31 22:35:12 2015 -0700
# Node ID 8ea63ae7d3fde67fdbf07518d7e0da1ebf787980
# Parent 93a8bab1c04858d9a4276d6727891959b788c1f6
json: implement {changeset} template
Output only contains basic changeset information for the moment. The
format is compatible with `hg log -Tjson`.
diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
--- a/mercurial/templates/json/map
+++ b/mercurial/templates/json/map
@@ -2,9 +2,22 @@ mimetype = 'application/json'
filerevision = '"not yet implemented"'
search = '"not yet implemented"'
shortlog = '"not yet implemented"'
changelog = '"not yet implemented"'
-changeset = '"not yet implemented"'
+changeset = '\{
+ "node": {node|json},
+ "date": {date|json},
+ "desc": {desc|json},
+ "branch": {if(branch, branch%changesetbranch, "default"|json)},
+ "bookmarks": [{join(changesetbookmark, ", ")}],
+ "tags": [{join(changesettag, ", ")}],
+ "user": {author|json},
+ "parents": [{join(parent%changesetparent, ", ")}]
+ }'
+changesetbranch = '{name|json}'
+changesetbookmark = '{bookmark|json}'
+changesettag = '{tag|json}'
+changesetparent = '{node|json}'
manifest = '"not yet implemented"'
tags = '\{
"node": {node|json},
"tags": [{join(entriesnotip%tagentry, ", ")}]
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
@@ -29,48 +29,68 @@
$ hg -q up -r 0
$ hg -q branch test-branch
$ echo branch > foo
$ hg commit -m 'create test branch'
+ $ echo branch_commit_2 > foo
+ $ hg commit -m 'another commit in test-branch'
+ $ hg -q up default
+ $ hg merge --tool :local test-branch
+ 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+ (branch merge, don't forget to commit)
+ $ hg commit -m 'merge test-branch into default'
$ hg log -G
- @ changeset: 7:6ab967a8ab34
- | branch: test-branch
- | tag: tip
- | parent: 0:06e557f3edf6
- | user: test
- | date: Thu Jan 01 00:00:00 1970 +0000
- | summary: create test branch
- |
- | o changeset: 6:ceed296fe500
+ @ changeset: 9:cc725e08502a
+ |\ tag: tip
+ | | parent: 6:ceed296fe500
+ | | parent: 8:ed66c30e87eb
+ | | user: test
+ | | date: Thu Jan 01 00:00:00 1970 +0000
+ | | summary: merge test-branch into default
+ | |
+ | o changeset: 8:ed66c30e87eb
+ | | branch: test-branch
+ | | user: test
+ | | date: Thu Jan 01 00:00:00 1970 +0000
+ | | summary: another commit in test-branch
+ | |
+ | o changeset: 7:6ab967a8ab34
+ | | branch: test-branch
+ | | parent: 0:06e557f3edf6
+ | | user: test
+ | | date: Thu Jan 01 00:00:00 1970 +0000
+ | | summary: create test branch
+ | |
+ o | changeset: 6:ceed296fe500
| | bookmark: bookmark2
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
| | summary: create tag2
| |
- | o changeset: 5:f2890a05fea4
+ o | changeset: 5:f2890a05fea4
| | tag: tag2
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
| | summary: another commit to da/foo
| |
- | o changeset: 4:93a8ce14f891
+ o | changeset: 4:93a8ce14f891
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
| | summary: create tag
| |
- | o changeset: 3:78896eb0e102
+ o | changeset: 3:78896eb0e102
| | tag: tag1
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
| | summary: move foo
| |
- | o changeset: 2:8d7c456572ac
+ o | changeset: 2:8d7c456572ac
| | bookmark: bookmark1
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
| | summary: modify da/foo
| |
- | o changeset: 1:f8bbb9024b10
+ o | changeset: 1:f8bbb9024b10
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: modify foo
|
@@ -128,30 +148,93 @@ changeset/ renders the tip changeset
$ request json-rev
200 Script output follows
- "not yet implemented"
+ {
+ "bookmarks": [],
+ "branch": "default",
+ "date": [
+ 0.0,
+ 0
+ ],
+ "desc": "merge test-branch into default",
+ "node": "cc725e08502a79dd1eda913760fbe06ed7a9abc7",
+ "parents": [
+ "ceed296fe500c3fac9541e31dad860cb49c89e45",
+ "ed66c30e87eb65337c05a4229efaa5f1d5285a90"
+ ],
+ "tags": [
+ "tip"
+ ],
+ "user": "test"
+ }
changeset/{revision} shows tags
$ request json-rev/78896eb0e102
200 Script output follows
- "not yet implemented"
+ {
+ "bookmarks": [],
+ "branch": "default",
+ "date": [
+ 0.0,
+ 0
+ ],
+ "desc": "move foo",
+ "node": "78896eb0e102174ce9278438a95e12543e4367a7",
+ "parents": [
+ "8d7c456572acf3557e8ed8a07286b10c408bcec5"
+ ],
+ "tags": [
+ "tag1"
+ ],
+ "user": "test"
+ }
changeset/{revision} shows bookmarks
$ request json-rev/8d7c456572ac
200 Script output follows
- "not yet implemented"
+ {
+ "bookmarks": [
+ "bookmark1"
+ ],
+ "branch": "default",
+ "date": [
+ 0.0,
+ 0
+ ],
+ "desc": "modify da/foo",
+ "node": "8d7c456572acf3557e8ed8a07286b10c408bcec5",
+ "parents": [
+ "f8bbb9024b10f93cdbb8d940337398291d40dea8"
+ ],
+ "tags": [],
+ "user": "test"
+ }
changeset/{revision} shows branches
$ request json-rev/6ab967a8ab34
200 Script output follows
- "not yet implemented"
+ {
+ "bookmarks": [],
+ "branch": "test-branch",
+ "date": [
+ 0.0,
+ 0
+ ],
+ "desc": "create test branch",
+ "node": "6ab967a8ab3489227a83f80e920faa039a71819f",
+ "parents": [
+ "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e"
+ ],
+ "tags": [],
+ "user": "test"
+ }
manifest/{revision}/{path} shows info about a directory at a revision
$ request json-manifest/06e557f3edf6/
@@ -164,9 +247,9 @@ tags/ shows tags info
$ request json-tags
200 Script output follows
{
- "node": "6ab967a8ab3489227a83f80e920faa039a71819f",
+ "node": "cc725e08502a79dd1eda913760fbe06ed7a9abc7",
"tags": [
{
"date": [
0.0,
@@ -209,9 +292,9 @@ bookmarks/ shows bookmarks info
],
"node": "ceed296fe500c3fac9541e31dad860cb49c89e45"
}
],
- "node": "6ab967a8ab3489227a83f80e920faa039a71819f"
+ "node": "cc725e08502a79dd1eda913760fbe06ed7a9abc7"
}
branches/ shows branches info
@@ -220,24 +303,24 @@ branches/ shows branches info
{
"branches": [
{
+ "branch": "default",
+ "date": [
+ 0.0,
+ 0
+ ],
+ "node": "cc725e08502a79dd1eda913760fbe06ed7a9abc7",
+ "status": "open"
+ },
+ {
"branch": "test-branch",
"date": [
0.0,
0
],
- "node": "6ab967a8ab3489227a83f80e920faa039a71819f",
- "status": "open"
- },
- {
- "branch": "default",
- "date": [
- 0.0,
- 0
- ],
- "node": "ceed296fe500c3fac9541e31dad860cb49c89e45",
- "status": "open"
+ "node": "ed66c30e87eb65337c05a4229efaa5f1d5285a90",
+ "status": "inactive"
}
]
}
More information about the Mercurial-devel
mailing list