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

clone: underbar, string cleanups

Changeset 5829512e6348

Parent 15a5b3c1efa5

by Steve Borho

Changes to one file · Browse files at 5829512e6348 Showing diff from parent 15a5b3c1efa5 Diff from another changeset...

Change 1 of 7 Show Entire File hggtk/​clone.py Stacked
 
25
26
27
28
29
30
 
 
 
31
32
33
 
 
34
35
36
 
 
37
38
 
39
40
41
 
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
 
158
159
160
161
 
162
163
164
165
166
167
168
 
169
170
171
172
 
173
174
175
 
 
176
177
178
 
180
181
182
183
 
184
185
186
187
 
 
188
189
190
 
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
227
 
228
229
 
230
231
 
232
233
234
235
236
 
 
 
 
237
238
239
240
241
242
 
243
244
245
246
247
248
 
249
250
251
 
264
265
266
267
 
268
269
 
270
271
 
272
273
274
 
275
276
277
 
296
297
298
299
300
301
 
 
 
302
303
304
 
25
26
27
 
 
 
28
29
30
31
 
 
32
33
34
 
 
35
36
37
 
38
39
40
41
 
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
 
159
160
161
 
162
163
164
165
166
167
168
 
169
170
171
 
 
172
173
 
 
174
175
176
177
178
 
180
181
182
 
183
184
185
 
 
186
187
188
189
190
 
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
 
227
228
 
229
230
 
231
232
 
 
 
 
233
234
235
236
237
238
239
240
241
 
242
243
244
245
246
247
 
248
249
250
251
 
264
265
266
 
267
268
 
269
270
 
271
272
273
 
274
275
276
277
 
296
297
298
 
 
 
