Merge lp:~mterry/update-manager/toggle-fix into lp:update-manager

Proposed by Michael Terry
Status: Merged
Merged at revision: 2594
Proposed branch: lp:~mterry/update-manager/toggle-fix
Merge into: lp:update-manager
Diff against target: 118 lines (+21/-36)
2 files modified
UpdateManager/Core/UpdateList.py (+5/-2)
UpdateManager/UpdatesAvailable.py (+16/-34)
To merge this branch: bzr merge lp:~mterry/update-manager/toggle-fix
Reviewer Review Type Date Requested Status
Martin Pitt Approve
Review via email: mp+149116@code.launchpad.net

Description of the change

-Refactors the toggle-an-item logic from two code paths down to one code path
-Introduce a convenience method is_selected() to cover a common question asked about a package
-Fixes bug 1129191 by dropping "auto_fix=False, auto_inst=False" when marking a package from install. These flags were inherited from the old "toggle_by_origin" method and seem to have been an optimization because we knew that all affected packages were from same PPA/origin and wouldn't need a fixer check. But we can no longer make that same assumption. Running the fixer makes the bug go away.

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

I can reproduce the bug and confirm that this branch fixes it, so I merged it. Thanks! However, see the bug for more details, I can't upload it just yet.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UpdateManager/Core/UpdateList.py'
2--- UpdateManager/Core/UpdateList.py 2013-01-23 15:46:52 +0000
3+++ UpdateManager/Core/UpdateList.py 2013-02-18 17:55:25 +0000
4@@ -50,6 +50,9 @@
5 self.name = name
6 self.pkg = pkg
7
8+ def is_selected(self):
9+ return self.pkg.marked_install or self.pkg.marked_upgrade
10+
11
12 class UpdateGroup(UpdateItem):
13 def __init__(self, pkg, name, icon):
14@@ -101,13 +104,13 @@
15
16 def packages_are_selected(self):
17 for item in self.items:
18- if item.pkg.marked_install or item.pkg.marked_upgrade:
19+ if item.is_selected():
20 return True
21 return False
22
23 def selection_is_inconsistent(self):
24 pkgs_installing = [item for item in self.items
25- if item.pkg.marked_install or item.pkg.marked_upgrade]
26+ if item.is_selected()]
27 return (len(pkgs_installing) > 0 and
28 len(pkgs_installing) < len(self.items))
29
30
31=== modified file 'UpdateManager/UpdatesAvailable.py'
32--- UpdateManager/UpdatesAvailable.py 2013-01-29 21:14:59 +0000
33+++ UpdateManager/UpdatesAvailable.py 2013-02-18 17:55:25 +0000
34@@ -420,7 +420,7 @@
35 for group in data.groups:
36 for item in group.items:
37 pkg = item.pkg
38- this_install = pkg.marked_install or pkg.marked_upgrade
39+ this_install = item.is_selected()
40 if saw_install is not None and saw_install != this_install:
41 inconsistent = True
42 break
43@@ -658,8 +658,7 @@
44 data = model.get_value(iter, LIST_UPDATE_DATA)
45 active = False
46 if data.item:
47- active = data.item.pkg.marked_install or \
48- data.item.pkg.marked_upgrade
49+ active = data.item.is_selected()
50 elif data.group:
51 active = data.group.packages_are_selected()
52 elif data.groups:
53@@ -871,32 +870,13 @@
54 data = self.store.get_value(iter, LIST_UPDATE_DATA)
55 # make sure that we don't allow to toggle deactivated updates
56 # this is needed for the call by the row activation callback
57- if data.groups or data.group:
58- if data.groups:
59- self.toggle_from_groups(data.groups)
60- elif data.group:
61- self.toggle_from_groups([data.group])
62- self.updates_changed()
63- self.treeview_update.queue_draw()
64- return
65- if (data.item is None or data.item.pkg is None or
66- data.item.pkg.name in self.list.held_back):
67- return False
68- self.setBusy(True)
69- # update the cache
70- if data.item.pkg.marked_install or data.item.pkg.marked_upgrade:
71- data.item.pkg.mark_keep()
72- if self.cache._depcache.broken_count:
73- Fix = apt_pkg.ProblemResolver(self.cache._depcache)
74- Fix.resolve_by_keep()
75+ if data.groups:
76+ self.toggle_from_items([item for group in data.groups
77+ for item in group.items])
78+ elif data.group:
79+ self.toggle_from_items(data.group.items)
80 else:
81- try:
82- data.item.pkg.mark_install()
83- except SystemError:
84- pass
85- self.updates_changed()
86- self.treeview_update.queue_draw()
87- self.setBusy(False)
88+ self.toggle_from_items([data.item])
89
90 def on_treeview_update_row_activated(self, treeview, path, column, *args):
91 """
92@@ -905,18 +885,20 @@
93 """
94 self.on_update_toggled(None, path)
95
96- def toggle_from_groups(self, groups):
97+ def toggle_from_items(self, items):
98 self.setBusy(True)
99 actiongroup = apt_pkg.ActionGroup(self.cache._depcache)
100
101- # Deselect all updates if any in group are selected
102- keep_packages = any([g.packages_are_selected() for g in groups])
103- for group in groups:
104- for item in group.items:
105+ # Deselect all updates if any are selected
106+ keep_packages = any([item.is_selected() for item in items])
107+ for item in items:
108+ try:
109 if keep_packages:
110 item.pkg.mark_keep()
111 elif not item.pkg.name in self.list.held_back:
112- item.pkg.mark_install(auto_fix=False, auto_inst=False)
113+ item.pkg.mark_install()
114+ except SystemError:
115+ pass
116
117 # check if we left breakage
118 if self.cache._depcache.broken_count:

Subscribers

People subscribed via source and target branches

to status/vote changes: