Rev 579: Merge trunk. in file:///data/jelmer/bzr-gtk/trunk/

Jelmer Vernooij jelmer at samba.org
Sun Jul 27 13:05:07 BST 2008


At file:///data/jelmer/bzr-gtk/trunk/

------------------------------------------------------------
revno: 579
revision-id: jelmer at samba.org-20080727120506-jeeik6ywvz8ny0im
parent: jelmer at samba.org-20080727120106-7u0y6lxt7j6wm7su
parent: colbrac at xs4all.nl-20080727120140-1agdlzkc9fumjk5f
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Sun 2008-07-27 14:05:06 +0200
message:
  Merge trunk.
modified:
  NEWS                           news-20070325173539-3va57o99cz3o57xe-1
  errors.py                      errors.py-20070129213417-8rr7unfjjdetfq83-1
  merge.py                       merge.py-20061009195451-45vs0pe2nphnckxh-1
    ------------------------------------------------------------
    revno: 577.1.1
    revision-id: colbrac at xs4all.nl-20080727120140-1agdlzkc9fumjk5f
    parent: colbrac at xs4all.nl-20080727114514-7x546ayrtreulp5u
    parent: colbrac at xs4all.nl-20080727113731-p2krsw6o3m57ctu6
    committer: Jasper Groenewegen <colbrac at xs4all.nl>
    branch nick: trunk
    timestamp: Sun 2008-07-27 14:01:40 +0200
    message:
      Merge merge dialog improvements
    modified:
      NEWS                           news-20070325173539-3va57o99cz3o57xe-1
      errors.py                      errors.py-20070129213417-8rr7unfjjdetfq83-1
      merge.py                       merge.py-20061009195451-45vs0pe2nphnckxh-1
    ------------------------------------------------------------
    revno: 576.3.2
    revision-id: colbrac at xs4all.nl-20080727113731-p2krsw6o3m57ctu6
    parent: colbrac at xs4all.nl-20080727112034-x3c07o6b5gk1drn5
    committer: Jasper Groenewegen <colbrac at xs4all.nl>
    branch nick: improve-merge
    timestamp: Sun 2008-07-27 13:37:31 +0200
    message:
      Add PointlessMerge error
      Merge dialog title change
      Merge dialog icon
      Tweak logic
    modified:
      errors.py                      errors.py-20070129213417-8rr7unfjjdetfq83-1
      merge.py                       merge.py-20061009195451-45vs0pe2nphnckxh-1
    ------------------------------------------------------------
    revno: 576.3.1
    revision-id: colbrac at xs4all.nl-20080727112034-x3c07o6b5gk1drn5
    parent: jelmer at samba.org-20080725213623-44iq5k34vc0v6z7y
    committer: Jasper Groenewegen <colbrac at xs4all.nl>
    branch nick: improve-merge
    timestamp: Sun 2008-07-27 13:20:34 +0200
    message:
      Merge dialog: Add ability to choose between folder and custom location as merge source
    modified:
      merge.py                       merge.py-20061009195451-45vs0pe2nphnckxh-1
