Merge lp:~simon-kersey/bzr-explorer/568728-fix into lp:bzr-explorer

Proposed by Simon Kersey on 2010-04-28
Status: Merged
Merged at revision: 485
Proposed branch: lp:~simon-kersey/bzr-explorer/568728-fix
Merge into: lp:bzr-explorer
Diff against target: 94 lines (+31/-7)
3 files modified
NEWS (+2/-0)
lib/explorer.py (+9/-7)
lib/location.py (+20/-0)
To merge this branch: bzr merge lp:~simon-kersey/bzr-explorer/568728-fix
Reviewer Review Type Date Requested Status
Alexander Belchenko 2010-04-28 Approve on 2010-08-24
Martin Packman (community) Abstain on 2010-05-03
Review via email: mp+24306@code.launchpad.net

Description of the Change

Fixes refresh when working tree directory renamed or deleted (Bug 568728)

Changed QExplorerMainWindow.do_refresh so that it only updates the working tree if the current location supports and has a working tree.

Refactored Location models so that they have methods to indicate that the model supports a working tree and has a working tree. Updated QExplorerMainWindow.changed_view to use this.

To test (on Windows):
- Start BzrExplorer
- Open a repository containing branches/checkouts
- Using OS copy one of the branches or checkouts within the repository
- In BzrExplorer refresh repository tab - check copied branch/checkout now shown
- Double click on the copied branch/checkout in BzrExplorer repository tab to open it
- Using OS attempt to delete copied branch/checkout: should fail whilst current tab in BzrExplorer is the copied branch/checkout (existing behaviour)
- Change current tab in BzrExplorer to be repository
- Using OS attempt to delete copied branch/checkout: should succeed
- Refresh the repository tab in BzrExplorer: deleted branch/checkout should be removed
- Change current tab in BzrExplorer to be deleted branch/checkout: "Unable to change to ..." error dialog should be displayed
- OK error dialog: tab for deleted branch/checkout should be closed

Repeat above but instead of deleting copied branch/checkout using OS rename it. The same results should be observed.

To post a comment you must log in.
Martin Packman (gz) wrote :

Try and avoid adding trailing whitespace to lines, it's bad for diff and blame:
45 -<EOL>
46 + <EOL>

Is there no way of writing an automated test for this? Steps to reproduce the problem are great, but aren't going to be repeated every release to ensure the bugfix still works.

review: Abstain
468. By Simon Kersey on 2010-05-06

Remove trailing whitespace

Simon Kersey (simon-kersey) wrote :

> Try and avoid adding trailing whitespace to lines, it's bad for diff and
> blame:
> 45 -<EOL>
> 46 + <EOL>
>

Updated to remove trailing whitespace

> Is there no way of writing an automated test for this? Steps to reproduce the
> problem are great, but aren't going to be repeated every release to ensure the
> bugfix still works.

At the moment there's not much in the way of tests for Bzr-Explorer. I don't mind trying to write some for this patch but don't have a clear idea where to start.

469. By Simon Kersey on 2010-08-23

merge trunk

Alexander Belchenko (bialix) wrote :

Sorry for the delay. I will review it soon. (Ping to myself)

Alexander Belchenko (bialix) wrote :

Just one note: please don't add extra blank lines between methods, as you do in lib/explorer.py after do_refresh method. I'll remove it before merging, this note for future.

Thank you for you fix!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-08-10 12:40:22 +0000
3+++ NEWS 2010-08-24 09:41:02 +0000
4@@ -22,6 +22,8 @@
5 * Custom switch dialog in colocated workspace works correctly with old PyQt 4.4.
6 (Bug #582714, Alexander Belchenko)
7
8+* Fixed refresh when directory renamed/deleted (Simon Kersey, #568728)
9+
10 Notes:
11
12 * bzr-explorer now requires qbzr 0.19.
13
14=== modified file 'lib/explorer.py'
15--- lib/explorer.py 2010-08-06 15:08:29 +0000
16+++ lib/explorer.py 2010-08-24 09:41:02 +0000
17@@ -599,9 +599,11 @@
18 available = self._supported_commands
19 kind = None
20 working_tree = None
21+ wt_applicable = False
22 if view:
23 kind = view.kind()
24- if kind != kinds.WELCOME_PAGE:
25+ wt_applicable = view.has_wt()
26+ if view.supports_wt():
27 working_tree = view.working_tree()
28 for action, conditions in self._conditions_by_action.items():
29 try:
30@@ -625,11 +627,6 @@
31 # Update the working tree browser, hiding it for pages where
32 # it's never applicable
33 action = self.ui.action_WorkingTree_Browser
34- wt_applicable = working_tree is not None and kind in [
35- kinds.BRANCH_KIND,
36- kinds.BOUND_BRANCH_KIND,
37- kinds.CHECKOUT_KIND,
38- ]
39 action.setEnabled(wt_applicable)
40 wt_visible = wt_applicable and action.isChecked()
41 self._wt_browser.setVisible(wt_visible)
42@@ -1691,8 +1688,13 @@
43
44 def do_refresh(self, reopen=False):
45 self.location_viewer.refresh_current(reopen=reopen)
46- self._wt_browser.refresh()
47+ #
48+ # only refresh working tree if current view has one
49+ view = self.current_view()
50+ if view and view.has_wt():
51+ self._wt_browser.refresh()
52 self.changed_view()
53+
54
55 def refresh_diagnostic_mode(self):
56 self.dry_run = self.ui.action_Diagnostic_Mode.isChecked()
57
58=== modified file 'lib/location.py'
59--- lib/location.py 2010-02-21 07:04:02 +0000
60+++ lib/location.py 2010-08-24 09:41:02 +0000
61@@ -135,6 +135,14 @@
62 def group(self):
63 """Return the group key or None if not part of a group."""
64 return None
65+
66+ def supports_wt(self):
67+ """Return true if model should have a working tree"""
68+ return False
69+
70+ def has_wt(self):
71+ """Return true if model has a working tree"""
72+ return False
73
74
75 class ExtensibleLocationModel(_AbstractLocationModel):
76@@ -275,6 +283,18 @@
77 """
78 return self.interesting_kind
79
80+ def supports_wt(self):
81+ """Return True if model should have a working tree"""
82+ return (self.interesting_kind in [
83+ BRANCH_KIND,
84+ BOUND_BRANCH_KIND,
85+ CHECKOUT_KIND,
86+ ])
87+
88+ def has_wt(self):
89+ """Return True if model has a working tree"""
90+ return (self.supports_wt() and self.tree is not None)
91+
92 def category(self):
93 """Return one of local, remote, None."""
94 return {True: "local", False: "remote"}[self._local]

Subscribers

People subscribed via source and target branches