Skip to content

Commit

Permalink
remote: operate on the model directly instead of using a copy
Browse files Browse the repository at this point in the history
The fetch/push/pull dialog previously operated on a copy of the main
model due to some early architectural decisions that have since changed.

Early on, the model needed to contain attributes that mapped to
widgets directly so that they could be kept in sync through a
generic update callback that attempted to keep the widgets in
sync with the model.  This led to the decision to use a copy of
the model so that we can avoid needing to add extra attributes
for just these dialog.

This subsystem no longer exists, and our use of the model is
non-destructive, so we can eliminate all of that complexity.
Operating on a copy causes notifications to be lost and prevents the
main model from updating itself in response to operations, since
the operations end up editing the copy only.

Eliminate the model copy that is created for the remote dialogs
and operate on the model directly.  This ensures that updates to
the model are seen by the rest of the application.

Closes #996
Reported-by: akontsevich on github.com
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Oct 7, 2019
1 parent c491770 commit bfe752f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 1 addition & 8 deletions cola/widgets/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,8 @@ def pull(context):
def run(context, RemoteDialog):
"""Launches fetch/push/pull dialogs."""
# Copy global stuff over to speedup startup
model = main.MainModel(context)
global_model = context.model
model.currentbranch = global_model.currentbranch
model.local_branches = global_model.local_branches
model.remote_branches = global_model.remote_branches
model.tags = global_model.tags
model.remotes = global_model.remotes
parent = qtutils.active_window()
view = RemoteDialog(context, model, parent=parent)
view = RemoteDialog(context, parent=parent)
view.show()
return view

Expand Down
6 changes: 5 additions & 1 deletion share/doc/git-cola/relnotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ Clone the git-cola repo to get the latest development version:

Fixes
-----
* The branches widget now refreshes its display when changing branhces.
* Fetch, push, and pull operations will now refresh the model and display when
operations complete.
(`#996 <https://github.com/git-cola/git-cola/issues/996>`_)

* The branches widget now refreshes its display when changing branches.
(`#992 <https://github.com/git-cola/git-cola/pull/992>`_)

Packaging
Expand Down

0 comments on commit bfe752f

Please sign in to comment.