mirror of
https://github.com/newren/git-filter-repo.git
synced 2024-07-06 18:32:14 +02:00
filter-repo: fix incremental imports and add a test
The AncestryGraph setup assumed we had previously seen all commits which would be used as parents; that interacted badly with doing an incremental import. Add a function which can be used to record external commits, each of which we'll treat like a root commit (i.e. depth 1 and having no parents of its own). Add a test to prevent regressions. Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
parent
69f7224d95
commit
cd9ea5af9b
@ -151,6 +151,17 @@ class AncestryGraph(object):
|
|||||||
# than the max depth of any of its ancestors.
|
# than the max depth of any of its ancestors.
|
||||||
self.graph = {}
|
self.graph = {}
|
||||||
|
|
||||||
|
def record_external_commits(self, external_commits):
|
||||||
|
"""
|
||||||
|
Record in graph that each commit in external_commits exists, and is
|
||||||
|
treated as a root commit with no parents.
|
||||||
|
"""
|
||||||
|
for c in external_commits:
|
||||||
|
if c not in self.value:
|
||||||
|
self.cur_value += 1
|
||||||
|
self.value[c] = self.cur_value
|
||||||
|
self.graph[self.cur_value] = (1, [])
|
||||||
|
|
||||||
def add_commit_and_parents(self, commit, parents):
|
def add_commit_and_parents(self, commit, parents):
|
||||||
"""
|
"""
|
||||||
Record in graph that commit has the given parents. parents _MUST_ have
|
Record in graph that commit has the given parents. parents _MUST_ have
|
||||||
@ -1441,6 +1452,10 @@ class FastExportFilter(object):
|
|||||||
_IDS.record_rename(id_, commit.id)
|
_IDS.record_rename(id_, commit.id)
|
||||||
|
|
||||||
# Record ancestry graph
|
# Record ancestry graph
|
||||||
|
external_parents = [p for p in commit.get_parents()
|
||||||
|
if not isinstance(p, int)]
|
||||||
|
self._graph.record_external_commits(external_parents)
|
||||||
|
self._orig_graph.record_external_commits(external_parents)
|
||||||
self._graph.add_commit_and_parents(commit.id, commit.get_parents())
|
self._graph.add_commit_and_parents(commit.id, commit.get_parents())
|
||||||
self._orig_graph.add_commit_and_parents(id_, orig_parents)
|
self._orig_graph.add_commit_and_parents(id_, orig_parents)
|
||||||
|
|
||||||
|
@ -788,4 +788,16 @@ test_expect_success 'mailmap sanity checks' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'incremental import' '
|
||||||
|
(
|
||||||
|
git clone file://"$(pwd)"/analyze_me incremental &&
|
||||||
|
cd incremental &&
|
||||||
|
|
||||||
|
original=$(git rev-parse master) &&
|
||||||
|
git fast-export --reference-excluded-parents master~2..master \
|
||||||
|
| git filter-repo --stdin --refname-callback "return \"develop\"" &&
|
||||||
|
test "$(git rev-parse develop)" = "$original"
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user