diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -760,6 +760,12 @@ class basefilectx(object): # result is crash somewhere else at to some point. return lkr + def isintroducedafter(self, changelogrev): + """True if a filectx has been introduced after a given floor revision + """ + return (self.linkrev() >= changelogrev + or self.introrev() >= changelogrev) + def introrev(self): """return the rev of the changeset which introduced this file revision diff --git a/mercurial/copies.py b/mercurial/copies.py --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -139,7 +139,7 @@ def _tracefile(fctx, am, limit=-1): for f in fctx.ancestors(): if am.get(f.path(), None) == f.filenode(): return f - if limit >= 0 and f.linkrev() < limit and f.rev() < limit: + if limit >= 0 and not f.isintroducedafter(limit): return None def _dirstatecopies(d, match=None):