[Pkg-bazaar-commits] ./bzr-gtk/unstable r365: Fixed locks and made tagging work.

Daniel Schierbeck daniel.schierbeck at gmail.com
Fri Apr 10 07:50:05 UTC 2009


------------------------------------------------------------
revno: 365
committer: Daniel Schierbeck <daniel.schierbeck at gmail.com>
branch nick: menubar
timestamp: Tue 2007-11-06 19:02:09 +0100
message:
  Fixed locks and made tagging work.
modified:
  __init__.py
  viz/branchwin.py
  viz/treeview.py
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2007-10-26 17:02:18 +0000
+++ b/__init__.py	2007-11-06 18:02:09 +0000
@@ -248,22 +248,18 @@
     def run(self, location=".", revision=None, limit=None):
         set_ui_factory()
         (br, path) = branch.Branch.open_containing(location)
-        br.lock_read()
-        try:
-            if revision is None:
-                revid = br.last_revision()
-                if revid is None:
-                    return
-            else:
-                (revno, revid) = revision[0].in_history(br)
+        if revision is None:
+            revid = br.last_revision()
+            if revid is None:
+                return
+        else:
+            (revno, revid) = revision[0].in_history(br)
 
-            import gtk
-            pp = start_viz_window(br, revid, limit)
-            pp.connect("destroy", lambda w: gtk.main_quit())
-            pp.show()
-            gtk.main()
-        finally:
-            br.unlock()
+        import gtk
+        pp = start_viz_window(br, revid, limit)
+        pp.connect("destroy", lambda w: gtk.main_quit())
+        pp.show()
+        gtk.main()
 
 
 class cmd_gannotate(GTKCommand):

=== modified file 'viz/branchwin.py'
--- a/viz/branchwin.py	2007-11-06 17:33:25 +0000
+++ b/viz/branchwin.py	2007-11-06 18:02:09 +0000
@@ -14,6 +14,7 @@
 import pango
 
 from bzrlib.plugins.gtk.window import Window
+from bzrlib.plugins.gtk.tags import AddTagDialog
 from bzrlib.plugins.gtk.preferences import PreferencesWindow
 from bzrlib.revision import Revision
 from bzrlib.config import BranchConfig
@@ -161,7 +162,10 @@
         revision_menu_diff.connect('activate', 
                 lambda w: self.treeview.show_diff())
 
-        revision_menu.add(gtk.MenuItem("Tag Revision"))
+        revision_menu_tag = gtk.MenuItem("Tag Revision")
+        revision_menu_tag.connect('activate', self._tag_revision_cb)
+
+        revision_menu.add(revision_menu_tag)
         revision_menu.add(revision_menu_diff)
 
         branch_menu = gtk.Menu()
@@ -325,6 +329,21 @@
     def _set_revision_cb(self, w, revision_id):
         self.treeview.set_revision_id(revision_id)
 
+    def _tag_revision_cb(self, w):
+        dialog = AddTagDialog(self.branch.repository, self.treeview.get_revision().revision_id, self.branch)
+        response = dialog.run()
+        if response != gtk.RESPONSE_NONE:
+            dialog.hide()
+        
+            if response == gtk.RESPONSE_OK:
+                try:
+                    self.branch.lock_write()
+                    self.branch.tags.set_tag(dialog.tagname, dialog._revid)
+                finally:
+                    self.branch.unlock()
+            
+            dialog.destroy()
+
     def _col_visibility_changed(self, col, property):
         self.treeview.set_property(property + '-column-visible', col.get_active())
 

=== modified file 'viz/treeview.py'
--- a/viz/treeview.py	2007-11-06 17:33:25 +0000
+++ b/viz/treeview.py	2007-11-06 18:02:09 +0000
@@ -73,7 +73,6 @@
         self.construct_treeview()
 
         self.branch = branch
-        self.branch.lock_read()
 
         gobject.idle_add(self.populate, start, maxnum, 
                          broken_line_length)
@@ -82,8 +81,6 @@
         self.children = None
         self.parents  = None
 
-        self.connect('destroy', lambda w: self.branch.unlock())
-
     def do_get_property(self, property):
         if property.name == 'revno-column-visible':
             return self.revno_column.get_visible()
@@ -179,20 +176,25 @@
         :param broken_line_length: After how much lines branches \
                        should be broken.
         """
-        (linegraphdata, index, columns_len) = linegraph(self.branch.repository,
-                                                        start,
-                                                        maxnum, 
-                                                        broken_line_length)
-
-        self.model = TreeModel(self.branch.repository, linegraphdata)
-        self.graph_cell.columns_len = columns_len
-        width = self.graph_cell.get_size(self.treeview)[2]
-        self.graph_column.set_fixed_width(width)
-        self.graph_column.set_max_width(width)
-        self.index = index
-        self.treeview.set_model(self.model)
-        self.treeview.set_cursor(0)
-        self.emit('revisions-loaded')
+        try:
+            self.branch.lock_read()
+            (linegraphdata, index, columns_len) = linegraph(self.branch.repository,
+                                                            start,
+                                                            maxnum, 
+                                                            broken_line_length)
+
+            self.model = TreeModel(self.branch.repository, linegraphdata)
+            self.graph_cell.columns_len = columns_len
+            width = self.graph_cell.get_size(self.treeview)[2]
+            self.graph_column.set_fixed_width(width)
+            self.graph_column.set_max_width(width)
+            self.index = index
+            self.treeview.set_model(self.model)
+            self.treeview.set_cursor(0)
+            self.emit('revisions-loaded')
+
+        finally:
+            self.branch.unlock()
 
         return False
 



More information about the Pkg-bazaar-commits mailing list