git.verbose = opt.verbose - 1
opt.bench = 1
if opt.max_pack_size:
- hashsplit.max_pack_size = parse_num(opt.max_pack_size)
+ git.max_pack_size = parse_num(opt.max_pack_size)
if opt.max_pack_objects:
- hashsplit.max_pack_objects = parse_num(opt.max_pack_objects)
+ git.max_pack_objects = parse_num(opt.max_pack_objects)
if opt.fanout:
hashsplit.fanout = parse_num(opt.fanout)
if opt.blobs:
files = extra and (open(fn) for fn in extra) or [sys.stdin]
if pack_writer and opt.blobs:
- shalist = hashsplit.split_to_blobs(pack_writer, files,
+ shalist = hashsplit.split_to_blobs(pack_writer.new_blob, files,
keep_boundaries=opt.keep_boundaries,
progress=prog)
for (sha, size, level) in shalist:
print sha.encode('hex')
reprogress()
elif pack_writer: # tree or commit or name
- shalist = hashsplit.split_to_shalist(pack_writer, files,
+ shalist = hashsplit.split_to_shalist(pack_writer.new_blob,
+ pack_writer.new_tree,
+ files,
keep_boundaries=opt.keep_boundaries,
progress=prog)
tree = pack_writer.new_tree(shalist)
from bup.helpers import *
from bup import _helpers, path, midx, bloom
+max_pack_size = 1000*1000*1000 # larger packs will slow down pruning
+max_pack_objects = 200*1000 # cache memory usage is about 83 bytes per object
SEEK_END=2 # os.SEEK_END is not defined in python 2.4
verbose = 0
if not sha:
sha = calc_hash(type, content)
size, crc = self._raw_write(_encode_packobj(type, content), sha=sha)
+ if self.outbytes >= max_pack_size or self.count >= max_pack_objects:
+ self.breakpoint()
return sha
def breakpoint(self):
def maybe_write(self, type, content):
"""Write an object to the pack file if not present and return its id."""
- self._require_objcache()
sha = calc_hash(type, content)
if not self.exists(sha):
self._write(sha, type, content)
+ self._require_objcache()
self.objcache.add(sha)
return sha
BLOB_READ_SIZE = 1024*1024
MAX_PER_TREE = 256
progress_callback = None
-max_pack_size = 1000*1000*1000 # larger packs will slow down pruning
-max_pack_objects = 200*1000 # cache memory usage is about 83 bytes per object
fanout = 16
# The purpose of this type of buffer is to avoid copying on peek(), get(),
total_split = 0
-def split_to_blobs(w, files, keep_boundaries, progress):
+def split_to_blobs(makeblob, files, keep_boundaries, progress):
global total_split
for (blob, level) in hashsplit_iter(files, keep_boundaries, progress):
- sha = w.new_blob(blob)
+ sha = makeblob(blob)
total_split += len(blob)
- if w.outbytes >= max_pack_size or w.count >= max_pack_objects:
- w.breakpoint()
if progress_callback:
progress_callback(len(blob))
yield (sha, len(blob), level)
return (shalist, total)
-def _squish(w, stacks, n):
+def _squish(maketree, stacks, n):
i = 0
while i<n or len(stacks[i]) > MAX_PER_TREE:
while len(stacks) <= i+1:
stacks[i+1] += stacks[i]
elif stacks[i]:
(shalist, size) = _make_shalist(stacks[i])
- tree = w.new_tree(shalist)
+ tree = maketree(shalist)
stacks[i+1].append(('40000', tree, size))
stacks[i] = []
i += 1
-def split_to_shalist(w, files, keep_boundaries, progress=None):
- sl = split_to_blobs(w, files, keep_boundaries, progress)
+def split_to_shalist(makeblob, maketree, files,
+ keep_boundaries, progress=None):
+ sl = split_to_blobs(makeblob, files, keep_boundaries, progress)
assert(fanout != 0)
if not fanout:
shal = []
for (sha,size,level) in sl:
stacks[0].append(('100644', sha, size))
if level:
- _squish(w, stacks, level)
+ _squish(maketree, stacks, level)
#log('stacks: %r\n' % [len(i) for i in stacks])
- _squish(w, stacks, len(stacks)-1)
+ _squish(maketree, stacks, len(stacks)-1)
#log('stacks: %r\n' % [len(i) for i in stacks])
return _make_shalist(stacks[-1])[0]
-def split_to_blob_or_tree(w, files, keep_boundaries):
- shalist = list(split_to_shalist(w, files, keep_boundaries))
+def split_to_blob_or_tree(makeblob, maketree, files, keep_boundaries):
+ shalist = list(split_to_shalist(makeblob, maketree,
+ files, keep_boundaries))
if len(shalist) == 1:
return (shalist[0][0], shalist[0][2])
elif len(shalist) == 0:
- return ('100644', w.new_blob(''))
+ return ('100644', makeblob(''))
else:
- return ('40000', w.new_tree(shalist))
+ return ('40000', maketree(shalist))
def open_noatime(name):