Merge lp:~mbp/bzr-gtk/707482-typeerror into lp:bzr-gtk/gtk2

Proposed by Martin Pool
Status: Merged
Merged at revision: 706
Proposed branch: lp:~mbp/bzr-gtk/707482-typeerror
Merge into: lp:bzr-gtk/gtk2
Diff against target: 106 lines (+20/-16)
1 file modified
annotate/gannotate.py (+20/-16)
To merge this branch: bzr merge lp:~mbp/bzr-gtk/707482-typeerror
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+47628@code.launchpad.net

Description of the change

Per <https://bugs.launchpad.net/bzr-gtk/+bug/707482>, we shouldn't assume that you can just poke ints into a string-typed list model column.

(My editor also changed some tabs to spaces, consistent with the rest of the file.)

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 1/26/2011 9:01 PM, Martin Pool wrote:
> Martin Pool has proposed merging lp:~mbp/bzr-gtk/707482-typeerror into lp:bzr-gtk.
>
> Requested reviews:
> Bazaar GTK maintainers (bzr-gtk)
> Related bugs:
> #707482 gannotate wrong column type
> https://bugs.launchpad.net/bugs/707482
>
> For more details, see:
> https://code.launchpad.net/~mbp/bzr-gtk/707482-typeerror/+merge/47628
>
> Per <https://bugs.launchpad.net/bzr-gtk/+bug/707482>, we shouldn't assume that you can just poke ints into a string-typed list model column.
>
> (My editor also changed some tabs to spaces, consistent with the rest of the file.)

I followed the conversation, and your logic is sensible here. I'm not
super familiar with pygtk, but your changes seem good to me.

I certainly agree that doing string compares to jump to a line number is
a bit odd, but hey, no worse than it was.

So approve from me, at least.
 review: approve

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1BG64ACgkQJdeBCYSNAAN0YwCgqzZxMApidpF6vhSShllo6Tv2
hVcAn1SFDnmc1YT6vFTrn2ya4WnrXuOJ
=59pA
-----END PGP SIGNATURE-----

review: Approve
Revision history for this message
Curtis Hovey (sinzui) wrote :

Hi Martin.

Thank you for the branch. This does fix the gtk column type issue in gannotate.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'annotate/gannotate.py'
2--- annotate/gannotate.py 2010-05-27 02:28:54 +0000
3+++ annotate/gannotate.py 2011-01-27 03:01:30 +0000
4@@ -49,9 +49,9 @@
5 self.all = all
6 self.plain = plain
7 self._branch = branch
8-
9+
10 Window.__init__(self, parent)
11-
12+
13 self.set_icon(self.render_icon(gtk.STOCK_FIND, gtk.ICON_SIZE_BUTTON))
14 self.annotate_colormap = AnnotateColorSaturation()
15
16@@ -68,15 +68,15 @@
17 self.revisionview.set_file_id(file_id)
18 self.revision_id = getattr(tree, 'get_revision_id',
19 lambda: CURRENT_REVISION)()
20-
21+
22 # [revision id, line number, author, revno, highlight color, line]
23 self.annomodel = gtk.ListStore(gobject.TYPE_STRING,
24- gobject.TYPE_STRING,
25+ gobject.TYPE_INT,
26 gobject.TYPE_STRING,
27 gobject.TYPE_STRING,
28 gobject.TYPE_STRING,
29 gobject.TYPE_STRING)
30-
31+
32 last_seen = None
33 try:
34 branch.lock_read()
35@@ -86,7 +86,7 @@
36 for revision_id, revno in revno_map.iteritems():
37 self.dotted[revision_id] = '.'.join(str(num) for num in revno)
38 for line_no, (revision, revno, line)\
39- in enumerate(self._annotate(tree, file_id)):
40+ in enumerate(self._annotate(tree, file_id)):
41 if revision.revision_id == last_seen and not self.all:
42 revno = author = ""
43 else:
44@@ -102,7 +102,7 @@
45 revno,
46 None,
47 line.rstrip("\r\n")
48- ])
49+ ])
50 self.annotations.append(revision)
51
52 if not self.plain:
53@@ -125,7 +125,7 @@
54 # bar?
55 print("gannotate: Line number %d does't exist. Defaulting to "
56 "line 1." % lineno)
57- return
58+ return
59 else:
60 row = lineno - 1
61
62@@ -218,7 +218,7 @@
63 hbox.pack_start(self.goto_button, expand=False, fill=True)
64 hbox.show()
65 vbox.pack_start(hbox, expand=False, fill=True)
66-
67+
68 self.pane = pane = gtk.VPaned()
69 pane.add1(swbox)
70 pane.add2(self.revisionview)
71@@ -532,18 +532,22 @@
72
73 def _match(self, model, iterator, column):
74 matching_case = self._match_case.get_active()
75- string, = model.get(iterator, column)
76+ cell_value, = model.get(iterator, column)
77 key = self._entry.get_text()
78- if self._regexp.get_active():
79+ if column == LINE_NUM_COL:
80+ # FIXME: For goto-line there are faster algorithms than searching
81+ # every line til we find the right one! -- mbp 2011-01-27
82+ return key.strip() == str(cell_value)
83+ elif self._regexp.get_active():
84 if matching_case:
85- match = re.compile(key).search(string, 1)
86+ match = re.compile(key).search(cell_value, 1)
87 else:
88- match = re.compile(key, re.I).search(string, 1)
89+ match = re.compile(key, re.I).search(cell_value, 1)
90 else:
91 if not matching_case:
92- string = string.lower()
93+ cell_value = cell_value.lower()
94 key = key.lower()
95- match = string.find(key) != -1
96+ match = cell_value.find(key) != -1
97
98 return match
99
100@@ -583,4 +587,4 @@
101 path = model.get_path(row)
102 self._view.set_cursor(path)
103 self._view.scroll_to_cell(path, use_align=True)
104- break
105+ break
106\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: