From: Avery Pennarun Date: Fri, 1 Jan 2010 00:04:59 +0000 (-0500) Subject: split: name chunkfiles more carefully to prevent name changes. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=61f4b114c69c3ead179ee4f9d4a459929087fa2e;p=packages%2Fb%2Fbup.git split: name chunkfiles more carefully to prevent name changes. This isn't perfect, but a bit of byte jitter here and there now won't cause unnecessary filename changes. --- diff --git a/cmd-split.py b/cmd-split.py index e755efe..a64819d 100755 --- a/cmd-split.py +++ b/cmd-split.py @@ -103,13 +103,24 @@ start_time = time.time() shalist = [] ofs = 0 - +last_ofs = 0 for f in autofiles(extra): - for (ofs, size, sha) in hashsplit_iter(f): + for (xofs, size, sha) in hashsplit_iter(f): #log('SPLIT @ %-8d size=%-8d\n' % (ofs, size)) if opt.blobs: print sha - shalist.append(('100644', '%016x.bupchunk' % ofs, sha)) + + # this silliness keeps chunk filenames "similar" when a file changes + # slightly. + bm = BLOB_MAX + while 1: + cn = ofs / bm * bm + #log('%x,%x,%x,%x\n' % (last_ofs,ofs,cn,bm)) + if cn > last_ofs or ofs == last_ofs: break + bm /= 2 + last_ofs = cn + shalist.append(('100644', 'bup.chunk.%016x' % cn, sha)) + ofs += size tree = git.gen_tree(shalist) if opt.tree: print tree