From: Johannes Berg Date: Wed, 18 Dec 2019 19:08:26 +0000 (+0100) Subject: git: remove global variable ignore_midx X-Git-Tag: 0.31~216 X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=commitdiff_plain;h=5dcd9acd912fda2259ec323a2a06666e0b01db49 git: remove global variable ignore_midx This can easily be kept as state in the git.PackIdxList() class instead, so do that. Signed-off-by: Johannes Berg Reviewed-by: Rob Browning Tested-by: Rob Browning --- diff --git a/cmd/margin-cmd.py b/cmd/margin-cmd.py index b01db3d..7eba448 100755 --- a/cmd/margin-cmd.py +++ b/cmd/margin-cmd.py @@ -26,9 +26,8 @@ if extra: o.fatal("no arguments expected") git.check_repo_or_die() -git.ignore_midx = opt.ignore_midx -mi = git.PackIdxList(git.repo('objects/pack')) +mi = git.PackIdxList(git.repo('objects/pack'), ignore_midx=opt.ignore_midx) def do_predict(ix): total = len(ix) diff --git a/cmd/memtest-cmd.py b/cmd/memtest-cmd.py index 2fe71f5..3dc47da 100755 --- a/cmd/memtest-cmd.py +++ b/cmd/memtest-cmd.py @@ -83,10 +83,8 @@ o = options.Options(optspec) if extra: o.fatal('no arguments expected') -git.ignore_midx = opt.ignore_midx - git.check_repo_or_die() -m = git.PackIdxList(git.repo('objects/pack')) +m = git.PackIdxList(git.repo('objects/pack'), ignore_midx=opt.ignore_midx) report(-1) _helpers.random_sha() diff --git a/lib/bup/git.py b/lib/bup/git.py index acceccc..e299da1 100644 --- a/lib/bup/git.py +++ b/lib/bup/git.py @@ -24,7 +24,6 @@ from bup.helpers import (Sha1, add_error, chunkyreader, debug1, debug2, from bup.pwdgrp import username, userfullname verbose = 0 -ignore_midx = 0 repodir = None # The default repository, once initialized _typemap = { 'blob':3, 'tree':2, 'commit':1, 'tag':4 } @@ -456,7 +455,7 @@ class PackIdxV2(PackIdx): _mpi_count = 0 class PackIdxList: - def __init__(self, dir): + def __init__(self, dir, ignore_midx=False): global _mpi_count assert(_mpi_count == 0) # these things suck tons of VM; don't waste it _mpi_count += 1 @@ -465,6 +464,7 @@ class PackIdxList: self.packs = [] self.do_bloom = False self.bloom = None + self.ignore_midx = ignore_midx self.refresh() def __del__(self): @@ -510,12 +510,12 @@ class PackIdxList: If skip_midx is True, all work on .midx files will be skipped and .midx files will be removed from the list. - The module-global variable 'ignore_midx' can force this function to + The instance variable 'ignore_midx' can force this function to always act as if skip_midx was True. """ self.bloom = None # Always reopen the bloom as it may have been relaced self.do_bloom = False - skip_midx = skip_midx or ignore_midx + skip_midx = skip_midx or self.ignore_midx d = dict((p.name, p) for p in self.packs if not skip_midx or not isinstance(p, midx.PackMidx)) if os.path.exists(self.dir):