Commit Diff


commit - 0bfa06e59123c574243c899182ffa6cc208efd09
commit + 7b0e91db76ad97ace322f6ffbb46cfa524e6eb9e
blob - 19c6f582c1e020ec9345cd369bc8a87e3a44778d
blob + 9f4075086dd293ffa2c6d58a2052c947c69dc292
--- swh/loader/git/loader.py
+++ swh/loader/git/loader.py
@@ -724,6 +724,7 @@ class GitLoader(BaseGitLoader):
         # Find all tags, commits and corresponding tree roots in the pack file
         tags = {}
         commits = {}
+        traversed_commits = set()
         commit_edges = []
         new_trees = []
         new_blobs = []
@@ -778,8 +779,9 @@ class GitLoader(BaseGitLoader):
             while len(parents) > 0:
                 commit_hex = parents.pop(0)
                 commit_hash = hashutil.bytehex_to_hash(commit_hex)
-                if commit_hash in commits.keys():
+                if commit_hash in traversed_commits:
                     continue
+                traversed_commits.add(commit_hash)
                 try:
                     commit = self.pack[commit_hex]
                 except KeyError:
@@ -796,7 +798,7 @@ class GitLoader(BaseGitLoader):
                     if parent_hex not in self.pack:
                         continue
                     parent_hash = hashutil.bytehex_to_hash(parent_hex)
-                    if parent_hash in commits.keys():
+                    if parent_hash in traversed_commits:
                         continue
                     parents.append(parent_hex)
                     commit_edges.append((commit_hash, parent_hash))