Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

thgimport: save source directories on finished importing

Changeset 80a29dbb8311

Parent 243fa0acaaa3

by Yuki KODAMA

Changes to one file · Browse files at 80a29dbb8311 Showing diff from parent 243fa0acaaa3 Diff from another changeset...

 
12
13
14
15
 
16
17
18
 
47
48
49
 
 
 
 
50
51
52
53
54
55
 
 
 
56
57
58
 
59
60
 
 
 
 
61
62
63
 
96
97
98
99
 
100
101
102
 
125
126
127
128
 
129
130
131
 
134
135
136
137
 
138
139
140
141
142
143
144
 
145
146
147
 
148
149
150
 
180
181
182
183
 
184
185
186
 
189
190
191
 
 
 
 
 
 
 
192
193
194
 
201
202
203
204
 
205
206
207
 
219
220
221
 
 
 
 
 
 
 
 
 
222
223
224
 
269
270
271
 
272
273
274
 
12
13
14
 
15
16
17
18
 
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
 
105
106
107
 
108
109
110
111
 
134
135
136
 
137
138
139
140
 
143
144
145
 
146
147
148
149
150
151
152
 
153
154
155
 
156
157
158
159
 
189
190
191
 
192
193
194
195
 
198
199
200
201
202
203
204
205
206
207
208
209
210
 
217
218
219
 
220
221
222
223
 
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
 
294
295
296
297
298
299
300
@@ -12,7 +12,7 @@
 from mercurial import hg, ui    from tortoisehg.util.i18n import _ -from tortoisehg.util import hglib, paths +from tortoisehg.util import hglib, paths, settings    from tortoisehg.hgtk import hgcmd, gtklib, gdialog, cslist   @@ -47,17 +47,26 @@
  self.set_title(_('Import - %s') % hglib.get_reponame(repo))   self.done = False   + # persistent settings + self.settings = settings.Settings('import') + self.recent = self.settings.mrul('src_paths') +   # layout table   self.table = table = gtklib.LayoutTable()   self.vbox.pack_start(table, True, True, 2)   - ## source path entry & browse button - self.source_entry = gtk.Entry() + ## source path combo & browse buttons + self.src_list = gtk.ListStore(str) + self.src_combo = gtk.ComboBoxEntry(self.src_list, 0)   self.files_btn = gtk.Button(_('Files...'))   self.dir_btn = gtk.Button(_('Directory...')) - table.add_row(_('Source:'), self.source_entry, 1, + table.add_row(_('Source:'), self.src_combo, 1,   self.files_btn, self.dir_btn, expand=0)   + ## add MRU paths to source combo + for path in self.recent: + self.src_list.append([path]) +   # copy form thgstrip.py   def createlabel():   label = gtk.Label() @@ -96,7 +105,7 @@
  self.dir_btn.connect('clicked', self.dir_clicked)   self.cslist.connect('list-updated', self.list_updated)   self.cslist.connect('files-dropped', self.files_dropped) - self.source_entry.connect('changed', lambda e: self.preview(queue=True)) + self.src_combo.connect('changed', lambda e: self.preview(queue=True))     # prepare to show   self.cslist.clear() @@ -125,7 +134,7 @@
  if result and result != initdir:   if not isinstance(result, basestring):   result = os.pathsep.join(result) - self.source_entry.set_text(result) + self.src_combo.child.set_text(result)   self.preview()     def dir_clicked(self, button): @@ -134,17 +143,17 @@
  title=_('Select Directory contains patches:'),   initial=initdir).run()   if result and result != initdir: - self.source_entry.set_text(result) + self.src_combo.child.set_text(result)   self.preview()     def list_updated(self, cslist, total, sel, *args):   self.update_status(sel)     def files_dropped(self, cslist, files, *args): - src = self.source_entry.get_text() + src = self.src_combo.child.get_text()   if src:   files = [src] + files - self.source_entry.set_text(os.pathsep.join(files)) + self.src_combo.child.set_text(os.pathsep.join(files))   self.preview()     def dialog_response(self, dialog, response_id): @@ -180,7 +189,7 @@
  self.run() # don't close dialog     def get_initial_dir(self): - src = self.source_entry.get_text() + src = self.src_combo.child.get_text()   if src and os.path.exists(src):   if os.path.isdir(src):   return src @@ -189,6 +198,13 @@
  return parent   return None   + def add_to_mru(self): + dirs = self.get_dirpaths() + for dir in dirs: + self.recent.add(dir) + self.src_list.append([dir]) + self.settings.write() +   def update_status(self, count):   if count:   info = _('<span weight="bold">%s patches</span> will' @@ -201,7 +217,7 @@
  self.importbtn.set_sensitive(bool(count))     def get_filepaths(self): - src = self.source_entry.get_text() + src = self.src_combo.child.get_text()   if not src:   return []   files = [] @@ -219,6 +235,15 @@
  files.append(path)   return files   + def get_dirpaths(self): + dirs = [] + files = self.get_filepaths() + for file in files: + dir = os.path.dirname(file) + if os.path.isdir(dir) and dir not in dirs: + dirs.append(dir) + return dirs +   def get_dest(self):   iter = self.dest_combo.get_active_iter()   return self.dest_model.get(iter, DEST_ID)[0] @@ -269,6 +294,7 @@
  def cmd_done(returncode, useraborted):   self.done = True   self.switch_to(MODE_NORMAL, cmd=False) + self.add_to_mru()   if hasattr(self, 'notify_func'):   self.notify_func(*self.notify_args, **self.notify_kargs)   if returncode == 0: