]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- work on dbus interface
authorArvin Schnell <aschnell@suse.de>
Mon, 16 Jul 2012 12:17:47 +0000 (14:17 +0200)
committerArvin Schnell <aschnell@suse.de>
Mon, 16 Jul 2012 12:17:47 +0000 (14:17 +0200)
12 files changed:
client/commands.cc
client/commands.h
client/snapper.cc
client/types.cc
client/types.h
server/Types.cc
server/Types.h
server/snapperd.cc
snapper/Comparison.cc
snapper/Comparison.h
snapper/File.cc
snapper/File.h

index ce82ed90dc2c5c9742d76956401dc938ace9760f..99df195e10c5c571a60c17c320f824742b1cd1f5 100644 (file)
@@ -72,7 +72,7 @@ command_create_xconfig(DBus::Connection& conn, const string& config_name, const
     DBus::Hoho hoho(call);
     hoho << config_name << subvolume << fstype << template_name;
 
-    DBus::Message reply = conn.send_and_reply_and_block(call);
+    conn.send_and_reply_and_block(call);
 }
 
 
@@ -84,7 +84,7 @@ command_delete_xconfig(DBus::Connection& conn, const string& config_name)
     DBus::Hoho hoho(call);
     hoho << config_name;
 
-    DBus::Message reply = conn.send_and_reply_and_block(call);
+    conn.send_and_reply_and_block(call);
 }
 
 
@@ -135,7 +135,7 @@ command_set_xsnapshot(DBus::Connection& conn, const string& config_name, unsigne
     DBus::Hoho hoho(call);
     hoho << config_name << num << data.description << data.cleanup << data.userdata;
 
-    DBus::Message reply = conn.send_and_reply_and_block(call);
+    conn.send_and_reply_and_block(call);
 }
 
 
@@ -211,7 +211,7 @@ command_delete_xsnapshots(DBus::Connection& conn, const string& config_name,
     DBus::Hoho hoho(call);
     hoho << config_name << nums;
 
-    DBus::Message reply = conn.send_and_reply_and_block(call);
+    conn.send_and_reply_and_block(call);
 }
 
 
@@ -224,7 +224,7 @@ command_mount_xsnapshots(DBus::Connection& conn, const string& config_name,
     DBus::Hoho hoho(call);
     hoho << config_name << num;
 
-    DBus::Message reply = conn.send_and_reply_and_block(call);
+    conn.send_and_reply_and_block(call);
 }
 
 
@@ -237,7 +237,7 @@ command_umount_xsnapshots(DBus::Connection& conn, const string& config_name,
     DBus::Hoho hoho(call);
     hoho << config_name << num;
 
-    DBus::Message reply = conn.send_and_reply_and_block(call);
+    conn.send_and_reply_and_block(call);
 }
 
 
@@ -250,7 +250,7 @@ command_create_xcomparison(DBus::Connection& conn, const string& config_name, un
     DBus::Hoho hoho(call);
     hoho << config_name << number1 << number2;
 
-    DBus::Message reply = conn.send_and_reply_and_block(call);
+    conn.send_and_reply_and_block(call);
 }
 
 
@@ -303,7 +303,7 @@ command_set_xundo(DBus::Connection& conn, const string& config_name, unsigned in
     DBus::Hoho hoho(call);
     hoho << config_name << number1 << number2 << undos;
 
-    DBus::Message reply = conn.send_and_reply_and_block(call);
+    conn.send_and_reply_and_block(call);
 }
 
 
@@ -316,38 +316,45 @@ command_set_xundo_all(DBus::Connection& conn, const string& config_name, unsigne
     DBus::Hoho hoho(call);
     hoho << config_name << number1 << number2 << undo;
 
-    DBus::Message reply = conn.send_and_reply_and_block(call);
+    conn.send_and_reply_and_block(call);
 }
 
 
-XUndoStatistic
-command_get_xundostatistic(DBus::Connection& conn, const string& config_name, unsigned int number1,
-                          unsigned int number2)
+vector<XUndoStep>
+command_get_xundo_steps(DBus::Connection& conn, const string& config_name, unsigned int number1,
+                       unsigned int number2)
 {
-    DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "GetUndoStatistic");
+    DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "GetUndoSteps");
 
     DBus::Hoho hoho(call);
     hoho << config_name << number1 << number2;
 
     DBus::Message reply = conn.send_and_reply_and_block(call);
 
-    XUndoStatistic ret;
+    vector<XUndoStep> undo_steps;
 
     DBus::Hihi hihi(reply);
