filter-repo: ensure we parse all merge parents, even if some became pruned

Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
Elijah Newren 2018-11-10 14:13:22 -08:00
parent 424faa3103
commit 9b88f3f094

View File

@ -993,12 +993,19 @@ class FastExportFilter(object):
self._translate_commit_hash, self._translate_commit_hash,
commit_msg) commit_msg)
parents = [] parents = [self._parse_optional_parent_ref('from')]
parents.append(self._parse_optional_parent_ref('from')) # Due to empty pruning, we can have real 'from' and 'merge' lines that
merge_ref = self._parse_optional_parent_ref('merge') # due to commit rewriting map to a parent of None. We need to record
while merge_ref: # 'from' if its non-None, and we need to parse all 'merge' lines.
parents.append(merge_ref) while self._currentline.startswith('merge '):
merge_ref = self._parse_optional_parent_ref('merge') parents.append(self._parse_optional_parent_ref('merge'))
# Since we may have added several 'None' parents due to empty pruning,
# get rid of all the non-existent parents
parents = [x for x in parents if x is not None]
# However, the splitting below into from_commit and merge_commits means
# we'd rather a parentless commit be represented as one None entry
if not parents:
parents.append(None)
was_merge = len(parents) > 1 was_merge = len(parents) > 1
# Remove redundant parents (if both sides of history are empty commits, # Remove redundant parents (if both sides of history are empty commits,