- Added support for URIs
 - Added push command (pushes *.data to remote location)
 - Added config option: merge.autopush
This commit is contained in:
Johannes Schlatow
2010-09-02 01:26:55 +02:00
parent d362088305
commit 869655e818
8 changed files with 85 additions and 5 deletions

View File

@@ -43,6 +43,7 @@
#include "util.h"
#include "main.h"
#include "../auto.h"
#include "TransportSSH.h"
#ifdef HAVE_LIBNCURSES
#include <ncurses.h>
@@ -596,19 +597,86 @@ void handleMerge (std::string& outs)
if (context.hooks.trigger ("pre-merge-command"))
{
std::string file = trim (context.task.get ("description"));
std::string tmpfile = "";
if (file.length () > 0)
{
context.tdb.lock (context.config.getBoolean ("locking"));
Directory location (context.config.get ("data.location"));
// add undo.data to path if necessary
if (file.find ("undo.data") == std::string::npos)
{
if (file[file.length()-1] != '/')
file += "/";
file += "undo.data";
}
Transport* transport;
if ((transport = Transport::getTransport (file)) != NULL )
{
tmpfile = location.data + "/undo_remote.data";
transport->recv (tmpfile);
delete transport;
file = tmpfile;
}
context.tdb.lock (context.config.getBoolean ("locking"));
context.tdb.merge (file);
context.tdb.unlock ();
context.hooks.trigger ("post-merge-command");
context.hooks.trigger ("post-merge-command");
if (tmpfile != "")
{
remove (tmpfile.c_str());
std::string autopush = context.config.get ("merge.autopush");
if ( ((autopush == "ask") && (confirm ("Do you want to push the changes to the database you merged from?")) )
|| (autopush == "yes") )
{
std::string out;
handlePush(out);
}
}
}
else
else // TODO : get default source from config file
throw std::string ("You must specify a file to merge.");
}
}
////////////////////////////////////////////////////////////////////////////////
void handlePush (std::string& outs)
{
if (context.hooks.trigger ("pre-push-command"))
{
std::string file = trim (context.task.get ("description"));
if (file.length () > 0)
{
Directory location (context.config.get ("data.location"));
Transport* transport;
if ((transport = Transport::getTransport (file)) != NULL )
{
transport->send (location.data + "/*.data");
delete transport;
}
else
{
throw std::string ("Push failed");
}
context.hooks.trigger ("post-push-command");
}
else // TODO : get default target from config file
throw std::string ("You must specify a target.");
}
}
////////////////////////////////////////////////////////////////////////////////
int handleVersion (std::string &outs)
{