sapling/eden/hg-server/tests/test-fb-hgext-fbhistedit-json.t
Durham Goode 98d9269874 server: copy hg to a new hg-server directory
Summary:
Create a fork of the Mercurial code that we can use to build server
rpms. The hg servers will continue to exist for a few more months while we move
the darkstorm and ediscovery use cases off them. In the mean time, we want to
start making breaking changes to the client, so let's create a stable copy of
the hg code to produce rpms for the hg servers.

The fork is based off c7770c78d, the latest hg release.

This copies the files as is, then adds some minor tweaks to get it to build:
- Disables some lint checks that appear to be bypassed by path
- sed replace eden/scm with eden/hg-server
- Removed a dependency on scm/telemetry from the edenfs-client tests since
  scm/telemetry pulls in the original eden/scm/lib/configparser which conflicts
  with the hg-server conflict parser.

allow-large-files

Reviewed By: quark-zju

Differential Revision: D27632557

fbshipit-source-id: b2f442f4ec000ea08e4d62de068750832198e1f4
2021-04-09 10:09:06 -07:00

219 lines
5.4 KiB
Perl

#chg-compatible
Tests JSON Input support for histedit
$ . "$TESTDIR/histedit-helpers.sh"
$ configure mutation-norecord
$ enable fbhistedit histedit rebase
$ initrepo ()
> {
> hg init r
> cd r
> for x in a b c ; do
> echo $x > $x
> hg add $x
> hg ci -m $x
> done
> }
$ initrepo
log before edit
$ hg log --graph -T "{node|short} {desc}"
@ 177f92b77385 c
o d2ae7f538514 b
o cb9a9f314b8b a
passing a json with invalid format
$ cat >> input <<EOF
> {
> "rebase": [
> {"action": "foo", "node": "cb9a9f314b8b"},
> {"action": "pick", "node": "d2ae7f538514"},
> {"action": "pick", "node": "177f92b77385"}
> ]
> }
> EOF
$ hg histedit --commands input
invalid JSON format, falling back to normal parsing
hg: parse error: malformed line "{"
[255]
$ cat >> input2 <<EOF
> {
> "histedit": [
> {"node": "cb9a9f314b8b"},
> {"action": "pick", "node": "d2ae7f538514"},
> {"action": "pick", "node": "177f92b77385"}
> ]
> }
> EOF
$ hg histedit --commands input2
invalid JSON format, falling back to normal parsing
hg: parse error: malformed line "{"
[255]
$ cat >> input3 <<EOF
> {
> "histedit": [
> {"action": "pick", "node": "cb9a9f314b8b"},
> {"action": "pick"},
> {"action": "pick", "node": "177f92b77385"}
> ]
> }
> EOF
$ hg histedit --commands input3
invalid JSON format, falling back to normal parsing
hg: parse error: malformed line "{"
[255]
passing a json with invalid action
$ cat >> foo <<EOF
> {
> "histedit": [
> {"action": "foo", "node": "cb9a9f314b8b"},
> {"action": "pick", "node": "d2ae7f538514"},
> {"action": "pick", "node": "177f92b77385"}
> ]
> }
> EOF
$ hg histedit --commands foo
hg: parse error: unknown action "foo"
[255]
passing a json with invalid node
$ cat >> bar <<EOF
> {
> "histedit": [
> {"action": "pick", "node": "123456abcdef"},
> {"action": "pick", "node": "d2ae7f538514"},
> {"action": "pick", "node": "177f92b77385"}
> ]
> }
> EOF
$ hg histedit --commands bar
hg: parse error: unknown changeset 123456abcdef listed
[255]
running histedit with a valid json file
$ cat >> a.json <<EOF
> {
> "histedit": [
> {"action": "pick", "node": "cb9a9f314b8b"},
> {"action": "exec", "command": "hg exp"},
> {"action": "pick", "node": "177f92b77385"},
> {"action": "exec", "command": "hg exp"},
> {"action": "pick", "node": "d2ae7f538514"},
> {"action": "exec", "command": "hg exp"}
> ]
> }
> EOF
$ hg histedit --commands a.json
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
# Parent 0000000000000000000000000000000000000000
a
diff -r 000000000000 -r cb9a9f314b8b a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/a Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+a
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID b346ab9a313db8537ecf96fca3ca3ca984ef3bd7
# Parent cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
c
diff -r cb9a9f314b8b -r b346ab9a313d c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/c Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+c
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID 503d1c1b466881fd108c7d4d26e78b510df14350
# Parent b346ab9a313db8537ecf96fca3ca3ca984ef3bd7
b
diff -r b346ab9a313d -r 503d1c1b4668 b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/b Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+b
log after histedit
$ hg log --graph -T "{node|short} {desc}"
@ 503d1c1b4668 b
o b346ab9a313d c
o cb9a9f314b8b a
testing with abbreviated/small verbs
$ cat >> small <<EOF
> {
> "histedit": [
> {"action": "p", "node": "cb9a9f314b8b"},
> {"action": "p", "node": "503d1c1b4668"},
> {"action": "p", "node": "b346ab9a313d"}
> ]
> }
> EOF
$ hg histedit --commands small
$ hg log --graph -T "{node} {desc}"
@ 573a8c672aaf44d2cf3f9467e5463f51f7414084 c
o 85032a8e4f13e773c4075d7c006e0f1bc1c63967 b
o cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b a
more testing with full hashes
$ cat >> b.json <<EOF
> {
> "histedit": [
> {"action": "pick", "node": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"},
> {"action": "pick", "node": "85032a8e4f13e773c4075d7c006e0f1bc1c63967"},
> {"action": "roll", "node": "573a8c672aaf44d2cf3f9467e5463f51f7414084"}
> ]
> }
> EOF
$ hg histedit --commands b.json
$ hg log --graph -T "{node|short} {desc}"
@ 04e1eac0d294 b
o cb9a9f314b8b a