mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Pull command
- Added pull command for cloning databases
This commit is contained in:
parent
0d364746c7
commit
68d5e3f296
11 changed files with 137 additions and 12 deletions
6
NEWS
6
NEWS
|
@ -17,6 +17,7 @@ New Features in taskwarrior 1.9.3
|
||||||
detection of duplicate imports.
|
detection of duplicate imports.
|
||||||
- New merge capability for syncing task data files.
|
- New merge capability for syncing task data files.
|
||||||
- New push capability for distributing merged changes.
|
- New push capability for distributing merged changes.
|
||||||
|
- New pull capability for copying data files from a remote location.
|
||||||
- When completing or modifying a task, the project status is displayed.
|
- When completing or modifying a task, the project status is displayed.
|
||||||
- The 'info' report is now colorized.
|
- The 'info' report is now colorized.
|
||||||
- Certain characters (#, $, @) are now supported for use in tags.
|
- Certain characters (#, $, @) are now supported for use in tags.
|
||||||
|
@ -36,6 +37,7 @@ New commands in taskwarrior 1.9.3
|
||||||
- New 'task merge <url>' command that can merge the local and an undo.data
|
- New 'task merge <url>' command that can merge the local and an undo.data
|
||||||
file from another taskwarrior user, to sync across machines, for example.
|
file from another taskwarrior user, to sync across machines, for example.
|
||||||
- New 'task push <url>' command to distribute merged changes.
|
- New 'task push <url>' command to distribute merged changes.
|
||||||
|
- New 'task pull <url>' command to copy data files from a remote location.
|
||||||
|
|
||||||
New configuration options in taskwarrior 1.9.3
|
New configuration options in taskwarrior 1.9.3
|
||||||
|
|
||||||
|
@ -45,6 +47,10 @@ New configuration options in taskwarrior 1.9.3
|
||||||
variable rule.precedence.color. Try "task show rule.pre" to show the
|
variable rule.precedence.color. Try "task show rule.pre" to show the
|
||||||
default settings.
|
default settings.
|
||||||
- merge.autopush to control whether pushing after merging is automated.
|
- merge.autopush to control whether pushing after merging is automated.
|
||||||
|
- merge.*.uri to configure source locations for the merge command
|
||||||
|
(e.g. merge.default.uri).
|
||||||
|
- push.*.uri to configure target locations for the push command.
|
||||||
|
- pull.*.uri to configure source locations for the pull command.
|
||||||
|
|
||||||
Newly deprecated features in taskwarrior 1.9.3
|
Newly deprecated features in taskwarrior 1.9.3
|
||||||
|
|
||||||
|
|
|
@ -170,14 +170,14 @@ a second database.
|
||||||
|
|
||||||
Here is a basic example of the procedure:
|
Here is a basic example of the procedure:
|
||||||
|
|
||||||
$ rsync myremotehost:.task/undo.data /tmp/undo_remote.data
|
$ task merge ssh://user@myremotehost/.task/
|
||||||
$ task merge /tmp/undo_remote.data
|
$ task push ssh://user@myremotehost/.task/
|
||||||
$ rsync ${HOME}/.task/*.data myremotehost:.task/
|
|
||||||
|
|
||||||
First you need to get the undo.data file from the remote system, or removable
|
The first command fetches the undo.data file from the remote system, reads the
|
||||||
media. When the merge command completes, you should copy all the local .data
|
changes made and updates the local database. When this merge command completes,
|
||||||
files to the remote system. This way you ensure that both systems are fully
|
you should copy all the local .data files to the remote system either by using
|
||||||
synchronized.
|
the push command explicitly or by activating the merge.autopush feature in the
|
||||||
|
~/.taskrc file. This way you ensure that both systems are fully synchronized.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B Q: The undo.data file gets very large - do I need it?
|
.B Q: The undo.data file gets very large - do I need it?
|
||||||
|
|
|
@ -143,9 +143,33 @@ Exports all tasks in YAML 1.1 format.
|
||||||
Redirect the output to a file, if you wish to save it, or pipe it to another command.
|
Redirect the output to a file, if you wish to save it, or pipe it to another command.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B merge path/to/second/undo.data
|
.B merge URL
|
||||||
Merges two task databases by comparing the modifications that are stored in the
|
Merges two task databases by comparing the modifications that are stored in the
|
||||||
undo.data files. The location of the second undo.data file must be passed on as argument.
|
undo.data files. The location of the second undo.data file must be passed on as argument. URL may have the following syntaxes:
|
||||||
|
|
||||||
|
|
||||||
|
ssh://[user@]host.xz[:port]/path/to/undo.data
|
||||||
|
|
||||||
|
rsync://[user@]host.xz[:port]/path/to/undo.data
|
||||||
|
|
||||||
|
[user@]host.xz:path/to/undo.data
|
||||||
|
|
||||||
|
/path/to/local/undo.data
|
||||||
|
|
||||||
|
You can set aliases for frequently used URLs in the .taskrc.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B push URL
|
||||||
|
Pushes the task database to a remote another location for distributing the
|
||||||
|
changes made by the merge command.
|
||||||
|
|
||||||
|
(See annotations above for valid URL syntaxes.)
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B pull URL
|
||||||
|
Overwrites the task database with those files found at the URL.
|
||||||
|
|
||||||
|
(See annotations above for valid URL syntaxes.)
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B color [sample | legend]
|
.B color [sample | legend]
|
||||||
|
|
|
@ -173,7 +173,8 @@ 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"));
|
commands.push_back (context.stringtable.get (CMD_PUSH, "push"));
|
||||||
|
commands.push_back (context.stringtable.get (CMD_PULL, "pull"));
|
||||||
|
|
||||||
// Now load the custom reports.
|
// Now load the custom reports.
|
||||||
std::vector <std::string> all;
|
std::vector <std::string> all;
|
||||||
|
@ -277,6 +278,7 @@ bool Cmd::isWriteCommand ()
|
||||||
command == context.stringtable.get (CMD_IMPORT, "import") ||
|
command == context.stringtable.get (CMD_IMPORT, "import") ||
|
||||||
command == context.stringtable.get (CMD_LOG, "log") ||
|
command == context.stringtable.get (CMD_LOG, "log") ||
|
||||||
command == context.stringtable.get (CMD_PREPEND, "prepend") ||
|
command == context.stringtable.get (CMD_PREPEND, "prepend") ||
|
||||||
|
command == context.stringtable.get (CMD_PULL, "pull") ||
|
||||||
command == context.stringtable.get (CMD_START, "start") ||
|
command == context.stringtable.get (CMD_START, "start") ||
|
||||||
command == context.stringtable.get (CMD_STOP, "stop") ||
|
command == context.stringtable.get (CMD_STOP, "stop") ||
|
||||||
command == context.stringtable.get (CMD_UNDO, "undo"))
|
command == context.stringtable.get (CMD_UNDO, "undo"))
|
||||||
|
|
|
@ -80,7 +80,6 @@ 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"
|
||||||
|
@ -232,6 +231,11 @@ std::string Config::defaults =
|
||||||
"fontunderline=yes # Uses underlines rather than -------\n"
|
"fontunderline=yes # Uses underlines rather than -------\n"
|
||||||
"shell.prompt=task> # Prompt used by the shell command\n"
|
"shell.prompt=task> # Prompt used by the shell command\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"# Merge options\n"
|
||||||
|
"merge.autopush=ask # Push database to remote origin after merge: yes, no, ask\n"
|
||||||
|
"#merge.default.uri=user@host.xz:.task/\n"
|
||||||
|
"#pull.default.uri=rsync://host.xz/task-backup/\n"
|
||||||
|
"\n"
|
||||||
"# Import heuristics - alternate names for fields (comma-separated list of names)\n"
|
"# Import heuristics - alternate names for fields (comma-separated list of names)\n"
|
||||||
"#import.synonym.bg=?\n"
|
"#import.synonym.bg=?\n"
|
||||||
"#import.synonym.description=?\n"
|
"#import.synonym.description=?\n"
|
||||||
|
|
|
@ -244,6 +244,7 @@ int Context::dispatch (std::string &out)
|
||||||
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 == "push") { handlePush (out); }
|
||||||
|
else if (cmd.command == "pull") { handlePull (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); }
|
||||||
|
|
|
@ -167,6 +167,8 @@ Hooks::Hooks ()
|
||||||
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-pull-command");
|
||||||
|
validProgramEvents.push_back ("post-pull-command");
|
||||||
validProgramEvents.push_back ("pre-push-command");
|
validProgramEvents.push_back ("pre-push-command");
|
||||||
validProgramEvents.push_back ("post-push-command");
|
validProgramEvents.push_back ("post-push-command");
|
||||||
validProgramEvents.push_back ("pre-shell-command");
|
validProgramEvents.push_back ("pre-shell-command");
|
||||||
|
|
|
@ -598,6 +598,20 @@ void handleMerge (std::string& outs)
|
||||||
{
|
{
|
||||||
std::string file = trim (context.task.get ("description"));
|
std::string file = trim (context.task.get ("description"));
|
||||||
std::string tmpfile = "";
|
std::string tmpfile = "";
|
||||||
|
|
||||||
|
if (file.length () == 0)
|
||||||
|
{
|
||||||
|
// get default target from config
|
||||||
|
file = context.config.get ("merge.default.uri");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// replace argument with uri from config
|
||||||
|
std::string tmp = context.config.get ("merge." + file + ".uri");
|
||||||
|
|
||||||
|
if (tmp != "")
|
||||||
|
file = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
if (file.length () > 0)
|
if (file.length () > 0)
|
||||||
{
|
{
|
||||||
|
@ -654,6 +668,20 @@ void handlePush (std::string& outs)
|
||||||
if (context.hooks.trigger ("pre-push-command"))
|
if (context.hooks.trigger ("pre-push-command"))
|
||||||
{
|
{
|
||||||
std::string file = trim (context.task.get ("description"));
|
std::string file = trim (context.task.get ("description"));
|
||||||
|
|
||||||
|
if (file.length () == 0)
|
||||||
|
{
|
||||||
|
// get default target from config
|
||||||
|
file = context.config.get ("push.default.uri");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// replace argument with uri from config
|
||||||
|
std::string tmp = context.config.get ("push." + file + ".uri");
|
||||||
|
|
||||||
|
if (tmp != "")
|
||||||
|
file = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
if (file.length () > 0)
|
if (file.length () > 0)
|
||||||
{
|
{
|
||||||
|
@ -672,6 +700,58 @@ void handlePush (std::string& outs)
|
||||||
|
|
||||||
context.hooks.trigger ("post-push-command");
|
context.hooks.trigger ("post-push-command");
|
||||||
}
|
}
|
||||||
|
else // TODO : get default target from config file
|
||||||
|
throw std::string ("You must specify a target.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void handlePull (std::string& outs)
|
||||||
|
{
|
||||||
|
if (context.hooks.trigger ("pre-pull-command"))
|
||||||
|
{
|
||||||
|
std::string file = trim (context.task.get ("description"));
|
||||||
|
|
||||||
|
if (file.length () == 0)
|
||||||
|
{
|
||||||
|
// get default target from config
|
||||||
|
file = context.config.get ("pull.default.uri");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// replace argument with uri from config
|
||||||
|
std::string tmp = context.config.get ("pull." + file + ".uri");
|
||||||
|
|
||||||
|
if (tmp != "")
|
||||||
|
file = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.length () > 0)
|
||||||
|
{
|
||||||
|
Directory location (context.config.get ("data.location"));
|
||||||
|
|
||||||
|
// add *.data to path if necessary
|
||||||
|
if (file.find ("*.data") == std::string::npos)
|
||||||
|
{
|
||||||
|
if (file[file.length()-1] != '/')
|
||||||
|
file += "/";
|
||||||
|
|
||||||
|
file += "*.data";
|
||||||
|
}
|
||||||
|
|
||||||
|
Transport* transport;
|
||||||
|
if ((transport = Transport::getTransport (file)) != NULL )
|
||||||
|
{
|
||||||
|
transport->recv (location.data + "/");
|
||||||
|
delete transport;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw std::string ("Pull failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
context.hooks.trigger ("post-pull-command");
|
||||||
|
}
|
||||||
else // TODO : get default target from config file
|
else // TODO : get default target from config file
|
||||||
throw std::string ("You must specify a target.");
|
throw std::string ("You must specify a target.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,7 @@
|
||||||
#define CMD_SHOW 231
|
#define CMD_SHOW 231
|
||||||
#define CMD_MERGE 232
|
#define CMD_MERGE 232
|
||||||
#define CMD_PUSH 233
|
#define CMD_PUSH 233
|
||||||
|
#define CMD_PULL 234
|
||||||
|
|
||||||
// 3xx Attributes
|
// 3xx Attributes
|
||||||
#define ATT_PROJECT 300
|
#define ATT_PROJECT 300
|
||||||
|
|
|
@ -79,6 +79,7 @@ int handleDuplicate (std::string &);
|
||||||
void handleUndo ();
|
void handleUndo ();
|
||||||
void handleMerge (std::string&);
|
void handleMerge (std::string&);
|
||||||
void handlePush (std::string&);
|
void handlePush (std::string&);
|
||||||
|
void handlePull (std::string&);
|
||||||
#ifdef FEATURE_SHELL
|
#ifdef FEATURE_SHELL
|
||||||
void handleShell ();
|
void handleShell ();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -209,7 +209,11 @@ int shortUsage (std::string &outs)
|
||||||
|
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 1, "task push URL");
|
table.addCell (row, 1, "task push URL");
|
||||||
table.addCell (row, 2, "Pushes the local undo.data files to the URL.");
|
table.addCell (row, 2, "Pushes the local *.data files to the URL.");
|
||||||
|
|
||||||
|
row = table.addRow ();
|
||||||
|
table.addCell (row, 1, "task pull URL");
|
||||||
|
table.addCell (row, 2, "Overwrites the local *.data files with those found at the URL.");
|
||||||
|
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 1, "task export.ical");
|
table.addCell (row, 1, "task export.ical");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue