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

cache: some optimisations

reuse cache if it contains the data
only call realpath if unclear else
clearer debug messages

Changeset 5c6c7ead318f

Parent 346a55135ec9

by Simon Heimberg

Changes to one file · Browse files at 5c6c7ead318f Showing diff from parent 346a55135ec9 Diff from another changeset...

 
105
106
107
108
 
 
 
 
109
110
111
112
113
 
115
116
117
118
 
 
 
119
120
121
 
132
133
134
 
 
135
 
136
137
138
 
174
175
176
177
178
 
 
179
180
181
 
105
106
107
 
108
109
110
111
112
 
113
114
115
 
117
118
119
 
120
121
122
123
124
125
 
136
137
138
139
140
141
142
143
144
145
 
181
182
183
 
 
184
185
186
187
188
@@ -105,9 +105,11 @@
  path = upath   # check if path is cached   pdir = os.path.dirname(path) - if cache_pdir == pdir and overlay_cache: + status = overlay_cache.get(path, '') + if overlay_cache and (cache_pdir == pdir or cache_pdir and + status not in ' r' and path.startswith(cache_pdir)): + #use cached data when pdir has not changed or when the cached state is a repo state   if tc - cache_tick_count < CACHE_TIMEOUT: - status = overlay_cache.get(path)   if not status:   if os.path.isdir(os.path.join(path, '.hg')):   add(path, ROOT) @@ -115,7 +117,9 @@
  else:   status = overlay_cache.get(pdir + '*', NOT_IN_REPO)   add(path, status) - debugf("%s: %s (cached)", (path, status)) + debugf("%s: %s (cached~)", (path, status)) + else: + debugf("%s: %s (cached)", (path, status))   return status   else:   debugf("Timed out!!") @@ -132,7 +136,10 @@
  debugf("find new root")   root = thgutil.find_root(path)   if root == path: + if not overlay_cache: + cache_root = pdir   add(path, ROOT) + debugf("%s: r", path)   return ROOT   cache_root = root   cache_pdir = pdir @@ -174,8 +181,8 @@
  cache_tick_count = GetTickCount()   return NOT_IN_REPO   tc1 = GetTickCount() - real = os.path.realpath(root) - if not repo or (repo.root != root and repo.root != real): + real = os.path.realpath #only test if necessary (symlink in path) + if not repo or (repo.root != root and repo.root != real(root)):   repo = hg.repository(ui.ui(), path=root)   debugf("hg.repository() took %g ticks", (GetTickCount() - tc1))   except RepoError: