mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 10:07:19 +02:00
Merge
- Added support for URIs - Added push command (pushes *.data to remote location) - Added config option: merge.autopush
This commit is contained in:
parent
d362088305
commit
869655e818
8 changed files with 85 additions and 5 deletions
|
@ -173,6 +173,7 @@ void Cmd::load ()
|
||||||
commands.push_back (context.stringtable.get (CMD_UNDO, "undo"));
|
commands.push_back (context.stringtable.get (CMD_UNDO, "undo"));
|
||||||
commands.push_back (context.stringtable.get (CMD_VERSION, "version"));
|
commands.push_back (context.stringtable.get (CMD_VERSION, "version"));
|
||||||
commands.push_back (context.stringtable.get (CMD_MERGE, "merge"));
|
commands.push_back (context.stringtable.get (CMD_MERGE, "merge"));
|
||||||
|
commands.push_back (context.stringtable.get (CMD_PUSH, "push"));
|
||||||
|
|
||||||
// Now load the custom reports.
|
// Now load the custom reports.
|
||||||
std::vector <std::string> all;
|
std::vector <std::string> all;
|
||||||
|
@ -247,6 +248,7 @@ bool Cmd::isReadOnlyCommand ()
|
||||||
command == context.stringtable.get (CMD_HELP, "help") ||
|
command == context.stringtable.get (CMD_HELP, "help") ||
|
||||||
command == context.stringtable.get (CMD_INFO, "info") ||
|
command == context.stringtable.get (CMD_INFO, "info") ||
|
||||||
command == context.stringtable.get (CMD_PROJECTS, "projects") ||
|
command == context.stringtable.get (CMD_PROJECTS, "projects") ||
|
||||||
|
command == context.stringtable.get (CMD_PUSH, "push") ||
|
||||||
command == context.stringtable.get (CMD_SHELL, "shell") ||
|
command == context.stringtable.get (CMD_SHELL, "shell") ||
|
||||||
command == context.stringtable.get (CMD_STATS, "stats") ||
|
command == context.stringtable.get (CMD_STATS, "stats") ||
|
||||||
command == context.stringtable.get (CMD_SUMMARY, "summary") ||
|
command == context.stringtable.get (CMD_SUMMARY, "summary") ||
|
||||||
|
|
|
@ -80,6 +80,7 @@ std::string Config::defaults =
|
||||||
"recurrence.indicator=R # What to show as a task recurrence indicator\n"
|
"recurrence.indicator=R # What to show as a task recurrence indicator\n"
|
||||||
"recurrence.limit=1 # Number of future recurring pending tasks\n"
|
"recurrence.limit=1 # Number of future recurring pending tasks\n"
|
||||||
"undo.style=side # Undo style - can be 'side', or 'diff'\n"
|
"undo.style=side # Undo style - can be 'side', or 'diff'\n"
|
||||||
|
"merge.autopush=ask # Push database to remote origin after merge: yes, no, ask\n"
|
||||||
"\n"
|
"\n"
|
||||||
"# Dates\n"
|
"# Dates\n"
|
||||||
"dateformat=m/d/Y # Preferred input and display date format\n"
|
"dateformat=m/d/Y # Preferred input and display date format\n"
|
||||||
|
|
|
@ -245,6 +245,7 @@ int Context::dispatch (std::string &out)
|
||||||
else if (cmd.command == "undo") { handleUndo ( ); }
|
else if (cmd.command == "undo") { handleUndo ( ); }
|
||||||
else if (cmd.command == "merge") { tdb.gc ();
|
else if (cmd.command == "merge") { tdb.gc ();
|
||||||
handleMerge (out); }
|
handleMerge (out); }
|
||||||
|
else if (cmd.command == "push") { handlePush (out); }
|
||||||
else if (cmd.command == "_projects") { rc = handleCompletionProjects (out); }
|
else if (cmd.command == "_projects") { rc = handleCompletionProjects (out); }
|
||||||
else if (cmd.command == "_tags") { rc = handleCompletionTags (out); }
|
else if (cmd.command == "_tags") { rc = handleCompletionTags (out); }
|
||||||
else if (cmd.command == "_commands") { rc = handleCompletionCommands (out); }
|
else if (cmd.command == "_commands") { rc = handleCompletionCommands (out); }
|
||||||
|
|
|
@ -159,12 +159,16 @@ Hooks::Hooks ()
|
||||||
validProgramEvents.push_back ("post-import-command");
|
validProgramEvents.push_back ("post-import-command");
|
||||||
validProgramEvents.push_back ("pre-info-command");
|
validProgramEvents.push_back ("pre-info-command");
|
||||||
validProgramEvents.push_back ("post-info-command");
|
validProgramEvents.push_back ("post-info-command");
|
||||||
|
validProgramEvents.push_back ("pre-merge-command");
|
||||||
|
validProgramEvents.push_back ("post-merge-command");
|
||||||
validProgramEvents.push_back ("pre-modify-command");
|
validProgramEvents.push_back ("pre-modify-command");
|
||||||
validProgramEvents.push_back ("post-modify-command");
|
validProgramEvents.push_back ("post-modify-command");
|
||||||
validProgramEvents.push_back ("pre-prepend-command");
|
validProgramEvents.push_back ("pre-prepend-command");
|
||||||
validProgramEvents.push_back ("post-prepend-command");
|
validProgramEvents.push_back ("post-prepend-command");
|
||||||
validProgramEvents.push_back ("pre-projects-command");
|
validProgramEvents.push_back ("pre-projects-command");
|
||||||
validProgramEvents.push_back ("post-projects-command");
|
validProgramEvents.push_back ("post-projects-command");
|
||||||
|
validProgramEvents.push_back ("pre-push-command");
|
||||||
|
validProgramEvents.push_back ("post-push-command");
|
||||||
validProgramEvents.push_back ("pre-shell-command");
|
validProgramEvents.push_back ("pre-shell-command");
|
||||||
validProgramEvents.push_back ("post-shell-command");
|
validProgramEvents.push_back ("post-shell-command");
|
||||||
validProgramEvents.push_back ("pre-start-command");
|
validProgramEvents.push_back ("pre-start-command");
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "../auto.h"
|
#include "../auto.h"
|
||||||
|
#include "TransportSSH.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBNCURSES
|
#ifdef HAVE_LIBNCURSES
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
|
@ -596,16 +597,83 @@ void handleMerge (std::string& outs)
|
||||||
if (context.hooks.trigger ("pre-merge-command"))
|
if (context.hooks.trigger ("pre-merge-command"))
|
||||||
{
|
{
|
||||||
std::string file = trim (context.task.get ("description"));
|
std::string file = trim (context.task.get ("description"));
|
||||||
|
std::string tmpfile = "";
|
||||||
|
|
||||||
if (file.length () > 0)
|
if (file.length () > 0)
|
||||||
{
|
{
|
||||||
|
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.lock (context.config.getBoolean ("locking"));
|
||||||
context.tdb.merge (file);
|
context.tdb.merge (file);
|
||||||
context.tdb.unlock ();
|
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 // 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
|
else
|
||||||
throw std::string ("You must specify a file to merge.");
|
{
|
||||||
|
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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,7 @@
|
||||||
#define CMD_CONFIG 230
|
#define CMD_CONFIG 230
|
||||||
#define CMD_SHOW 231
|
#define CMD_SHOW 231
|
||||||
#define CMD_MERGE 232
|
#define CMD_MERGE 232
|
||||||
|
#define CMD_PUSH 233
|
||||||
|
|
||||||
// 3xx Attributes
|
// 3xx Attributes
|
||||||
#define ATT_PROJECT 300
|
#define ATT_PROJECT 300
|
||||||
|
|
|
@ -78,6 +78,7 @@ int handleDenotate (std::string &);
|
||||||
int handleDuplicate (std::string &);
|
int handleDuplicate (std::string &);
|
||||||
void handleUndo ();
|
void handleUndo ();
|
||||||
void handleMerge (std::string&);
|
void handleMerge (std::string&);
|
||||||
|
void handlePush (std::string&);
|
||||||
#ifdef FEATURE_SHELL
|
#ifdef FEATURE_SHELL
|
||||||
void handleShell ();
|
void handleShell ();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,6 +45,7 @@ if (open my $fh, '>', 'local.rc')
|
||||||
{
|
{
|
||||||
print $fh "data.location=./local\n",
|
print $fh "data.location=./local\n",
|
||||||
"confirmation=no\n",
|
"confirmation=no\n",
|
||||||
|
"merge.autopush=no\n",
|
||||||
"report.list.description=DESC\n",
|
"report.list.description=DESC\n",
|
||||||
"report.list.columns=id,project,active,priority,description,tags\n",
|
"report.list.columns=id,project,active,priority,description,tags\n",
|
||||||
"report.list.labels=id,pro,a,pri,d,t\n",
|
"report.list.labels=id,pro,a,pri,d,t\n",
|
||||||
|
@ -58,6 +59,7 @@ if (open my $fh, '>', 'remote.rc')
|
||||||
{
|
{
|
||||||
print $fh "data.location=./remote\n",
|
print $fh "data.location=./remote\n",
|
||||||
"confirmation=no\n",
|
"confirmation=no\n",
|
||||||
|
"merge.autopush=no\n",
|
||||||
"report.list.description=DESC\n",
|
"report.list.description=DESC\n",
|
||||||
"report.list.columns=id,project,active,priority,description,tags\n",
|
"report.list.columns=id,project,active,priority,description,tags\n",
|
||||||
"report.list.labels=id,pro,a,pri,d,t\n",
|
"report.list.labels=id,pro,a,pri,d,t\n",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue