comparison mercurial/localrepo.py @ 15348:c681e478c429 stable

windows: sanity-check symlink placeholders On Windows, we store symlinks as plain files with the link contents. Via user error or NFS/Samba assistance, these files often end up with 'normal' file contents. Committing these changes thus gives an invalid symlink that can't be checked out on Unix. Here we filter out any modified symlink placeholders that look suspicious when computing status: - more than 1K (looks more like a normal file) - contain NULs (not allowed on Unix, probably a binary) - contains \n (filenames can't contain \n, very unusual for symlinks, very common for files)
author Matt Mackall <mpm@selenic.com>
date Sun, 23 Oct 2011 16:32:27 -0500
parents e174353e8cda
children dbdb777502dc
comparison
equal deleted inserted replaced
15347:799e56609ef6 15348:c681e478c429
1351 clean.append(fn) 1351 clean.append(fn)
1352 del mf1[fn] 1352 del mf1[fn]
1353 elif fn not in deleted: 1353 elif fn not in deleted:
1354 added.append(fn) 1354 added.append(fn)
1355 removed = mf1.keys() 1355 removed = mf1.keys()
1356
1357 if working and modified and not self.dirstate._checklink:
1358 # Symlink placeholders may get non-symlink-like contents
1359 # via user error or dereferencing by NFS or Samba servers,
1360 # so we filter out any placeholders that don't look like a
1361 # symlink
1362 sane = []
1363 for f in modified:
1364 if ctx2.flags(f) == 'l':
1365 d = ctx2[f].data()
1366 if len(d) >= 1024 or '\n' in d or util.binary(d):
1367 self.ui.debug('ignoring suspect symlink placeholder'
1368 ' "%s"\n' % f)
1369 continue
1370 sane.append(f)
1371 modified = sane
1356 1372
1357 r = modified, added, removed, deleted, unknown, ignored, clean 1373 r = modified, added, removed, deleted, unknown, ignored, clean
1358 1374
1359 if listsubrepos: 1375 if listsubrepos:
1360 for subpath, sub in subrepo.itersubrepos(ctx1, ctx2): 1376 for subpath, sub in subrepo.itersubrepos(ctx1, ctx2):