Mercurial > public > mercurial-scm > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Sun Oct 23 21:59:15 2011 +0200 +++ b/mercurial/localrepo.py Sun Oct 23 16:32:27 2011 -0500 @@ -1354,6 +1354,22 @@ added.append(fn) removed = mf1.keys() + if working and modified and not self.dirstate._checklink: + # Symlink placeholders may get non-symlink-like contents + # via user error or dereferencing by NFS or Samba servers, + # so we filter out any placeholders that don't look like a + # symlink + sane = [] + for f in modified: + if ctx2.flags(f) == 'l': + d = ctx2[f].data() + if len(d) >= 1024 or '\n' in d or util.binary(d): + self.ui.debug('ignoring suspect symlink placeholder' + ' "%s"\n' % f) + continue + sane.append(f) + modified = sane + r = modified, added, removed, deleted, unknown, ignored, clean if listsubrepos: