#define INTERFACE "org.opensuse.snapper"
+XConfigInfo
+command_get_xconfig(DBus::Connection& conn, const string& config_name)
+{
+ DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "ListConfigs");
+
+ DBus::Message reply = conn.send_and_reply_and_block(call);
+
+ list<XConfigInfo> ret;
+
+ DBus::Hihi hihi(reply);
+ hihi >> ret;
+
+ for (list<XConfigInfo>::const_iterator it = ret.begin(); it != ret.end(); ++it)
+ {
+ if (it->config_name == config_name)
+ return *it;
+ }
+
+ throw;
+}
+
+
list<XConfigInfo>
command_list_xconfigs(DBus::Connection& conn)
{
vector<string>
command_get_xdiff(DBus::Connection& conn, const string& config_name, unsigned int number1,
- unsigned int number2, const string& filename, const string& options)
+ unsigned int number2, const string& name, const string& options)
{
DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "GetDiff");
DBus::Hoho hoho(call);
- hoho << config_name << number1 << number2 << filename << options;
+ hoho << config_name << number1 << number2 << name << options;
DBus::Message reply = conn.send_and_reply_and_block(call);
}
+string
+add_subvolume(const string& subvolume, const string& name)
+{
+ return subvolume == "/" ? name : subvolume + name;
+}
+
+
+string
+remove_subvolume(const string& subvolume, const string& name)
+{
+ if (!boost::starts_with(name, subvolume))
+ throw;
+
+ if (subvolume == "/")
+ return name;
+ else
+ return string(name, subvolume.size());
+}
+
+
void
help_list_configs()
{
}
}
+ XConfigInfo ci = command_get_xconfig(conn, config_name);
+
for (list<XFile>::const_iterator it = files.begin(); it != files.end(); ++it)
- fprintf(file, "%s %s\n", it->status.c_str(), it->filename.c_str()); // TODO abs filename
+ fprintf(file, "%s %s\n", it->status.c_str(), add_subvolume(ci.subvolume, it->name).c_str());
if (file != stdout)
fclose(file);
command_create_xcomparison(conn, config_name, nums.first, nums.second);
- list<XFile> files = command_get_xfiles(conn, config_name, nums.first, nums.second);
-
if (getopts.numArgs() == 0)
{
+ list<XFile> files = command_get_xfiles(conn, config_name, nums.first, nums.second);
+
for (list<XFile>::const_iterator it1 = files.begin(); it1 != files.end(); ++it1)
{
vector<string> lines = command_get_xdiff(conn, config_name, nums.first, nums.second,
- it1->filename, "--unified --new-file");
+ it1->name, "--unified --new-file");
for (vector<string>::const_iterator it2 = lines.begin(); it2 != lines.end(); ++it2)
cout << it2->c_str() << endl;
}
}
else
{
+ XConfigInfo ci = command_get_xconfig(conn, config_name);
+
while (getopts.numArgs() > 0)
{
- string name = getopts.popArg();
+ string name = remove_subvolume(ci.subvolume, getopts.popArg());
- /*
- Files::const_iterator tmp = files.findAbsolutePath(name);
- if (tmp == files.end())
- continue;
-
- vector<string> lines = tmp->getDiff("--unified --new-file");
+ vector<string> lines = command_get_xdiff(conn, config_name, nums.first, nums.second,
+ name, "--unified --new-file");
for (vector<string>::const_iterator it2 = lines.begin(); it2 != lines.end(); ++it2)
cout << it2->c_str() << endl;
- */
}
}
}
if (file)
{
+ XConfigInfo ci = command_get_xconfig(conn, config_name);
+
+ list<XUndo> undos;
+
AsciiFileReader asciifile(file);
string line;
name.erase(0, pos + 1);
}
- /*
- Files::iterator it = files.findAbsolutePath(name);
- if (it == files.end())
- {
- cerr << sformat(_("File '%s' not found."), name.c_str()) << endl;
- exit(EXIT_FAILURE);
- }
-
- it->setUndo(true);
- */
+ XUndo undo;
+ undo.undo = true;
+ undo.name = remove_subvolume(ci.subvolume, name);
+ undos.push_back(undo);
}
+
+ command_set_xundo(conn, config_name, nums.first, nums.second, undos);
}
else
{
}
else
{
- while (getopts.numArgs() > 0)
- {
- string name = getopts.popArg();
+ XConfigInfo ci = command_get_xconfig(conn, config_name);
- /*
- Files::iterator tmp = files.findAbsolutePath(name);
- if (tmp == files.end())
- continue;
+ list<XUndo> undos;
- tmp->setUndo(true);
- */
+ while (getopts.numArgs() > 0)
+ {
+ XUndo undo;
+ undo.undo = true;
+ undo.name = remove_subvolume(ci.subvolume, getopts.popArg());
+ undos.push_back(undo);
}
+
+ command_set_xundo(conn, config_name, nums.first, nums.second, undos);
}
}
if (s.empty())
{
- cout << "nothing to do" << endl;
+ cout << _("nothing to do") << endl;
return;
}
- cout << "create:" << s.numCreate << " modify:" << s.numModify << " delete:" << s.numDelete
- << endl;
+ cout << sformat(_("create:%d modify:%d delete:%d"), s.numCreate, s.numModify, s.numDelete) << endl;
/*
comparison.doUndo();