#
# patch "ChangeLog"
# from [7a1c3b6d8d553c35d9bd58c117fc8e582377768c]
# to [2f5f957c42f95a35bd776407af355130d1f32ba9]
#
# patch "automate.cc"
# from [e3bc754e30f0356b70c015dff6ee413a3969b5f3]
# to [a39a6df56427a12cf3e79ee2cd155e5239393560]
#
# patch "commands.cc"
# from [6536a5fec8f4c742203ff8b03081b958c2b44be3]
# to [a7f7b4207fe8aec6f9796646229e7d2ecc888d18]
#
# patch "monotone.texi"
# from [7eeb1754841491852c6101dddadee3d1435a85d6]
# to [383efd9fcf269d36a6519cea9645d7a674be4478]
#
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,9 @@
+2005-04-20 Sebastian Spaeth
+
+ * commands.cc:
+ * automate.cc: new command: automate ancestors
+ * monotone.texi: adapt documentation
+
2005-04-20 Nathaniel Smith
* tests/t_log_depth_single.at:
--- automate.cc
+++ automate.cc
@@ -63,6 +63,53 @@
output << (*i).inner()() << std::endl;
}
+// Name: ancestors
+// Arguments:
+// 1 or more: revision ids
+// Added in: 0.1
+// Purpose: Prints the ancestors (exclusive) of the given revisions
+// Output format: A list of revision ids, in hexadecimal, each followed by a
+// newline. Revision ids are printed in alphabetically sorted order.
+// Error conditions: If any of the revisions do not exist, prints nothing to
+// stdout, prints an error message to stderr, and exits with status 1.
+static void
+automate_ancestors(std::vector args,
+ std::string const & help_name,
+ app_state & app,
+ std::ostream & output)
+{
+ if (args.size() == 0)
+ throw usage(help_name);
+
+ std::set ancestors;
+ std::vector frontier;
+ for (std::vector::const_iterator i = args.begin(); i != args.end(); ++i)
+ {
+ revision_id rid((*i)());
+ N(app.db.revision_exists(rid), F("No such revision %s") % rid);
+ frontier.push_back(rid);
+ }
+ while (!frontier.empty())
+ {
+ revision_id rid = frontier.back();
+ frontier.pop_back();
+ std::set parents;
+ app.db.get_revision_parents(rid, ancestors);
+ for (std::set::const_iterator i = parents.begin();
+ i != parents.end(); ++i)
+ {
+ if (ancestors.find(*i) == ancestors.end())
+ {
+ frontier.push_back(*i);
+ ancestors.insert(*i);
+ }
+ }
+ }
+ for (std::set::const_iterator i = ancestors.begin();
+ i != ancestors.end(); ++i)
+ output << (*i).inner()() << std::endl;
+}
+
// Name: descendents
// Arguments:
// 1 or more: revision ids
@@ -110,6 +157,7 @@
output << (*i).inner()() << std::endl;
}
+
// Name: erase_ancestors
// Arguments:
// 0 or more: revision ids
@@ -261,6 +309,8 @@
automate_interface_version(args, root_cmd_name, app, output);
else if (cmd() == "heads")
automate_heads(args, root_cmd_name, app, output);
+ else if (cmd() == "ancestors")
+ automate_ancestors(args, root_cmd_name, app, output);
else if (cmd() == "descendents")
automate_descendents(args, root_cmd_name, app, output);
else if (cmd() == "erase_ancestors")
--- commands.cc
+++ commands.cc
@@ -3906,6 +3906,7 @@
CMD(automate, "automation",
"interface_version\n"
"heads [BRANCH]\n"
+ "ancestors REV1 [REV2 [REV3 [...]]]\n"
"descendents REV1 [REV2 [REV3 [...]]]\n"
"erase_ancestors [REV1 [REV2 [REV3 [...]]]]\n"
"toposort [REV1 [REV2 [REV3 [...]]]]\n"
--- monotone.texi
+++ monotone.texi
@@ -4293,6 +4293,47 @@
@end table
address@hidden monotone automate ancestors @var{rev1} address@hidden [...]]
+
address@hidden @strong
address@hidden Arguments:
+
+One or more revision ids, @var{rev1}, @var{rev2}, etc.
+
address@hidden Added in:
+
+0.1
+
address@hidden Purpose:
+
+Prints the ancestors of one or more revisions.
+
address@hidden Sample output:
+
address@hidden
+28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61
+75156724e0e2e3245838f356ec373c50fa469f1f
address@hidden verbatim
+
address@hidden Output format:
+
+Zero or more lines, each giving the id of one ancestor of the given
+revisions. Each line consists of a revision id, in hexadecimal,
+followed by a newline. The lines are printed in alphabetically sorted
+order.
+
+The output does not include @var{rev1}, @var{rev2}, etc., except if
address@hidden is itself an ancestor of @var{rev1}, then @var{rev2} will be
+included in the output.
+
address@hidden Error conditions:
+
+If any of the revisions do not exist, prints nothing to stdout, prints
+an error message to stderr, and exits with status 1.
+
address@hidden table
+
+
@item monotone automate descendents @var{rev1} address@hidden [...]]
@table @strong