-    hihi >> ret.numCreate >> ret.numModify >> ret.numDelete;
+    hihi >> undo_steps;
 
-    return ret;
+    return undo_steps;
 }
 
 
-void
-command_xundo_changes(DBus::Connection& conn, const string& config_name, unsigned int number1,
-                     unsigned int number2)
+bool
+command_do_xundo_step(DBus::Connection& conn, const string& config_name, unsigned int number1,
+                     unsigned int number2, const XUndoStep& undo_step)
 {
-    DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "UndoChanges");
+    DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "DoUndoStep");
 
     DBus::Hoho hoho(call);
-    hoho << config_name << number1 << number2;
+    hoho << config_name << number1 << number2 << undo_step;
 
     DBus::Message reply = conn.send_and_reply_and_block(call);
+
+    bool ret;
+
+    DBus::Hihi hihi(reply);
+    hihi >> ret;
+
+    return ret;
 }
index 5e8e5147d58a35d6f269d67a164591b62073a981..0a0b75b5968b75bc6d92911ca8ef4d87dc646f72 100644 (file)
@@ -103,10 +103,10 @@ void
 command_set_xundo_all(DBus::Connection& conn, const string& config_name, unsigned int number1,
                      unsigned int number2, bool undo);
 
-XUndoStatistic
-command_get_xundostatistic(DBus::Connection& conn, const string& config_name, unsigned int number1,
-                          unsigned int number2);
+vector<XUndoStep>
+command_get_xundo_steps(DBus::Connection& conn, const string& config_name, unsigned int number1,
+                       unsigned int number2);
 
-void
-command_xundo_changes(DBus::Connection& conn, const string& config_name, unsigned int number1,
-                     unsigned int number2);
+bool
+command_do_xundo_step(DBus::Connection& conn, const string& config_name, unsigned int number1,
+                     unsigned int number2, const XUndoStep& undo_step);
index 2163cf92c1d734d8edbe98737c66d666d7589195..6b94633a273bd080c48fd7e37c65c3c12c04580d 100644 (file)
@@ -923,17 +923,66 @@ command_undo(DBus::Connection& conn)
        }
     }
 
-    XUndoStatistic s = command_get_xundostatistic(conn, config_name, nums.first, nums.second);
+    vector<XUndoStep> undo_steps = command_get_xundo_steps(conn, config_name, nums.first, nums.second);
 
-    if (s.empty())
+    int numCreate = 0;
+    int numModify = 0;
+    int numDelete = 0;
+
+    for (vector<XUndoStep>::const_iterator it = undo_steps.begin(); it != undo_steps.end(); ++it)
+    {
+       switch (it->action)
+       {
+           case CREATE: numCreate++; break;
+           case MODIFY: numModify++; break;
+           case DELETE: numDelete++; break;
+       }
+    }
+
+    if (numCreate == 0 && numModify == 0 && numDelete == 0)
     {
        cout << _("nothing to do") << endl;
        return;
     }
 
-    cout << sformat(_("create:%d modify:%d delete:%d"), s.numCreate, s.numModify, s.numDelete) << endl;
+    cout << sformat(_("create:%d modify:%d delete:%d"), numCreate, numModify, numDelete) << endl;
+
+    XConfigInfo ci = command_get_xconfig(conn, config_name);
 
-    command_xundo_changes(conn, config_name, nums.first, nums.second);
+    for (vector<XUndoStep>::const_iterator it = undo_steps.begin(); it != undo_steps.end(); ++it)
+    {
+       if (verbose)
+       {
+           switch (it->action)
+           {
+               case CREATE:
+                   cout << sformat(_("creating %s"), add_subvolume(ci.subvolume, it->name).c_str()) << endl;
+                   break;
+               case MODIFY:
+                   cout << sformat(_("modifying %s"), add_subvolume(ci.subvolume, it->name).c_str()) << endl;
+                   break;
+               case DELETE:
+                   cout << sformat(_("deleting %s"), add_subvolume(ci.subvolume, it->name).c_str()) << endl;
+                   break;
+           }
+       }
+
+       if (!command_do_xundo_step(conn, config_name, nums.first, nums.second, *it))
+       {
+           switch (it->action)
+           {
+               case CREATE:
+                   cout << sformat(_("failed to create %s"), add_subvolume(ci.subvolume, it->name).c_str()) << endl;
+                   break;
+               case MODIFY:
+                   cout << sformat(_("failed to modify %s"), add_subvolume(ci.subvolume, it->name).c_str()) << endl;
+                   break;
+               case DELETE:
+                   cout << sformat(_("failed to delete %s"), add_subvolume(ci.subvolume, it->name).c_str()) << endl;
+                   break;
+           }
+       }
+    }
 }
 
 
