]> arthur.barton.de Git - bup.git/commitdiff
git: remove global variable ignore_midx
authorJohannes Berg <johannes@sipsolutions.net>
Wed, 18 Dec 2019 19:08:26 +0000 (20:08 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sun, 12 Jan 2020 16:48:01 +0000 (10:48 -0600)
This can easily be kept as state in the git.PackIdxList()
class instead, so do that.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
cmd/margin-cmd.py
cmd/memtest-cmd.py
lib/bup/git.py

index b01db3d1864e151fe7e74059b024f3eb08be1ebd..7eba44844c6769a5b9279c2cddbbc06501dd7aa6 100755 (executable)
@@ -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)
index 2fe71f516bc29370b1e4da931948bb82d65f4e71..3dc47dacc752c01c03da3aa9c8453808ce0c51a1 100755 (executable)
@@ -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()
index acceccc74fee13c1addc193c6f90c1773542d83f..e299da193e95f3f3d5158e7c68dc2cdcc4bcd7aa 100644 (file)
@@ -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):