##// END OF EJS Templates
dirstate: group return logic and clarify each function in flagfunc...
Raphaël Gomès -
r49103:0d6a099b default
parent child Browse files
Show More
@@ -242,65 +242,68 b' class dirstate(object):'
242 return self._rootdir + f
242 return self._rootdir + f
243
243
244 def flagfunc(self, buildfallback):
244 def flagfunc(self, buildfallback):
245 if self._checklink and self._checkexec:
245 if not (self._checklink and self._checkexec):
246
246 fallback = buildfallback()
247 def f(x):
248 try:
249 st = os.lstat(self._join(x))
250 if util.statislink(st):
251 return b'l'
252 if util.statisexec(st):
253 return b'x'
254 except OSError:
255 pass
256 return b''
257
247
258 return f
248 def check_both(x):
259
249 """This platform supports symlinks and exec permissions"""
260 fallback = buildfallback()
250 try:
261 if self._checklink:
251 st = os.lstat(self._join(x))
262
252 if util.statislink(st):
263 def f(x):
264 if os.path.islink(self._join(x)):
265 return b'l'
253 return b'l'
266 entry = self.get_entry(x)
254 if util.statisexec(st):
267 if entry.has_fallback_exec:
268 if entry.fallback_exec:
269 return b'x'
270 elif b'x' in fallback(x):
271 return b'x'
255 return b'x'
272 return b''
256 except OSError:
257 pass
258 return b''
259
260 def check_link(x):
261 """This platform only supports symlinks"""
262 if os.path.islink(self._join(x)):
263 return b'l'
264 entry = self.get_entry(x)
265 if entry.has_fallback_exec:
266 if entry.fallback_exec:
267 return b'x'
268 elif b'x' in fallback(x):
269 return b'x'
270 return b''
273
271
274 return f
272 def check_exec(x):
275 if self._checkexec:
273 """This platform only supports exec permissions"""
276
274 if b'l' in fallback(x):
277 def f(x):
275 return b'l'
278 if b'l' in fallback(x):
276 entry = self.get_entry(x)
277 if entry.has_fallback_symlink:
278 if entry.fallback_symlink:
279 return b'l'
279 return b'l'
280 entry = self.get_entry(x)
280 if util.isexec(self._join(x)):
281 if entry.has_fallback_symlink:
281 return b'x'
282 if entry.fallback_symlink:
282 return b''
283 return b'l'
284 if util.isexec(self._join(x)):
285 return b'x'
286 return b''
287
283
288 return f
284 def check_fallback(x):
289 else:
285 """This platform supports neither symlinks nor exec permissions, so
286 check the fallback in the dirstate if it exists, otherwise figure it
287 out the more expensive way from the parents."""
288 entry = self.get_entry(x)
289 if entry.has_fallback_symlink:
290 if entry.fallback_symlink:
291 return b'l'
292 if entry.has_fallback_exec:
293 if entry.fallback_exec:
294 return b'x'
295 elif entry.has_fallback_symlink:
296 return b''
297 return fallback(x)
290
298
291 def f(x):
299 if self._checklink and self._checkexec:
292 entry = self.get_entry(x)
300 return check_both
293 if entry.has_fallback_symlink:
301 elif self._checklink:
294 if entry.fallback_symlink:
302 return check_link
295 return b'l'
303 elif self._checkexec:
296 if entry.has_fallback_exec:
304 return check_exec
297 if entry.fallback_exec:
305 else:
298 return b'x'
306 return check_fallback
299 elif entry.has_fallback_symlink:
300 return b''
301 return fallback(x)
302
303 return f
304
307
305 @propertycache
308 @propertycache
306 def _cwd(self):
309 def _cwd(self):
General Comments 0
You need to be logged in to leave comments. Login now