##// 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 242 return self._rootdir + f
243 243
244 244 def flagfunc(self, buildfallback):
245 if self._checklink and self._checkexec:
246
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''
245 if not (self._checklink and self._checkexec):
246 fallback = buildfallback()
257 247
258 return f
259
260 fallback = buildfallback()
261 if self._checklink:
262
263 def f(x):
264 if os.path.islink(self._join(x)):
248 def check_both(x):
249 """This platform supports symlinks and exec permissions"""
250 try:
251 st = os.lstat(self._join(x))
252 if util.statislink(st):
265 253 return b'l'
266 entry = self.get_entry(x)
267 if entry.has_fallback_exec:
268 if entry.fallback_exec:
269 return b'x'
270 elif b'x' in fallback(x):
254 if util.statisexec(st):
271 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
275 if self._checkexec:
276
277 def f(x):
278 if b'l' in fallback(x):
272 def check_exec(x):
273 """This platform only supports exec permissions"""
274 if b'l' in fallback(x):
275 return b'l'
276 entry = self.get_entry(x)
277 if entry.has_fallback_symlink:
278 if entry.fallback_symlink:
279 279 return b'l'
280 entry = self.get_entry(x)
281 if entry.has_fallback_symlink:
282 if entry.fallback_symlink:
283 return b'l'
284 if util.isexec(self._join(x)):
285 return b'x'
286 return b''
280 if util.isexec(self._join(x)):
281 return b'x'
282 return b''
287 283
288 return f
289 else:
284 def check_fallback(x):
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):
292 entry = self.get_entry(x)
293 if entry.has_fallback_symlink:
294 if entry.fallback_symlink:
295 return b'l'
296 if entry.has_fallback_exec:
297 if entry.fallback_exec:
298 return b'x'
299 elif entry.has_fallback_symlink:
300 return b''
301 return fallback(x)
302
303 return f
299 if self._checklink and self._checkexec:
300 return check_both
301 elif self._checklink:
302 return check_link
303 elif self._checkexec:
304 return check_exec
305 else:
306 return check_fallback
304 307
305 308 @propertycache
306 309 def _cwd(self):
General Comments 0
You need to be logged in to leave comments. Login now