Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

recovery: capitalize text in toolbar buttons, like all the other dialog

Changeset 1bb55fcc793f

Parent 91c87cc8e5cc

by Giampaolo Fadel

Changes to one file · Browse files at 1bb55fcc793f Showing diff from parent 91c87cc8e5cc Diff from another changeset...

Change 1 of 1 Show Changes Only hggtk/​recovery.py Stacked
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
48
49
50
51
52
 
53
54
55
56
57
58
 
59
60
61
62
63
 
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
47
48
49
50
51
 
52
53
54
55
56
57
 
58
59
60
61
62
 
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
 #  # Repository recovery dialog for TortoiseHg  #  # Copyright (C) 2007 Steve Borho <steve@borho.org>  # Copyright (C) 2007 TK Soh <teekaysoh@gmail.com>  #    import gtk  import gobject  import pango  import Queue  import os  import time    from mercurial import hg, ui    from thgutil.i18n import _  from thgutil import hglib, shlib, paths    from hggtk import gdialog, dialog, gtklib, hgthread    class RecoveryDialog(gtk.Window):   def __init__(self):   """ Initialize the Dialog. """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)   gtklib.set_tortoise_icon(self, 'general.ico')   gtklib.set_tortoise_keys(self)     self.root = paths.find_root()   self.selected_path = None   self.hgthread = None   self.connect('delete-event', self._delete)     self.set_default_size(600, 400)     name = os.path.basename(os.path.abspath(self.root))   self.set_title(_('TortoiseHg Recovery - ') + name)     # toolbar   self.tbar = gtk.Toolbar()   self.tips = gtk.Tooltips()   self._stop_button = self._toolbutton(gtk.STOCK_STOP,   _('Stop'), self._stop_clicked, tip=_('Stop the hg operation'))   self._stop_button.set_sensitive(False)   tbuttons = [   self._toolbutton(gtk.STOCK_CLEAR, - _('clean'), + _('Clean'),   self._clean_clicked,   tip=_('Clean checkout, undo all changes')),   gtk.SeparatorToolItem(),   self._toolbutton(gtk.STOCK_UNDO, - _('rollback'), + _('Rollback'),   self._rollback_clicked,   tip=_('Rollback (undo) last transaction to'   ' repository (pull, commit, etc)')),   gtk.SeparatorToolItem(),   self._toolbutton(gtk.STOCK_CLEAR, - _('recover'), + _('Recover'),   self._recover_clicked,   tip=_('Recover from interrupted operation')),   gtk.SeparatorToolItem(),   self._toolbutton(gtk.STOCK_APPLY, - _('verify'), + _('Verify'),   self._verify_clicked,   tip=_('Validate repository consistency')),   gtk.SeparatorToolItem(),   self._stop_button,   gtk.SeparatorToolItem(),   ]   for btn in tbuttons:   self.tbar.insert(btn, -1)   vbox = gtk.VBox()   self.add(vbox)   vbox.pack_start(self.tbar, False, False, 2)     # hg output window   scrolledwindow = gtk.ScrolledWindow()   scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)   scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   self.textview = gtk.TextView(buffer=None)   self.textview.set_editable(False)   self.textview.modify_font(pango.FontDescription('Monospace'))   scrolledwindow.add(self.textview)   self.textbuffer = self.textview.get_buffer()   self.textbuffer.create_tag('error', weight=pango.WEIGHT_HEAVY,   foreground='#900000')   vbox.pack_start(scrolledwindow, True, True)     self.stbar = gtklib.StatusBar()   vbox.pack_start(self.stbar, False, False, 2)     def _delete(self, widget, event):   if not self.should_live():   self.destroy()   return True     def should_live(self):   if self._cmd_running():   dialog.error_dialog(self, _('Cannot close now'),   _('command is running'))   return True   return False     def _toolbutton(self, stock, label, handler,   menu=None, userdata=None, tip=None):   if menu:   tbutton = gtk.MenuToolButton(stock)   tbutton.set_menu(menu)   else:   tbutton = gtk.ToolButton(stock)     tbutton.set_label(label)   if tip:   tbutton.set_tooltip(self.tips, tip)   tbutton.connect('clicked', handler, userdata)   return tbutton     def _clean_clicked(self, toolbutton, data=None):   response = gdialog.Confirm(_('Confirm clean repository'), [], self,   "%s ?" % os.path.basename(self.root)).run()   if response != gtk.RESPONSE_YES:   return   try:   repo = hg.repository(ui.ui(), path=self.root)   except hglib.RepoError:   self.write(_('Unable to find repo at %s\n') % (self.root), False)   return   pl = repo.parents()   cmd = ['update', '--clean', '--rev', str(pl[0].rev())]   self._exec_cmd(cmd, postfunc=self._notify)     def _notify(self, ret, *args):   time.sleep(0.5) # give fs some time to pick up changes   shlib.shell_notify([self.root])     def _rollback_clicked(self, toolbutton, data=None):   response = gdialog.Confirm(_('Confirm rollback repository'), [], self,   "%s ?" % os.path.basename(self.root)).run()   if response != gtk.RESPONSE_YES:   return   cmd = ['rollback']   self._exec_cmd(cmd, postfunc=self._notify)     def _recover_clicked(self, toolbutton, data=None):   cmd = ['recover']   self._exec_cmd(cmd)     def _verify_clicked(self, toolbutton, data=None):   cmd = ['verify']   self._exec_cmd(cmd)     def _stop_clicked(self, toolbutton, data=None):   if self.hgthread and self.hgthread.isAlive():   self.hgthread.terminate()   self._stop_button.set_sensitive(False)     def _exec_cmd(self, cmd, postfunc=None):   if self._cmd_running():   dialog.error_dialog(self, _('Cannot run now'),   _('Please try again after the previous command is completed'))   return     self._stop_button.set_sensitive(True)   cmdline = cmd   cmdline.append('--verbose')   cmdline.append('--repository')   cmdline.append(self.root)     # show command to be executed   self.write("", False)     # execute command and show output on text widget   gobject.timeout_add(10, self.process_queue)   self.hgthread = hgthread.HgThread(cmdline, postfunc)   self.hgthread.start()   self.stbar.begin()   self.stbar.set_status_text('hg ' + ' '.join(cmdline))     def _cmd_running(self):   if self.hgthread and self.hgthread.isAlive():   return True   else:   return False     def write(self, msg, append=True):   msg = hglib.toutf(msg)   if append:   enditer = self.textbuffer.get_end_iter()   self.textbuffer.insert(enditer, msg)   else:   self.textbuffer.set_text(msg)     def write_err(self, msg):   enditer = self.textbuffer.get_end_iter()   self.textbuffer.insert_with_tags_by_name(enditer, msg, 'error')   self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)     def process_queue(self):   """   Handle all the messages currently in the queue (if any).   """   self.hgthread.process_dialogs()   while self.hgthread.getqueue().qsize():   try:   msg = self.hgthread.getqueue().get(0)   self.write(msg)   except Queue.Empty:   pass   while self.hgthread.geterrqueue().qsize():   try:   msg = self.hgthread.geterrqueue().get(0)   self.write_err(msg)   except Queue.Empty:   pass     if self._cmd_running():   return True   else:   self.stbar.end()   self._stop_button.set_sensitive(False)   if self.hgthread.return_code() is None:   self.write_err(_('[command interrupted]'))   return False # Stop polling this function    def run(ui, *pats, **opts):   return RecoveryDialog()