fate#312127 list patches until certain date only
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 18 Apr 2011 08:19:49 +0000 (10:19 +0200)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 18 Apr 2011 08:19:49 +0000 (10:19 +0200)
src/RequestFeedback.cc
src/SolverRequester.cc
src/SolverRequester.h
src/Zypper.cc
src/update.cc

index 069a294..d38a5e4 100644 (file)
@@ -216,6 +216,14 @@ string SolverRequester::Feedback::asUserString(
        pname.str().c_str());
   }
 
+  case PATCH_TOO_NEW:
+  {
+    ostringstream pname;
+    pname << _objsel->name() << "-" << _objsel->edition();
+    return str::form(_("Patch '%s' was issued after the specified date."),
+        pname.str().c_str());
+  }
+
   case SET_TO_INSTALL:
     return str::form(
         _("Selecting '%s' from repository '%s' for installation."),
@@ -273,6 +281,7 @@ void SolverRequester::Feedback::print(
   case PATCH_NOT_NEEDED:
   case PATCH_UNWANTED:
   case PATCH_WRONG_CAT:
+  case PATCH_TOO_NEW:
   case FORCED_INSTALL:
     out.info(asUserString(opts));
     break;
index c249b2f..3479e4e 100644 (file)
@@ -408,11 +408,19 @@ bool SolverRequester::installPatch(
         DBG << "candidate patch " << patch << " is locked" << endl;
         addFeedback(Feedback::PATCH_UNWANTED, patchspec, selected, selected);
       }
+
       else if (!_opts.category.empty() && _opts.category != patch->category())
       {
        DBG << "candidate patch " << patch << " is not in the specified category" << endl;
        addFeedback(Feedback::PATCH_WRONG_CAT, patchspec, selected, selected);
       }
+
+      else if (_opts.date_limit != Date()
+               && patch->timestamp() > _opts.date_limit)
+      {
+        DBG << "candidate patch " << patch << " is newer than specified date" << endl;
+        addFeedback(Feedback::PATCH_TOO_NEW, patchspec, selected, selected);
+      }
       else
       {
         // TODO use _opts.force
index 58594c9..6d8475d 100644 (file)
@@ -7,7 +7,7 @@
 
 
 /** \file SolverRequester.h
- * 
+ *
  */
 
 #ifndef SOLVERREQUESTER_H_
@@ -16,6 +16,7 @@
 #include <string>
 
 #include "zypp/ZConfig.h"
+#include "zypp/Date.h"
 #include "zypp/PoolItem.h"
 
 #include "Command.h"
@@ -96,6 +97,11 @@ public:
      */
     std::string category;
 
+    /**
+     * Whether to skip updates issued later than this date
+     */
+    zypp::Date date_limit;
+
     /** Whether to ignore vendor when selecting packages */
     bool allow_vendor_change;
 
@@ -183,6 +189,11 @@ public:
        */
       PATCH_WRONG_CAT,
 
+      /**
+       * Patch is too new and a date limit was specified
+       */
+      PATCH_TOO_NEW,
+
       // ********** zypp requests *********************************************
 
       SET_TO_INSTALL,
index 3f8a1ee..6c26bbc 100644 (file)
@@ -1677,6 +1677,7 @@ void Zypper::processCommandOptions()
       {"bugzilla",                  required_argument, 0, 'b'},
       {"cve",                       required_argument, 0,  0 },
       {"category",                  required_argument, 0, 'g'},
+      {"date",                      required_argument, 0,  0 },
       {"help", no_argument, 0, 'h'},
       {0, 0, 0, 0}
     };
@@ -1697,6 +1698,7 @@ void Zypper::processCommandOptions()
       "-b, --bugzilla #            Install patch fixing the specified bugzilla issue.\n"
       "    --cve #                 Install patch fixing the specified CVE issue.\n"
       "-g  --category <category>   Install all patches in this category.\n"
+     "    --date <YYYY-MM-DD>      Install patches issued until the specified date\n"
       "    --debug-solver          Create solver test case for debugging.\n"
       "    --no-recommends         Do not install recommended packages, only required.\n"
       "    --recommends            Install also recommended packages in addition\n"
@@ -1718,6 +1720,7 @@ void Zypper::processCommandOptions()
       {"bugzilla",    optional_argument, 0, 'b'},
       {"cve",         optional_argument, 0,  0 },
       {"category",    required_argument, 0, 'g'},
+      {"date",        required_argument, 0,  0 },
       {"issues",      optional_argument, 0,  0 },
       {"all",         no_argument,       0, 'a'},
       {"help", no_argument, 0, 'h'},
@@ -1736,6 +1739,7 @@ void Zypper::processCommandOptions()
       "    --issues[=string]      Look for issues matching the specified string.\n"
       "-a, --all                  List all patches, not only the needed ones.\n"
       "-r, --repo <alias|#|URI>   List only patches from the specified repository.\n"
+      "    --date <YYYY-MM-DD>    List patches issued up to the specified date\n"
     );
     break;
   }
@@ -4063,7 +4067,8 @@ void Zypper::doCommand()
     else
     {
       SolverRequester::Options sropts;
-      if (copts.find("force") != copts.end())
+      if (copts.find("force") !=
+copts.end())
         sropts.force = true;
       sropts.best_effort = best_effort;
       sropts.skip_interactive = skip_interactive; // bcn #647214
@@ -4082,6 +4087,22 @@ void Zypper::doCommand()
        }
       }
 
+      // if --date is specified
+      {
+        parsed_opts::const_iterator optit;
+        optit = copts.find("date");
+        if (optit != copts.end())
+        {
+          for_(i, optit->second.begin(), optit->second.end())
+          {
+            // ISO 8601 format
+            sropts.date_limit = Date(*i, "%F");
+            break;
+          }
+        }
+
+      }
+
       SolverRequester sr(sropts);
       if (arguments().empty())
       {
index 903767b..d2fb417 100755 (executable)
@@ -195,6 +195,21 @@ static void xml_list_updates(const ResKindSet & kinds)
 static bool list_patch_updates(Zypper & zypper)
 {
   bool all = zypper.cOpts().count("all");
+  // if --date is specified
+  Date date_limit;
+  {
+    parsed_opts::const_iterator it;
+    it = zypper.cOpts().find("date");
+    if (it != zypper.cOpts().end())
+    {
+      for_(i, it->second.begin(), it->second.end())
+      {
+        // ISO 8601 format
+          date_limit = Date(*i, "%F");
+          break;
+      }
+    }
+  }
 
   // if --category is specified
   string category;
@@ -245,6 +260,10 @@ static bool list_patch_updates(Zypper & zypper)
     if (all || (it->isBroken() && !it->isUnwanted()))
     {
       Patch::constPtr patch = asKind<Patch>(res);
+      if (date_limit != Date() && patch->timestamp() > date_limit ) {
+          DBG << patch->ident() << " skipped. (too new and date limit specified)" << endl;
+          continue;
+      }
 
       if (!category.empty() && category != patch->category())
       {
@@ -252,6 +271,7 @@ static bool list_patch_updates(Zypper & zypper)
         continue;
       }
 
+      // table
       {
         TableRow tr (cols);
         tr << (zypper.config().show_alias ? patch->repoInfo().alias() : patch->repoInfo().name());