299
300
301
302
303
304
@@ -25,17 +25,17 @@
  self.set_title(_('TortoiseHg Clone'))     self.ui = ui.ui() - self._settings = settings.Settings('clone') - self._recent_src = self._settings.mrul('src_paths') - self._recent_dest = self._settings.mrul('dest_paths') + self.clonesettings = settings.Settings('clone') + self.recentsrc = self.clonesettings.mrul('src_paths') + self.recentdest = self.clonesettings.mrul('dest_paths')   - self._src_path = os.getcwd() - self._dest_path = self._src_path + srcpath = os.getcwd() + destpath = srcpath   if len(repos) > 1: - self._src_path = repos[0] - self._dest_path = repos[1] + srcpath = repos[0] + destpath = repos[1]   elif len(repos): - self._src_path = repos[0] + srcpath = repos[0]     ewidth = 20   @@ -49,100 +49,101 @@
  lbl.set_alignment(0, 0.5)     # create drop-down list for source paths - self._srclist = gtk.ListStore(str) - self._srclistbox = gtk.ComboBoxEntry(self._srclist, 0) - self._src_input = self._srclistbox.get_child() - self._src_input.set_text(self._src_path) - self._src_input.set_position(-1) + self.srclist = gtk.ListStore(str) + srccombo = gtk.ComboBoxEntry(self.srclist, 0) + self.srcentry = srccombo.get_child() + self.srcentry.set_text(srcpath) + self.srcentry.set_position(-1)     # replace the drop-down widget so we can modify it's properties - self._srclistbox.clear() + srccombo.clear()   cell = gtk.CellRendererText()   cell.set_property('ellipsize', pango.ELLIPSIZE_MIDDLE) - self._srclistbox.pack_start(cell) - self._srclistbox.add_attribute(cell, 'text', 0) + srccombo.pack_start(cell) + srccombo.add_attribute(cell, 'text', 0)   - self._btn_src_browse = gtk.Button(_('Browse...')) - self._btn_src_browse.connect('clicked', self._btn_src_clicked) + srcbrowse = gtk.Button(_('Browse...')) + srcbrowse.connect('clicked', self.source_browse_clicked)   srcbox.pack_start(lbl, False, False) - srcbox.pack_start(self._srclistbox, True, True) - srcbox.pack_end(self._btn_src_browse, False, False, 5) + srcbox.pack_start(srccombo, True, True) + srcbox.pack_end(srcbrowse, False, False, 5)   vbox.pack_start(srcbox, False, False, 2)     # add pre-defined src paths to pull-down list   sync_src = settings.Settings('synch').mrul('src_paths')   sympaths = [x[1] for x in self.ui.configitems('paths')] - recent = [x for x in self._recent_src] + recent = [x for x in self.recentsrc]   syncsrc = [x for x in sync_src]   paths = list(set(sympaths + recent + syncsrc))   paths.sort()   for p in paths: - self._srclist.append([p]) + self.srclist.append([p])     # clone destination   destbox = gtk.HBox()   lbl = gtk.Label(_('Destination Path:'))   lbl.set_property('width-chars', ewidth)   lbl.set_alignment(0, 0.5) - self._destlist = gtk.ListStore(str) - self._destlistbox = gtk.ComboBoxEntry(self._destlist, 0) - self._dest_input = self._destlistbox.get_child() - self._dest_input.set_text(self._dest_path) - self._dest_input.set_position(-1) + self.destlist = gtk.ListStore(str) + destcombo = gtk.ComboBoxEntry(self.destlist, 0) + self.destentry = destcombo.get_child() + self.destentry.set_text(destpath) + self.destentry.set_position(-1) + self.destentry.connect('activate', self.clone_clicked)     # replace the drop-down widget so we can modify it's properties - self._destlistbox.clear() + destcombo.clear()   cell = gtk.CellRendererText()   cell.set_property('ellipsize', pango.ELLIPSIZE_MIDDLE) - self._destlistbox.pack_start(cell) - self._destlistbox.add_attribute(cell, 'text', 0) + destcombo.pack_start(cell) + destcombo.add_attribute(cell, 'text', 0)   - self._btn_dest_browse = gtk.Button(_('Browse...')) - self._btn_dest_browse.connect('clicked', self._btn_dest_clicked) + srcbrowse = gtk.Button(_('Browse...')) + srcbrowse.connect('clicked', self.dest_browse_clicked)   destbox.pack_start(lbl, False, False) - destbox.pack_start(self._destlistbox, True, True) - destbox.pack_end(self._btn_dest_browse, False, False, 5) + destbox.pack_start(destcombo, True, True) + destbox.pack_end(srcbrowse, False, False, 5)   vbox.pack_start(destbox, False, False, 2)     # add most-recent dest paths to pull-down list - paths = list(self._recent_dest) + paths = list(self.recentdest)   paths.sort()   for p in paths: - self._destlist.append([p]) + self.destlist.append([p])     # revision input   revbox = gtk.HBox()   lbl = gtk.Label(_('Clone To Revision:'))   lbl.set_property('width-chars', ewidth)   lbl.set_alignment(0, 0.5) - self._rev_input = gtk.Entry() - self._rev_input.set_text("") + self.reventry = gtk.Entry() + self.reventry.set_text("")   revbox.pack_start(lbl, False, False) - revbox.pack_start(self._rev_input, False, False) + revbox.pack_start(self.reventry, False, False)   vbox.pack_start(revbox, False, False, 2)     # options   option_box = gtk.VBox() - self._opt_update = gtk.CheckButton(_('do not update the new working directory')) - self._opt_pull = gtk.CheckButton(_('use pull protocol to copy metadata')) - self._opt_uncomp = gtk.CheckButton(_('use uncompressed transfer')) - self._opt_proxy = gtk.CheckButton(_('use proxy server')) - option_box.pack_start(self._opt_update, False, False) - option_box.pack_start(self._opt_pull, False, False) - option_box.pack_start(self._opt_uncomp, False, False) - option_box.pack_start(self._opt_proxy, False, False) + self.optupdate = gtk.CheckButton(_('do not update the new working directory')) + self.optpull = gtk.CheckButton(_('use pull protocol to copy metadata')) + self.optuncomp = gtk.CheckButton(_('use uncompressed transfer')) + self.optproxy = gtk.CheckButton(_('use proxy server')) + option_box.pack_start(self.optupdate, False, False) + option_box.pack_start(self.optpull, False, False) + option_box.pack_start(self.optuncomp, False, False) + option_box.pack_start(self.optproxy, False, False)   vbox.pack_start(option_box, False, False, 15)     if self.ui.config('http_proxy', 'host'): - self._opt_proxy.set_active(True) + self.optproxy.set_active(True)   else: - self._opt_proxy.set_sensitive(False) + self.optproxy.set_sensitive(False)     # remote cmd   lbl = gtk.Label(_('Remote Cmd:'))   lbl.set_alignment(0, 0.5) - self._remote_cmd = gtk.Entry() - vbox.pack_start(self._remote_cmd, False, False, 1) + self.remotecmdentry = gtk.Entry() + vbox.pack_start(self.remotecmdentry, False, False, 1)   vbox.pack_start(lbl, False, False, 1)     accelgroup = gtk.AccelGroup() @@ -158,21 +159,20 @@
  key, modifier = gtk.accelerator_parse('Escape')   close.add_accelerator('clicked', accelgroup, key, 0,   gtk.ACCEL_VISIBLE) - self._close_button = close + self.close_button = close   hbbox.add(close)     clone = gtk.Button(_('Clone'))   key, modifier = gtk.accelerator_parse(mod+'Return')   clone.add_accelerator('clicked', accelgroup, key, modifier,   gtk.ACCEL_VISIBLE) - clone.connect('clicked', self._btn_clone_clicked) + clone.connect('clicked', self.clone_clicked)   hbbox.add(clone)   - self._destlistbox.grab_focus() - self._destlistbox.child.connect('activate', self._btn_clone_clicked) + destcombo.grab_focus()   - def _btn_dest_clicked(self, button): - """ select folder as clone destination """ + def dest_browse_clicked(self, button): + 'select folder as clone destination'   dialog = gtk.FileChooserDialog(title=None,   action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,   buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL, @@ -180,11 +180,11 @@
  dialog.set_default_response(gtk.RESPONSE_OK)   response = dialog.run()   if response == gtk.RESPONSE_OK: - self._dest_input.set_text(dialog.get_filename()) + self.destentry.set_text(dialog.get_filename())   dialog.destroy()   - def _btn_src_clicked(self, button): - """ select source folder to clone """ + def source_browse_clicked(self, button): + 'select source folder to clone'   dialog = gtk.FileChooserDialog(title=None,   action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,   buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL, @@ -192,60 +192,60 @@
  dialog.set_default_response(gtk.RESPONSE_OK)   response = dialog.run()   if response == gtk.RESPONSE_OK: - self._src_input.set_text(dialog.get_filename()) + self.srcentry.set_text(dialog.get_filename())   dialog.destroy()   - def _add_src_to_recent(self, src): + def add_src_to_recent(self, src):   if os.path.exists(src):   src = os.path.abspath(src)     # save path to recent list in history - self._recent_src.add(src) - self._settings.write() + self.recentsrc.add(src) + self.clonesettings.write()     # update drop-down list - self._srclist.clear() + self.srclist.clear()   sympaths = [x[1] for x in self.ui.configitems('paths')] - paths = list(set(sympaths + [x for x in self._recent_src])) + paths = list(set(sympaths + [x for x in self.recentsrc]))   paths.sort()   for p in paths: - self._srclist.append([p]) + self.srclist.append([p])   - def _add_dest_to_recent(self, dest): + def add_dest_to_recent(self, dest):   if not dest:   return   if os.path.exists(dest):   dest = os.path.abspath(dest)     # save path to recent list in history - self._recent_dest.add(dest) - self._settings.write() + self.recentdest.add(dest) + self.clonesettings.write()     # update drop down list - paths = list(self._recent_dest) + paths = list(self.recentdest)   paths.sort() - self._destlist.clear() + self.destlist.clear()   for p in paths: - self._destlist.append([p]) + self.destlist.append([p])   - def _btn_clone_clicked(self, toolbutton, data=None): + def clone_clicked(self, toolbutton, data=None):   # gather input data - src = self._src_input.get_text() - dest = self._dest_input.get_text() or os.path.basename(src) - remotecmd = self._remote_cmd.get_text() - rev = self._rev_input.get_text() + src = self.srcentry.get_text() + dest = self.destentry.get_text() or os.path.basename(src) + remotecmd = self.remotecmdentry.get_text() + rev = self.reventry.get_text()     # verify input   if src == '':   gdialog.Prompt(_('Source path is empty'),   _('Please enter a valid source path'), self).run() - self._src_input.grab_focus() + self.srcentry.grab_focus()   return False     if src == dest:   gdialog.Prompt(_('Source and dest are the same'),   _('Please specify a different destination'), self).run() - self._dest_input.grab_focus() + self.destentry.grab_focus()   return False     if dest == os.getcwd(): @@ -264,14 +264,14 @@
  # start cloning   try:   cmdline = ['hg', 'clone'] - if self._opt_update.get_active(): + if self.optupdate.get_active():   cmdline.append('--noupdate') - if self._opt_uncomp.get_active(): + if self.optuncomp.get_active():   cmdline.append('--uncompressed') - if self._opt_pull.get_active(): + if self.optpull.get_active():   cmdline.append('--pull')   if self.ui.config('http_proxy', 'host'): - if not self._opt_proxy.get_active(): + if not self.optproxy.get_active():   cmdline += ['--config', 'http_proxy.host=']   if remotecmd:   cmdline.append('--remotecmd') @@ -296,9 +296,9 @@
  traceback.format_exc(), self).run()   return False   - self._add_src_to_recent(src) - self._add_dest_to_recent(dest) - self._close_button.grab_focus() + self.add_src_to_recent(src) + self.add_dest_to_recent(dest) + self.close_button.grab_focus()     if dlg.return_code() == 0:   shlib.shell_notify([dest])