schacon/hg-git

too many open files, due to missing close of file

grobian opened this issue · 2 comments

problem:

% hg pull
pulling from git+ssh://git@git.overlays.gentoo.org/proj/portage.git
importing Hg objects into Git
["git-upload-pack '/proj/portage.git'"]
Counting objects: 3664, done.
Compressing objects: 100% (2573/2573), done.
Total 3664 (delta 2289), reused 1743 (delta 1091)
importing Git objects into Hg
abort: Too many open files: /export/gentoo/portage-hg/.hg/git/objects/pack/pack-9fb8d5a8932a495a2ed28ac993b4329a1ad3c680.pack
%

This problem stems from commit 59c7b6d
the code block for hgrepo.py around line 50 opens tf, but doesn't close it. Adding tf.close() after the tf.read line, resolves the too many open files problem.

I can't find a attach function or something, so here is the simple fix inline:

--- hgrepo.py.orig 2011-03-13 17:09:21.000000000 +0100
+++ hgrepo.py 2011-03-13 17:09:43.000000000 +0100
@@ -55,6 +55,7 @@
if os.path.exists(tagfile):
tf = open(tagfile, 'rb')
tagdata = tf.read().split('\n')

  •            tf.close()
               td = [line.split(' ', 1) for line in tagdata if line]
               return dict([(name, bin(sha)) for sha, name in td])
           return {}
    

hmmm, this fix only worked on some systems, not all. The real problem is dulwich opening all pack files at the same time, so not a bug in hg-git.