Esempio n. 1
0
File: gc.py Progetto: xx4h/bup
def bup_gc(threshold=10, compression=1, verbosity=0):
    cat_pipe = git.cp()
    existing_count = count_objects(git.repo('objects/pack'), verbosity)
    if verbosity:
        log('found %d objects\n' % existing_count)
    if not existing_count:
        if verbosity:
            log('nothing to collect\n')
    else:
        try:
            live_objects = find_live_objects(existing_count, cat_pipe,
                                             verbosity=verbosity)
        except MissingObject as ex:
            log('bup: missing object %r \n' % ex.id.encode('hex'))
            sys.exit(1)
        try:
            # FIXME: just rename midxes and bloom, and restore them at the end if
            # we didn't change any packs?
            if verbosity: log('clearing midx files\n')
            midx.clear_midxes()
            if verbosity: log('clearing bloom filter\n')
            bloom.clear_bloom(git.repo('objects/pack'))
            if verbosity: log('clearing reflog\n')
            expirelog_cmd = ['git', 'reflog', 'expire', '--all', '--expire=all']
            expirelog = subprocess.Popen(expirelog_cmd, preexec_fn = git._gitenv())
            git._git_wait(' '.join(expirelog_cmd), expirelog)
            if verbosity: log('removing unreachable data\n')
            sweep(live_objects, existing_count, cat_pipe,
                  threshold, compression,
                  verbosity)
        finally:
            live_objects.close()
Esempio n. 2
0
def bup_gc(threshold=10, compression=1, verbosity=0):
    cat_pipe = git.cp()
    existing_count = count_objects(git.repo(b'objects/pack'), verbosity)
    if verbosity:
        log('found %d objects\n' % existing_count)
    if not existing_count:
        if verbosity:
            log('nothing to collect\n')
    else:
        try:
            live_objects = find_live_objects(existing_count,
                                             cat_pipe,
                                             verbosity=verbosity)
        except MissingObject as ex:
            log('bup: missing object %r \n' % hexstr(ex.oid))
            sys.exit(1)
        try:
            # FIXME: just rename midxes and bloom, and restore them at the end if
            # we didn't change any packs?
            packdir = git.repo(b'objects/pack')
            if verbosity: log('clearing midx files\n')
            midx.clear_midxes(packdir)
            if verbosity: log('clearing bloom filter\n')
            bloom.clear_bloom(packdir)
            if verbosity: log('clearing reflog\n')
            expirelog_cmd = [
                b'git', b'reflog', b'expire', b'--all', b'--expire=all'
            ]
            expirelog = subprocess.Popen(expirelog_cmd, env=git._gitenv())
            git._git_wait(b' '.join(expirelog_cmd), expirelog)
            if verbosity: log('removing unreachable data\n')
            sweep(live_objects, existing_count, cat_pipe, threshold,
                  compression, verbosity)
        finally:
            live_objects.close()
Esempio n. 3
0
File: gc.py Progetto: jmberg/bup
def bup_gc(repo, threshold=10, compression=1, verbosity=0):
    # Yes - this is a hack. We should use repo.cat() instead of cat_pipe.get(),
    # but the repo abstraction right now can't properly deal with the fact that
    # we modify the repository underneath.
    repodir = os.path.join(repo.packdir(), b'..', b'..')
    cat_pipe = git.cp(repodir)
    existing_count = count_objects(repo.packdir(), verbosity)
    if verbosity:
        log('found %d objects\n' % existing_count)
    if not existing_count:
        if verbosity:
            log('nothing to collect\n')
    else:
        try:
            live_objects = find_live_objects(repo, existing_count, cat_pipe,
                                             verbosity=verbosity)
        except MissingObject as ex:
            log('bup: missing object %r \n' % hexstr(ex.oid))
            sys.exit(1)
        try:
            # FIXME: just rename midxes and bloom, and restore them at the end if
            # we didn't change any packs?
            packdir = repo.packdir()
            if verbosity: log('clearing midx files\n')
            midx.clear_midxes(packdir)
            if verbosity: log('clearing bloom filter\n')
            bloom.clear_bloom(packdir)
            if verbosity: log('clearing reflog\n')
            expirelog_cmd = [b'git', b'reflog', b'expire', b'--all', b'--expire=all']
            expirelog = subprocess.Popen(expirelog_cmd,
                                         env=git._gitenv(repo_dir=repodir))
            git._git_wait(b' '.join(expirelog_cmd), expirelog)
            if verbosity: log('removing unreachable data\n')
            sweep(repo, live_objects, existing_count, cat_pipe,
                  threshold, compression,
                  verbosity)
        finally:
            live_objects.close()
Esempio n. 4
0
File: gc-cmd.py Progetto: 0xkag/bup
cat_pipe = vfs.cp()
existing_count = count_objects(git.repo('objects/pack'))
if opt.verbose:
    log('found %d objects\n' % existing_count)
if not existing_count:
    if opt.verbose:
        log('nothing to collect\n')
else:
    live_objects = find_live_objects(existing_count, cat_pipe, opt)
    try:
        # FIXME: just rename midxes and bloom, and restore them at the end if
        # we didn't change any packs?
        if opt.verbose: log('clearing midx files\n')
        midx.clear_midxes()
        if opt.verbose: log('clearing bloom filter\n')
        bloom.clear_bloom(git.repo('objects/pack'))
        if opt.verbose: log('clearing reflog\n')
        expirelog_cmd = ['git', 'reflog', 'expire', '--all', '--expire=all']
        expirelog = subprocess.Popen(expirelog_cmd, preexec_fn = git._gitenv())
        git._git_wait(' '.join(expirelog_cmd), expirelog)
        if opt.verbose: log('removing unreachable data\n')
        sweep(live_objects, existing_count, cat_pipe, opt)
    finally:
        live_objects.close()
        os.unlink(live_objects.name)

if saved_errors:
    log('WARNING: %d errors encountered during gc\n' % len(saved_errors))
    sys.exit(1)
Esempio n. 5
0
cat_pipe = vfs.cp()
existing_count = count_objects(git.repo('objects/pack'))
if opt.verbose:
    log('found %d objects\n' % existing_count)
if not existing_count:
    if opt.verbose:
        log('nothing to collect\n')
else:
    live_objects = find_live_objects(existing_count, cat_pipe, opt)
    try:
        # FIXME: just rename midxes and bloom, and restore them at the end if
        # we didn't change any packs?
        if opt.verbose: log('clearing midx files\n')
        midx.clear_midxes()
        if opt.verbose: log('clearing bloom filter\n')
        bloom.clear_bloom(git.repo('objects/pack'))
        if opt.verbose: log('clearing reflog\n')
        expirelog_cmd = ['git', 'reflog', 'expire', '--all', '--expire=all']
        expirelog = subprocess.Popen(expirelog_cmd, preexec_fn=git._gitenv())
        git._git_wait(' '.join(expirelog_cmd), expirelog)
        if opt.verbose: log('removing unreachable data\n')
        sweep(live_objects, existing_count, cat_pipe, opt)
    finally:
        live_objects.close()
        os.unlink(live_objects.name)

if saved_errors:
    log('WARNING: %d errors encountered during gc\n' % len(saved_errors))
    sys.exit(1)