D9965: Work around for issue6456, check content of symlinks because st_size may indicate the size of encrypted data.
cschuhen (Corey Schuhen)
phabricator at mercurial-scm.org
Sun Feb 7 23:15:56 UTC 2021
cschuhen created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D9965
AFFECTED FILES
mercurial/context.py
mercurial/dirstate.py
CHANGE DETAILS
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -1270,6 +1270,7 @@
if not st and state in b"nma":
dadd(fn)
elif state == b'n':
+ islink = (stat.S_IFLNK == (st.st_mode & stat.S_IFLNK))
if (
size >= 0
and (
@@ -1279,7 +1280,12 @@
or size == -2 # other parent
or fn in copymap
):
- madd(fn)
+ if (islink):
+ # issue6456: Size returned may be longer due to
+ # encryption on EXT-4 fscrypt, undecided.
+ ladd(fn)
+ else:
+ madd(fn)
elif (
time != st[stat.ST_MTIME]
and time != st[stat.ST_MTIME] & _rangemask
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -993,8 +993,10 @@
# if file data starts with '\1\n', empty metadata block is
# prepended, which adds 4 bytes to filelog.size().
return self._filelog.cmp(self._filenode, fctx.data())
- if self.size() == fctx.size():
+ if self.size() == fctx.size() or self.flags() == b'l':
# size() matches: need to compare content
+ # issue6456: Always compare symlinks because size can represent
+ # encrypted string for EXT-4 encryption(fscrypt).
return self._filelog.cmp(self._filenode, fctx.data())
# size() differs
To: cschuhen, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list