Rev 583: Show diffs of threads, allow switching to different threads. in file:///data/jelmer/bzr-gtk/trunk/
Jelmer Vernooij
jelmer at samba.org
Thu Jul 31 02:09:02 BST 2008
At file:///data/jelmer/bzr-gtk/trunk/
------------------------------------------------------------
revno: 583
revision-id: jelmer at samba.org-20080731010901-2wbyaorsf4wbukrx
parent: jelmer at samba.org-20080731000721-tbg7rh6302eywkj8
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Thu 2008-07-31 03:09:01 +0200
message:
Show diffs of threads, allow switching to different threads.
modified:
__init__.py __init__.py-20060519165329-a1fd52c8a829fcd5
loom.py loom.py-20080730235158-elzoq27ll0eh6401-1
=== modified file '__init__.py'
--- a/__init__.py 2008-07-30 23:52:06 +0000
+++ b/__init__.py 2008-07-31 01:09:01 +0000
@@ -185,10 +185,15 @@
takes_args = [ "location?" ]
def run(self, location="."):
- (br, path) = branch.Branch.open_containing(location)
+ try:
+ (tree, path) = workingtree.WorkingTree.open_containing(location)
+ br = tree.branch
+ except NoWorkingTree, e:
+ (br, path) = branch.Branch.open_containing(location)
+ tree = None
open_display()
from bzrlib.plugins.gtk.loom import LoomDialog
- dialog = LoomDialog(br)
+ dialog = LoomDialog(br, tree)
dialog.run()
=== modified file 'loom.py'
--- a/loom.py 2008-07-31 00:07:21 +0000
+++ b/loom.py 2008-07-31 01:09:01 +0000
@@ -24,20 +24,27 @@
import gobject
from bzrlib.plugins.gtk import _i18n
+from bzrlib.plugins.gtk.diff import DiffWidget
from bzrlib.plugins.gtk.dialog import question_dialog
from bzrlib.plugins.loom import branch as loom_branch
+from bzrlib.plugins.loom import tree as loom_tree
class LoomDialog(gtk.Dialog):
"""Simple Loom browse dialog."""
- def __init__(self, branch, parent=None):
+ def __init__(self, branch, tree=None, parent=None):
gtk.Dialog.__init__(self, title="Threads",
parent=parent,
flags=0,
buttons=(gtk.STOCK_CLOSE,gtk.RESPONSE_OK))
self.branch = branch
+ if tree is not None:
+ self.tree = loom_tree.LoomTreeDecorator(tree)
+ else:
+ self.tree = None
self._construct()
+ self._load_threads()
def run(self):
try:
@@ -55,24 +62,51 @@
return super(LoomDialog, self).run()
def _construct(self):
+ hbox = gtk.HBox()
+
self._threads_scroller = gtk.ScrolledWindow()
self._threads_scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self._threads_view = gtk.TreeView()
- self._threads_view.show()
self._threads_scroller.add(self._threads_view)
self._threads_scroller.set_shadow_type(gtk.SHADOW_IN)
- self._threads_scroller.show()
- self.vbox.pack_start(self._threads_scroller)
+ hbox.pack_start(self._threads_scroller)
self._threads_store = gtk.ListStore(
- gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
+ gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT, gobject.TYPE_STRING)
self._threads_view.set_model(self._threads_store)
self._threads_view.append_column(gtk.TreeViewColumn("Name", gtk.CellRendererText(), text=0))
+ self._threads_view.connect('cursor-changed', self._on_view_thread)
+ if self.tree is not None:
+ self._threads_view.connect('row-activated', self._on_switch_thread)
+
+ self._diff = DiffWidget()
+ self._diff.show()
+ hbox.pack_end(self._diff)
+
+ hbox.show_all()
+ self.vbox.pack_start(hbox)
# Buttons: combine-thread, export-loom, revert-loom, up-thread
- self.set_default_size(200, 350)
-
- self._load_threads()
+ self.set_default_size(500, 350)
+
+ def _on_view_thread(self, treeview):
+ treeselection = treeview.get_selection()
+ (model, selection) = treeselection.get_selected()
+ if selection is None:
+ return
+ revid, parent_revid = model.get(selection, 1, 3)
+ if parent_revid is None:
+ return
+ self.branch.lock_read()
+ try:
+ (rev_tree, parent_tree) = tuple(self.branch.repository.revision_trees([revid, parent_revid]))
+ self._diff.set_diff(rev_tree, parent_tree)
+ finally:
+ self.branch.unlock()
+
+ def _on_switch_thread(self, treeview, path, view_column):
+ new_thread = self._threads_store.get_value(self._threads_store.get_iter(path), 0)
+ self.tree.down_thread(new_thread)
def _load_threads(self):
self._threads_store.clear()
@@ -80,7 +114,9 @@
self.branch.lock_read()
try:
threads = self.branch.get_loom_state().get_threads()
- for thread in reversed(threads):
- self._threads_store.append(thread)
+ last_revid = None
+ for name, revid, parent_ids in reversed(threads):
+ self._threads_store.append([name, revid, parent_ids, last_revid])
+ last_revid = revid
finally:
self.branch.unlock()
More information about the bazaar-commits
mailing list