monotone-commits-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-commits-diffs] net.venge.monotone: 0b2b933284c39df390c33af1cb3


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone: 0b2b933284c39df390c33af1cb322ae545039108
Date: Tue, 26 Jun 2012 11:36:30 +0200 (CEST)

revision:            0b2b933284c39df390c33af1cb322ae545039108
date:                2012-06-26T09:35:23
author:              address@hidden
branch:              net.venge.monotone
changelog:
* doc/monotone.texi (Using packets): transfer key first, get rev, file ids from 
test func/using_packets

* test/func/using_packets: New directory.

manifest:
format_version "1"

new_manifest [bc3d7058e6545d225cb33686dfdc9919bee13e8c]

old_revision [a4549e0dd9f2288465eb61bb885ceaaf07359776]

add_dir "test/func/using_packets"

add_file "test/func/using_packets/__driver__.lua"
 content [81b274b427a5b932c6c965dc0ce82ea31f22885c]

patch "doc/monotone.texi"
 from [fcb6bf46ff101899bad9b7500c75716a6bc278fc]
   to [ebe81dfcdba71897e9e5841f05005e7a69ee4702]
============================================================
--- doc/monotone.texi	fcb6bf46ff101899bad9b7500c75716a6bc278fc
+++ doc/monotone.texi	ebe81dfcdba71897e9e5841f05005e7a69ee4702
@@ -4378,7 +4378,10 @@ @section Using packets
 We will create two databases, A and B, then create a few revisions in
 A, and transfer part of them to B.
 
-First we initialize the databases:
+First we initialize the databases (we assume you have a key for
+commits already):
address@hidden see ../test/func/using_packets/__driver__.lua for implementation of
address@hidden this example; keep that up to date if changing this.
 
 @smallexample
 @group
@@ -4426,9 +4429,9 @@ @section Using packets
 @group
 $ cd ..
 $ mtn -d A automate select i: | mtn -d A automate toposort address@hidden
-a423db0ad651c74e41ab2529eca6f17513ccf714
-d14e89582ad9030e1eb62f563c8721be02ca0b65
-151f1fb125f19ebe11eb8bfe3a5798fcbea4e736
+2d0b9a10f73ce2445213506c2a0a81b8e910b923
+b2ae639e410e4970cab274a580e87d08adc87ee7
+299b021a6d426f2ff3b09fabcd165abe5d82f2b5
 @end group
 @end smallexample
 
@@ -4437,17 +4440,17 @@ @section Using packets
 
 @smallexample
 @group
-$ mtn -d A automate get_revision a423db0ad651c74e41ab2529eca6f17513ccf714
+$ mtn -d A automate get_revision 2d0b9a10f73ce2445213506c2a0a81b8e910b923
 format_version "1"
 
-new_manifest [b6dbdbbe0e7f41e44d9b72f9fe29b1f1a4f47f18]
+new_manifest [e93adafbcdcafc2fccc1188de73d0d96f8dd2818]
 
 old_revision []
 
 add_dir ""
 
 add_file "file"
- content [8714e0ef31edb00e33683f575274379955b3526c]
+ content [66b27417d37e024c46526c2f6d358a754fc552f3]
 @end group
 @end smallexample
 
@@ -4455,43 +4458,47 @@ @section Using packets
 We should transfer:
 
 @enumerate
address@hidden the key used to sign things
 @item The file data (fdata) and file deltas (fdeltas), if any
 @item The release data (rdata)
 @item The certs
 @end enumerate
 
-In that order. This is because certs make reference to release data, and release data
-makes reference to file data and file deltas.
+In that order. This is because certs make reference to revision data
+and keys, and revision data makes reference to file data and file
+deltas.
 
 @smallexample
 @group
-mtn -d A automate packet_for_fdata 8714e0ef31edb00e33683f575274379955b3526c > PACKETS
-mtn -d A automate packet_for_rdata a423db0ad651c74e41ab2529eca6f17513ccf714 >> PACKETS
-mtn -d A automate packets_for_certs a423db0ad651c74e41ab2529eca6f17513ccf714 >> PACKETS
-mtn -d B read < PACKETS
+mtn -d A pubkey johndoe@@domain.com > KEY_PACKETS
+mtn -d A automate packet_for_fdata 66b27417d37e024c46526c2f6d358a754fc552f3 > PACKETS
+mtn -d A automate packet_for_rdata 2d0b9a10f73ce2445213506c2a0a81b8e910b923 >> PACKETS
+mtn -d A automate packets_for_certs 2d0b9a10f73ce2445213506c2a0a81b8e910b923 >> PACKETS
+mtn -d B read KEY_PACKETS PACKETS
 @end group
 @end smallexample
 