=== modified file 'NEWS'
--- a/NEWS	2008-07-27 11:45:14 +0000
+++ b/NEWS	2008-07-27 12:01:40 +0000
@@ -22,6 +22,8 @@
   * Sort Olive bookmarks by title (Jasper Groenewegen)
   
   * Add controls to wrap long lines in gdiff and diff in visualise. (Jasper Groenewegen, #229789)
+  
+  * Made merge dialog to give choice between folder and custom location (Jasper Groenewegen)
 
  BUG FIXES
 

=== modified file 'errors.py'
--- a/errors.py	2008-05-05 18:16:46 +0000
+++ b/errors.py	2008-07-27 11:37:31 +0000
@@ -16,7 +16,7 @@
 
 import bzrlib.errors as errors
 from bzrlib.plugins.gtk import _i18n
-from dialog import error_dialog
+from dialog import error_dialog, info_dialog, warning_dialog
 
 
 def show_bzr_error(unbound):
@@ -33,6 +33,9 @@
         except errors.PointlessCommit:
             error_dialog(_i18n('No changes to commit'),
                          _i18n('Try force commit if you want to commit anyway.'))
+        except errors.PointlessMerge:
+            info_dialog(_i18n('No changes to merge'),
+                         _i18n('Merge location is already fully merged in working tree.'))
         except errors.ConflictsInTree:
             error_dialog(_i18n('Conflicts in tree'),
                          _i18n('You need to resolve the conflicts before committing.'))

=== modified file 'merge.py'
--- a/merge.py	2008-07-25 15:42:45 +0000
+++ b/merge.py	2008-07-27 11:37:31 +0000
@@ -27,7 +27,7 @@
 from bzrlib.branch import Branch
 import bzrlib.errors as errors
 
-from bzrlib.plugins.gtk import _i18n
+from bzrlib.plugins.gtk import _i18n, icon_path
 from bzrlib.plugins.gtk.dialog import error_dialog, info_dialog, warning_dialog
 from bzrlib.plugins.gtk.errors import show_bzr_error
 
@@ -37,52 +37,97 @@
     
     def __init__(self, wt, wtpath, default_branch_path=None, parent=None):
         """ Initialize the Merge dialog. """
-        gtk.Dialog.__init__(self, title="Olive - Merge",
+        gtk.Dialog.__init__(self, title="Merge changes",
                                   parent=parent,
                                   flags=0,
                                   buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
-        
+        self.set_icon_from_file(icon_path("bzr-icon-64.png"))
         # Get arguments
         self.wt = wt
         self.wtpath = wtpath
-        
-        if default_branch_path and os.path.isdir(default_branch_path.partition('file://')[2]):
-            directory = default_branch_path.partition('file://')[2]
-        else:
-            directory = os.path.dirname(self.wt.abspath(self.wtpath))
+        self.default_branch_path = default_branch_path
+        self.parent_window = parent
         
         # Create widgets
         self._hbox = gtk.HBox()
+        self._source = gtk.HBox()
         self._label_merge_from = gtk.Label(_i18n("Merge from"))
-        self._filechooser_dialog = gtk.FileChooserDialog(title="Please select a folder",
-                                    parent=self.window,
-                                    action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
-                                    buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
-                                             gtk.STOCK_OPEN, gtk.RESPONSE_OK))
-        self._filechooser_dialog.set_default_response(gtk.RESPONSE_OK)
-        self._filechooser = gtk.FileChooserButton(self._filechooser_dialog)
+        self._combo_source = gtk.combo_box_new_text()
+        for entry in [_i18n("Folder"),_i18n("Custom Location")]:
+            self._combo_source.append_text(entry)
+        self._combo_source.connect("changed", self._on_combo_changed)
         self._button_merge = gtk.Button(_i18n("_Merge"))
         self._button_merge_icon = gtk.Image()
         self._button_merge_icon.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
         self._button_merge.set_image(self._button_merge_icon)
-        
         self._button_merge.connect('clicked', self._on_merge_clicked)
         
-        # Set location
-        self._filechooser_dialog.set_current_folder(directory)
-        
         # Add widgets to dialog
-        self.vbox.add(self._hbox)
+        self.vbox.pack_start(self._hbox, False, False, 0)
         self._hbox.add(self._label_merge_from)
-        self._hbox.add(self._filechooser)
+        self._hbox.add(self._combo_source)
         self._hbox.set_spacing(5)
         self.action_area.pack_end(self._button_merge)
         
+        if self.default_branch_path and os.path.isdir(
+                            self.default_branch_path.partition('file://')[2]):
+            self.directory = self.default_branch_path.partition('file://')[2]
+            self._combo_source.set_active(0)
+        elif self.default_branch_path:
+            self._combo_source.set_active(1)
+        else:
+            # If no default_branch_path give, default to folder source with current folder
+            self._combo_source.set_active(0)
         self.vbox.show_all()
-
+    
+    def _on_folder_source(self):
+        """ Merge from folder, create a filechooser dialog and button """
+        self._source = gtk.HBox()
+        self._filechooser_dialog = gtk.FileChooserDialog(title="Please select a folder",
+                                    parent=self.parent_window,
+                                    action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
+                                    buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+                                             gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+        self._filechooser_dialog.set_default_response(gtk.RESPONSE_OK)
+        self._filechooser = gtk.FileChooserButton(self._filechooser_dialog)
+        self._filechooser.show()
+        directory = getattr(self, 'directory', None)
+        if not directory:
+            directory = os.path.dirname(self.wt.abspath(self.wtpath))
+        self._filechooser_dialog.set_current_folder(directory)
+        self._source.pack_start(self._filechooser, True, True, 0)
+        self.vbox.pack_start(self._source, True, True, 5)
+        self._source.show()
+    
+    def _on_custom_source(self):
+        """ Merge from a custom source (can be folder, remote, etc), create entry """
+        self._source = gtk.HBox()
+        self._custom_entry = gtk.Entry()
+        if self.default_branch_path:
+            self._custom_entry.set_text(self.default_branch_path)
+        self._custom_entry.connect("activate", self._on_merge_clicked)
+        self._custom_entry.show()
+        self._source.pack_start(self._custom_entry, True, True, 0)
+        self.vbox.pack_start(self._source, True, True, 5)
+        self._source.show()
+    
+    def _on_combo_changed(self, widget):
+        merge_source = self._combo_source.get_active()
+        self._source.destroy()
+        if merge_source == 0:
+            # Merge from folder
+            self._on_folder_source()
+        elif merge_source == 1:
+            # Merge from custom
+            self._on_custom_source()
+    
     @show_bzr_error
     def _on_merge_clicked(self, widget):
-        branch = self._filechooser.get_filename()
+        merge_source = self._combo_source.get_active()
+        if merge_source == 0:
+            branch = self._filechooser.get_filename()
+        elif merge_source == 1:
+            branch = self._custom_entry.get_text()
         if branch == "":
             error_dialog(_i18n('Branch not given'),
                          _i18n('Please specify a branch to merge from.'))




More information about the bazaar-commits mailing list