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

cachethg: support all of the new registry values

Changeset 40b14d0b9813

Parent 2b11d425c317

by Steve Borho

Changes to one file · Browse files at 40b14d0b9813 Showing diff from parent 2b11d425c317 Diff from another changeset...

 
8
9
10
 
 
 
 
11
12
 
13
14
15
16
17
18
19
20
21
22
 
 
 
 
 
 
 
 
 
 
23
24
25
 
31
32
33
 
 
 
 
34
35
36
 
76
77
78
 
 
79
80
81
 
129
130
131
 
 
 
 
 
 
132
133
 
 
134
135
136
137
138
139
140
141
142
 
 
 
143
144
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
147
148
149
150
151
 
152
153
154
155
 
156
157
158
 
8
9
10
11
12
13
14
15
16
17
18
19
 
20
 
 
 
 
 
 
21
22
23
24
25
26
27
28
29
30
31
32
33
 
39
40
41
42
43
44
45
46
47
48
 
88
89
90
91
92
93
94
95
 
143
144
145
146
147
148
149
150
151
152
 
153
154
155
156
 
 
 
 
 
 
 
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
 
184
185
186
187
188
189
190
191
192
@@ -8,18 +8,26 @@
  from mercurial.repo import RepoError    debugging = False +enabled = True +localonly = False +includepaths = [] +excludepaths = []    try: + from _winreg import HKEY_CURRENT_USER, OpenKey, QueryValueEx   from win32api import GetTickCount   CACHE_TIMEOUT = 5000 - import _winreg   try: - hkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, - r"Software\TortoiseHg", 0, - _winreg.KEY_ALL_ACCESS) - val = _winreg.QueryValueEx(hkey, 'OverlayDebug')[0] - if val in ('1', 'True'): - debugging = True + hkey = OpenKey(HKEY_CURRENT_USER, r"Software\TortoiseHg") + enabled = QueryValueEx(hkey, 'EnableOverlays')[0] in ('1', 'True') + localonly = QueryValueEx(hkey, 'LocalDisksOnly')[0] in ('1', 'True') + incs = QueryValueEx(hkey, 'IncludePath')[0] + excs = QueryValueEx(hkey, 'ExcludePath')[0] + debugging = QueryValueEx(hkey, 'OverlayDebug')[0] in ('1', 'True') + for p in incs.split(';'): + includepaths.append(p.strip()) + for p in excs.split(';'): + excludepaths.append(p.strip())   except EnvironmentError:   pass  except ImportError: @@ -31,6 +39,10 @@
  def debugf(str, args=None):   if args: print str % args   else: print str + print 'Enabled', enabled + print 'LocalDisksOnly', localonly + print 'IncludePaths', includepaths + print 'ExcludePaths', excludepaths  else:   def debugf(str, args=None):   pass @@ -76,6 +88,8 @@
  """   global overlay_cache, cache_tick_count   global cache_root, cache_pdir + global enabled, localonly + global includepaths, excludepaths     #debugf("called: _get_state(%s)", path)   tc = GetTickCount() @@ -129,30 +143,50 @@
  add(pdir, NOT_IN_REPO)   return NOT_IN_REPO   try: + if not enabled: + overlay_cache = {None: None} + cache_tick_count = GetTickCount() + debugf("overlayicons disabled") + return NOT_IN_REPO +   tc1 = GetTickCount() - if not repo or (repo.root != root and repo.root != os.path.realpath(root)): + real = os.path.realpath(root) + if not repo or (repo.root != root and repo.root != real):   repo = hg.repository(ui.ui(), path=root)   debugf("hg.repository() took %g ticks", (GetTickCount() - tc1)) - # check if to display overlay icons in this repo - overlayopt = repo.ui.config('tortoisehg', 'overlayicons', ' ').lower() - debugf("%s: repo overlayicons = %s", (path, overlayopt)) - if overlayopt == 'localdisk': - overlayopt = bool(thgutil.netdrive_status(path)) - if not overlayopt or overlayopt in 'false off no'.split(): - debugf("%s: overlayicons disabled", path) + + if localonly and thgutil.netdrive_status(path): + debugf("%s: is a network drive", path)   overlay_cache = {None: None}   cache_tick_count = GetTickCount()   return NOT_IN_REPO + if includepaths: + for p in includepaths: + if path.startswith(p): + break; + else: + debugf("%s: is not in an include path", path) + overlay_cache = {None: None} + cache_tick_count = GetTickCount() + return NOT_IN_REPO + if excludepaths: + for p in excludepaths: + if path.startswith(p): + debugf("%s: is in an exclude path", path) + overlay_cache = {None: None} + cache_tick_count = GetTickCount() + return NOT_IN_REPO   except RepoError:   # We aren't in a working tree   debugf("%s: not in repo", pdir)   add(pdir, IGNORED)   return IGNORED - except StandardError, e: + except Exception, e:   debugf("error while handling %s:", pdir)   debugf(e)   add(pdir, UNKNOWN)   return UNKNOWN +   # get file status   tc1 = GetTickCount()