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  | 
||
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
27  | 
from bzrlib.branch import Branch  | 
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
28  | 
import bzrlib.errors as errors  | 
| 
533.1.1
by Jasper Groenewegen
 Replace MergeDialog with glade-less version.  | 
29  | 
|
| 
475.1.2
by Vincent Ladeuil
 Fix bug #187283 fix replacing _() by _i18n().  | 
30  | 
from bzrlib.plugins.gtk import _i18n  | 
| 
533.1.1
by Jasper Groenewegen
 Replace MergeDialog with glade-less version.  | 
31  | 
from bzrlib.plugins.gtk.dialog import error_dialog, info_dialog, warning_dialog  | 
32  | 
from bzrlib.plugins.gtk.errors import show_bzr_error  | 
|
33  | 
||
34  | 
||
35  | 
class MergeDialog(gtk.Dialog):  | 
|
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
36  | 
""" Display the Merge dialog and perform the needed actions. """  | 
| 
533.1.1
by Jasper Groenewegen
 Replace MergeDialog with glade-less version.  | 
37  | 
|
38  | 
def __init__(self, wt, wtpath, default_branch_path=None, parent=None):  | 
|
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
39  | 
""" Initialize the Merge dialog. """  | 
| 
533.1.1
by Jasper Groenewegen
 Replace MergeDialog with glade-less version.  | 
40  | 
gtk.Dialog.__init__(self, title="Olive - Merge",  | 
41  | 
parent=parent,  | 
|
42  | 
flags=0,  | 
|
43  | 
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))  | 
|
44  | 
||
45  | 
        # Get arguments
 | 
|
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
46  | 
self.wt = wt  | 
47  | 
self.wtpath = wtpath  | 
|
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
48  | 
|
| 
533.1.1
by Jasper Groenewegen
 Replace MergeDialog with glade-less version.  | 
49  | 
directory = os.path.dirname(self.wt.abspath(self.wtpath))  | 
50  | 
||
51  | 
        # Create widgets
 | 
|
52  | 
self._hbox = gtk.HBox()  | 
|
53  | 
self._label_merge_from = gtk.Label(_i18n("Merge from"))  | 
|
54  | 
self._filechooser_dialog = gtk.FileChooserDialog(title="Please select a folder",  | 
|
55  | 
parent=self.window,  | 
|
56  | 
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,  | 
|
57  | 
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,  | 
|
58  | 
gtk.STOCK_OPEN, gtk.RESPONSE_OK))  | 
|
59  | 
self._filechooser_dialog.set_default_response(gtk.RESPONSE_OK)  | 
|
60  | 
self._filechooser = gtk.FileChooserButton(self._filechooser_dialog)  | 
|
61  | 
self._button_merge = gtk.Button(_i18n("_Merge"))  | 
|
62  | 
self._button_merge_icon = gtk.Image()  | 
|
63  | 
self._button_merge_icon.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)  | 
|
64  | 
self._button_merge.set_image(self._button_merge_icon)  | 
|
65  | 
||
66  | 
self._button_merge.connect('clicked', self._on_merge_clicked)  | 
|
67  | 
||
68  | 
        # Set location
 | 
|
69  | 
self._filechooser_dialog.set_current_folder(directory)  | 
|
70  | 
||
71  | 
        # Add widgets to dialog
 | 
|
72  | 
self.vbox.add(self._hbox)  | 
|
73  | 
self._hbox.add(self._label_merge_from)  | 
|
| 
533.2.4
by Jasper Groenewegen
 Fix what is broken  | 
74  | 
self._hbox.add(self._filechooser)  | 
| 
533.1.1
by Jasper Groenewegen
 Replace MergeDialog with glade-less version.  | 
75  | 
self._hbox.set_spacing(5)  | 
76  | 
self.action_area.pack_end(self._button_merge)  | 
|
77  | 
||
78  | 
self.vbox.show_all()  | 
|
| 
93
by Szilveszter Farkas (Phanatic)
 Began to implement Merge dialog.  | 
79  | 
|
| 
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.  | 
80  | 
    @show_bzr_error
 | 
| 
533.1.1
by Jasper Groenewegen
 Replace MergeDialog with glade-less version.  | 
81  | 
def _on_merge_clicked(self, widget):  | 
82  | 
branch = self._filechooser.get_filename()  | 
|
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
83  | 
if branch == "":  | 
| 
475.1.2
by Vincent Ladeuil
 Fix bug #187283 fix replacing _() by _i18n().  | 
84  | 
error_dialog(_i18n('Branch not given'),  | 
85  | 
_i18n('Please specify a branch to merge from.'))  | 
|
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
86  | 
            return
 | 
87  | 
||
| 
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.  | 
88  | 
other_branch = Branch.open_containing(branch)[0]  | 
89  | 
||
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
90  | 
try:  | 
91  | 
conflicts = self.wt.merge_from_branch(other_branch)  | 
|
92  | 
except errors.BzrCommandError, errmsg:  | 
|
| 
475.1.2
by Vincent Ladeuil
 Fix bug #187283 fix replacing _() by _i18n().  | 
93  | 
error_dialog(_i18n('Bazaar command error'), str(errmsg))  | 
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
94  | 
            return
 | 
95  | 
||
96  | 
if conflicts == 0:  | 
|
97  | 
            # No conflicts found.
 | 
|
| 
475.1.2
by Vincent Ladeuil
 Fix bug #187283 fix replacing _() by _i18n().  | 
98  | 
info_dialog(_i18n('Merge successful'),  | 
99  | 
_i18n('All changes applied successfully.'))  | 
|
| 
98
by Szilveszter Farkas (Phanatic)
 Implemented basic Merge functionality.  | 
100  | 
else:  | 
101  | 
            # There are conflicts to be resolved.
 | 
|
| 
475.1.2
by Vincent Ladeuil
 Fix bug #187283 fix replacing _() by _i18n().  | 
102  | 
warning_dialog(_i18n('Conflicts encountered'),  | 
103  | 
_i18n('Please resolve the conflicts manually before committing.'))  | 
|
| 
533.1.1
by Jasper Groenewegen
 Replace MergeDialog with glade-less version.  | 
104  | 
|
105  | 
self.response(gtk.RESPONSE_OK)  |