diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2945,17 +2945,18 @@ fnode = ctx.filenode(fn) except error.LookupError: continue - try: - copied = flog.renamed(fnode) - except error.WdirUnsupported: - copied = ctx[fn].renamed() - copy = follow and copied and copied[0] - if copy: - copies.setdefault(rev, {})[fn] = copy - if fn in skip: + copy = None + if follow: + try: + copied = flog.renamed(fnode) + except error.WdirUnsupported: + copied = ctx[fn].renamed() + copy = copied and copied[0] if copy: - skip[copy] = True - continue + copies.setdefault(rev, {})[fn] = copy + if fn in skip: + skip[copy] = True + continue files.append(fn) if fn not in matches[rev]: