|
@@ -1718,8 +1718,8 @@ class Archiver:
|
|
|
# see issue #1867.
|
|
|
repository.commit()
|
|
|
|
|
|
- @with_repository(exclusive=True, cache=True, compatibility=(Manifest.Operation.WRITE,))
|
|
|
- def do_config(self, args, repository, manifest, key, cache):
|
|
|
+ @with_repository(exclusive=True, manifest=False)
|
|
|
+ def do_config(self, args, repository):
|
|
|
"""get, set, and delete values in a repository or cache config file"""
|
|
|
|
|
|
def repo_validate(section, name, value=None, check_value=True):
|
|
@@ -1770,34 +1770,43 @@ class Archiver:
|
|
|
name = args.name
|
|
|
|
|
|
if args.cache:
|
|
|
- cache.cache_config.load()
|
|
|
- config = cache.cache_config._config
|
|
|
- save = cache.cache_config.save
|
|
|
- validate = cache_validate
|
|
|
- else:
|
|
|
- config = repository.config
|
|
|
- save = lambda: repository.save_config(repository.path, repository.config)
|
|
|
- validate = repo_validate
|
|
|
-
|
|
|
- if args.delete:
|
|
|
- validate(section, name, check_value=False)
|
|
|
- config.remove_option(section, name)
|
|
|
- if len(config.options(section)) == 0:
|
|
|
- config.remove_section(section)
|
|
|
- save()
|
|
|
- elif args.value:
|
|
|
- validate(section, name, args.value)
|
|
|
- if section not in config.sections():
|
|
|
- config.add_section(section)
|
|
|
- config.set(section, name, args.value)
|
|
|
- save()
|
|
|
- else:
|
|
|
- try:
|
|
|
- print(config.get(section, name))
|
|
|
- except (configparser.NoOptionError, configparser.NoSectionError) as e:
|
|
|
- print(e, file=sys.stderr)
|
|
|
- return EXIT_WARNING
|
|
|
- return EXIT_SUCCESS
|
|
|
+ manifest, key = Manifest.load(repository, (Manifest.Operation.WRITE,))
|
|
|
+ assert_secure(repository, manifest)
|
|
|
+ cache = Cache(repository, key, manifest, lock_wait=self.lock_wait)
|
|
|
+
|
|
|
+ try:
|
|
|
+ if args.cache:
|
|
|
+ cache.cache_config.load()
|
|
|
+ config = cache.cache_config._config
|
|
|
+ save = cache.cache_config.save
|
|
|
+ validate = cache_validate
|
|
|
+ else:
|
|
|
+ config = repository.config
|
|
|
+ save = lambda: repository.save_config(repository.path, repository.config)
|
|
|
+ validate = repo_validate
|
|
|
+
|
|
|
+ if args.delete:
|
|
|
+ validate(section, name, check_value=False)
|
|
|
+ config.remove_option(section, name)
|
|
|
+ if len(config.options(section)) == 0:
|
|
|
+ config.remove_section(section)
|
|
|
+ save()
|
|
|
+ elif args.value:
|
|
|
+ validate(section, name, args.value)
|
|
|
+ if section not in config.sections():
|
|
|
+ config.add_section(section)
|
|
|
+ config.set(section, name, args.value)
|
|
|
+ save()
|
|
|
+ else:
|
|
|
+ try:
|
|
|
+ print(config.get(section, name))
|
|
|
+ except (configparser.NoOptionError, configparser.NoSectionError) as e:
|
|
|
+ print(e, file=sys.stderr)
|
|
|
+ return EXIT_WARNING
|
|
|
+ return EXIT_SUCCESS
|
|
|
+ finally:
|
|
|
+ if args.cache:
|
|
|
+ cache.close()
|
|
|
|
|
|
def do_debug_info(self, args):
|
|
|
"""display system information for debugging / bug reports"""
|