-This revision (a423db0ad651c74e41ab2529eca6f17513ccf714) was already sent to database
-B. You may want to check the PACKETS file to see what the packets look like.
+Database B now contains revision
+2d0b9a10f73ce2445213506c2a0a81b8e910b923. You may want to check the
+PACKETS file to see what the packets look like.
 
 Now let's transfer one more revision:
 
 @smallexample
 @group
-mtn -d A automate get_revision d14e89582ad9030e1eb62f563c8721be02ca0b65
+mtn -d A automate get_revision b2ae639e410e4970cab274a580e87d08adc87ee7
 format_version "1"
 
-new_manifest [48a03530005d46ed9c31c8f83ad96c4fa22b8b28]
+new_manifest [a13f0659778955abbe84f5676d328382ca71008f]
 
-old_revision [a423db0ad651c74e41ab2529eca6f17513ccf714]
+old_revision [2d0b9a10f73ce2445213506c2a0a81b8e910b923]
 
 add_file "file2"
- content [d2178687226560032947c1deacb39d16a16ea5c6]
+ content [ca085d538b534aa2f1746ac9a61c6f1d279356a4]
 
 patch "file"
- from [8714e0ef31edb00e33683f575274379955b3526c]
-   to [8b52d96d4fab6c1e56d6364b0a2673f4111b228e]
+ from [66b27417d37e024c46526c2f6d358a754fc552f3]
+   to [491cd4818acc21cb6fb3f8fd5676633d60a6b973]
 @end group
 @end smallexample
 
@@ -4500,10 +4507,11 @@ @section Using packets
 
 @smallexample
 @group
-mtn -d A automate packet_for_fdata d2178687226560032947c1deacb39d16a16ea5c6 > PACKETS2
-mtn -d A automate packet_for_fdelta 8714e0ef31edb00e33683f575274379955b3526c 8b52d96d4fab6c1e56d6364b0a2673f4111b228e >> PACKETS2
-mtn -d A automate packet_for_rdata d14e89582ad9030e1eb62f563c8721be02ca0b65 >> PACKETS2
-mtn -d A automate packets_for_certs d14e89582ad9030e1eb62f563c8721be02ca0b65 >> PACKETS2
+mtn -d A automate packet_for_fdata ca085d538b534aa2f1746ac9a61c6f1d279356a4 > PACKETS2
+mtn -d A automate packet_for_fdelta
+66b27417d37e024c46526c2f6d358a754fc552f3 491cd4818acc21cb6fb3f8fd5676633d60a6b973 >> PACKETS2
+mtn -d A automate packet_for_rdata b2ae639e410e4970cab274a580e87d08adc87ee7 >> PACKETS2
+mtn -d A automate packets_for_certs b2ae639e410e4970cab274a580e87d08adc87ee7 >> PACKETS2
 mtn -d B read < PACKETS2
 @end group
 @end smallexample
@@ -4514,34 +4522,26 @@ @section Using packets
 @smallexample
 @group
 $ mtn -d A automate select i: | mtn -d A automate toposort address@hidden
-a423db0ad651c74e41ab2529eca6f17513ccf714
-d14e89582ad9030e1eb62f563c8721be02ca0b65
-151f1fb125f19ebe11eb8bfe3a5798fcbea4e736
+2d0b9a10f73ce2445213506c2a0a81b8e910b923
+b2ae639e410e4970cab274a580e87d08adc87ee7
+299b021a6d426f2ff3b09fabcd165abe5d82f2b5
 
 $ mtn -d B automate select i: | mtn -d B automate toposort address@hidden
-a423db0ad651c74e41ab2529eca6f17513ccf714
-d14e89582ad9030e1eb62f563c8721be02ca0b65
+2d0b9a10f73ce2445213506c2a0a81b8e910b923
+b2ae639e410e4970cab274a580e87d08adc87ee7
 @end group
 @end smallexample
 
-Good! B has the two first revisions (as expected), and A has all three. However, a checkout
-of that branch on B will not work, because the certificate signatures cannot be verified.
-We need to transfer the signatures too (suppose the key used had the ID @code{"johndoe@@domain.com"}):
+Good! B has the two first revisions (as expected), and A has all
+three. We can checkout from B:
 
 @smallexample
 @group
-mtn -d A pubkey johndoe@@domain.com > KEY_PACKETS
-mtn -d B read < KEY_PACKETS
address@hidden group
address@hidden smallexample
-
-Done.
-
address@hidden
address@hidden
 $ mtn -d B co -b test test-B
 $ ls test-B
-file2  _MTN  x
+file file2  _MTN
+$ more test-B/file
+ERASE
 $ more test-B/file2
 file 2 getting in
 @end group
