From b8a3c1b5656f9da61a08e49ca943488cefa1d724 Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Sat, 7 Aug 2010 17:49:17 +0200 Subject: [PATCH 1/3] Man pages - Added documentation of merge commmand to task.1 and task-faq.5 --- doc/man/task-faq.5 | 19 +++++++++++++++++++ doc/man/task.1 | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/doc/man/task-faq.5 b/doc/man/task-faq.5 index c3d9d0b46..1449fab2e 100644 --- a/doc/man/task-faq.5 +++ b/doc/man/task-faq.5 @@ -153,6 +153,24 @@ modifying the: configuration variable. Check out DropBox at http://www.dropbox.com. +.TP +.B Q: I don't like dropbox. Is there another way to synchronize my tasks? +Of course. Especially if you want to modify tasks offline on both machines and +synchronize them later on. For this purpose task provides a 'merge' command which +is able to insert the modifications you made to one of your task databases into a +second database. + +Here is a basic example of the procedure: + + $ rsync myremotehost:.task/undo.data /tmp/undo_remote.data + $ task merge /tmp/undo_remote.data + $ rsync ${HOME}/.task/*.data myremotehost:.task/ + +First you need to get the undo.data file from the remote system with a network +protocol of your choice or a removable medium as well. When task finished the merge +command you should copy all the local .data files to the remote system. This way you +ensure that both systems are fully synchronized. + .TP .B Q: The undo.data file gets very large - do I need it? You need it if you want the undo capability. But if it gets large, you can @@ -286,6 +304,7 @@ non-exact match: This will remove the second annotation - the first non-exact match. + .SH "CREDITS & COPYRIGHTS" task was written by P. Beckingham . .br diff --git a/doc/man/task.1 b/doc/man/task.1 index f23b6c053..57b1d252a 100644 --- a/doc/man/task.1 +++ b/doc/man/task.1 @@ -142,6 +142,11 @@ Redirect the output to a file, if you wish to save it, or pipe it to another com 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. +.TP +.B merge path/to/remote/undo.data +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. + .TP .B color [sample | legend] Displays all possible colors, a named sample, or a legend containing all From 7294869d0777b249cdb268855742bdf5feb8e0b2 Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Sat, 7 Aug 2010 17:50:02 +0200 Subject: [PATCH 2/3] Merge command * Renamed command _merge into merge --- src/Cmd.cpp | 4 ++-- src/Context.cpp | 2 +- src/i18n.h | 1 + src/tests/merge.t | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Cmd.cpp b/src/Cmd.cpp index 86c7d00d3..d8578892c 100644 --- a/src/Cmd.cpp +++ b/src/Cmd.cpp @@ -134,7 +134,6 @@ void Cmd::load () commands.push_back ("_ids"); commands.push_back ("_config"); commands.push_back ("_version"); - commands.push_back ("_merge"); commands.push_back ("_urgency"); commands.push_back ("export.csv"); commands.push_back ("export.ical"); @@ -174,6 +173,7 @@ void Cmd::load () commands.push_back (context.stringtable.get (CMD_TIMESHEET, "timesheet")); 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_MERGE, "merge")); // Now load the custom reports. std::vector all; @@ -264,7 +264,7 @@ bool Cmd::isReadOnlyCommand () // Commands that directly modify the data files. bool Cmd::isWriteCommand () { - if (command == "_merge" || + if (command == context.stringtable.get (CMD_MERGE, "merge") || command == context.stringtable.get (CMD_ADD, "add") || command == context.stringtable.get (CMD_APPEND, "append") || command == context.stringtable.get (CMD_ANNOTATE, "annotate") || diff --git a/src/Context.cpp b/src/Context.cpp index a32d47701..37a606d60 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -241,7 +241,7 @@ int Context::dispatch (std::string &out) else if (cmd.command == "shell") { handleShell ( ); } #endif else if (cmd.command == "undo") { handleUndo ( ); } - else if (cmd.command == "_merge") { tdb.gc (); + else if (cmd.command == "merge") { tdb.gc (); handleMerge (out); } else if (cmd.command == "_projects") { rc = handleCompletionProjects (out); } else if (cmd.command == "_tags") { rc = handleCompletionTags (out); } diff --git a/src/i18n.h b/src/i18n.h index 0690e6c9f..568052aa7 100644 --- a/src/i18n.h +++ b/src/i18n.h @@ -98,6 +98,7 @@ #define CMD_SHELL 229 #define CMD_CONFIG 230 #define CMD_SHOW 231 +#define CMD_MERGE 232 // 3xx Attributes #define ATT_PROJECT 300 diff --git a/src/tests/merge.t b/src/tests/merge.t index 2e1511d92..7b0f99aad 100755 --- a/src/tests/merge.t +++ b/src/tests/merge.t @@ -134,7 +134,7 @@ sleep(1); qx{../task rc:remote.rc 4 +gym}; # right_newer # merge remote into local -my $output_l = qx{../task rc:local.rc _merge remote/undo.data}; +my $output_l = qx{../task rc:local.rc merge remote/undo.data}; #check output like ($output_l, qr/Running redo/, "local-merge finished"); @@ -142,7 +142,7 @@ unlike ($output_l, qr/Missing/, "local-merge: no missing entry"); unlike ($output_l, qr/Not adding duplicate/, "local-merge: no duplicates"); # merge local into remote -my $output_r = qx{../task rc:remote.rc _merge local/undo.data}; +my $output_r = qx{../task rc:remote.rc merge local/undo.data}; # check output like ($output_r, qr/Running redo/, "remote-merge finished"); From 5f8f8b51c463e5cb201ebe580014e6be52a3475f Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Sat, 7 Aug 2010 17:52:46 +0200 Subject: [PATCH 3/3] Bash completion - Added filename completion for the merge command --- scripts/bash/task_completion.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/bash/task_completion.sh b/scripts/bash/task_completion.sh index 5d4600ac7..56876363c 100644 --- a/scripts/bash/task_completion.sh +++ b/scripts/bash/task_completion.sh @@ -117,6 +117,14 @@ _task() COMPREPLY=( $(compgen -W "${config}" -- ${cur}) ) return 0 ;; + *) + case "${prev}" in + merge) + COMPREPLY=( $(compgen -o "default" -- ${cur}) ) + return 0 + ;; + esac + ;; esac ;; esac