index d3e544c4034931dd42f9e50b299131e6a2e73c3a..465421b1e937122de2899083997fd8e993eaa3eb 100644 (file)
@@ -57,19 +57,13 @@ XSnapshots::findPost(const_iterator pre) const
 }
 
 
-bool
-XUndoStatistic::empty() const
-{
-    return numCreate == 0 && numModify == 0 && numDelete == 0;
-}
-
-
 namespace DBus
 {
     const char* TypeInfo<XConfigInfo>::signature = "(ssa{ss})";
     const char* TypeInfo<XSnapshot>::signature = "(uquussa{ss})";
     const char* TypeInfo<XFile>::signature = "(ssb)";
     const char* TypeInfo<XUndo>::signature = "(sb)";
+    const char* TypeInfo<XUndoStep>::signature = "(sq)";
 
 
     Hihi&
@@ -130,4 +124,25 @@ namespace DBus
        return hoho;
     }
 
+
+    Hihi&
+    operator>>(Hihi& hihi, XUndoStep& data)
+    {
+       hihi.open_recurse();
+       dbus_uint16_t tmp;
+       hihi >> data.name >> tmp;
+       data.action = static_cast<Action>(tmp);
+       hihi.close_recurse();
+       return hihi;
+    }
+
+
+    Hoho&
+    operator<<(Hoho& hoho, const XUndoStep& data)
+    {
+       hoho.open_struct();
+       hoho << data.name << static_cast<dbus_uint16_t>(data.action);
+       hoho.close_struct();
+       return hoho;
+    }
 }
index 7975b4581e846e5796eee8aff15a10fb459bb800..033626f77ee870b647a16bf9803972142288759d 100644 (file)
@@ -31,6 +31,7 @@ using std::map;
 #include "dbus/DBusConnection.h"
 #include "dbus/DBusMessage.h"
 #include "snapper/Snapshot.h"
+#include "snapper/File.h"
 
 using namespace snapper;
 
@@ -101,13 +102,10 @@ struct XUndo
 };
 
 
-struct XUndoStatistic
+struct XUndoStep
 {
-    bool empty() const;
-
-    unsigned int numCreate;
-    unsigned int numModify;
-    unsigned int numDelete;
+    string name;
+    Action action;
 };
 
 
@@ -118,6 +116,7 @@ namespace DBus
     template <> struct TypeInfo<XConfigInfo> { static const char* signature; };
     template <> struct TypeInfo<XFile> { static const char* signature; };
     template <> struct TypeInfo<XUndo> { static const char* signature; };
+    template <> struct TypeInfo<XUndoStep> { static const char* signature; };
 
     Hihi& operator>>(Hihi& hihi, XConfigInfo& data);
 
@@ -130,5 +129,8 @@ namespace DBus
 
     Hoho& operator<<(Hoho& hoho, const XUndo& data);
 
+    Hihi& operator>>(Hihi& hihi, XUndoStep& data);
+    Hoho& operator<<(Hoho& hoho, const XUndoStep& data);
+
 };
 
index 9bb62d8258d03b57a6b4460b528bd240a9e7b2d1..3611f34728ffb5d9ffcedc10997df85f64523dae 100644 (file)
@@ -29,6 +29,7 @@ namespace DBus
     const char* TypeInfo<Snapshot>::signature = "(uquussa{ss})";
     const char* TypeInfo<File>::signature = "(ssb)";
     const char* TypeInfo<Undo>::signature = "(sb)";
+    const char* TypeInfo<UndoStep>::signature = "(sq)";
 
 
     Hoho&
@@ -121,5 +122,27 @@ namespace DBus
        return hoho;
     }
 
+
+    Hihi&
+    operator>>(Hihi& hihi, UndoStep& data)
+    {
+       hihi.open_recurse();
+       dbus_uint16_t tmp;
+       hihi >> data.name >> tmp;
+       data.action = static_cast<Action>(tmp);
+       hihi.close_recurse();
+       return hihi;
+    }
+
+
+    Hoho&
+    operator<<(Hoho& hoho, const UndoStep& data)
+    {
+       hoho.open_struct();
+       hoho << data.name << static_cast<dbus_uint16_t>(data.action);
+       hoho.close_struct();
+       return hoho;
+    }
+
 }
 
index 735716d1ef558deeb15da656da68582d0fce4cbb..3677c6a9f5f8048ea3f871c3aa049c657482f110 100644 (file)
@@ -57,6 +57,7 @@ namespace DBus
     template <> struct TypeInfo<Snapshot> { static const char* signature; };
     template <> struct TypeInfo<File> { static const char* signature; };
     template <> struct TypeInfo<Undo> { static const char* signature; };
+    template <> struct TypeInfo<UndoStep> { static const char* signature; };
 
     Hoho& operator<<(Hoho& hoho, const ConfigInfo& data);
 
@@ -74,4 +75,7 @@ namespace DBus
     Hihi& operator>>(Hihi& hihi, Undo& data);
     Hoho& operator<<(Hoho& hoho, const Undo& data);
 
+    Hihi& operator>>(Hihi& hihi, UndoStep& data);
+    Hoho& operator<<(Hoho& hoho, const UndoStep& data);
+
 };
index 01c02f4addc7aac408e9bce20c84ea98e081f787..b8f4346cf178298b6587a93439316ab869f72213 100644 (file)
@@ -202,19 +202,18 @@ reply_to_introspect(DBus::Connection& conn, DBus::Message& msg)
        "      <arg name='undo' type='b' direction='in'/>\n"
        "    </method>\n"
 
-       "    <method name='GetUndoStatistic'>\n"
+       "    <method name='GetUndoSteps'>\n"
        "      <arg name='config-name' type='s' direction='in'/>\n"
        "      <arg name='number1' type='u' direction='in'/>\n"
        "      <arg name='number2' type='u' direction='in'/>\n"
-       "      <arg name='number-create' type='u' direction='out'/>\n"
-       "      <arg name='number-modify' type='u' direction='out'/>\n"
-       "      <arg name='number-delete' type='u' direction='out'/>\n"
+       "      <arg name='undo-steps' type='a(sq)' direction='out'/>\n"
        "    </method>\n"
 
-       "    <method name='UndoChanges'>\n"
+       "    <method name='DoUndoStep'>\n"
        "      <arg name='config-name' type='s' direction='in'/>\n"
        "      <arg name='number1' type='u' direction='in'/>\n"
        "      <arg name='number2' type='u' direction='in'/>\n"
+       "      <arg name='undo-step' type='(sq)' direction='in'/>\n"
        "    </method>\n"
 
        "  </interface>\n"
@@ -780,6 +779,9 @@ reply_to_command_umount_snapshot(DBus::Connection& conn, DBus::Message& msg)
 
 struct Comparing : public Job
 {
+    Comparing(Comparison* comparison)
+       : comparison(comparison) {}
+
     DBus::Connection* conn;
     DBus::MessageMethodReturn* reply;
 
@@ -819,10 +821,9 @@ reply_to_command_create_comparison(DBus::Connection& conn, DBus::Message& msg)
     assert(it != clients.end());
     it->comparisons.push_back(comparison);
 
-    Comparing* job = new Comparing;
+    Comparing* job = new Comparing(comparison);
     job->conn = &conn;
     job->reply = new DBus::MessageMethodReturn(msg);
-    job->comparison = comparison;
 
     jobs.add(job);
 }
