sapling/tests/test-fb-hgext-crdump.t
Aida Getoeva c752c3c3d5 Obsolete markers inside crdump
Summary: Added obsolete markers for each revision into `hg debugcrdump` output

Reviewed By: ryanmce

Differential Revision: D7416991

fbshipit-source-id: 9cca7339a4c465c5df81f2646e2ad0ce87bd2c3d
2018-04-13 21:51:38 -07:00

312 lines
8.4 KiB
Raku

$ cat >> $HGRCPATH << EOF
> [extensions]
> fbamend=
> crdump=
> [experimental]
> evolution.createmarkers=True
> EOF
$ showgraph() {
> hg log --graph --hidden -T "{rev} {desc|firstline}" | sed \$d
> }
Create repo
$ mkdir repo
$ cd repo
$ hg init
$ echo A > a
$ printf "A\0\n" > bin1
$ hg addremove
adding a
adding bin1
$ hg commit -m a
$ hg phase -p .
$ printf "A\nB\nC\nD\nE\nF\n" > a
$ printf "a\0b\n" > bin1
$ printf "b\0\n" > bin2
$ hg addremove
adding bin2
$ revision="Differential Revision: https://phabricator.facebook.com/D123"
$ hg commit -m "b
> $revision"
$ showgraph
@ 1 b
|
o 0 a
Test obsolete markers
$ printf "a\0b\0c\n" > bin1
$ hg amend -m "b'
> $revision"
$ showgraph
@ 2 b'
|
| x 1 b
|/
o 0 a
$ hg debugcrdump -U 1 -r . --obsolete --traceback
{
"commits": [
{
"binary_files": [
{
"file_name": "bin1",
"new_file": "69403266b0b9ca9c9403df5097a07d01b74f3e23",
"old_file": "23c26c825bddcb198e701c6f7043a4e35dcb8b97"
},
{
"file_name": "bin2",
"new_file": "31f7b4d23cf93fd41972d0a879086e900cbf06c9",
"old_file": null
}
],
"bookmarks": [],
"date": [
0,
0
],
"desc": "b'\nDifferential Revision: https://phabricator.facebook.com/D123",
"files": [
"a",
"bin1",
"bin2"
],
"node": "9e6c8a14e241d3140575d17288d4a91bd8c9a3c8",
"obsolete": [
{
"date": [
0.0,
0
],
"flag": 0,
"metadata": {
"operation": "amend",
"user": "test"
},
"prednode": "6370cd64643d547e11c6bc91920bca7b44ea21b5",
"succnodes": [
"9e6c8a14e241d3140575d17288d4a91bd8c9a3c8"
]
}
],
"p1": {
"node": "65d913976cc18347138f7b9f5186010d39b39b0f"
},
"patch_file": "9e6c8a14e241d3140575d17288d4a91bd8c9a3c8.patch",
"public_base": {
"node": "65d913976cc18347138f7b9f5186010d39b39b0f"
},
"user": "test"
}
],
"output_directory": "*" (glob)
}
$ echo G >> a
$ echo C > c
$ rm bin2
$ echo x > bin1
$ hg addremove
removing bin2
adding c
$ hg commit -m c
$ hg bookmark bookmark1 -i
Test basic dump of two commits
$ hg debugcrdump -U 1 -r ".^^::." --traceback| tee ../json_output
{
"commits": [
{
"binary_files": [
{
"file_name": "bin1",
"new_file": "23c26c825bddcb198e701c6f7043a4e35dcb8b97",
"old_file": null
}
],
"bookmarks": [],
"date": [
0,
0
],
"desc": "a",
"files": [
"a",
"bin1"
],
"node": "65d913976cc18347138f7b9f5186010d39b39b0f",
"p1": {
"node": "0000000000000000000000000000000000000000"
},
"patch_file": "65d913976cc18347138f7b9f5186010d39b39b0f.patch",
"public_base": {
"node": "65d913976cc18347138f7b9f5186010d39b39b0f"
},
"user": "test"
},
{
"binary_files": [
{
"file_name": "bin1",
"new_file": "69403266b0b9ca9c9403df5097a07d01b74f3e23",
"old_file": "23c26c825bddcb198e701c6f7043a4e35dcb8b97"
},
{
"file_name": "bin2",
"new_file": "31f7b4d23cf93fd41972d0a879086e900cbf06c9",
"old_file": null
}
],
"bookmarks": [],
"date": [
0,
0
],
"desc": "b'\nDifferential Revision: https://phabricator.facebook.com/D123",
"files": [
"a",
"bin1",
"bin2"
],
"node": "9e6c8a14e241d3140575d17288d4a91bd8c9a3c8",
"p1": {
"node": "65d913976cc18347138f7b9f5186010d39b39b0f"
},
"patch_file": "9e6c8a14e241d3140575d17288d4a91bd8c9a3c8.patch",
"public_base": {
"node": "65d913976cc18347138f7b9f5186010d39b39b0f"
},
"user": "test"
},
{
"binary_files": [
{
"file_name": "bin1",
"new_file": "08f31c375398e39fe9c485a2a06a79dfc296580e",
"old_file": "69403266b0b9ca9c9403df5097a07d01b74f3e23"
},
{
"file_name": "bin2",
"new_file": null,
"old_file": "31f7b4d23cf93fd41972d0a879086e900cbf06c9"
}
],
"bookmarks": [
"bookmark1"
],
"date": [
0,
0
],
"desc": "c",
"files": [
"a",
"bin1",
"bin2",
"c"
],
"node": "e3a67aeeade9ad9e292f1762f8f075a8322042b7",
"p1": {
"differential_revision": "123",
"node": "9e6c8a14e241d3140575d17288d4a91bd8c9a3c8"
},
"patch_file": "e3a67aeeade9ad9e292f1762f8f075a8322042b7.patch",
"public_base": {
"node": "65d913976cc18347138f7b9f5186010d39b39b0f"
},
"user": "test"
}
],
"output_directory": "*" (glob)
}
>>> import json
>>> from os import path
>>> with open("../json_output") as f:
... data = json.loads(f.read())
... outdir = data['output_directory']
... for commit in data['commits']:
... print("#### commit %s" % commit['node'])
... print(open(path.join(outdir, commit['patch_file'])).read())
... for binfile in commit['binary_files']:
... print("######## file %s" % binfile['file_name'])
... if binfile['old_file'] is not None:
... print("######## old")
... print(open(path.join(outdir, binfile['old_file'])).read().encode('hex'))
... if binfile['new_file'] is not None:
... print("######## new")
... print(open(path.join(outdir, binfile['new_file'])).read().encode('hex'))
... import shutil
... shutil.rmtree(outdir)
#### commit 65d913976cc18347138f7b9f5186010d39b39b0f
diff --git a/a b/a
new file mode 100644
--- /dev/null
+++ b/a
@@ -0,0 +1,1 @@
+A
diff --git a/bin1 b/bin1
new file mode 100644
Binary file bin1 has changed
######## file bin1
######## new
41000a
#### commit 9e6c8a14e241d3140575d17288d4a91bd8c9a3c8
diff --git a/a b/a
--- a/a
+++ b/a
@@ -1,1 +1,6 @@
A
+B
+C
+D
+E
+F
diff --git a/bin1 b/bin1
Binary file bin1 has changed
diff --git a/bin2 b/bin2
new file mode 100644
Binary file bin2 has changed
######## file bin1
######## old
41000a
######## new
61006200630a
######## file bin2
######## new
62000a
#### commit e3a67aeeade9ad9e292f1762f8f075a8322042b7
diff --git a/a b/a
--- a/a
+++ b/a
@@ -6,1 +6,2 @@
F
+G
diff --git a/bin1 b/bin1
Binary file bin1 has changed
diff --git a/bin2 b/bin2
deleted file mode 100644
Binary file bin2 has changed
diff --git a/c b/c
new file mode 100644
--- /dev/null
+++ b/c
@@ -0,0 +1,1 @@
+C
######## file bin1
######## old
61006200630a
######## new
780a
######## file bin2
######## old
62000a