浏览代码

* lp:~mvo/apt/config-clear:
- support Configuration.Clear() for a clear of the entire
configuration
Conflicts:
debian/changelog

Michael Vogt 13 年之前
父节点
当前提交
d8a06f6e47
共有 4 个文件被更改,包括 22 次插入0 次删除
  1. 12 0
      apt-pkg/contrib/configuration.cc
  2. 1 0
      apt-pkg/contrib/configuration.h
  3. 5 0
      debian/changelog
  4. 4 0
      test/libapt/configuration_test.cc

+ 12 - 0
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				/*{{{*/

+ 1 - 0
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);

+ 5 - 0
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 <michael.vogt@ubuntu.com>  Thu, 15 Aug 2013 09:27:35 +0200
 
 apt (0.9.10) unstable; urgency=low

+ 4 - 0
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