From d8a06f6e478323b2fa8573f6f885c0b16d403642 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 17 Oct 2012 10:29:52 +0200 Subject: * lp:~mvo/apt/config-clear: - support Configuration.Clear() for a clear of the entire configuration Conflicts: debian/changelog --- apt-pkg/contrib/configuration.cc | 12 ++++++++++++ apt-pkg/contrib/configuration.h | 1 + debian/changelog | 5 +++++ test/libapt/configuration_test.cc | 4 ++++ 4 files changed, 22 insertions(+) diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 376617401..4ef4663c0 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -420,6 +420,18 @@ void Configuration::Clear(string const &Name, string const &Value) } } +} + /*}}}*/ +// Configuration::Clear - Clear everything /*{{{*/ +// --------------------------------------------------------------------- +void Configuration::Clear() +{ + const Configuration::Item *Top = Tree(0); + while( Top != 0 ) + { + Clear(Top->FullTag()); + Top = Top->Next; + } } /*}}}*/ // Configuration::Clear - Clear an entire tree /*{{{*/ diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index ea94c2fe6..8e09ea0a6 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -94,6 +94,7 @@ class Configuration // clear a whole tree void Clear(const std::string &Name); + void Clear(); // remove a certain value from a list (e.g. the list of "APT::Keep-Fds") void Clear(std::string const &List, std::string const &Value); diff --git a/debian/changelog b/debian/changelog index 6172cb332..1c7afd863 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,11 @@ apt (0.9.11) UNRELEASED; urgency=low * Show a error message if {,dist-}upgrade is used with additional arguments (closes: #705510) + [ Michael Vogt ] + * lp:~mvo/apt/config-clear: + - support Configuration.Clear() for a clear of the entire + configuration + -- Michael Vogt Thu, 15 Aug 2013 09:27:35 +0200 apt (0.9.10) unstable; urgency=low diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc index 87d5699ef..2c974ee0a 100644 --- a/test/libapt/configuration_test.cc +++ b/test/libapt/configuration_test.cc @@ -98,6 +98,10 @@ int main(int argc,const char *argv[]) { equals(Cnf.FindDir("Dir::State"), "/rootdir/dev/null"); equals(Cnf.FindDir("Dir::State::lists"), "/rootdir/dev/null"); + Cnf.Set("Moo::Bar", "1"); + Cnf.Clear(); + equals(Cnf.Find("Moo::Bar"), ""); + //FIXME: Test for configuration file parsing; // currently only integration/ tests test them implicitly -- cgit v1.2.3-70-g09d2