/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/frontend/gtk/commit.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-07-25 12:38:56 UTC
  • mto: (0.14.1 main) (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060725123856-f7b3018de9dc669f
2006-07-25  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * olive-gtk: display error if python 2.4 not available (Mario Đanić)
      (Fixed: #54014)
    * olive-gtk: display error if pygtk2 (and glade) not available (Mario Đanić)
      (Fixed: #54013)

2006-07-24  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * olive/frontend/gtk/push.py: display number of pushed revisions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
2
 
#
 
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
#
 
7
 
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
#
 
12
 
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
25
    import gtk
26
26
    import gtk.glade
27
27
    import gobject
28
 
    import pango
29
28
except:
30
29
    sys.exit(1)
31
30
 
32
 
from bzrlib import version_info
33
 
 
34
 
if version_info < (0, 9):
35
 
    # function deprecated after 0.9
36
 
    from bzrlib.delta import compare_trees
37
 
 
 
31
from bzrlib.delta import compare_trees
38
32
import bzrlib.errors as errors
39
33
from bzrlib.workingtree import WorkingTree
40
34
 
 
35
from dialog import OliveDialog
 
36
 
41
37
class OliveCommit:
42
38
    """ Display Commit dialog and perform the needed actions. """
43
 
    def __init__(self, gladefile, comm, dialog):
 
39
    def __init__(self, gladefile, comm):
44
40
        """ Initialize the Commit dialog. """
45
41
        self.gladefile = gladefile
46
 
        self.glade = gtk.glade.XML(self.gladefile, 'window_commit', 'olive-gtk')
 
42
        self.glade = gtk.glade.XML(self.gladefile, 'window_commit')
47
43
        
48
 
        # Communication object
49
44
        self.comm = comm
50
 
        # Dialog object
51
 
        self.dialog = dialog
52
 
        
53
 
        # Get some important widgets
54
 
        self.window = self.glade.get_widget('window_commit')
55
 
        self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
56
 
        self.textview = self.glade.get_widget('textview_commit')
57
 
        self.file_view = self.glade.get_widget('treeview_commit_select')
58
 
 
 
45
        
 
46
        self.dialog = OliveDialog(self.gladefile)
 
47
        
59
48
        # Check if current location is a branch
60
49
        try:
61
50
            (self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
75
64
        
76
65
        # Set the delta
77
66
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
78
 
        if version_info < (0, 9):
79
 
            self.delta = compare_trees(self.old_tree, self.wt)
80
 
        else:
81
 
            self.delta = self.wt.changes_from(self.old_tree)
 
67
        self.delta = compare_trees(self.old_tree, self.wt)
 
68
        
 
69
        # Get the Commit dialog widget
 
70
        self.window = self.glade.get_widget('window_commit')
82
71
        
83
72
        # Dictionary for signal_autoconnect
84
73
        dic = { "on_button_commit_commit_clicked": self.commit,
93
82
    def display(self):
94
83
        """ Display the Push dialog. """
95
84
        if self.notbranch:
96
 
            self.dialog.error_dialog(_('Directory is not a branch'),
97
 
                                     _('You can perform this action only in a branch.'))
98
 
            self.close()
 
85
            self.dialog.error_dialog('Directory is not a branch.')
99
86
        else:
100
 
            from olive.backend.info import is_checkout
101
 
            if is_checkout(self.comm.get_path()):
102
 
                # we have a checkout, so the local commit checkbox must appear
103
 
                self.checkbutton_local.show()
104
 
            
105
 
            self.textview.modify_font(pango.FontDescription("Monospace"))
106
 
            self.window.show()
107
 
            
 
87
            self.window.show_all()
108
88
    
109
89
    # This code is from Jelmer Vernooij's bzr-gtk branch
110
90
    def _create_file_view(self):
111
91
        self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN,
112
92
                                        gobject.TYPE_STRING,
113
93
                                        gobject.TYPE_STRING)
 
94
        self.file_view = self.glade.get_widget('treeview_commit_select')
114
95
        self.file_view.set_model(self.file_store)
115
96
        crt = gtk.CellRendererToggle()
116
97
        crt.set_property("activatable", True)
117
98
        crt.connect("toggled", self._toggle_commit, self.file_store)
118
 
        self.file_view.append_column(gtk.TreeViewColumn(_('Commit'),
 
99
        self.file_view.append_column(gtk.TreeViewColumn("Commit",
119
100
                                     crt, active=0))
120
 
        self.file_view.append_column(gtk.TreeViewColumn(_('Path'),
 
101
        self.file_view.append_column(gtk.TreeViewColumn("Path",
121
102
                                     gtk.CellRendererText(), text=1))
122
 
        self.file_view.append_column(gtk.TreeViewColumn(_('Type'),
 
103
        self.file_view.append_column(gtk.TreeViewColumn("Type",
123
104
                                     gtk.CellRendererText(), text=2))
124
105
 
125
 
        for path, id, kind in self.delta.added:
126
 
            self.file_store.append([ True, path, _('added') ])
127
 
 
128
 
        for path, id, kind in self.delta.removed:
129
 
            self.file_store.append([ True, path, _('removed') ])
130
 
 
131
 
        for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:
132
 
            self.file_store.append([ True, oldpath, _('renamed') ])
133
 
 
134
 
        for path, id, kind, text_modified, meta_modified in self.delta.modified:
135
 
            self.file_store.append([ True, path, _('modified') ])
 
106
        for path, _, _ in self.delta.added:
 
107
            self.file_store.append([ True, path, "added" ])
 
108
 
 
109
        for path, _, _ in self.delta.removed:
 
110
            self.file_store.append([ True, path, "removed" ])
 
111
 
 
112
        for oldpath, _, _, _, _, _ in self.delta.renamed:
 
113
            self.file_store.append([ True, oldpath, "renamed"])
 
114
 
 
115
        for path, _, _, _, _ in self.delta.modified:
 
116
            self.file_store.append([ True, path, "modified"])
136
117
    
137
118
    def _get_specific_files(self):
138
119
        ret = []
150
131
        return
151
132
    
152
133
    def commit(self, widget):
153
 
        textbuffer = self.textview.get_buffer()
 
134
        textview = self.glade.get_widget('textview_commit')
 
135
        textbuffer = textview.get_buffer()
154
136
        start, end = textbuffer.get_bounds()
155
137
        message = textbuffer.get_text(start, end)
156
138
        
 
139
        checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
157
140
        checkbutton_strict = self.glade.get_widget('checkbutton_commit_strict')
158
141
        checkbutton_force = self.glade.get_widget('checkbutton_commit_force')
159
142
        
160
143
        specific_files = self._get_specific_files()
161
144
        
162
 
        self.comm.set_busy(self.window)
163
145
        # merged from Jelmer Vernooij's olive integration branch
164
146
        try:
165
147
            self.wt.commit(message, 
166
148
                           allow_pointless=checkbutton_force.get_active(),
167
149
                           strict=checkbutton_strict.get_active(),
168
 
                           local=self.checkbutton_local.get_active(),
 
150
                           local=checkbutton_local.get_active(),
169
151
                           specific_files=specific_files)
170
152
        except errors.NotBranchError:
171
 
            self.dialog.error_dialog(_('Directory is not a branch'),
172
 
                                     _('You can perform this action only in a branch.'))
173
 
            self.comm.set_busy(self.window, False)
 
153
            self.dialog.error_dialog('Directory is not a branch.')
174
154
            return
175
155
        except errors.LocalRequiresBoundBranch:
176
 
            self.dialog.error_dialog(_('Directory is not a checkout'),
177
 
                                     _('You can perform local commit only on checkouts.'))
178
 
            self.comm.set_busy(self.window, False)
 
156
            self.dialog.error_dialog('Local commit requires a bound branch.')
179
157
            return
180
158
        except errors.PointlessCommit:
181
 
            self.dialog.error_dialog(_('No changes to commit'),
182
 
                                     _('Try force commit if you want to commit anyway.'))
183
 
            self.comm.set_busy(self.window, False)
 
159
            self.dialog.error_dialog('No changes to commit. Try force commit.')
184
160
            return
185
161
        except errors.ConflictsInTree:
186
 
            self.dialog.error_dialog(_('Conflicts in tree'),
187
 
                                     _('You need to resolve the conflicts before committing.'))
188
 
            self.comm.set_busy(self.window, False)
 
162
            self.dialog.error_dialog('Conflicts in tree. Please resolve them first.')
189
163
            return
190
164
        except errors.StrictCommitFailed:
191
 
            self.dialog.error_dialog(_('Strict commit failed'),
192
 
                                     _('There are unknown files in the working tree.\nPlease add or delete them.'))
193
 
            self.comm.set_busy(self.window, False)
 
165
            self.dialog.error_dialog('Strict commit failed. There are unknown files.')
194
166
            return
195
167
        except errors.BoundBranchOutOfDate, errmsg:
196
 
            self.dialog.error_dialog(_('Bound branch is out of date'),
197
 
                                     _('%s') % errmsg)
198
 
            self.comm.set_busy(self.window, False)
 
168
            self.dialog.error_dialog('Bound branch is out of date: %s' % errmsg)
199
169
            return
200
170
        except:
201
171
            raise