filter-repo: avoid dying with --analyze on commits with unseen parents

analyze_commit() calls add_commit_and_parents() which does a sanity
check that we have seen all parents previously.  --refs breaks that
assumption, so we need to workaround that check when ref limiting is in
effect.

Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
Elijah Newren 2020-03-21 19:48:16 -07:00
parent 46549e7d3f
commit fe33fc42b3

View File

@ -2339,6 +2339,12 @@ class RepoAnalyze(object):
filenames = [PathQuoting.dequote(x) for x in splits[1:]]
file_changes.append([modes, shas, change_types, filenames])
# If someone is trying to analyze a subset of the history, make sure
# to avoid dying on commits with parents that we haven't seen before
if args.refs:
graph.record_external_commits([p for p in parents
if not p in graph.value])
# Analyze this commit and update progress
RepoAnalyze.analyze_commit(stats, graph, commit, parents, date,
file_changes)