]> arthur.barton.de Git - bup.git/commitdiff
Change WalkItem hex id to binary oid
authorRob Browning <rlb@defaultvalue.org>
Mon, 4 Sep 2017 00:23:41 +0000 (19:23 -0500)
committerRob Browning <rlb@defaultvalue.org>
Thu, 21 Sep 2017 05:36:31 +0000 (00:36 -0500)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/gc.py
lib/bup/git.py

index 61300ec1076df0becd5e3614aa4c39c167e7ce7a..819756ffa480f0adb96981a99c31815159f56252 100644 (file)
@@ -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'
index f99b3e9adb4c68646ca05510c5f55910c3a2efd1..5e52ab6f1a6ae627dfee5bd375682405eaf80a25 100644 (file)
@@ -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))