#
# patch "ChangeLog"
# from [4c959afd1ed9add6bcdfe94c3a1254202485f3fe]
# to [121999fc08f8913be21aa8d8cb9dd06c80f71158]
#
# patch "commands.cc"
# from [dde1422d1313b53651309387092c5526749dac1a]
# to [8e9a7ef57dfbd12095ccd8581a3d41d8c93bf478]
#
# patch "commands.hh"
# from [f2f45ab20f37d33f52054ae343a0b1a099494a35]
# to [cce382e66cf7064f56e731f8e9a48fe8be62d71c]
#
# patch "database.cc"
# from [0a1542f214b0484670459195dac39b34ce961f27]
# to [2da6799d3dada5cd96d8ac78aaa4410546d080da]
#
# patch "database.hh"
# from [3a53260736a538a083b6bfeea95830663c3fccd7]
# to [cb12c936ded945b41b94a74c24ce6855e48780f7]
#
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,8 @@
+2005-04-17 Sebastian Spaeth
+
+ * commands.cc,database.cc: add 'db kill_rev_locally ' command
+ still missing: documentation and autotests. Otherwise seems ok.
+
2005-04-17 Richard Levitte
* transforms.cc: Remove tabs and make sure emacs doesn't add
--- commands.cc
+++ commands.cc
@@ -2453,7 +2453,7 @@
if (idx(args, 0)() == "execute")
app.db.debug(idx(args, 1)(), cout);
else if (idx(args, 0)() == "kill_rev_locally")
- app.db.delete_existing_revs_and_certs(idx(args, 1)());
+ kill_rev_locally(app,idx(args, 1)());
else if (idx(args, 0)() == "clear_epoch")
app.db.clear_epoch(cert_value(idx(args, 1)()));
else
@@ -2471,6 +2471,24 @@
throw usage(name);
}
+/// Deletes a revision from the local database
+/// This can be used to 'undo' a changed revision from a local database without
+/// leaving a trace.
+void kill_rev_locally(app_state& app, std::string const& id){
+ revision_id ident;
+ complete(app, id, ident);
+ N(app.db.revision_exists(ident),
+ F("no revision %s found in database") % ident);
+
+ //check that the revision does not have any children
+ set children;
+ app.db.get_revision_children(ident, children);
+ N(!children.size(),
+ F("revision %s already has children. We cannot kill it.") % ident);
+
+ app.db.delete_existing_rev_and_certs(ident);
+}
+
CMD(attr, "working copy", "set FILE ATTR VALUE\nget FILE [ATTR]",
"get or set file attributes")
{
--- commands.hh
+++ commands.hh
@@ -25,6 +25,7 @@
namespace commands {
void explain_usage(std::string const & cmd, std::ostream & out);
int process(app_state & app, std::string const & cmd, std::vector const & args);
+ void kill_rev_locally(app_state& app, std::string const & id);
typedef enum
{
sel_author,
--- database.cc
+++ database.cc
@@ -1468,18 +1468,22 @@
}
/// Deletes one revision from the local database.
-/// This can be used to 'undo' a changed revision from a local database without
-/// leaving a trace
+/// @see kill_rev_locally
void
-database::delete_existing_revs_and_certs(std::string const & rid){
+database::delete_existing_rev_and_certs(revision_id const & rid){
- //FIXME perform a completion here instead of blindly assigning
- revision_id ident = (revision_id)rid;
+ //check that the revision exists and doesn't have any children
+ I(revision_exists(rid));
+ set children;
+ get_revision_children(rid, children);
+ I(!children.size());
- N(revision_exists(ident),
- F("no revision %s found in database") % ident);
-
- cout << "This is a noop for now!!! It should delete rev: "<