comparison mercurial/cmdutil.py @ 16165:60101427d618 stable

log: fix --follow FILE ancestry calculation Currently, --follow FILE looks for a FILE filelog, scans it and collects linkrevs and renames, then filters them. The problem is the filelog scan does not start at FILE filenode in parent revision but at the last filelog revision. So: - Files not in the parent revision can be followed, the starting node is unexpected - Files in the parent revision can be followed from an incorrect starting node. This patch makes log --follow FILE fail if FILE is not in parent revision, and computes ancestors of the parent revision FILE filenode.
author Patrick Mezard <patrick@mezard.eu>
date Fri, 24 Feb 2012 20:57:59 +0100
parents f7e0d95d0a0b
children 6c4dbe28dda3
comparison
equal deleted inserted replaced
16164:18743c4d1989 16165:60101427d618
1022 revs.append((linkrev, parentlinkrevs, 1022 revs.append((linkrev, parentlinkrevs,
1023 follow and filelog.renamed(n))) 1023 follow and filelog.renamed(n)))
1024 1024
1025 return reversed(revs) 1025 return reversed(revs)
1026 def iterfiles(): 1026 def iterfiles():
1027 pctx = repo['.']
1027 for filename in match.files(): 1028 for filename in match.files():
1028 yield filename, None 1029 if follow:
1030 if filename not in pctx:
1031 raise util.Abort(_('cannot follow file not in parent '
1032 'revision: "%s"') % filename)
1033 yield filename, pctx[filename].filenode()
1034 else:
1035 yield filename, None
1029 for filename_node in copies: 1036 for filename_node in copies:
1030 yield filename_node 1037 yield filename_node
1031 for file_, node in iterfiles(): 1038 for file_, node in iterfiles():
1032 filelog = repo.file(file_) 1039 filelog = repo.file(file_)
1033 if not len(filelog): 1040 if not len(filelog):