bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
1  | 
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
 | 
2  | 
#
 | 
|
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.
 | 
|
7  | 
#
 | 
|
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.
 | 
|
12  | 
#
 | 
|
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
 | 
|
16  | 
||
17  | 
import os  | 
|
18  | 
||
19  | 
try:  | 
|
20  | 
import pygtk  | 
|
21  | 
pygtk.require("2.0")  | 
|
22  | 
except:  | 
|
23  | 
    pass
 | 
|
24  | 
||
25  | 
import gtk  | 
|
26  | 
import gtk.glade  | 
|
27  | 
||
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
28  | 
from bzrlib.branch import Branch  | 
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
29  | 
import bzrlib.errors as errors  | 
30  | 
||
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
31  | 
from dialog import error_dialog, info_dialog, warning_dialog  | 
| 
132
by Jelmer Vernooij
 Use decorator for catching and showing bzr-gtk errors graphically. Eventually, this should go away and should be handled by the ui factory.  | 
32  | 
from errors import show_bzr_error  | 
| 
93.1.12
by Alexander Belchenko
 Names XML files with GUI resources obtained via olive/guifiles.py  | 
33  | 
from guifiles import GLADEFILENAME  | 
| 
93.1.6
by Alexander Belchenko
 detecting name of glade file doing in separate module (olive.gladefile)  | 
34  | 
|
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
35  | 
|
36  | 
class MergeDialog:  | 
|
37  | 
""" Display the Merge dialog and perform the needed actions. """  | 
|
38  | 
def __init__(self, wt, wtpath):  | 
|
39  | 
""" Initialize the Merge dialog. """  | 
|
| 
93.1.6
by Alexander Belchenko
 detecting name of glade file doing in separate module (olive.gladefile)  | 
40  | 
self.glade = gtk.glade.XML(GLADEFILENAME, 'window_merge', 'olive-gtk')  | 
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
41  | 
|
42  | 
self.window = self.glade.get_widget('window_merge')  | 
|
43  | 
||
44  | 
        # Dictionary for signal_autoconnect
 | 
|
45  | 
dic = { "on_button_merge_merge_clicked": self.merge,  | 
|
46  | 
"on_button_merge_cancel_clicked": self.close,  | 
|
47  | 
"on_button_merge_open_clicked": self.open }  | 
|
48  | 
||
49  | 
        # Connect the signals to the handlers
 | 
|
50  | 
self.glade.signal_autoconnect(dic)  | 
|
51  | 
||
52  | 
self.wt = wt  | 
|
53  | 
self.wtpath = wtpath  | 
|
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
54  | 
|
55  | 
        # Get some widgets
 | 
|
56  | 
self.entry = self.glade.get_widget('entry_merge')  | 
|
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
57  | 
|
58  | 
def display(self):  | 
|
59  | 
""" Display the Add file(s) dialog. """  | 
|
60  | 
self.window.show_all()  | 
|
61  | 
||
| 
132
by Jelmer Vernooij
 Use decorator for catching and showing bzr-gtk errors graphically. Eventually, this should go away and should be handled by the ui factory.  | 
62  | 
    @show_bzr_error
 | 
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
63  | 
def merge(self, widget):  | 
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
64  | 
branch = self.entry.get_text()  | 
65  | 
if branch == "":  | 
|
66  | 
error_dialog(_('Branch not given'),  | 
|
67  | 
_('Please specify a branch to merge from.'))  | 
|
68  | 
            return
 | 
|
69  | 
||
| 
132
by Jelmer Vernooij
 Use decorator for catching and showing bzr-gtk errors graphically. Eventually, this should go away and should be handled by the ui factory.  | 
70  | 
other_branch = Branch.open_containing(branch)[0]  | 
71  | 
||
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
72  | 
try:  | 
73  | 
conflicts = self.wt.merge_from_branch(other_branch)  | 
|
74  | 
except errors.BzrCommandError, errmsg:  | 
|
75  | 
error_dialog(_('Bazaar command error'), str(errmsg))  | 
|
76  | 
            return
 | 
|
77  | 
||
78  | 
self.close()  | 
|
79  | 
if conflicts == 0:  | 
|
80  | 
            # No conflicts found.
 | 
|
81  | 
info_dialog(_('Merge successful'),  | 
|
82  | 
_('All changes applied successfully.'))  | 
|
83  | 
else:  | 
|
84  | 
            # There are conflicts to be resolved.
 | 
|
85  | 
warning_dialog(_('Conflicts encountered'),  | 
|
86  | 
_('Please resolve the conflicts manually before committing.'))  | 
|
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
87  | 
|
88  | 
def open(self, widget):  | 
|
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
89  | 
fcd = gtk.FileChooserDialog(title="Please select a folder",  | 
90  | 
parent=self.window,  | 
|
91  | 
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,  | 
|
92  | 
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,  | 
|
93  | 
gtk.STOCK_OPEN, gtk.RESPONSE_OK))  | 
|
94  | 
fcd.set_default_response(gtk.RESPONSE_OK)  | 
|
95  | 
||
96  | 
if fcd.run() == gtk.RESPONSE_OK:  | 
|
97  | 
self.entry.set_text(fcd.get_filename())  | 
|
98  | 
||
99  | 
fcd.destroy()  | 
|
100  | 
||
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
101  | 
def close(self, widget=None):  | 
102  | 
self.window.destroy()  |