Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 27234:15c6eb0a51bd
context: use a the nofsauditor when matching file in history (issue4749)
Before this change, asking for file from history (eg: 'hg cat -r 42 foo/bar')
could fail because of the current content of the working copy (eg: current
"foo" being a symlink). As the working copy state have no influence on the
content of the history, we can safely skip these checks.
The working copy context class have a different 'match'
implementation. That implementation still use the repo.auditor will
still catch symlink traversal.
I've audited all stuff calling "match" and they all go through a ctx
in a sensible way. The most unclear case was diff which still seemed
okay. You raised my paranoid level today and I double checked through
tests. They behave properly.
The odds of someone using the wrong (matching with a changectx for
operation that will eventually touch the file system) is non-zero
because you are never sure of what people will do. But I dunno if we
can fight against that. So I would not commit to "never" for "at this
level" and "in the future" if someone write especially bad code.
However, as a last defense, the vfs itself is running path auditor in
all cases outside of .hg/. So I think anything passing the 'matcher'
for buggy reason would growl at the vfs layer.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 03 Dec 2015 13:23:46 -0800 |
parents | 0945539a3a6b |
children | e6d3dad71e44 |
comparison
equal
deleted
inserted
replaced
27233:dfb836a31b61 | 27234:15c6eb0a51bd |
---|---|
269 def match(self, pats=[], include=None, exclude=None, default='glob', | 269 def match(self, pats=[], include=None, exclude=None, default='glob', |
270 listsubrepos=False, badfn=None): | 270 listsubrepos=False, badfn=None): |
271 r = self._repo | 271 r = self._repo |
272 return matchmod.match(r.root, r.getcwd(), pats, | 272 return matchmod.match(r.root, r.getcwd(), pats, |
273 include, exclude, default, | 273 include, exclude, default, |
274 auditor=r.auditor, ctx=self, | 274 auditor=r.nofsauditor, ctx=self, |
275 listsubrepos=listsubrepos, badfn=badfn) | 275 listsubrepos=listsubrepos, badfn=badfn) |
276 | 276 |
277 def diff(self, ctx2=None, match=None, **opts): | 277 def diff(self, ctx2=None, match=None, **opts): |
278 """Returns a diff generator for the given contexts and matcher""" | 278 """Returns a diff generator for the given contexts and matcher""" |
279 if ctx2 is None: | 279 if ctx2 is None: |