-
-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore support for
task info
journal (#3671)
This support was removed before Taskwarrior-3.x, and is now restored, including the original tests removed in ddd3672
- Loading branch information
Showing
13 changed files
with
438 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2006 - 2024, Tomas Babej, Paul Beckingham, Federico Hernandez. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included | ||
// in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
// | ||
// https://www.opensource.org/licenses/mit-license.php | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
#include <cmake.h> | ||
// cmake.h include header must come first | ||
|
||
#include <Operation.h> | ||
#include <taskchampion-cpp/lib.h> | ||
|
||
#include <vector> | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
Operation::Operation(const tc::Operation& op) : op(&op) {} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
std::vector<Operation> Operation::operations(const rust::Vec<tc::Operation>& operations) { | ||
return {operations.begin(), operations.end()}; | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
Operation& Operation::operator=(const Operation& other) { | ||
op = other.op; | ||
return *this; | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
bool Operation::operator<(Operation& other) const { | ||
if (is_create()) { | ||
return !other.is_create(); | ||
} else if (is_update()) { | ||
if (other.is_create()) { | ||
return false; | ||
} else if (other.is_update()) { | ||
return get_timestamp() < other.get_timestamp(); | ||
} else { | ||
return true; | ||
} | ||
} else if (is_delete()) { | ||
if (other.is_create() || other.is_update() || other.is_delete()) { | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} else if (is_undo_point()) { | ||
return !other.is_undo_point(); | ||
} | ||
return false; // not reachable | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2006 - 2024, Tomas Babej, Paul Beckingham, Federico Hernandez. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included | ||
// in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
// | ||
// https://www.opensource.org/licenses/mit-license.php | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef INCLUDED_OPERATIOn | ||
#define INCLUDED_OPERATIOn | ||
|
||
#include <taskchampion-cpp/lib.h> | ||
|
||
#include <optional> | ||
#include <vector> | ||
|
||
// Representation of a TaskChampion operation. | ||
// | ||
// This class wraps `tc::Operation&` and thus cannot outlive that underlying | ||
// type. | ||
class Operation { | ||
public: | ||
explicit Operation(const tc::Operation &); | ||
|
||
Operation(const Operation &other) = default; | ||
Operation &operator=(const Operation &other); | ||
|
||
// Create a vector of Operations given the result of `Replica::get_undo_operations` or | ||
// `Replica::get_task_operations`. The resulting vector must not outlive the input `rust::Vec`. | ||
static std::vector<Operation> operations(const rust::Vec<tc::Operation> &); | ||
|
||
// Methods from the underlying `tc::Operation`. | ||
bool is_create() const { return op->is_create(); } | ||
bool is_update() const { return op->is_update(); } | ||
bool is_delete() const { return op->is_delete(); } | ||
bool is_undo_point() const { return op->is_undo_point(); } | ||
std::string get_uuid() const { return std::string(op->get_uuid().to_string()); } | ||
::rust::Vec<::tc::PropValuePair> get_old_task() const { return op->get_old_task(); }; | ||
std::string get_property() const { | ||
std::string value; | ||
op->get_property(value); | ||
return value; | ||
} | ||
std::optional<std::string> get_value() const { | ||
std::optional<std::string> value{std::string()}; | ||
if (!op->get_value(value.value())) { | ||
value = std::nullopt; | ||
} | ||
return value; | ||
} | ||
std::optional<std::string> get_old_value() const { | ||
std::optional<std::string> old_value{std::string()}; | ||
if (!op->get_old_value(old_value.value())) { | ||
old_value = std::nullopt; | ||
} | ||
return old_value; | ||
} | ||
time_t get_timestamp() const { return static_cast<time_t>(op->get_timestamp()); } | ||
|
||
// Define a partial order on Operations: | ||
// - Create < Update < Delete < UndoPoint | ||
// - Given two updates, sort by timestamp | ||
bool operator<(Operation &other) const; | ||
|
||
private: | ||
const tc::Operation *op; | ||
}; | ||
|
||
#endif | ||
//////////////////////////////////////////////////////////////////////////////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.