-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BREAKING] Unify Task and TaskMut #435
[BREAKING] Unify Task and TaskMut #435
Conversation
60febf9
to
ccdb0d0
Compare
This breaking change removes the `TaskMut` type and moves its high-level setters to `Task`. `Task` derefs to `TaskData`, making the methods of that type available for `Task` values. Several methods are deprecated, as detailed below. While these methods remain, they may be less performant than the recommended methods, either by reading unnecessary data from the database (e.g., to construct a dependency map) or by modifying the database in multiple transactions. Breaking Changes: - `Task`: - All `TaskMut` setters are now methods on `Task`, and take `&mut ops` as their last argument. - `Task::into_mut` is removed. - `Task::get_taskmap` is deprecated - prefer `TaskData::properties`. - `Replica`: - `Replica::add_to_working_set` is removed - working set maintenance is now entirely automatic. - `Replica::new_task` is deprecated - prefer `Replica::create_task` and setting the `entry`, `description`, and `status` properties directly. - `Replica::import_task_with_uuid` is deprecated - prefer `Replica::create_task`. - `Replica::update_task` is deprecated - prefer `TaskData::update`. - `Replica::delete_task` is deprecated - prefer `TaskData::delete`. - Management of undo points in the replica, including `Replica::add_undo_point` and automatically adding undo points for various operations, is no longer supported; use `Operations::new_with_undo_point` to add one when necessary.
ccdb0d0
to
1574799
Compare
I haven't dug into it yet but I thought one of the premises of the refactor was to keep the high and low level interfaces distinct and that applications should be conscientious about which interface they're using. I'm not sure I still see this distinction as valuable with the current implementation, but without this distinction what value do we get from the extra wrapper layer of TaskData? |
It's possible to ignore the That reminds me:
I don't think this will cause confusion, and if it did it would be a shallow bug. |
Hm, and as I'm working on using https://cxx.rs/ to bind this into Taskwarrior:
|
Yes, but as a Task user, don't you need to be conscientious when using TaskData methods since they don't commit operations? Doesn't the |
The new Task methods do not commit either: like Task data, they add operations to an But the Deref may not add a lot of value for users. Should I remove it? |
I'll make a few changes here:
|
52a0379
to
4b8c708
Compare
- deprecate `Task::delete` - remove Deref/DerefMut implementations for `Task` - `TaskData::delete` takes `&mut self`
4b8c708
to
531db93
Compare
I don't understand how this is the case. Pretty much all the Task methods call Edit: I now see that this PR removes this line! |
pub(crate) fn new(uuid: Uuid, taskmap: TaskMap, depmap: Rc<DependencyMap>) -> Task { | ||
pub(crate) fn new(data: TaskData, depmap: Rc<DependencyMap>) -> Task { | ||
Task { | ||
data: TaskData::new(uuid, taskmap), | ||
data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the rationale for this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC,it was so I could call Ok(Task::new(TaskData::create(uuid, ops), depmap))
without having to de-construct and re-construct that TaskData
.
You had me really worried & confused :) |
This breaking change removes the
TaskMut
type and moves its high-level setters toTask
.Task
derefs toTaskData
, making the methods of that type available forTask
values.Several methods are deprecated, as detailed below. While these methods remain, they may be less performant than the recommended methods, either by reading unnecessary data from the database (e.g., to construct a dependency map) or by modifying the database in multiple transactions.
Breaking Changes:
Task
:TaskMut
setters are now methods onTask
, and take&mut ops
as their last argument.Task::into_mut
is removed.Task::delete
is deprecated. UseTask::set_status
withStatus::Deleted
instead.Replica
:Replica::add_to_working_set
is removed - working set maintenance is now entirely automatic.Replica::new_task
is deprecated - preferReplica::create_task
and setting theentry
,description
, andstatus
properties directly.Replica::import_task_with_uuid
is deprecated - preferReplica::create_task
.Replica::update_task
is deprecated - preferTaskData::update
.Replica::delete_task
is deprecated - preferTaskData::delete
.Replica::add_undo_point
and automatically adding undo points for various operations, is no longer supported; useOperations::new_with_undo_point
to add one when necessary.This is the first of two breaking changes for #372, which will necessitate a 0.7.0 release.