Przeglądaj źródła

Show only the candidate with "apt show"

Display only the candidate version with "apt show pkg" but show
a notice that there is more to see.
Michael Vogt 12 lat temu
rodzic
commit
06293aa79b
2 zmienionych plików z 13 dodań i 1 usunięć
  1. 4 0
      apt-private/private-cmndline.cc
  2. 9 1
      apt-private/private-show.cc

+ 4 - 0
apt-private/private-cmndline.cc

@@ -235,6 +235,10 @@ bool addArgumentsAPT(std::vector<CommandLine::Args> &Args, char const * const Cm
       // FIXME: find a better term
       addArg(0,"dist","APT::Cmd::Dist-Upgrade", CommandLine::Boolean);
    }
+   else if (CmdMatches("show"))
+   {
+      addArg('a', "all-versions", "APT::Cache::AllVersions", 0);
+   }
    else if (addArgumentsAPTGet(Args, Cmd) || addArgumentsAPTCache(Args, Cmd))
    {
        // we have no (supported) command-name overlaps so far, so we call

+ 9 - 1
apt-private/private-show.cc

@@ -104,12 +104,20 @@ bool ShowPackage(CommandLine &CmdL)					/*{{{*/
 {
    pkgCacheFile CacheFile;
    CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
-   APT::VersionList::Version const select = APT::VersionList::CANDIDATE;
+   APT::VersionList::Version const select = _config->FindB("APT::Cache::AllVersions", false) ?
+			APT::VersionList::ALL : APT::VersionList::CANDIDATE;
    APT::VersionList const verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper);
    for (APT::VersionList::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
       if (DisplayRecord(CacheFile, Ver, c1out) == false)
 	 return false;
 
+   if (select == APT::VersionList::CANDIDATE)
+   {
+      APT::VersionList const verset_all = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionList::ALL, helper);
+      if (verset_all.size() > verset.size())
+         _error->Notice(ngettext("There is %lu additional record. Please use the '-a' switch to see it", "There are %lu additional records. Please use the '-a' switch to see them.", verset_all.size() - verset.size()), verset_all.size() - verset.size());
+   }
+
    for (APT::PackageSet::const_iterator Pkg = helper.virtualPkgs.begin();
 	Pkg != helper.virtualPkgs.end(); ++Pkg)
    {