[PATCH 2 of 8] localrepo: move symlink logic to workingctx
Sean Farley
sean.michael.farley at gmail.com
Tue May 6 23:33:19 UTC 2014
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1394227957 28800
# Fri Mar 07 13:32:37 2014 -0800
# Node ID e8cfd36c584cb7aafeb51830592176e69061eb46
# Parent c8586e9a821d8abbc88438f2e78aa564e0b5e87a
localrepo: move symlink logic to workingctx
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1178,10 +1178,29 @@ class workingctx(committablectx):
self._repo.dirstate.add(dest)
self._repo.dirstate.copy(source, dest)
finally:
wlock.release()
+ def _filtersuspectsymlink(self, files):
+ if not files or self._repo.dirstate._checklink:
+ return files
+
+ # 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 files:
+ if self.flags(f) == 'l':
+ d = self[f].data()
+ if d == '' or len(d) >= 1024 or '\n' in d or util.binary(d):
+ self._repo.ui.debug('ignoring suspect symlink placeholder'
+ ' "%s"\n' % f)
+ continue
+ sane.append(f)
+ return sane
+
class committablefilectx(basefilectx):
"""A committablefilectx provides common functionality for a file context
that wants the ability to commit, e.g. workingfilectx or memfilectx."""
def __init__(self, repo, path, filelog=None, ctx=None):
self._repo = repo
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1611,25 +1611,12 @@ class localrepository(object):
del mf1[fn]
elif fn not in deleted:
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 d == '' or 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
+ if working:
+ modified = ctx2._filtersuspectsymlink(modified)
if reversed:
added, removed = removed, added
deleted, unknown = unknown, deleted
More information about the Mercurial-devel
mailing list