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 |
475.1.2
by Vincent Ladeuil
Fix bug #187283 fix replacing _() by _i18n(). |
30 |
from bzrlib.plugins.gtk import _i18n |
93
by Szilveszter Farkas (Phanatic)
Began to implement Merge dialog. |
31 |
|
153
by Jelmer Vernooij
Fix references to dialog. |
32 |
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. |
33 |
from errors import show_bzr_error |
144
by Jelmer Vernooij
Actually add the preference tests this time (forgot to ran 'bzr add'...) |
34 |
from olive.guifiles import GLADEFILENAME |
93.1.6
by Alexander Belchenko
detecting name of glade file doing in separate module (olive.gladefile) |
35 |
|
93
by Szilveszter Farkas (Phanatic)
Began to implement Merge dialog. |
36 |
|
37 |
class MergeDialog: |
|
38 |
""" Display the Merge dialog and perform the needed actions. """ |
|
274.1.2
by Mateusz Korniak
Add default_branch_path to MergeDialog and use it from olive-gtk |
39 |
def __init__(self, wt, wtpath,default_branch_path=None): |
93
by Szilveszter Farkas (Phanatic)
Began to implement Merge dialog. |
40 |
""" Initialize the Merge dialog. """ |
93.1.6
by Alexander Belchenko
detecting name of glade file doing in separate module (olive.gladefile) |
41 |
self.glade = gtk.glade.XML(GLADEFILENAME, 'window_merge', 'olive-gtk') |
93
by Szilveszter Farkas (Phanatic)
Began to implement Merge dialog. |
42 |
|
43 |
self.window = self.glade.get_widget('window_merge') |
|
44 |
||
45 |
# Dictionary for signal_autoconnect
|
|
46 |
dic = { "on_button_merge_merge_clicked": self.merge, |
|
47 |
"on_button_merge_cancel_clicked": self.close, |
|
48 |
"on_button_merge_open_clicked": self.open } |
|
49 |
||
50 |
# Connect the signals to the handlers
|
|
51 |
self.glade.signal_autoconnect(dic) |
|
52 |
||
53 |
self.wt = wt |
|
54 |
self.wtpath = wtpath |
|
98
by Szilveszter Farkas (Phanatic)
Implemented basic Merge functionality. |
55 |
|
56 |
# Get some widgets
|
|
57 |
self.entry = self.glade.get_widget('entry_merge') |
|
274.1.2
by Mateusz Korniak
Add default_branch_path to MergeDialog and use it from olive-gtk |
58 |
if default_branch_path: |
59 |
self.entry.set_text(default_branch_path) |
|
93
by Szilveszter Farkas (Phanatic)
Began to implement Merge dialog. |
60 |
|
61 |
def display(self): |
|
62 |
""" Display the Add file(s) dialog. """ |
|
63 |
self.window.show_all() |
|
64 |
||
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. |
65 |
@show_bzr_error
|
93
by Szilveszter Farkas (Phanatic)
Began to implement Merge dialog. |
66 |
def merge(self, widget): |
98
by Szilveszter Farkas (Phanatic)
Implemented basic Merge functionality. |
67 |
branch = self.entry.get_text() |
68 |
if branch == "": |
|
475.1.2
by Vincent Ladeuil
Fix bug #187283 fix replacing _() by _i18n(). |
69 |
error_dialog(_i18n('Branch not given'), |
70 |
_i18n('Please specify a branch to merge from.')) |
|
98
by Szilveszter Farkas (Phanatic)
Implemented basic Merge functionality. |
71 |
return
|
72 |
||
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. |
73 |
other_branch = Branch.open_containing(branch)[0] |
74 |
||
98
by Szilveszter Farkas (Phanatic)
Implemented basic Merge functionality. |
75 |
try: |
76 |
conflicts = self.wt.merge_from_branch(other_branch) |
|
77 |
except errors.BzrCommandError, errmsg: |
|
475.1.2
by Vincent Ladeuil
Fix bug #187283 fix replacing _() by _i18n(). |
78 |
error_dialog(_i18n('Bazaar command error'), str(errmsg)) |
98
by Szilveszter Farkas (Phanatic)
Implemented basic Merge functionality. |
79 |
return
|
80 |
||
81 |
self.close() |
|
82 |
if conflicts == 0: |
|
83 |
# No conflicts found.
|
|
475.1.2
by Vincent Ladeuil
Fix bug #187283 fix replacing _() by _i18n(). |
84 |
info_dialog(_i18n('Merge successful'), |
85 |
_i18n('All changes applied successfully.')) |
|
98
by Szilveszter Farkas (Phanatic)
Implemented basic Merge functionality. |
86 |
else: |
87 |
# There are conflicts to be resolved.
|
|
475.1.2
by Vincent Ladeuil
Fix bug #187283 fix replacing _() by _i18n(). |
88 |
warning_dialog(_i18n('Conflicts encountered'), |
89 |
_i18n('Please resolve the conflicts manually before committing.')) |
|
93
by Szilveszter Farkas (Phanatic)
Began to implement Merge dialog. |
90 |
|
91 |
def open(self, widget): |
|
98
by Szilveszter Farkas (Phanatic)
Implemented basic Merge functionality. |
92 |
fcd = gtk.FileChooserDialog(title="Please select a folder", |
93 |
parent=self.window, |
|
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) |
|
98 |
||
99 |
if fcd.run() == gtk.RESPONSE_OK: |
|
100 |
self.entry.set_text(fcd.get_filename()) |
|
101 |
||
102 |
fcd.destroy() |
|
103 |
||
93
by Szilveszter Farkas (Phanatic)
Began to implement Merge dialog. |
104 |
def close(self, widget=None): |
105 |
self.window.destroy() |