[Aptitude-devel] r3157 - in branches/aptitude-0.3/aptitude: . doc/en src/generic

Daniel Burrows dburrows@costa.debian.org
Thu, 28 Apr 2005 00:05:04 +0000


Author: dburrows
Date: Thu Apr 28 00:04:59 2005
New Revision: 3157

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/doc/en/aptitude.xml
   branches/aptitude-0.3/aptitude/src/generic/matchers.cc
Log:
Tweak how searches for held packages work.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Thu Apr 28 00:04:59 2005
@@ -1,5 +1,12 @@
 2005-04-27  Daniel Burrows  <dburrows@debian.org>
 
+	* doc/en/aptitude.xml, src/generic/matchers.cc:
+
+	  Make ~ahold find packages that are actually *held*.  ~akeep now
+	  finds packages upon which no action is being taken; the old
+	  meaning of ~ahold is available via "~U~akeep".
+	  (Closes: #216730)
+
 	* src/apt_info_tree.cc, src/apt_info_tree.h, src/ui.cc:
 
 	  Apply a similar treatment to the various apt_info_trees: create

Modified: branches/aptitude-0.3/aptitude/doc/en/aptitude.xml
==============================================================================
--- branches/aptitude-0.3/aptitude/doc/en/aptitude.xml	(original)
+++ branches/aptitude-0.3/aptitude/doc/en/aptitude.xml	Thu Apr 28 00:04:59 2005
@@ -3220,8 +3220,12 @@
 	      performed.  <replaceable>action</replaceable> can be
 	      <quote><literal>install</literal></quote>,
 	      <quote><literal>upgrade</literal></quote>,
-	      <quote><literal>remove</literal></quote>, <quote><literal>purge</literal></quote>,
-	      or <quote><literal>hold</literal></quote>.
+	      <quote><literal>remove</literal></quote>,
+	      <quote><literal>purge</literal></quote>,
+	      <quote><literal>hold</literal></quote> (tests whether a
+	      package has been placed on hold), or
+	      <quote><literal>keep</literal></quote> (tests whether a
+	      package will be unchanged).
 	      <!-- Should I document more extensively what each option
 	           does? -->
 	    </para>

Modified: branches/aptitude-0.3/aptitude/src/generic/matchers.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/matchers.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/matchers.cc	Thu Apr 28 00:04:59 2005
@@ -1,6 +1,6 @@
 // matchers.cc
 //
-//  Copyright 2000,2001 Daniel Burrows
+//  Copyright 2000-2005 Daniel Burrows
 //
 //  This program is free software; you can redistribute it and/or modify
 //  it under the terms of the GNU General Public License as published by
@@ -307,24 +307,41 @@
       return false;
     else
       {
-	pkg_action_state thetype=find_pkg_state(pkg);
-
 	switch(type)
 	  {
 	  case pkg_install:
-	    return thetype==pkg_install || thetype==pkg_auto_install;
+	    {
+	      pkg_action_state thetype=find_pkg_state(pkg);
+	      return thetype==pkg_install || thetype==pkg_auto_install;
+	    }
 	  case pkg_hold:
-	    return !pkg.CurrentVer().end() && ((*apt_cache_file)[pkg].Held() || (*apt_cache_file)->get_ext_state(pkg).selection_state==pkgCache::State::Hold);
+	    return !pkg.CurrentVer().end() && (*apt_cache_file)->get_ext_state(pkg).selection_state==pkgCache::State::Hold;
 	  case pkg_remove:
-	    return thetype==pkg_remove || thetype==pkg_auto_remove ||
-	      thetype==pkg_unused_remove;
+	    {
+	      pkg_action_state thetype=find_pkg_state(pkg);
+
+	      return thetype==pkg_remove || thetype==pkg_auto_remove ||
+		thetype==pkg_unused_remove;
+	    }
 	  default:
-	    return thetype==type;
+	    {
+	      pkg_action_state thetype=find_pkg_state(pkg);
+
+	      return thetype==type;
+	    }
 	  }
       }
   }
 };
 
+class pkg_keep_matcher:public pkg_matcher
+{
+  bool matches(pkgCache::PkgIterator pkg, pkgCache::VerIterator ver)
+  {
+    return !pkg.CurrentVer().end() && (*apt_cache_file)[pkg].Keep();
+  }
+};
+
 class pkg_virtual_matcher:public pkg_matcher
 // Matches *pure* virtual packages -- ie, those that /have/ no versions.
 {
@@ -924,6 +941,8 @@
 			// Match held packages
 			else if(!strcasecmp(substr.c_str(), "hold"))
 			  return new pkg_action_matcher(pkg_hold, false);
+			else if(!strcasecmp(substr.c_str(), "keep"))
+			  return new pkg_keep_matcher;
 
 			else
 			  {