#!/usr/bin/env python
-import sys, math, struct, glob
+import sys, math, struct, glob, resource
from bup import options, git
from bup.helpers import *
def _group(l, count):
for i in xrange(0, len(l), count):
yield l[i:i+count]
+
+
+def max_files():
+ mf = min(resource.getrlimit(resource.RLIMIT_NOFILE))
+ if mf > 32:
+ mf -= 20 # just a safety margin
+ else:
+ mf -= 6 # minimum safety margin
+ return mf
def merge(idxlist, bits, table):
o,output= output midx filename (default: auto-generated)
a,auto automatically create .midx from any unindexed .idx files
f,force automatically create .midx from *all* .idx files
-max-files= maximum number of idx files to open at once [500]
+max-files= maximum number of idx files to open at once [-1]
"""
o = options.Options('bup midx', optspec)
(opt, flags, extra) = o.parse(sys.argv[1:])
git.check_repo_or_die()
+if opt.max_files < 0:
+ opt.max_files = max_files()
+assert(opt.max_files >= 5)
+
if extra:
do_midx(git.repo('objects/pack'), opt.output, extra)
elif opt.auto or opt.force: