Changeset - fc8a5cbfa0da
[Not reviewed]
default
0 1 0
domruf - 10 years ago 2016-03-31 20:53:23
dominikruf@gmail.com
compare: close Dulwich internals for Git repositories to avoid leaking open files

Fix failing test_compare.py on Windows by explicitly closing internal
object_store objects.
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/compare.py
Show inline comments
 
@@ -121,24 +121,27 @@ class CompareController(BaseRepoControll
 

	
 
                revs = []
 
                for x in gitrepo_remote.get_walker(include=[other_rev],
 
                                                   exclude=[org_rev]):
 
                    revs.append(x.commit.id)
 

	
 
                other_changesets = [other_repo.get_changeset(rev) for rev in reversed(revs)]
 
                if other_changesets:
 
                    ancestor = other_changesets[0].parents[0].raw_id
 
                else:
 
                    # no changesets from other repo, ancestor is the other_rev
 
                    ancestor = other_rev
 
                # dulwich 0.9.9 doesn't have a Repo.close() so we have to mess with internals:
 
                gitrepo.object_store.close()
 
                gitrepo_remote.object_store.close()
 

	
 
            else:
 
                so, se = org_repo.run_git_command(
 
                    ['log', '--reverse', '--pretty=format:%H',
 
                     '-s', '%s..%s' % (org_rev, other_rev)]
 
                )
 
                other_changesets = [org_repo.get_changeset(cs)
 
                              for cs in re.findall(r'[0-9a-fA-F]{40}', so)]
 
                so, se = org_repo.run_git_command(
 
                    ['merge-base', org_rev, other_rev]
 
                )
 
                ancestor = re.findall(r'[0-9a-fA-F]{40}', so)[0]
0 comments (0 inline, 0 general)