1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
from bzrlib.branch import Branch
29
import bzrlib.errors as errors
31
from dialog import error_dialog, info_dialog, warning_dialog
32
from guifiles import GLADEFILENAME
36
""" Display the Merge dialog and perform the needed actions. """
37
def __init__(self, wt, wtpath):
38
""" Initialize the Merge dialog. """
39
self.glade = gtk.glade.XML(GLADEFILENAME, 'window_merge', 'olive-gtk')
41
self.window = self.glade.get_widget('window_merge')
43
# Dictionary for signal_autoconnect
44
dic = { "on_button_merge_merge_clicked": self.merge,
45
"on_button_merge_cancel_clicked": self.close,
46
"on_button_merge_open_clicked": self.open }
48
# Connect the signals to the handlers
49
self.glade.signal_autoconnect(dic)
55
self.entry = self.glade.get_widget('entry_merge')
58
""" Display the Add file(s) dialog. """
59
self.window.show_all()
61
def merge(self, widget):
62
branch = self.entry.get_text()
64
error_dialog(_('Branch not given'),
65
_('Please specify a branch to merge from.'))
69
other_branch = Branch.open_containing(branch)[0]
70
except errors.NotBranchError:
71
error_dialog(_('Specified location not a branch'),
72
_('Please specify a branch you want to merge from.'))
76
conflicts = self.wt.merge_from_branch(other_branch)
77
except errors.BzrCommandError, errmsg:
78
error_dialog(_('Bazaar command error'), str(errmsg))
84
info_dialog(_('Merge successful'),
85
_('All changes applied successfully.'))
87
# There are conflicts to be resolved.
88
warning_dialog(_('Conflicts encountered'),
89
_('Please resolve the conflicts manually before committing.'))
91
def open(self, widget):
92
fcd = gtk.FileChooserDialog(title="Please select a folder",
94
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
95
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
96
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
97
fcd.set_default_response(gtk.RESPONSE_OK)
99
if fcd.run() == gtk.RESPONSE_OK:
100
self.entry.set_text(fcd.get_filename())
104
def close(self, widget=None):
105
self.window.destroy()