[PATCH 4 of 5] context: use a the nofsauditor when matching file in history (issue4749)
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Thu Dec 3 16:01:28 CST 2015
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1449177826 28800
# Thu Dec 03 13:23:46 2015 -0800
# Node ID 65797f84a2cc0317f1326215701befd382d04299
# Parent 64a5cdedfc87c8c3d47d8147612e62186a5228c4
# EXP-Topic symlink.issue4749
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
# hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 65797f84a2cc
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.
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -269,11 +269,11 @@ class basectx(object):
def match(self, pats=[], include=None, exclude=None, default='glob',
listsubrepos=False, badfn=None):
r = self._repo
return matchmod.match(r.root, r.getcwd(), pats,
include, exclude, default,
- auditor=r.auditor, ctx=self,
+ auditor=r.nofsauditor, ctx=self,
listsubrepos=listsubrepos, badfn=badfn)
def diff(self, ctx2=None, match=None, **opts):
"""Returns a diff generator for the given contexts and matcher"""
if ctx2 is None:
diff --git a/tests/test-audit-path.t b/tests/test-audit-path.t
--- a/tests/test-audit-path.t
+++ b/tests/test-audit-path.t
@@ -25,10 +25,49 @@ should still fail - maybe
$ hg add b/b
abort: path 'b/b' traverses symbolic link 'b' (glob)
[255]
+ $ hg commit -m 'add symlink b'
+
+
+Test symlink traversing when accessing history:
+-----------------------------------------------
+
+(build a changeset where the path exists as a directory)
+
+ $ hg up 0
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ $ mkdir b
+ $ echo c > b/a
+ $ hg add b/a
+ $ hg ci -m 'add directory b'
+ created new head
+
+Test that hg cat does not do anything wrong the working copy has 'b' as directory
+
+ $ hg cat b/a
+ c
+ $ hg cat -r "desc(directory)" b/a
+ c
+ $ hg cat -r "desc(symlink)" b/a
+ b/a: no such file in rev bc151a1f53bd
+ [1]
+
+Test that hg cat does not do anything wrong the working copy has 'b' as a symlink (issue4749)
+
+ $ hg up 'desc(symlink)'
+ 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ $ hg cat b/a
+ b/a: no such file in rev bc151a1f53bd
+ [1]
+ $ hg cat -r "desc(directory)" b/a
+ c
+ $ hg cat -r "desc(symlink)" b/a
+ b/a: no such file in rev bc151a1f53bd
+ [1]
+
#endif
unbundle tampered bundle
More information about the Mercurial-devel
mailing list