From 61f4b114c69c3ead179ee4f9d4a459929087fa2e Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Thu, 31 Dec 2009 19:04:59 -0500 Subject: [PATCH] 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. --- cmd-split.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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 -- 2.39.2