Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.4rc1, 0.4rc2, and 0.4rc3

hggtk/synch: remember only ten most-recent src paths

Changeset 8dd7ec3f5bce

Parent 2326651b2694

by TK Soh

Changes to one file · Browse files at 8dd7ec3f5bce Showing diff from parent 2326651b2694 Diff from another changeset...

Change 1 of 4 Show Entire File hggtk/​synch.py Stacked
 
23
24
25
 
 
26
27
28
 
35
36
37
38
39
40
41
42
43
 
129
130
131
132
133
 
 
 
 
134
135
136
 
423
424
425
426
 
 
 
 
 
 
 
 
 
 
427
428
429
430
431
432
433
434
435
436
 
 
437
438
439
440
441
442
443
444
 
 
 
 
445
446
447
 
23
24
25
26
27
28
29
30
 
37
38
39
 
 
 
40
41
42
 
128
129
130
 
 
131
132
133
134
135
136
137
 
424
425
426
 
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
 
 
442
443
 
444
445
446
447
448
449
450
451
 
 
452
453
454
455
456
457
458
@@ -23,6 +23,8 @@
 import shlib  import gtklib   +HistorySize = 10 +  class SynchDialog(gtk.Window):   def __init__(self, cwd='', root = '', repos=[]):   """ Initialize the Dialog. """ @@ -35,9 +37,6 @@
    # persistent app data   self._settings = shlib.Settings('synch') - if not 'src_paths' in self._settings: - self._settings['src_paths'] = [] - self.recent_paths = self._settings['src_paths']     self.set_default_size(610, 400)   @@ -129,8 +128,10 @@
  elif defpushrow is not None:   self._pathbox.set_active(defpushrow)   - for p in self.recent_paths: - self.pathlist.append([p]) + sympaths = [x[1] for x in self.paths] + for p in self._settings.get('src_paths', []): + if p not in sympaths: + self.pathlist.append([p])     # create checkbox to disable proxy   self._use_proxy = gtk.CheckButton("use proxy server") @@ -423,25 +424,35 @@
  self.stbar.set_status_text('hg ' + ' '.join(cmd + [remote_path]))     self._add_src_to_recent(remote_path) - + + def _update_setting_list(self, key, path): + paths = self._settings.get(key, []) + if path in paths: + paths.remove(path) + paths.append(path) + while len(paths) > HistorySize: + del paths[0] + self._settings[key] = paths +   def _add_src_to_recent(self, src):   if os.path.exists(src):   src = os.path.abspath(src)     srclist = [x[0] for x in self.pathlist] - if src in srclist: - return     # update drop-down list - srclist.append(src) + if src not in srclist: + srclist.append(src)   srclist.sort()   self.pathlist.clear()   for p in srclist:   self.pathlist.append([p])     # save path to recent list in history - self.recent_paths.append(src) - self._settings.write() + sympaths = [x[1] for x in self.paths] + if src not in sympaths: + self._update_setting_list('src_paths', src) + self._settings.write()     def write(self, msg, append=True):   msg = unicode(msg, 'iso-8859-1')