[Pkg-bazaar-commits] ./bzr-gtk/unstable r433: Merge with mainline
Aaron Bentley
aaron at aaronbentley.com
Fri Apr 10 07:50:17 UTC 2009
------------------------------------------------------------
revno: 433
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: gtk-applymerge
timestamp: Sat 2008-02-23 02:39:17 -0500
message:
Merge with mainline
modified:
branchview/linegraph.py
branchview/treeview.py
revbrowser.py
viz/branchwin.py
------------------------------------------------------------
revno: 423.1.17
committer: Gary van der Merwe <garyvdm at garyvdm-desktop>
branch nick: gtk
timestamp: Thu 2008-02-14 21:01:19 +0200
message:
Reuse the viz treeview in the revision browser.
modified:
branchview/treeview.py
revbrowser.py
viz/branchwin.py
------------------------------------------------------------
revno: 423.1.18
committer: Gary van der Merwe <garyvdm at garyvdm-desktop>
branch nick: gtk
timestamp: Thu 2008-02-14 21:59:06 +0200
message:
Add options to viz treeview to not show the line graph, and to only show the main line.
Set the revision browser to use these options.
modified:
branchview/linegraph.py
branchview/treeview.py
revbrowser.py
-------------- next part --------------
=== modified file 'branchview/linegraph.py'
--- a/branchview/linegraph.py 2008-01-13 14:12:49 +0000
+++ b/branchview/linegraph.py 2008-02-14 19:59:06 +0000
@@ -11,7 +11,8 @@
from bzrlib.tsort import merge_sort
-def linegraph(repository, start, maxnum, broken_line_length=None):
+def linegraph(repository, start, maxnum, broken_line_length = None,
+ graph_data = True, mainline_only = False):
"""Produce a directed graph of a bzr repository.
Returns a tuple of (line_graph, revid_index, columns_len) where
@@ -54,6 +55,10 @@
else:
merge_sorted_revisions = ()
+ if mainline_only:
+ merge_sorted_revisions = [elem for elem in merge_sorted_revisions \
+ if len(elem[3])==1 ]
+
revid_index = {}
revno_index = {}
@@ -76,18 +81,6 @@
if maxnum and rev_index >= maxnum:
break
revid_index[revid] = rev_index
- revno_index[revno_sequence] = rev_index
-
- branch_id = revno_sequence[0:-1]
-
- branch_line = None
- if branch_id not in branch_lines:
- branch_line = []
- branch_lines[branch_id] = branch_line
- else:
- branch_line = branch_lines[branch_id]
-
- branch_line.append(rev_index)
parents = graph_parents[revid]
for parent_revid in parents:
@@ -99,207 +92,223 @@
parents,
None,
revno_sequence])
+
+ if graph_data:
+ revno_index[revno_sequence] = rev_index
+
+ branch_id = revno_sequence[0:-1]
+
+ branch_line = None
+ if branch_id not in branch_lines:
+ branch_line = []
+ branch_lines[branch_id] = branch_line
+ else:
+ branch_line = branch_lines[branch_id]
+
+ branch_line.append(rev_index)
- branch_ids = branch_lines.keys()
-
- def branch_id_cmp(x, y):
- """Compaire branch_id's first by the number of digits, then reversed
- by their value"""
- len_x = len(x)
- len_y = len(y)
- if len_x == len_y:
- return -cmp(x, y)
- return cmp(len_x, len_y)
-
- branch_ids.sort(branch_id_cmp)
- # This will hold a tuple of (child_index, parent_index, col_index) for each
- # line that needs to be drawn. If col_index is not none, then the line is
- # drawn along that column, else the the line can be drawn directly between
- # the child and parent because either the child and parent are in the same
- # branch line, or the child and parent are 1 row apart.
- lines = []
- empty_column = [False for i in range(len(graph_parents))]
- # This will hold a bit map for each cell. If the cell is true, then the
- # cell allready contains a node or line. This use when deciding what column
- # to place a branch line or line in, without it overlaping something else.
- columns = [list(empty_column)]
-
-
- for branch_id in branch_ids:
- branch_line = branch_lines[branch_id]
-
- # Find the col_index for the direct parent branch. This will be the
- # starting point when looking for a free column.
- parent_col_index = 0
- parent_index = None
- if len(branch_id) > 1:
- parent_revno = branch_id[0:-1]
- if parent_revno in revno_index:
- parent_index = revno_index[parent_revno]
- parent_node = linegraph[parent_index][1]
- if parent_node:
- parent_col_index = parent_node[0]
-
-
- col_search_order = _branch_line_col_search_order(columns,
- parent_col_index)
- color = reduce(lambda x, y: x+y, branch_id, 0)
- cur_cont_line = []
-
- line_range = []
- last_rev_index = None
- for rev_index in branch_line:
- if last_rev_index:
- if broken_line_length and \
- rev_index - last_rev_index > broken_line_length:
- line_range.append(last_rev_index+1)
- line_range.append(rev_index-1)
- else:
- line_range.extend(range(last_rev_index+1, rev_index))
-
- line_range.append(rev_index)
- last_rev_index = rev_index
-
- if parent_index:
- if broken_line_length and \
- parent_index - last_rev_index > broken_line_length:
- line_range.append(last_rev_index+1)
- else:
- line_range.extend(range(last_rev_index+1, parent_index))
-
- col_index = _find_free_column(columns,
- empty_column,
- col_search_order,
- line_range)
- node = (col_index, color)
- for rev_index in branch_line:
- linegraph[rev_index][1] = node
- columns[col_index][rev_index] = True
-
- for rev_index in branch_line:
- (sequence_number,
- revid,
- merge_depth,
- revno_sequence,
- end_of_merge) = merge_sorted_revisions[rev_index]
-
- linegraph[rev_index][4] = graph_children[revid]
- col_index = linegraph[rev_index][1][0]
-
- for parent_revid in graph_parents[revid]:
- if parent_revid in revid_index:
-
- parent_index = revid_index[parent_revid]
+ if graph_data:
+ branch_ids = branch_lines.keys()
+
+ def branch_id_cmp(x, y):
+ """Compaire branch_id's first by the number of digits, then reversed
+ by their value"""
+ len_x = len(x)
+ len_y = len(y)
+ if len_x == len_y:
+ return -cmp(x, y)
+ return cmp(len_x, len_y)
+
+ branch_ids.sort(branch_id_cmp)
+ # This will hold a tuple of (child_index, parent_index, col_index) for each
+ # line that needs to be drawn. If col_index is not none, then the line is
+ # drawn along that column, else the the line can be drawn directly between
+ # the child and parent because either the child and parent are in the same
+ # branch line, or the child and parent are 1 row apart.
+ lines = []
+ empty_column = [False for i in range(len(graph_parents))]
+ # This will hold a bit map for each cell. If the cell is true, then the
+ # cell allready contains a node or line. This use when deciding what column
+ # to place a branch line or line in, without it overlaping something else.
+ columns = [list(empty_column)]
+
+
+ for branch_id in branch_ids:
+ branch_line = branch_lines[branch_id]
+
+ # Find the col_index for the direct parent branch. This will be the
+ # starting point when looking for a free column.
+ parent_col_index = 0
+ parent_index = None
+ if len(branch_id) > 1:
+ parent_revno = branch_id[0:-1]
+ if parent_revno in revno_index:
+ parent_index = revno_index[parent_revno]
parent_node = linegraph[parent_index][1]
if parent_node:
parent_col_index = parent_node[0]
+
+
+ col_search_order = _branch_line_col_search_order(columns,
+ parent_col_index)
+ color = reduce(lambda x, y: x+y, branch_id, 0)
+ cur_cont_line = []
+
+ line_range = []
+ last_rev_index = None
+ for rev_index in branch_line:
+ if last_rev_index:
+ if broken_line_length and \
+ rev_index - last_rev_index > broken_line_length:
+ line_range.append(last_rev_index+1)
+ line_range.append(rev_index-1)
else:
- parent_col_index = None
- col_search_order = \
- _line_col_search_order(columns,
- parent_col_index,
- col_index)
-
- # If this line is really long, break it.
- if len(branch_id) > 0 and \
- broken_line_length and \
- parent_index - rev_index > broken_line_length:
- child_line_col_index = \
- _find_free_column(columns,
- empty_column,
- col_search_order,
- (rev_index + 1,))
- _mark_column_as_used(columns,
- child_line_col_index,
- (rev_index + 1,))
-
- # Recall _line_col_search_order to reset it back to
- # the beging.
+ line_range.extend(range(last_rev_index+1, rev_index))
+
+ line_range.append(rev_index)
+ last_rev_index = rev_index
+
+ if parent_index:
+ if broken_line_length and \
+ parent_index - last_rev_index > broken_line_length:
+ line_range.append(last_rev_index+1)
+ else:
+ line_range.extend(range(last_rev_index+1, parent_index))
+
+ col_index = _find_free_column(columns,
+ empty_column,
+ col_search_order,
+ line_range)
+ node = (col_index, color)
+ for rev_index in branch_line:
+ linegraph[rev_index][1] = node
+ columns[col_index][rev_index] = True
+
+ for rev_index in branch_line:
+ (sequence_number,
+ revid,
+ merge_depth,
+ revno_sequence,
+ end_of_merge) = merge_sorted_revisions[rev_index]
+
+ linegraph[rev_index][4] = graph_children[revid]
+ col_index = linegraph[rev_index][1][0]
+
+ for parent_revid in graph_parents[revid]:
+ if parent_revid in revid_index:
+
+ parent_index = revid_index[parent_revid]
+ parent_node = linegraph[parent_index][1]
+ if parent_node:
+ parent_col_index = parent_node[0]
+ else:
+ parent_col_index = None
col_search_order = \
_line_col_search_order(columns,
parent_col_index,
col_index)
- parent_col_line_index = \
- _find_free_column(columns,
- empty_column,
- col_search_order,
- (parent_index - 1,))
- _mark_column_as_used(columns,
- parent_col_line_index,
- (parent_index - 1,))
- lines.append((rev_index,
- parent_index,
- (child_line_col_index,
- parent_col_line_index)))
- else :
- line_col_index = col_index
- if parent_index - rev_index >1:
- line_range = range(rev_index + 1, parent_index)
- line_col_index = \
- _find_free_column(columns,
- empty_column,
- col_search_order,
- line_range)
- _mark_column_as_used(columns,
- line_col_index,
- line_range)
- lines.append((rev_index,
- parent_index,
- (line_col_index,)))
-
- for (child_index, parent_index, line_col_indexes) in lines:
- (child_col_index, child_color) = linegraph[child_index][1]
- (parent_col_index, parent_color) = linegraph[parent_index][1]
+
+ # If this line is really long, break it.
+ if len(branch_id) > 0 and \
+ broken_line_length and \
+ parent_index - rev_index > broken_line_length:
+ child_line_col_index = \
+ _find_free_column(columns,
+ empty_column,
+ col_search_order,
+ (rev_index + 1,))
+ _mark_column_as_used(columns,
+ child_line_col_index,
+ (rev_index + 1,))
+
+ # Recall _line_col_search_order to reset it back to
+ # the beging.
+ col_search_order = \
+ _line_col_search_order(columns,
+ parent_col_index,
+ col_index)
+ parent_col_line_index = \
+ _find_free_column(columns,
+ empty_column,
+ col_search_order,
+ (parent_index - 1,))
+ _mark_column_as_used(columns,
+ parent_col_line_index,
+ (parent_index - 1,))
+ lines.append((rev_index,
+ parent_index,
+ (child_line_col_index,
+ parent_col_line_index)))
+ else :
+ line_col_index = col_index
+ if parent_index - rev_index >1:
+ line_range = range(rev_index + 1, parent_index)
+ line_col_index = \
+ _find_free_column(columns,
+ empty_column,
+ col_search_order,
+ line_range)
+ _mark_column_as_used(columns,
+ line_col_index,
+ line_range)
+ lines.append((rev_index,
+ parent_index,
+ (line_col_index,)))
- if len(line_col_indexes) == 1:
- if parent_index - child_index == 1:
- linegraph[child_index][2].append(
- (child_col_index,
- parent_col_index,
- parent_color))
+ for (child_index, parent_index, line_col_indexes) in lines:
+ (child_col_index, child_color) = linegraph[child_index][1]
+ (parent_col_index, parent_color) = linegraph[parent_index][1]
+
+ if len(line_col_indexes) == 1:
+ if parent_index - child_index == 1:
+ linegraph[child_index][2].append(
+ (child_col_index,
+ parent_col_index,
+ parent_color))
+ else:
+ # line from the child's column to the lines column
+ linegraph[child_index][2].append(
+ (child_col_index,
+ line_col_indexes[0],
+ parent_color))
+ # lines down the line's column
+ for line_part_index in range(child_index+1, parent_index-1):
+ linegraph[line_part_index][2].append(
+ (line_col_indexes[0],
+ line_col_indexes[0],
+ parent_color))
+ # line from the line's column to the parent's column
+ linegraph[parent_index-1][2].append(
+ (line_col_indexes[0],
+ parent_col_index,
+ parent_color))
else:
+ # Broken line
# line from the child's column to the lines column
linegraph[child_index][2].append(
(child_col_index,
line_col_indexes[0],
parent_color))
- # lines down the line's column
- for line_part_index in range(child_index+1, parent_index-1):
- linegraph[line_part_index][2].append(
- (line_col_indexes[0],
- line_col_indexes[0],
- parent_color))
+ # Broken line end
+ linegraph[child_index+1][2].append(
+ (line_col_indexes[0],
+ None,
+ parent_color))
+
+ # Broken line end
+ linegraph[parent_index-2][2].append(
+ (None,
+ line_col_indexes[1],
+ parent_color))
# line from the line's column to the parent's column
linegraph[parent_index-1][2].append(
- (line_col_indexes[0],
+ (line_col_indexes[1],
parent_col_index,
parent_color))
- else:
- # Broken line
- # line from the child's column to the lines column
- linegraph[child_index][2].append(
- (child_col_index,
- line_col_indexes[0],
- parent_color))
- # Broken line end
- linegraph[child_index+1][2].append(
- (line_col_indexes[0],
- None,
- parent_color))
-
- # Broken line end
- linegraph[parent_index-2][2].append(
- (None,
- line_col_indexes[1],
- parent_color))
- # line from the line's column to the parent's column
- linegraph[parent_index-1][2].append(
- (line_col_indexes[1],
- parent_col_index,
- parent_color))
-
+ return (linegraph, revid_index, len(columns))
+ else:
+ return (linegraph, revid_index, 0)
- return (linegraph, revid_index, len(columns))
def _branch_line_col_search_order(columns, parent_col_index):
for col_index in range(parent_col_index, len(columns)):
=== modified file 'branchview/treeview.py'
--- a/branchview/treeview.py 2008-02-13 09:25:46 +0000
+++ b/branchview/treeview.py 2008-02-14 19:59:06 +0000
@@ -49,11 +49,17 @@
gobject.PARAM_READABLE),
'revno-column-visible': (gobject.TYPE_BOOLEAN,
- 'Revision number',
+ 'Revision number column',
'Show revision number column',
True,
gobject.PARAM_READWRITE),
+ 'graph-column-visible': (gobject.TYPE_BOOLEAN,
+ 'Graph column',
+ 'Show graph column',
+ True,
+ gobject.PARAM_READWRITE),
+
'date-column-visible': (gobject.TYPE_BOOLEAN,
'Date',
'Show date column',
@@ -64,7 +70,13 @@
'Compact view',
'Break ancestry lines to save space',
True,
- gobject.PARAM_CONSTRUCT | gobject.PARAM_READWRITE)
+ gobject.PARAM_CONSTRUCT | gobject.PARAM_READWRITE),
+
+ 'mainline-only': (gobject.TYPE_BOOLEAN,
+ 'Mainline only',
+ 'Only show the mainline history.',
+ False,
+ gobject.PARAM_CONSTRUCT | gobject.PARAM_READWRITE),
}
@@ -75,6 +87,9 @@
'revision-selected': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
()),
+ 'revision-activated': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ (gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT)),
'tag-added': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
(gobject.TYPE_STRING, gobject.TYPE_STRING))
@@ -97,7 +112,8 @@
lambda x: self.loading_msg_box.hide())
self.scrolled_window = gtk.ScrolledWindow()
- self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
+ gtk.POLICY_AUTOMATIC)
self.scrolled_window.set_shadow_type(gtk.SHADOW_IN)
self.scrolled_window.show()
self.pack_start(self.scrolled_window, expand=True, fill=True)
@@ -120,10 +136,14 @@
def do_get_property(self, property):
if property.name == 'revno-column-visible':
return self.revno_column.get_visible()
+ elif property.name == 'graph-column-visible':
+ return self.graph_column.get_visible()
elif property.name == 'date-column-visible':
return self.date_column.get_visible()
elif property.name == 'compact':
return self.compact
+ elif property.name == 'mainline-only':
+ return self.mainline_only
elif property.name == 'branch':
return self.branch
elif property.name == 'revision':
@@ -140,10 +160,14 @@
def do_set_property(self, property, value):
if property.name == 'revno-column-visible':
self.revno_column.set_visible(value)
+ elif property.name == 'graph-column-visible':
+ self.graph_column.set_visible(value)
elif property.name == 'date-column-visible':
self.date_column.set_visible(value)
elif property.name == 'compact':
self.compact = value
+ elif property.name == 'mainline-only':
+ self.mainline_only = value
elif property.name == 'branch':
self.branch = value
elif property.name == 'revision':
@@ -256,12 +280,16 @@
broken_line_length = 32
else:
broken_line_length = None
+
+ show_graph = self.graph_column.get_visible()
self.branch.lock_read()
(linegraphdata, index, columns_len) = linegraph(self.branch.repository,
self.start,
self.maxnum,
- broken_line_length)
+ broken_line_length,
+ show_graph,
+ self.mainline_only)
self.model = TreeModel(self.branch, linegraphdata)
self.graph_cell.columns_len = columns_len
@@ -282,29 +310,6 @@
return False
- def show_diff(self, revid=None, parentid=None):
- """Open a new window to show a diff between the given revisions."""
- from bzrlib.plugins.gtk.diff import DiffWindow
- window = DiffWindow(parent=self)
-
- parents = self.get_parents()
-
- if revid is None:
- revid = self.get_revision().revision_id
-
- if parentid is None and len(parents) > 0:
- parentid = parents[0]
-
- if parentid is None:
- parentid = NULL_REVISION
-
- rev_tree = self.branch.repository.revision_tree(revid)
- parent_tree = self.branch.repository.revision_tree(parentid)
-
- description = revid + " - " + self.branch.nick
- window.set_diff(description, rev_tree, parent_tree)
- window.show()
-
def construct_treeview(self):
self.treeview = gtk.TreeView()
@@ -422,15 +427,4 @@
menu.popup(None, None, None, event.button, event.get_time())
def _on_revision_activated(self, widget, path, col):
- # TODO: more than one parent
- """Callback for when a treeview row gets activated."""
- revision_id = self.model[path][treemodel.REVID]
- parents = self.model[path][treemodel.PARENTS]
-
- if len(parents) == 0:
- parent_id = None
- else:
- parent_id = parents[0]
-
- self.show_diff(revision_id, parent_id)
- self.treeview.grab_focus()
+ self.emit('revision-activated', path, col)
=== modified file 'revbrowser.py'
--- a/revbrowser.py 2007-05-18 11:09:31 +0000
+++ b/revbrowser.py 2008-02-14 19:59:06 +0000
@@ -26,6 +26,7 @@
import gtk
from bzrlib.osutils import format_date
+from bzrlib.plugins.gtk.branchview.treeview import TreeView
class RevisionBrowser(gtk.Dialog):
@@ -40,114 +41,38 @@
self.branch = branch
# Create the widgets
- self._hbox = gtk.HBox()
- self._image_loading = gtk.image_new_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON)
- self._label_loading = gtk.Label(_("Please wait, revisions are being loaded..."))
- self._scrolledwindow = gtk.ScrolledWindow()
- self._treeview = gtk.TreeView()
self._button_select = gtk.Button(_("_Select"), use_underline=True)
+ self.treeview = TreeView(branch,branch.last_revision(), None)
# Set callbacks
self._button_select.connect('clicked', self._on_select_clicked)
- self._treeview.connect('row-activated', self._on_treeview_row_activated)
+ self.treeview.connect('revision-activated',
+ self._on_treeview_revision_activated)
# Set properties
- self._scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC,
- gtk.POLICY_AUTOMATIC)
+ self.set_default_size(600, 400)
self.vbox.set_spacing(3)
- self.set_default_size(600, 400)
- self._label_loading.set_alignment(0.0, 0.5)
- self._hbox.set_spacing(5)
- self._hbox.set_border_width(5)
-
- # Construct the TreeView columns
- self._treeview.append_column(gtk.TreeViewColumn(_('Revno'),
- gtk.CellRendererText(), text=0))
- self._treeview.append_column(gtk.TreeViewColumn(_('Summary'),
- gtk.CellRendererText(), text=1))
- self._treeview.append_column(gtk.TreeViewColumn(_('Committer'),
- gtk.CellRendererText(), text=2))
- self._treeview.append_column(gtk.TreeViewColumn(_('Time'),
- gtk.CellRendererText(), text=3))
- self._treeview.get_column(1).get_cell_renderers()[0].set_property("width-chars", 40)
- self._treeview.get_column(2).get_cell_renderers()[0].set_property("width-chars", 40)
- self._treeview.get_column(3).get_cell_renderers()[0].set_property("width-chars", 40)
+ self.treeview.set_property('graph-column-visible', False)
+ self.treeview.set_property('date-column-visible', True)
+ self.treeview.set_property('mainline-only', True)
# Construct the dialog
self.action_area.pack_end(self._button_select)
- self._scrolledwindow.add(self._treeview)
-
- self._hbox.pack_start(self._image_loading, False, False)
- self._hbox.pack_start(self._label_loading, True, True)
-
- self.vbox.pack_start(self._hbox, False, False)
- self.vbox.pack_start(self._scrolledwindow, True, True)
+ self.vbox.pack_start(self.treeview, True, True)
# Show the dialog
self.show_all()
-
- # Fill up with revisions
- self._fill_revisions()
-
- def _fill_revisions(self):
- """ Fill up the treeview with the revisions. """
- # [ revno, message, committer, timestamp, revid ]
- self.model = gtk.ListStore(gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING)
- self._treeview.set_model(self.model)
-
- repo = self.branch.repository
- revs = self.branch.revision_history()
- r = repo.get_revisions(revs)
- r.reverse()
-
- for rev in r:
- if rev.committer is not None:
- timestamp = format_date(rev.timestamp, rev.timezone)
- else:
- timestamp = None
- self.model.append([ self.branch.revision_id_to_revno(rev.revision_id),
- rev.get_summary(),
- rev.committer,
- timestamp,
- rev.revision_id ])
- while gtk.events_pending():
- gtk.main_iteration()
- tend = time.time()
-
- # Finished loading
- self._hbox.hide()
-
- def _get_selected_revno(self):
- """ Return the selected revision's revno. """
- treeselection = self._treeview.get_selection()
- (model, iter) = treeselection.get_selected()
-
- if iter is None:
- return None
- else:
- return model.get_value(iter, 0)
-
- def _get_selected_revid(self):
- """ Return the selected revision's revid. """
- treeselection = self._treeview.get_selection()
- (model, iter) = treeselection.get_selected()
-
- if iter is None:
- return None
- else:
- return model.get_value(iter, 4)
-
- def _on_treeview_row_activated(self, treeview, path, column):
+
+
+ def _on_treeview_revision_activated(self, treeview, path, column):
""" Double-click on a row should also select a revision. """
self._on_select_clicked(treeview)
def _on_select_clicked(self, widget):
""" Select button clicked handler. """
- self.selected_revno = self._get_selected_revno()
- self.selected_revid = self._get_selected_revid()
+
+ self.selected_revno = self.treeview.get_property('revision-number')
+ self.selected_revid = \
+ self.treeview.get_property('revision').revision_id
self.response(gtk.RESPONSE_OK)
=== modified file 'viz/branchwin.py'
--- a/viz/branchwin.py 2008-02-13 09:25:46 +0000
+++ b/viz/branchwin.py 2008-02-14 19:01:19 +0000
@@ -16,7 +16,7 @@
from bzrlib.plugins.gtk.window import Window
from bzrlib.plugins.gtk.tags import AddTagDialog
from bzrlib.plugins.gtk.preferences import PreferencesWindow
-from bzrlib.plugins.gtk.branchview import TreeView
+from bzrlib.plugins.gtk.branchview import TreeView, treemodel
from bzrlib.revision import Revision
from bzrlib.config import BranchConfig
from bzrlib.config import GlobalConfig
@@ -226,6 +226,8 @@
self.treeview.connect('revision-selected',
self._treeselection_changed_cb)
+ self.treeview.connect('revision-activated',
+ self._tree_revision_activated)
self.treeview.connect('tag-added', lambda w, t, r: self._update_tags())
@@ -328,6 +330,21 @@
self.revisionview.set_revision(revision)
self.revisionview.set_children(children)
+
+ def _tree_revision_activated(self, widget, path, col):
+ # TODO: more than one parent
+ """Callback for when a treeview row gets activated."""
+ revision = self.treeview.get_revision()
+ parents = self.treeview.get_parents()
+
+ if len(parents) == 0:
+ parent_id = None
+ else:
+ parent_id = parents[0]
+
+ self.show_diff(revision.revision_id, parent_id)
+ self.treeview.grab_focus()
+
def _back_clicked_cb(self, *args):
"""Callback for when the back button is clicked."""
@@ -344,7 +361,7 @@
def _show_clicked_cb(self, revid, parentid):
"""Callback for when the show button for a parent is clicked."""
- self.treeview.show_diff(revid, parentid)
+ self.show_diff(revid, parentid)
self.treeview.grab_focus()
def _set_revision_cb(self, w, revision_id):
@@ -420,4 +437,19 @@
self.go_menu_tags.show_all()
+ def show_diff(self, revid=None, parentid=None):
+ """Open a new window to show a diff between the given revisions."""
+ from bzrlib.plugins.gtk.diff import DiffWindow
+ window = DiffWindow(parent=self)
+
+ if parentid is None:
+ parentid = NULL_REVISION
+
+ rev_tree = self.branch.repository.revision_tree(revid)
+ parent_tree = self.branch.repository.revision_tree(parentid)
+
+ description = revid + " - " + self.branch.nick
+ window.set_diff(description, rev_tree, parent_tree)
+ window.show()
+
More information about the Pkg-bazaar-commits
mailing list