From: Rob Browning Date: Mon, 4 Sep 2017 00:23:41 +0000 (-0500) Subject: Change WalkItem hex id to binary oid X-Git-Tag: 0.30~179 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=20494763c5ab8e33ee705d839e3d0ab2f8e37cbf;ds=sidebyside Change WalkItem hex id to binary oid Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/gc.py b/lib/bup/gc.py index 61300ec..819756f 100644 --- a/lib/bup/gc.py +++ b/lib/bup/gc.py @@ -109,15 +109,14 @@ def find_live_objects(existing_count, cat_pipe, verbosity=0): if verbosity: report_live_item(approx_live_count, existing_count, ref_name, ref_id, item, verbosity) - bin_id = item.id.decode('hex') if trees_visited is not None and item.type == 'tree': - trees_visited.add(bin_id) + trees_visited.add(item.oid) if verbosity: - if not live_objs.exists(bin_id): - live_objs.add(bin_id) + if not live_objs.exists(item.oid): + live_objs.add(item.oid) approx_live_count += 1 else: - live_objs.add(bin_id) + live_objs.add(item.oid) trees_visited = None if verbosity: log('expecting to retain about %.2f%% unnecessary objects\n' diff --git a/lib/bup/git.py b/lib/bup/git.py index f99b3e9..5e52ab6 100644 --- a/lib/bup/git.py +++ b/lib/bup/git.py @@ -1263,7 +1263,7 @@ class MissingObject(KeyError): KeyError.__init__(self, 'object %r is missing' % oid.encode('hex')) -WalkItem = namedtuple('WalkItem', ['id', 'type', 'mode', +WalkItem = namedtuple('WalkItem', ['oid', 'type', 'mode', 'path', 'chunk_path', 'data']) # The path is the mangled path, and if an item represents a fragment # of a chunked file, the chunk_path will be the chunked subtree path @@ -1290,6 +1290,7 @@ def walk_object(cat_pipe, oidx, pending = [(oidx, [], [], None)] while len(pending): oidx, parent_path, chunk_path, mode = pending.pop() + oid = oidx.decode('hex') if stop_at and stop_at(oidx): continue @@ -1297,7 +1298,7 @@ def walk_object(cat_pipe, oidx, # If the object is a "regular file", then it's a leaf in # the graph, so we can skip reading the data if the caller # hasn't requested it. - yield WalkItem(id=oidx, type='blob', + yield WalkItem(oid=oid, type='blob', chunk_path=chunk_path, path=parent_path, mode=mode, data=None) @@ -1319,7 +1320,7 @@ def walk_object(cat_pipe, oidx, else: data = ''.join(item_it) - yield WalkItem(id=oidx, type=typ, + yield WalkItem(oid=oid, type=typ, chunk_path=chunk_path, path=parent_path, mode=mode, data=(data if include_data else None))