============================================================
--- /dev/null	
+++ test/func/using_packets/__driver__.lua	81b274b427a5b932c6c965dc0ce82ea31f22885c
@@ -0,0 +1,107 @@
+-- Test for "Using packets" example in manual; also issue 185
+
+-- We need two databases A and B, and one workspace '.'.
+
+function mtnA(...)
+  return mtn("--db=A.db", ...)
+end
+
+function mtnB(...)
+  return mtn("--db=B.db", ...)
+end
+
+-- initialize the databases, setup the workspace
+
+-- copied from ../../func-testsuite.lua mtn_setup
+check(getstd("test_keys"))
+check(getstd("test_hooks.lua"))
+check(getstd("min_hooks.lua"))
+
+check(mtnA("db", "init"), 0, false, false)
+check(mtnB("db", "init"), 0, false, false)
+
+check(mtnA("read", "test_keys"), 0, false, false)
+remove("test_keys")
+
+check(mtnA("setup", "--branch=test", "."), 0, false, false)
+
+-- add revisions to A
+
+writefile("file", "xyz")
+check(mtnA("add", "file"), 0, nil, false)
+check(mtnA("commit", "-m", "One"), 0, nil, false)
+rev_one = base_revision()
+
+writefile("file2", "file 2 getting in")
+writefile("file", "ERASE")
+check(mtnA("add", "file2"), 0, nil, false)
+check(mtnA("commit", "-m", "Two"), 0, nil, false)
+rev_two = base_revision()
+
+writefile("file", "THIRD")
+check(mtnA("commit", "-m", "Three"), 0, nil, false)
+rev_three = base_revision()
+
+-- There's no easy way to pipe the output of one mtn cmd to another
+-- here, so we skip the toposort.
+check(mtnA("automate", "select", "i:"), 0, true, nil)
+check(samelines("stdout", {rev_three, rev_one, rev_two}))
+-- show the rev ids, so we can copy them into monotone.texi
+check(samelines("stdout",
+{"299b021a6d426f2ff3b09fabcd165abe5d82f2b5", -- rev_three
+ "2d0b9a10f73ce2445213506c2a0a81b8e910b923", -- rev_one
+ "b2ae639e410e4970cab274a580e87d08adc87ee7"})) -- rev_two
+
+-- Transfer rev_one to db B
+-- first, get the file id
+file_id_one = "66b27417d37e024c46526c2f6d358a754fc552f3"
+check(mtnA("automate", "get_revision", rev_one), 0, true, nil)
+check(qgrep(file_id_one, "stdout"))
+
+-- we don't have Lua functions to add lines to files, so we create
+-- several packet files.
+
+check(mtnA("pubkey", "address@hidden"), 0, true, nil)
+rename("stdout", "KEY_PACKETS")
+
+check(mtnA("automate", "packet_for_fdata", file_id_one), 0, true, nil)
+rename("stdout", "PACKET1")
+
+check(mtnA("automate", "packet_for_rdata", rev_one), 0, true, nil)
+rename("stdout", "PACKET2")
+
+check(mtnA("automate", "packets_for_certs", rev_one), 0, true, nil)
+rename("stdout", "PACKET3")
+
+check(mtnB("read", "KEY_PACKETS", "PACKET1", "PACKET2", "PACKET3"), 0, nil, false)
+
+-- Now transfer rev_two
+file_id_two = "491cd4818acc21cb6fb3f8fd5676633d60a6b973"
+file2_id_two = "ca085d538b534aa2f1746ac9a61c6f1d279356a4"
+check(mtnA("automate", "get_revision", rev_two), 0, true, nil)
+check(qgrep(file_id_two, "stdout"))
+check(qgrep(file2_id_two, "stdout"))
+
+check(mtnA("automate", "packet_for_fdata", file2_id_two), 0, true, nil)
+rename("stdout", "PACKET1")
+
+check(mtnA("automate", "packet_for_fdelta", file_id_one, file_id_two), 0, true, nil)
+rename("stdout", "PACKET2")
+
+check(mtnA("automate", "packet_for_rdata", rev_two), 0, true, nil)
+rename("stdout", "PACKET3")
+
+check(mtnA("automate", "packets_for_certs", rev_two), 0, true, nil)
+rename("stdout", "PACKET4")
+
+check(mtnB("read", "PACKET1", "PACKET2", "PACKET3", "PACKET4"), 0, nil, false)
+
+--  Compare checkout of rev_two from db A to rev_two from db B
+check(mtnA("update", "-r", rev_two), 0, nil, false)
+
+check(mtnB("checkout", "--branch", "test", "test-B"), 0, nil, false)
+
+check(samefile("file", "test-b/file"))
+check(samefile("file2", "test-b/file2"))
+
+-- end of file

reply via email to

[Prev in Thread] Current Thread [Next in Thread]