# # add_file "tests/t_read_from_file.at" # # patch "ChangeLog" # from [3c6943c2be22765877d58898ebe23f16a8afc0dc] # to [582662f010ba6296805e042d56073dee74f2157d] # # patch "commands.cc" # from [e87259761fc59458df0deaab4c322cb9e6f5b549] # to [2ecf17e9af453dfeefb1373b837142e57a3479a7] # # patch "monotone.1" # from [13b293fa383be617acadc13c07e4fa813ac01689] # to [e555ecf47d53884594f8fd6c5ea0fb12afc5a1c8] # # patch "monotone.texi" # from [15985641e4896b703d700a1618478a0f63cbbf4f] # to [3abc599a9ba2f2739baafe5c4b147f7253488761] # # patch "tests/t_read_from_file.at" # from [] # to [0608337d7a71893cbcfa3befad75d4cbf207cfb2] # # patch "testsuite.at" # from [741ef98aae7baf028209c07c9ea530a35c34b919] # to [6793ac5be3d28a0c6c3f1d3c616dc38ae01db618] # ======================================================================== --- ChangeLog 3c6943c2be22765877d58898ebe23f16a8afc0dc +++ ChangeLog 582662f010ba6296805e042d56073dee74f2157d @@ -1,5 +1,13 @@ 2005-08-26 Nathaniel Smith + * commands.cc (read): Optionally take files on command line. + * tests/t_read_from_file.at, testsuite.at: New test. + * monotone.texi (Network Service): Show Jim using this. + (Packet I/O, Commands): Document. + * monotone.1: Likewise. + +2005-08-26 Nathaniel Smith + * change_set.cc (move_files_from_tmp_top_down): Typo again. 2005-08-26 Nathaniel Smith ======================================================================== --- commands.cc e87259761fc59458df0deaab4c322cb9e6f5b549 +++ commands.cc 2ecf17e9af453dfeefb1373b837142e57a3479a7 @@ -1908,12 +1908,30 @@ } -CMD(read, N_("packet i/o"), "", N_("read packets from stdin"), +CMD(read, N_("packet i/o"), "[FILE1 [FILE2 [...]]]", + N_("read packets from files or stdin"), OPT_NONE) { packet_db_writer dbw(app, true); - size_t count = read_packets(cin, dbw); - N(count != 0, F("no packets found on stdin")); + size_t count = 0; + if (args.empty()) + { + count += read_packets(cin, dbw); + N(count != 0, F("no packets found on stdin")); + } + else + { + for (std::vector::const_iterator i = args.begin(); i != args.end(); ++i) + { + data dat; + read_data(system_path(*i), dat); + istringstream ss(dat()); + count += read_packets(ss, dbw); + } + N(count != 0, FP("no packets found in given file", + "no packets found in given files", + args.size())); + } P(FP("read %d packet", "read %d packets", count) % count); } ======================================================================== --- monotone.1 13b293fa383be617acadc13c07e4fa813ac01689 +++ monotone.1 e555ecf47d53884594f8fd6c5ea0fb12afc5a1c8 @@ -101,8 +101,8 @@ \fBpubkey\fP \fI\fP Write public key packet to stdout. .TP -\fBread\fP -Read packets from stdin. +\fBread\fP \fI[ [ [...]]]\fP +Read packets from files or stdin. .TP \fBcvs_import\fP \fI/\fP Import all versions in CVS module. Reconstructs revisions and converts ======================================================================== --- monotone.texi 15985641e4896b703d700a1618478a0f63cbbf4f +++ monotone.texi 3abc599a9ba2f2739baafe5c4b147f7253488761 @@ -1602,10 +1602,8 @@ @smallexample @group -$ monotone --db=~/jim.db read <~/abe.pubkey -monotone: read 1 packet -$ monotone --db=~/jim.db read <~/beth.pubkey -monotone: read 1 packet +$ monotone --db=~/jim.db read ~/abe.pubkey ~/beth.pubkey +monotone: read 2 packets @end group @end smallexample @@ -4198,9 +4196,10 @@ @item monotone read address@hidden monotone read @var{file1} @var{file2...} -This command reads packets from @code{stdin} and applies them to your -database. +This command reads packets from files or @code{stdin} and stores them +in your database. @end ftable @@ -6737,10 +6736,8 @@ Write public key packet to stdout. @comment TROFF INPUT: .TP address@hidden @b{read} -Read packets from stdin. It is very important to @b{only read keys -from trusted sources}; all other trust relationships are built out of -the trust assigned to keys. address@hidden @b{read} @i{[ [ [...]]]} +Read packets from files or stdin. @comment TROFF INPUT: .TP @item @b{cvs_import} @i{/} ======================================================================== --- tests/t_read_from_file.at +++ tests/t_read_from_file.at 0608337d7a71893cbcfa3befad75d4cbf207cfb2 @@ -0,0 +1,14 @@ +AT_SETUP([monotone read FILE]) +MONOTONE_SETUP + +AT_CHECK(MONOTONE db init --db foo.db, [], [ignore], [ignore]) +AT_CHECK((echo 'foo'; echo 'foo') | MONOTONE --db foo.db genkey foo, [], [ignore], [ignore]) + +AT_CHECK(MONOTONE --db foo.db pubkey foo >foo.keyfile, [], [ignore], [ignore]) +AT_CHECK(MONOTONE read nonexistent, [1], [ignore], [ignore]) +AT_CHECK(MONOTONE read foo.keyfile, [], [ignore], [ignore]) + +AT_CHECK(MONOTONE ls keys, [], [stdout], [ignore]) +AT_CHECK(QGREP(foo stdout), []) + +AT_CLEANUP ======================================================================== --- testsuite.at 741ef98aae7baf028209c07c9ea530a35c34b919 +++ testsuite.at 6793ac5be3d28a0c6c3f1d3c616dc38ae01db618 @@ -696,3 +696,4 @@ m4_include(tests/t_explicit_merge_with_anc.at) m4_include(tests/t_drop_execute.at) m4_include(tests/t_rename_execute.at) +m4_include(tests/t_read_from_file.at)