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

hggtk/shlib: add compact() method to SimpleMRUList class

Changeset 1c90692f9e22

Parent 8669972ec212

by TK Soh

Changes to one file · Browse files at 1c90692f9e22 Showing diff from parent 8669972ec212 Diff from another changeset...

Change 1 of 2 Show Entire File hggtk/​shlib.py Stacked
 
12
13
14
15
 
16
17
 
 
18
19
20
 
37
38
39
 
 
 
 
 
 
 
 
 
40
41
42
 
12
13
14
 
15
16
17
18
19
20
21
22
 
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@@ -12,9 +12,11 @@
 import time    class SimpleMRUList(object): - def __init__(self, size=10, reflist=[]): + def __init__(self, size=10, reflist=[], compact=True):   self._size = size   self._list = reflist + if compact: + self.compact()     def __iter__(self):   for elem in self._list: @@ -37,6 +39,15 @@
  while len(self._list) > self._size:   del self._list[-1]   + def compact(self): + ''' remove duplicate in list ''' + list = [] + for v in self._list: + if v not in list: + list.append(v) + self._list[:] = list + +  class Settings(object):   version = 1.0