[Pkg-bazaar-commits] ./bzr-gtk/unstable r553: Merge asking the user whether to create an index.

Jelmer Vernooij jelmer at samba.org
Fri Apr 10 07:50:41 UTC 2009


------------------------------------------------------------
revno: 553
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-07-18 17:19:21 +0200
message:
  Merge asking the user whether to create an index.
modified:
  search.py
  viz/branchwin.py
    ------------------------------------------------------------
    revno: 533.11.1
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: trunk
    timestamp: Thu 2008-07-17 14:30:39 +0200
    message:
      Ask user whether to index if there is no index present yet.
    modified:
      search.py
      viz/branchwin.py
-------------- next part --------------
=== modified file 'search.py'
--- a/search.py	2008-07-01 15:28:30 +0000
+++ b/search.py	2008-07-17 12:30:39 +0000
@@ -26,7 +26,7 @@
 
 class SearchDialog(gtk.Dialog):
     """Search dialog."""
-    def __init__(self, branch, parent=None):
+    def __init__(self, index, parent=None):
         gtk.Dialog.__init__(self, title="Search Revisions",
                                   parent=parent,
                                   flags=gtk.DIALOG_MODAL,
@@ -34,9 +34,7 @@
                                            gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
     
         # Get arguments
-        self.branch = branch
-
-        self.index = _mod_index.open_index_url(branch.base)
+        self.index = index
 
         self.searchbar = gtk.HBox()
         self.searchentry = gtk.Entry()

=== modified file 'viz/branchwin.py'
--- a/viz/branchwin.py	2008-07-18 12:37:56 +0000
+++ b/viz/branchwin.py	2008-07-18 15:19:21 +0000
@@ -477,8 +477,25 @@
         _mod_index.index_url(self.branch.base)
 
     def _branch_search_cb(self, w):
+        from bzrlib.plugins.search import index as _mod_index
         from bzrlib.plugins.gtk.search import SearchDialog
-        dialog = SearchDialog(self.branch)
+        from bzrlib.plugins.search import errors as search_errors
+
+        try:
+            index = _mod_index.open_index_url(self.branch.base)
+        except search_errors.NoSearchIndex:
+            dialog = gtk.MessageDialog(self, type=gtk.MESSAGE_QUESTION, 
+                buttons=gtk.BUTTONS_OK_CANCEL, 
+                message_format="This branch has not been indexed yet. "
+                               "Index now?")
+            if dialog.run() == gtk.RESPONSE_OK:
+                dialog.destroy()
+                index = _mod_index.index_url(self.branch.base)
+            else:
+                dialog.destroy()
+                return
+
+        dialog = SearchDialog(index)
         
         if dialog.run() == gtk.RESPONSE_OK:
             self.set_revision(dialog.get_revision())



More information about the Pkg-bazaar-commits mailing list