#
# patch "ChangeLog"
# from [b04c6468f79f0dabe29efdade5dae1276e1ce6e1]
# to [52d31a8460434b6c239d2cdb4eddf8e56b31217f]
#
# patch "automate.cc"
# from [01d2a759958e74ea48078b2f337131e9ca4156e7]
# to [004901821667adc38fe25860366b855c46af630d]
#
# patch "commands.cc"
# from [61582d84558e7e68ba83c0f9d89e094667401d6c]
# to [53d4ec64d060ed8ba6d2d784a9d84f0e870708b4]
#
# patch "monotone.texi"
# from [9fa042b0e5ce6df153f037a5d9db40e8b1e556fe]
# to [960f09d94f2b0189794b11c523426f755ef48f1c]
#
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,12 @@
+2005-05-13 Timothy Brownawell
+
+ Add "monotone automate stdio", to let the automation interface
+ take commands on standard input.
+ * automate.cc: (automate_stdio) New function.
+ (automate_command) Add it.
+ * commands.cc: Add to description for "automate".
+ * monotone.texi: Add to documentation.
+
2005-05-13 Joel Reed
* tests/t_unidiff3.at: opps. forgot to add this file which
--- automate.cc
+++ automate.cc
@@ -791,6 +791,110 @@
automate_command(utf8 cmd, std::vector args,
std::string const & root_cmd_name,
app_state & app,
+ std::ostream & output);
+
+// Name: stdio
+// Arguments: none
+// Added in: 1.0
+// Purpose: Allow multiple automate commands to be run from one instance
+// of monotone.
+//
+// Input format: The input is a series of lines of the form
+// "command [args...]", where "command" is a valid "monotone automate"
+// subcommand. Example:
+// leaves
+// parents 1f4ef73c3e056883c6a5ff66728dd764557db5e6
+// inventory
+//
+// Output format: The output consists of the output of each command given,
+// preceeded by the line "###BEGIN ###" and followed by the line
+// "###END ###", where is the command given. Example:
+// ###BEGIN leaves###
+// bdff75b3d1a58d5370d1b9aaeed1b5a4d0cba564
+// ed0306ed417d258d82716bee36841199d8bb7626
+// ee0f35591c79c9390baff5e0638b545963d1babf
+// ###END leaves###
+// ###BEGIN parents###
+// 094a5075b4bd7fe379f810edeb5f03283b50e13a
+// ###END parents###
+// ###BEGIN inventory###
+// "work.cc"
+// "work.hh"
+// "xdelta.cc"
+// "xdelta.hh"
+// ###END inventory###
+//
+// Error conditions: If an invalid command line is recieved, prints
+// "###ERR usage###" to standard output, where is the name
+// of the command that was given.
+// If some other error condition occurrs during execution of a command
+// received on input, prints "###ERR msg ###", where
+// is the name of the command, and is the
+// error message provided by that command, which would have been output on
+// standard error if the command was invoked directly.
+// This "###ERR ###" line replaces the "###END ###" line.
+// Example:
+// (Input)
+// inventor
+// inventory
+// (Output)
+// ###BEGIN inventor###
+// ###ERR inventor usage###
+// ###BEGIN inventory###
+// ###ERR inventory msg misuse: working copy directory required but not found###
+//
+// Errors do not affect the return value.
+
+static void
+automate_stdio(std::vector args,
+ std::string const & help_name,
+ app_state & app,
+ std::ostream & output)
+{
+ if (args.size() != 0)
+ throw usage(help_name);
+ while(!std::cin.eof())
+ {
+ std::string x;
+ utf8 cmd;
+ args.clear();
+ bool first=true;
+ do
+ {
+ std::cin>>x;
+ if(first)
+ cmd=utf8(x);
+ else
+ args.push_back(utf8(x));
+ first=false;
+ }
+ while(!std::cin.eof()
+ && (std::cin.peek() != '\n')
+ && (std::cin.peek() != '\r'));
+ if(cmd() != "")
+ {
+ output<<(F("###BEGIN %s###") % cmd)< args,
+ std::string const & root_cmd_name,
+ app_state & app,
std::ostream & output)
{
if (cmd() == "interface_version")
@@ -821,6 +925,8 @@
automate_inventory(args, root_cmd_name, app, output);
else if (cmd() == "attributes")
automate_attributes(args, root_cmd_name, app, output);
+ else if (cmd() == "stdio")
+ automate_stdio(args, root_cmd_name, app, output);
else
throw usage(root_cmd_name);
}
--- commands.cc
+++ commands.cc
@@ -3612,7 +3612,8 @@
"toposort [REV1 [REV2 [REV3 [...]]]]\n"
"ancestry_difference NEW_REV [OLD_REV1 [OLD_REV2 [...]]]\n"
"leaves\n"
- "inventory",
+ "inventory\n"
+ "stdio\n",
"automation interface",
OPT_NONE)
{
--- monotone.texi
+++ monotone.texi
@@ -4898,6 +4898,83 @@
@end table
address@hidden monotone automate stdio
+
address@hidden @strong
address@hidden Arguments:
+
+none
+
address@hidden Added in:
+
+1.0
+
address@hidden Purpose:
+
+Allow multiple automate commands to be run from one instance of monotone.
+
address@hidden Sample input:
+
address@hidden
+leaves
+parents 1f4ef73c3e056883c6a5ff66728dd764557db5e6
+inventory
address@hidden verbatim
+
address@hidden Input format:
+
+The input is a series of lines of the form "command [args...]", where
+"command" is a valid "monotone automate" subcommand.
+
address@hidden Sample output:
+
address@hidden
+###BEGIN leaves###
+bdff75b3d1a58d5370d1b9aaeed1b5a4d0cba564
+ed0306ed417d258d82716bee36841199d8bb7626
+ee0f35591c79c9390baff5e0638b545963d1babf
+###END leaves###
+###BEGIN parents###
+094a5075b4bd7fe379f810edeb5f03283b50e13a
+###END parents###
+###BEGIN inventory###
+ "work.cc"
+ "work.hh"
+ "xdelta.cc"
+ "xdelta.hh"
+###END inventory###
address@hidden verbatim
+
address@hidden Output format:
+
+The output consists of the output of each command given, preceeded by
+the line "###BEGIN ###" and followed by the line
+"###END ###", where is the name of the command.
+If an error is encountered while running the command received, the
+"###END ###" line is replaced with one of the
+"###ERR name ###"lines shown below.
+
address@hidden Error conditions:
+
+If an invalid command line is recieved, prints "###ERR usage###"
+to standard output, where is the name of the command that was
+given. If some other error condition occurrs during execution of a command
+received on input, prints "###ERR msg ###", where
+ is the name of the command, and is the error message
+provided by that command, which would have been output on standard error
+if the command was invoked directly. Output with errors looks like:
+
address@hidden
+###BEGIN inventor###
+###ERR inventor usage###
+###BEGIN inventory###
+###ERR inventory msg misuse: working copy directory required but not found###
address@hidden verbatim
+
+Errors do not affect the return value.
+
address@hidden table
+
@end ftable
@page