##// 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,9 +242,11 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 fallback = buildfallback()
246
247
247 def f(x):
248 def check_both(x):
249 """This platform supports symlinks and exec permissions"""
248 try:
250 try:
249 st = os.lstat(self._join(x))
251 st = os.lstat(self._join(x))
250 if util.statislink(st):
252 if util.statislink(st):
@@ -255,12 +257,8 b' class dirstate(object):'
255 pass
257 pass
256 return b''
258 return b''
257
259
258 return f
260 def check_link(x):
259
261 """This platform only supports symlinks"""
260 fallback = buildfallback()
261 if self._checklink:
262
263 def f(x):
264 if os.path.islink(self._join(x)):
262 if os.path.islink(self._join(x)):
265 return b'l'
263 return b'l'
266 entry = self.get_entry(x)
264 entry = self.get_entry(x)
@@ -271,10 +269,8 b' class dirstate(object):'
271 return b'x'
269 return b'x'
272 return b''
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
277 def f(x):
278 if b'l' in fallback(x):
274 if b'l' in fallback(x):
279 return b'l'
275 return b'l'
280 entry = self.get_entry(x)
276 entry = self.get_entry(x)
@@ -285,10 +281,10 b' class dirstate(object):'
285 return b'x'
281 return b'x'
286 return b''
282 return b''
287
283
288 return f
284 def check_fallback(x):
289 else:
285 """This platform supports neither symlinks nor exec permissions, so
290
286 check the fallback in the dirstate if it exists, otherwise figure it
291 def f(x):
287 out the more expensive way from the parents."""
292 entry = self.get_entry(x)
288 entry = self.get_entry(x)
293 if entry.has_fallback_symlink:
289 if entry.has_fallback_symlink:
294 if entry.fallback_symlink:
290 if entry.fallback_symlink:
@@ -300,7 +296,14 b' class dirstate(object):'
300 return b''
296 return b''
301 return fallback(x)
297 return fallback(x)
302
298
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 @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