Merge lp:~songofacandy/qbzr/qbrowse-fix into lp:qbzr

Proposed by methane
Status: Merged
Merged at revision: not available
Proposed branch: lp:~songofacandy/qbzr/qbrowse-fix
Merge into: lp:qbzr
Diff against target: 84 lines (+17/-10)
1 file modified
lib/treewidget.py (+17/-10)
To merge this branch: bzr merge lp:~songofacandy/qbzr/qbrowse-fix
Reviewer Review Type Date Requested Status
Gary van der Merwe Approve
Review via email: mp+16069@code.launchpad.net
To post a comment you must log in.
Revision history for this message
methane (songofacandy) wrote :

* Can use 'F2' to start renaming.
* Fix error on end renaming without changes.

Revision history for this message
Gary van der Merwe (garyvdm) :
review: Approve
Revision history for this message
Gary van der Merwe (garyvdm) wrote :

PS: INADA: I see you are now a member of qbzr-dev - so I'm leaving this for you to merge. If you want me to merge it, let me know.

Revision history for this message
methane (songofacandy) wrote :

I've merged this. Thank you.

On Mon, Dec 21, 2009 at 10:11 PM, Gary van der Merwe <email address hidden> wrote:
> PS: INADA: I see you are now a member of qbzr-dev - so I'm leaving this for you to merge. If you want me to merge it, let me know.
> --
> https://code.edge.launchpad.net/~songofacandy/qbzr/qbrowse-fix/+merge/16069
> You are the owner of lp:~songofacandy/qbzr/qbrowse-fix.
>

--
Naoki INADA <email address hidden>

Revision history for this message
Alexander Belchenko (bialix) wrote :

INADA Naoki пишет:
> I've merged this. Thank you.

Please, next time write something in the NEWS about your bugfix.

Revision history for this message
methane (songofacandy) wrote :

On Tue, Dec 22, 2009 at 12:45 AM, Alexander Belchenko <email address hidden> wrote:
> INADA Naoki пишет:
>> I've merged this. Thank you.
>
> Please, next time write something in the NEWS about your bugfix.

roger.

Revision history for this message
Alexander Belchenko (bialix) wrote :

Naoki, sorry for asking so late.

Why you're using posixpath module instead of bzrlib.osutils.pathjoin function? I think the right way is to use the latter function. Do you have any specific reasons to avoid it?

Revision history for this message
Gary van der Merwe (garyvdm) wrote :

On 06/01/2010 12:18, Alexander Belchenko wrote:
> Why you're using posixpath module instead of bzrlib.osutils.pathjoin
> function? I think the right way is to use the latter function. Do you
> have any specific reasons to avoid it?

I questioned that when I reviewed this. In this case, we need '/', even
on windows. This is to fix bug 495519.

https://bugs.launchpad.net/qbzr/+bug/495519

Revision history for this message
Alexander Belchenko (bialix) wrote :

Gary van der Merwe пишет:
> On 06/01/2010 12:18, Alexander Belchenko wrote:
>> Why you're using posixpath module instead of bzrlib.osutils.pathjoin
>> function? I think the right way is to use the latter function. Do you
>> have any specific reasons to avoid it?
>
> I questioned that when I reviewed this. In this case, we need '/', even
> on windows. This is to fix bug 495519.

Gary, osutils.pathjoin *forces* '/' on Windows. That's why I've asked
about it.

Revision history for this message
Gary van der Merwe (garyvdm) wrote :

On Wed, Jan 6, 2010 at 2:09 PM, Alexander Belchenko <email address hidden> wrote:
> Gary, osutils.pathjoin *forces* '/' on Windows. That's why I've asked
> about it.

Oh! Maybe it should be reverted?

Revision history for this message
methane (songofacandy) wrote :

> Gary, osutils.pathjoin *forces* '/' on Windows. That's why I've asked
> about it.

I haven't know about bzrlib.osutils.pathjoin!
The posixpath.join should be replaced by it.

--
Naoki INADA <email address hidden>

Revision history for this message
Alexander Belchenko (bialix) wrote :

INADA Naoki пишет:
>> Gary, osutils.pathjoin *forces* '/' on Windows. That's why I've asked
>> about it.
>
> I haven't know about bzrlib.osutils.pathjoin!
> The posixpath.join should be replaced by it.

OK, I will change the code to use osutils then. I think it will be more
consistent in our usage of bzrlib functions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/treewidget.py'
2--- lib/treewidget.py 2009-12-06 15:16:30 +0000
3+++ lib/treewidget.py 2009-12-12 01:39:12 +0000
4@@ -18,6 +18,7 @@
5 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6
7 import os, sys
8+import posixpath # to use '/' path sep in path.join().
9 from time import (strftime, localtime)
10 from PyQt4 import QtCore, QtGui
11 from bzrlib import errors
12@@ -820,7 +821,9 @@
13 value = unicode(value.toString())
14 item_data = self.inventory_data[index.internalId()]
15 parent = self.inventory_data[item_data.parent_id]
16- new_path = os.path.join(parent.path, value)
17+ new_path = posixpath.join(parent.path, value)
18+ if item_data.path == new_path:
19+ return False
20 try:
21 if item_data.item.file_id:
22 # Versioned file
23@@ -870,8 +873,11 @@
24 if role == QtCore.Qt.DisplayRole:
25 return QtCore.QVariant(item.name)
26 if role == QtCore.Qt.EditRole:
27- parent = self.inventory_data[item_data.parent_id]
28- return QtCore.QVariant(item_data.path[len(parent.path):])
29+ path = item_data.path
30+ if item_data.parent_id:
31+ parent = self.inventory_data[item_data.parent_id]
32+ path = path[len(parent.path)+1:]
33+ return QtCore.QVariant(path)
34 if role == QtCore.Qt.DecorationRole:
35 if item_data.icon is None:
36 if item_data.change and not item_data.change.is_on_disk():
37@@ -945,12 +951,12 @@
38 return QtCore.QVariant()
39
40 def flags(self, index):
41- #if not index.isValid():
42- # return QtCore.Qt.ItemIsEnabled
43+ if not index.isValid():
44+ return 0
45
46 flags = (QtCore.Qt.ItemIsEnabled |
47 QtCore.Qt.ItemIsSelectable)
48-
49+
50 if isinstance(self.tree, WorkingTree):
51 flags = flags | QtCore.Qt.ItemIsDragEnabled
52
53@@ -958,7 +964,7 @@
54 flags = flags | QtCore.Qt.ItemIsEditable
55 if self.checkable:
56 flags = flags | QtCore.Qt.ItemIsUserCheckable
57-
58+
59 id = index.internalId()
60 if id < len(self.inventory_data):
61 item_data = self.inventory_data[index.internalId()]
62@@ -1218,10 +1224,11 @@
63
64 def __init__(self, *args):
65 RevisionTreeView.__init__(self, *args)
66-
67+
68 self.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
69 self.setUniformRowHeights(True)
70- self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
71+ self.setEditTriggers(QtGui.QAbstractItemView.SelectedClicked |
72+ QtGui.QAbstractItemView.EditKeyPressed)
73 self.viewport().setAcceptDrops(True)
74 self.setDropIndicatorShown(True)
75 self.setDragDropMode(QtGui.QAbstractItemView.InternalMove);
76@@ -1900,7 +1907,7 @@
77 """Rename the selected file."""
78
79 indexes = self.get_selection_indexes()
80- if len(indexes) <> 1:
81+ if len(indexes) != 1:
82 return
83 index = indexes[0]
84 index = self.tree_filter_model.mapFromSource (index)

Subscribers

People subscribed via source and target branches