Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9, 0.9.1, and 0.9.1.1

archive: use CmdWidget instead of CmdDialog

Changeset 442801050ab8

Parent 5551d8edef0c

by Yuki KODAMA

Changes to one file · Browse files at 442801050ab8 Showing diff from parent 5551d8edef0c Diff from another changeset...

 
15
16
17
18
 
19
20
 
 
 
21
22
23
 
45
46
47
48
 
49
50
51
 
57
58
59
60
 
61
62
63
 
106
107
108
 
 
 
 
 
 
 
 
 
 
 
 
109
110
 
 
 
 
111
112
113
114
 
 
 
 
 
 
 
 
 
 
 
 
 
115
116
 
 
 
117
118
119
 
163
164
165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
168
169
170
 
171
172
173
174
175
176
177
178
179
180
 
 
 
 
 
 
181
182
183
 
15
16
17
 
18
19
 
20
21
22
23
24
25
 
47
48
49
 
50
51
52
53
 
59
60
61
 
62
63
64
65
 
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
 
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
227
228
229
230
231
232
233
234
@@ -15,9 +15,11 @@
 from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, paths   -from tortoisehg.hgtk import hgcmd, gtklib +from tortoisehg.hgtk import hgcmd, gtklib, gdialog   -_working_dir_parent_ = _('= Working Directory Parent =') +WD_PARENT = _('= Working Directory Parent =') +MODE_NORMAL = 'normal' +MODE_WORKING = 'working'    class ArchiveDialog(gtk.Dialog):   """ Dialog to archive a Mercurial repo """ @@ -45,7 +47,7 @@
  self.set_title(title)     # layout table - table = gtklib.LayoutTable() + self.table = table = gtklib.LayoutTable()   self.vbox.pack_start(table, True, True, 2)     ## revision combo @@ -57,7 +59,7 @@
  if rev:   combo.append_text(str(rev))   else: - combo.append_text(_working_dir_parent_) + combo.append_text(WD_PARENT)   combo.set_active(0)   for b in repo.branchtags():   combo.append_text(b) @@ -106,14 +108,44 @@
    # prepare to show   self.archivebtn.grab_focus() + gobject.idle_add(self.after_init) + + def after_init(self): + # CmdWidget + self.cmd = hgcmd.CmdWidget() + self.cmd.show_all() + self.cmd.hide() + self.vbox.pack_start(self.cmd, True, True, 6) + + # abort button + self.abortbtn = self.add_button(_('Abort'), gtk.RESPONSE_CANCEL) + self.abortbtn.hide()     def dialog_response(self, dialog, response_id): + def abort(): + self.cmd.stop() + self.cmd.show_log() + self.switch_to(MODE_NORMAL, cmd=False)   # Archive button   if response_id == gtk.RESPONSE_OK:   self.archive() - self.run() + # Close button or dialog closing by the user + elif response_id in (gtk.RESPONSE_CLOSE, gtk.RESPONSE_DELETE_EVENT): + if self.cmd.is_alive(): + ret = gdialog.Confirm(_('Confirm Abort'), [], self, + _('Do you want to abort?')).run() + if ret == gtk.RESPONSE_YES: + abort() + else: + self.destroy() + return # close dialog + # Abort button + elif response_id == gtk.RESPONSE_CANCEL: + abort()   else: - self.destroy() + raise _('unexpected response id: %s') % response_id + + self.run() # doesn't close dialog     def get_default_path(self):   """Return the default destination path""" @@ -163,21 +195,40 @@
  if response:   self.destentry.set_text(response)   + def switch_to(self, mode, cmd=True): + if mode == MODE_NORMAL: + normal = True + self.closebtn.grab_focus() + elif mode == MODE_WORKING: + normal = False + self.abortbtn.grab_focus() + else: + raise _('unknown mode name: %s') % mode + working = not normal + + self.table.set_sensitive(normal) + self.archivebtn.set_property('visible', normal) + self.closebtn.set_property('visible', normal) + if cmd: + self.cmd.set_property('visible', working) + self.abortbtn.set_property('visible', working) +   def archive(self): + cmdline = ['hg', 'archive', '--verbose']   rev = self.combo.get_active_text() - - cmdline = ['hg', 'archive', '--verbose'] - if rev != _working_dir_parent_: + if rev != WD_PARENT:   cmdline.append('--rev')   cmdline.append(rev) -   cmdline.append('-t')   cmdline.append(self.get_selected_archive_type()['type'])   cmdline.append(hglib.fromutf(self.destentry.get_text()))   - dlg = hgcmd.CmdDialog(cmdline) - dlg.run() - dlg.hide() + def cmd_done(returncode): + self.switch_to(MODE_NORMAL, cmd=False) + if returncode == 0 and not self.cmd.is_show_log(): + self.response(gtk.RESPONSE_CLOSE) + self.switch_to(MODE_WORKING) + self.cmd.execute(cmdline, cmd_done)    def run(ui, *pats, **opts):   return ArchiveDialog(opts.get('rev'))