2017-08-03 14:50:46 +03:00
|
|
|
$ cat >> $HGRCPATH << EOF
|
|
|
|
> [extensions]
|
2018-03-28 14:16:56 +03:00
|
|
|
> fbamend=
|
2018-01-09 14:06:09 +03:00
|
|
|
> crdump=
|
2018-03-28 14:16:56 +03:00
|
|
|
> [experimental]
|
|
|
|
> evolution.createmarkers=True
|
2017-08-03 14:50:46 +03:00
|
|
|
> EOF
|
2018-03-28 14:16:56 +03:00
|
|
|
$ showgraph() {
|
|
|
|
> hg log --graph --hidden -T "{rev} {desc|firstline}" | sed \$d
|
|
|
|
> }
|
2017-08-03 14:50:46 +03:00
|
|
|
|
|
|
|
Create repo
|
|
|
|
$ mkdir repo
|
|
|
|
$ cd repo
|
|
|
|
$ hg init
|
|
|
|
$ echo A > a
|
2017-08-03 18:50:12 +03:00
|
|
|
$ printf "A\0\n" > bin1
|
2017-08-03 14:50:46 +03:00
|
|
|
$ hg addremove
|
|
|
|
adding a
|
|
|
|
adding bin1
|
|
|
|
$ hg commit -m a
|
|
|
|
$ hg phase -p .
|
|
|
|
|
|
|
|
$ printf "A\nB\nC\nD\nE\nF\n" > a
|
2017-08-03 18:50:12 +03:00
|
|
|
$ printf "a\0b\n" > bin1
|
|
|
|
$ printf "b\0\n" > bin2
|
2017-08-03 14:50:46 +03:00
|
|
|
$ hg addremove
|
|
|
|
adding bin2
|
2018-03-28 14:16:56 +03:00
|
|
|
$ revision="Differential Revision: https://phabricator.facebook.com/D123"
|
2017-08-03 14:50:46 +03:00
|
|
|
$ hg commit -m "b
|
2018-03-28 14:16:56 +03:00
|
|
|
> $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)
|
|
|
|
}
|
|
|
|
|
2017-08-03 14:50:46 +03:00
|
|
|
|
|
|
|
$ echo G >> a
|
|
|
|
$ echo C > c
|
|
|
|
$ rm bin2
|
|
|
|
$ echo x > bin1
|
|
|
|
$ hg addremove
|
|
|
|
removing bin2
|
|
|
|
adding c
|
|
|
|
$ hg commit -m c
|
2018-02-24 03:37:19 +03:00
|
|
|
$ hg bookmark bookmark1 -i
|
2017-08-03 14:50:46 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
],
|
2018-02-24 03:37:19 +03:00
|
|
|
"bookmarks": [],
|
2017-08-03 14:50:46 +03:00
|
|
|
"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",
|
2018-03-28 14:16:56 +03:00
|
|
|
"new_file": "69403266b0b9ca9c9403df5097a07d01b74f3e23",
|
2017-08-03 14:50:46 +03:00
|
|
|
"old_file": "23c26c825bddcb198e701c6f7043a4e35dcb8b97"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"file_name": "bin2",
|
|
|
|
"new_file": "31f7b4d23cf93fd41972d0a879086e900cbf06c9",
|
|
|
|
"old_file": null
|
|
|
|
}
|
|
|
|
],
|
2018-02-24 03:37:19 +03:00
|
|
|
"bookmarks": [],
|
2017-08-03 14:50:46 +03:00
|
|
|
"date": [
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
],
|
2018-03-28 14:16:56 +03:00
|
|
|
"desc": "b'\nDifferential Revision: https://phabricator.facebook.com/D123",
|
2017-08-03 14:50:46 +03:00
|
|
|
"files": [
|
|
|
|
"a",
|
|
|
|
"bin1",
|
|
|
|
"bin2"
|
|
|
|
],
|
2018-03-28 14:16:56 +03:00
|
|
|
"node": "9e6c8a14e241d3140575d17288d4a91bd8c9a3c8",
|
2017-08-03 14:50:46 +03:00
|
|
|
"p1": {
|
|
|
|
"node": "65d913976cc18347138f7b9f5186010d39b39b0f"
|
|
|
|
},
|
2018-03-28 14:16:56 +03:00
|
|
|
"patch_file": "9e6c8a14e241d3140575d17288d4a91bd8c9a3c8.patch",
|
2017-08-03 14:50:46 +03:00
|
|
|
"public_base": {
|
|
|
|
"node": "65d913976cc18347138f7b9f5186010d39b39b0f"
|
|
|
|
},
|
|
|
|
"user": "test"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"binary_files": [
|
|
|
|
{
|
|
|
|
"file_name": "bin1",
|
2018-03-28 14:16:56 +03:00
|
|
|
"new_file": "08f31c375398e39fe9c485a2a06a79dfc296580e",
|
|
|
|
"old_file": "69403266b0b9ca9c9403df5097a07d01b74f3e23"
|
2017-08-03 14:50:46 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"file_name": "bin2",
|
|
|
|
"new_file": null,
|
|
|
|
"old_file": "31f7b4d23cf93fd41972d0a879086e900cbf06c9"
|
|
|
|
}
|
|
|
|
],
|
2018-02-24 03:37:19 +03:00
|
|
|
"bookmarks": [
|
|
|
|
"bookmark1"
|
|
|
|
],
|
2017-08-03 14:50:46 +03:00
|
|
|
"date": [
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
],
|
|
|
|
"desc": "c",
|
|
|
|
"files": [
|
|
|
|
"a",
|
|
|
|
"bin1",
|
|
|
|
"bin2",
|
|
|
|
"c"
|
|
|
|
],
|
2018-03-28 14:16:56 +03:00
|
|
|
"node": "e3a67aeeade9ad9e292f1762f8f075a8322042b7",
|
2017-08-03 14:50:46 +03:00
|
|
|
"p1": {
|
|
|
|
"differential_revision": "123",
|
2018-03-28 14:16:56 +03:00
|
|
|
"node": "9e6c8a14e241d3140575d17288d4a91bd8c9a3c8"
|
2017-08-03 14:50:46 +03:00
|
|
|
},
|
2018-03-28 14:16:56 +03:00
|
|
|
"patch_file": "e3a67aeeade9ad9e292f1762f8f075a8322042b7.patch",
|
2017-08-03 14:50:46 +03:00
|
|
|
"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']:
|
2018-01-09 14:06:09 +03:00
|
|
|
... print("#### commit %s" % commit['node'])
|
|
|
|
... print(open(path.join(outdir, commit['patch_file'])).read())
|
2017-08-03 14:50:46 +03:00
|
|
|
... for binfile in commit['binary_files']:
|
2018-01-09 14:06:09 +03:00
|
|
|
... print("######## file %s" % binfile['file_name'])
|
2017-08-03 14:50:46 +03:00
|
|
|
... if binfile['old_file'] is not None:
|
2018-01-09 14:06:09 +03:00
|
|
|
... print("######## old")
|
|
|
|
... print(open(path.join(outdir, binfile['old_file'])).read().encode('hex'))
|
2017-08-03 14:50:46 +03:00
|
|
|
... if binfile['new_file'] is not None:
|
2018-01-09 14:06:09 +03:00
|
|
|
... print("######## new")
|
|
|
|
... print(open(path.join(outdir, binfile['new_file'])).read().encode('hex'))
|
2017-08-03 14:50:46 +03:00
|
|
|
... 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
|
2018-03-28 14:16:56 +03:00
|
|
|
#### commit 9e6c8a14e241d3140575d17288d4a91bd8c9a3c8
|
2017-08-03 14:50:46 +03:00
|
|
|
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
|
2018-03-28 14:16:56 +03:00
|
|
|
61006200630a
|
2017-08-03 14:50:46 +03:00
|
|
|
######## file bin2
|
|
|
|
######## new
|
|
|
|
62000a
|
2018-03-28 14:16:56 +03:00
|
|
|
#### commit e3a67aeeade9ad9e292f1762f8f075a8322042b7
|
2017-08-03 14:50:46 +03:00
|
|
|
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
|
2018-03-28 14:16:56 +03:00
|
|
|
61006200630a
|
2017-08-03 14:50:46 +03:00
|
|
|
######## new
|
|
|
|
780a
|
|
|
|
######## file bin2
|
|
|
|
######## old
|
|
|
|
62000a
|
|
|
|
|