@@ -842,7 +843,6 @@ Comparing::operator()()
 void
 Comparing::done()
 {
-    DBus::Hoho hoho(*reply);
     conn->send(*reply);
 
     delete reply;
@@ -995,7 +995,7 @@ reply_to_command_set_undo_all(DBus::Connection& conn, DBus::Message& msg)
 
 
 void
-reply_to_command_get_undo_statistics(DBus::Connection& conn, DBus::Message& msg)
+reply_to_command_get_undo_steps(DBus::Connection& conn, DBus::Message& msg)
 {
     string config_name;
     dbus_uint32_t num1, num2;
@@ -1003,7 +1003,7 @@ reply_to_command_get_undo_statistics(DBus::Connection& conn, DBus::Message& msg)
     DBus::Hihi hihi(msg);
     hihi >> config_name >> num1 >> num2;
 
-    y2mil("GetUndoStatistic config_name:" << config_name << " num1:" << num1 << " num2:" <<
+    y2mil("GetUndoSteps config_name:" << config_name << " num1:" << num1 << " num2:" <<
          num2);
 
     check_permission(conn, msg, config_name);
@@ -1015,12 +1015,12 @@ reply_to_command_get_undo_statistics(DBus::Connection& conn, DBus::Message& msg)
 
     Comparison* comparison = it->find_comparison(config_name, num1, num2);
 
-    UndoStatistic statistic = comparison->getUndoStatistic();
+    vector<UndoStep> undo_steps = comparison->getUndoSteps();
 
     DBus::MessageMethodReturn reply(msg);
 
     DBus::Hoho hoho(reply);
-    hoho << statistic.numCreate << statistic.numModify << statistic.numDelete;
+    hoho << undo_steps;
 
     conn.send(reply);
 }
@@ -1028,10 +1028,14 @@ reply_to_command_get_undo_statistics(DBus::Connection& conn, DBus::Message& msg)
 
 struct Undoing : public Job
 {
+    Undoing(Comparison* comparison, const UndoStep& undo_step)
+       : comparison(comparison), undo_step(undo_step) {}
+
     DBus::Connection* conn;
     DBus::MessageMethodReturn* reply;
 
     Comparison* comparison;
+    UndoStep undo_step;
 
     void done();
 
@@ -1043,15 +1047,16 @@ protected:
 
 
 void
-reply_to_command_undo_changes(DBus::Connection& conn, DBus::Message& msg)
+reply_to_command_do_undo_step(DBus::Connection& conn, DBus::Message& msg)
 {
     string config_name;
     dbus_uint32_t num1, num2;
+    UndoStep undo_step("", MODIFY);
 
     DBus::Hihi hihi(msg);
-    hihi >> config_name >> num1 >> num2;
+    hihi >> config_name >> num1 >> num2 >> undo_step;
 
-    y2mil("UndoChanges config_name:" << config_name << " num1:" << num1 << " num2:" <<
+    y2mil("GetUndoSteps config_name:" << config_name << " num1:" << num1 << " num2:" <<
          num2);
 
     check_permission(conn, msg, config_name);
@@ -1063,10 +1068,9 @@ reply_to_command_undo_changes(DBus::Connection& conn, DBus::Message& msg)
 
     Comparison* comparison = it->find_comparison(config_name, num1, num2);
 
-    Undoing* job = new Undoing;
+    Undoing* job = new Undoing(comparison, undo_step);
     job->conn = &conn;
     job->reply = new DBus::MessageMethodReturn(msg);
-    job->comparison = comparison;
 
     jobs.add(job);
 }
@@ -1077,7 +1081,10 @@ Undoing::operator()()
 {
     boost::this_thread::sleep(seconds(2));
 
-    comparison->doUndo();
+    bool ret = comparison->doUndoStep(undo_step);
+
+    DBus::Hoho hoho(*reply);
+    hoho << ret;
 
     boost::this_thread::sleep(seconds(2));
 }
@@ -1086,7 +1093,6 @@ Undoing::operator()()
 void
 Undoing::done()
 {
-    DBus::Hoho hoho(*reply);
     conn->send(*reply);
 
     delete reply;
@@ -1199,10 +1205,10 @@ dispatch(DBus::Connection& conn, DBus::Message& msg)
            reply_to_command_set_undo(conn, msg);
        else if (msg.is_method_call(INTERFACE, "SetUndoAll"))
            reply_to_command_set_undo_all(conn, msg);
-       else if (msg.is_method_call(INTERFACE, "GetUndoStatistic"))
-           reply_to_command_get_undo_statistics(conn, msg);
-       else if (msg.is_method_call(INTERFACE, "UndoChanges"))
-           reply_to_command_undo_changes(conn, msg);
+       else if (msg.is_method_call(INTERFACE, "GetUndoSteps"))
+           reply_to_command_get_undo_steps(conn, msg);
+       else if (msg.is_method_call(INTERFACE, "DoUndoStep"))
+           reply_to_command_do_undo_step(conn, msg);
        else if (msg.is_method_call(INTERFACE, "Debug"))
            reply_to_command_debug(conn, msg);
        else
index f847beb8ce417a532ae5dded0c7b945c6343bec6..81cc34adeecff041fa78beae6de9d4745891ff8d 100644 (file)
@@ -92,6 +92,26 @@ namespace snapper
     }
 
 
+    vector<UndoStep>
+    Comparison::getUndoSteps() const
+    {
+       if (!initialized)
+           throw;
+
+       return files.getUndoSteps();
+    }
+
+
+    bool
+    Comparison::doUndoStep(const UndoStep& undo_step)
+    {
+       if (!initialized)
+           throw;
+
+       return files.doUndoStep(undo_step);
+    }
+
+
     bool
     Comparison::doUndo()
     {
index 474be89dddfa00a2f7c594a1572cd63d7389c2a5..0250c25a81c26bfa2afe6fad517e1003b7252f37 100644 (file)
@@ -52,6 +52,10 @@ namespace snapper
 
        UndoStatistic getUndoStatistic() const;
 
+       vector<UndoStep> getUndoSteps() const;
+
+       bool doUndoStep(const UndoStep& undo_step);
+
        bool doUndo();
 
     private:
index 1d69c5c6a2d0ec6daf4b4e55f41046b49ed3301f..ca0aba2451705692094fdaed3627720808c3a459 100644 (file)
@@ -726,7 +726,7 @@ namespace snapper
     }
 
 
-    File::Action
+    Action
     File::getAction() const
     {
        if (getPreToPostStatus() == CREATED)
@@ -751,9 +751,9 @@ namespace snapper
            {
                switch (it->getAction())
                {
-                   case File::CREATE: rs.numCreate++; break;
-                   case File::MODIFY: rs.numModify++; break;
-                   case File::DELETE: rs.numDelete++; break;
+                   case CREATE: rs.numCreate++; break;
+                   case MODIFY: rs.numModify++; break;
+                   case DELETE: rs.numDelete++; break;
                }
            }
        }
@@ -762,6 +762,50 @@ namespace snapper
     }
 
 
+    vector<UndoStep>
+    Files::getUndoSteps() const
+    {
+       if (comparison->getSnapshot1()->isCurrent())
+           throw IllegalSnapshotException();
+
+       vector<UndoStep> undo_steps;
+
+       for (vector<File>::const_reverse_iterator it = entries.rbegin(); it != entries.rend(); ++it)
+       {
+           if (it->getUndo())
+           {
+               if (it->getPreToPostStatus() == CREATED)
+                   undo_steps.push_back(UndoStep(it->getName(), it->getAction()));
+           }
+       }
+
+       for (vector<File>::const_iterator it = entries.begin(); it != entries.end(); ++it)
+       {
+           if (it->getUndo())
+           {
+               if (it->getPreToPostStatus() != CREATED)
+                   undo_steps.push_back(UndoStep(it->getName(), it->getAction()));
+           }
+       }
+
+       return undo_steps;
+    }
+
+
+    bool
+    Files::doUndoStep(const UndoStep& undo_step)
+    {
+       if (comparison->getSnapshot1()->isCurrent())
+           throw IllegalSnapshotException();
+
+       vector<File>::iterator it = find(undo_step.name);
+       if (it == end())
+           return false;
+
+       return it->doUndo();
+    }
+
+
     bool
     Files::doUndo()
     {
@@ -778,9 +822,7 @@ namespace snapper
            if (it->getUndo())
            {
                if (it->getPreToPostStatus() == CREATED)
-               {
                    it->doUndo();
-               }
            }
        }
 
@@ -789,9 +831,7 @@ namespace snapper
            if (it->getUndo())
            {
                if (it->getPreToPostStatus() != CREATED)
-               {
                    it->doUndo();
-               }
            }
        }
 
index caa2a79f9472f270dd23e9263506f55827914180..9482990b067346c2c3d51adf63cda539a6bfdaf4 100644 (file)
@@ -56,6 +56,11 @@ namespace snapper
        LOC_PRE, LOC_POST, LOC_SYSTEM
     };
 
+    enum Action
+    {
+       CREATE, MODIFY, DELETE
+    };
+
 
     struct UndoStatistic
     {
@@ -71,6 +76,16 @@ namespace snapper
     };
 
 
+    struct UndoStep
+    {
+       UndoStep(const string& name, Action action)
+           : name(name), action(action) {}
+
+       string name;
+       Action action;
+    };
+
+
     class File
     {
     public:
@@ -97,8 +112,6 @@ namespace snapper
        void setUndo(bool value) { undo = value; }
        bool doUndo();
 
-       enum Action { CREATE, MODIFY, DELETE };
-
        Action getAction() const;
 
        friend std::ostream& operator<<(std::ostream& s, const File& file);
@@ -178,6 +191,10 @@ namespace snapper
 
        UndoStatistic getUndoStatistic() const;
 
+       vector<UndoStep> getUndoSteps() const;
+
+       bool doUndoStep(const UndoStep& undo_step);
+
        bool doUndo();
 
        const Comparison* comparison;