Remove all 'Config::show_alias' fumbling
authorMichael Andres <ma@suse.de>
Wed, 7 May 2014 11:14:53 +0000 (13:14 +0200)
committerMichael Andres <ma@suse.de>
Wed, 7 May 2014 11:14:53 +0000 (13:14 +0200)
It's transaparently handled by using Repository/RepoInfo::asUserString

13 files changed:
src/Config.cc
src/Config.h
src/RequestFeedback.cc
src/Summary.cc
src/Summary.h
src/Zypper.cc
src/callbacks/keyring.h
src/info.cc
src/repos.cc
src/search.cc
src/search.h
src/solve-commit.cc
src/update.cc

index 982dcab..b9d0f3c 100644 (file)
@@ -130,8 +130,7 @@ string ConfigOption::asString() const
 
 
 Config::Config()
-  : show_alias(false)
-  , repo_list_columns("anr")
+  : repo_list_columns("anr")
   , solver_installRecommends(!ZConfig::instance().solver_onlyRequires())
   , do_colors        (false)
   , color_useColors  ("never")
@@ -164,8 +163,8 @@ void Config::read(const string & file)
     s = augeas.getOption(ConfigOption::MAIN_SHOW_ALIAS.asString());
     if (!s.empty())
     {
-      show_alias = str::strToBool(s, false);
-      ZConfig::instance().repoLabelIsAlias(show_alias);
+      // using Repository::asUserString() will follow repoLabelIsAlias!
+      ZConfig::instance().repoLabelIsAlias( str::strToBool(s, false) );
     }
 
     s = augeas.getOption(ConfigOption::MAIN_REPO_LIST_COLUMNS.asString());
index a2625b1..098cd79 100644 (file)
@@ -89,9 +89,6 @@ struct Config
   /** Reads zypper.conf and stores the result */
   void read(const std::string & file = "");
 
-  /** Whether to show repo alias instead of name wherever we need to show repo*/
-  bool show_alias;
-
   /** Which columns to show in repo list by default (string of short options).*/
   std::string repo_list_columns;
 
index 3180d39..12531a6 100644 (file)
@@ -173,9 +173,7 @@ string SolverRequester::Feedback::asUserString(
       "The selected package '%s' from repository '%s' has lower"
       " version than the installed one."),
       resolvable_user_string(*_objsel.resolvable()).c_str(),
-      Zypper::instance()->config().show_alias ?
-          _objsel->repoInfo().alias().c_str() :
-          _objsel->repoInfo().name().c_str());
+      _objsel->repoInfo().asUserString().c_str() );
     msg << " ";
     msg << str::form(
         // translators: %s = "zypper install --oldpackage package-version.arch"
@@ -228,17 +226,13 @@ string SolverRequester::Feedback::asUserString(
     return str::form(
         _("Selecting '%s' from repository '%s' for installation."),
         resolvable_user_string(*_objsel.resolvable()).c_str(),
-        Zypper::instance()->config().show_alias ?
-            _objsel->repoInfo().alias().c_str() :
-            _objsel->repoInfo().name().c_str());
+        _objsel->repoInfo().asUserString().c_str() );
 
   case FORCED_INSTALL:
     return str::form(
         _("Forcing installation of '%s' from repository '%s'."),
         resolvable_user_string(*_objsel.resolvable()).c_str(),
-        Zypper::instance()->config().show_alias ?
-            _objsel->repoInfo().alias().c_str() :
-            _objsel->repoInfo().name().c_str());
+        _objsel->repoInfo().asUserString().c_str() );
 
   case SET_TO_REMOVE:
     return str::form(_("Selecting '%s' for removal."),
index 63b0cd3..445b7c8 100644 (file)
@@ -46,7 +46,6 @@ bool Summary::ResPairNameCompare::operator()(
 
 Summary::Summary(const zypp::ResPool & pool, const ViewOptions options)
   : _viewop(options)
-  , _show_repo_alias(false)
   , _wrap_width(80)
   , _force_no_color(false)
   , _download_only(false)
@@ -452,9 +451,7 @@ void Summary::writeResolvableList(ostream & out, const ResPairSet & resolvables)
     {
       // we do not know about repository changes, only show the repo from
       // which the package will be installed
-      tr << (_show_repo_alias ?
-          resit->second->repoInfo().alias() :
-          resit->second->repoInfo().name());
+      tr << resit->second->repoInfo().asUserString();
     }
     if (_viewop & SHOW_VENDOR)
     {
index fbb91a3..e159287 100644 (file)
@@ -64,9 +64,6 @@ public:
   { _viewop = (ViewOptions) (_viewop & ~option); }
   void toggleViewOption(const ViewOptions option)
   { _viewop & option ? unsetViewOption(option) : setViewOption(option); }
-  /** Show alias instead of name when showing repositories. */
-  void setShowRepoAlias(bool value = true)
-  { _show_repo_alias = value; }
   void setForceNoColor(bool value = true)
   { _force_no_color = value; }
   void setDownloadOnly(bool value = true)
@@ -117,7 +114,6 @@ private:
 
 private:
   ViewOptions _viewop;
-  bool _show_repo_alias;
   mutable unsigned _wrap_width;
   bool _force_no_color;
   bool _download_only;
index b7baca0..466e43f 100644 (file)
@@ -3945,7 +3945,7 @@ void Zypper::doCommand()
         {
           out().warning(boost::str(format(
             _("Specified repository '%s' is disabled."))
-              % (config().show_alias ? repo_it->alias() : repo_it->name())));
+              % repo_it->asUserString() ));
         }
       }
     }
index 2fd1df5..881fe4f 100644 (file)
@@ -32,7 +32,6 @@ namespace zypp
     {
       KeyRingReceive()
           : _gopts(Zypper::instance()->globalOpts())
-          , _show_alias(Zypper::instance()->config().show_alias)
           {}
 
       ////////////////////////////////////////////////////////////////////
@@ -53,7 +52,7 @@ namespace zypp
           else
             Zypper::instance()->out().warning(boost::str(
               boost::format(_("Accepting an unsigned file '%s' from repository '%s'."))
-                % file % (_show_alias ? context.repoInfo().alias() : context.repoInfo().name())),
+                % file % context.repoInfo().asUserString() ),
               Out::HIGH);
 
           return true;
@@ -68,7 +67,7 @@ namespace zypp
           question = boost::str(boost::format(
             // TranslatorExplanation: speaking of a file
             _("File '%s' from repository '%s' is unsigned, continue?"))
-            % file % (_show_alias ? context.repoInfo().alias() : context.repoInfo().name()));
+            % file % context.repoInfo().asUserString() );
 
         return read_bool_answer(PROMPT_YN_GPG_UNSIGNED_FILE_ACCEPT, question, false);
       }
@@ -95,7 +94,7 @@ namespace zypp
           else
             Zypper::instance()->out().warning(boost::str(boost::format(
                 _("Accepting file '%s' from repository '%s' signed with an unknown key '%s'."))
-                % file % (_show_alias ? context.repoInfo().alias() : context.repoInfo().name()) % id));
+                % file % context.repoInfo().asUserString() % id));
 
           return true;
         }
@@ -109,7 +108,7 @@ namespace zypp
           question = boost::str(boost::format(
             // translators: the last %s is gpg key ID
             _("File '%s' from repository '%s' is signed with an unknown key '%s'. Continue?"))
-             % file % (_show_alias ? context.repoInfo().alias() : context.repoInfo().name()) % id);
+             % file % context.repoInfo().asUserString() % id);
 
         return read_bool_answer(PROMPT_YN_GPG_UNKNOWN_KEY_ACCEPT, question, false);
       }
@@ -140,9 +139,7 @@ namespace zypp
           << str::form(_("Key Created: %s"), key.created().asString().c_str()) << std::endl
           << str::form(_("Key Expires: %s"), key.expiresAsString().c_str()) << std::endl;
         if (!context.empty())
-          s << str::form(_("Repository: %s"), _show_alias ?
-              context.repoInfo().alias().c_str() :
-              context.repoInfo().name().c_str())
+          s << str::form(_("Repository: %s"), context.repoInfo().asUserString().c_str())
             << std::endl;
 
         // if --gpg-auto-import-keys or --no-gpg-checks print info and don't ask
@@ -227,7 +224,7 @@ namespace zypp
             msg << boost::format(
                 _("Ignoring failed signature verification for file '%s'"
                   " from repository '%s'!")) % file
-                  % (_show_alias ? context.repoInfo().alias() : context.repoInfo().name());
+                  % context.repoInfo().asUserString();
 
           msg
             << std::endl
@@ -245,7 +242,7 @@ namespace zypp
         else
           question << boost::format(
             _("Signature verification failed for file '%s' from repository '%s'."))
-              % file % (_show_alias ? context.repoInfo().alias() : context.repoInfo().name());
+              % file % context.repoInfo().asUserString();
 
         question
           << std::endl
@@ -258,7 +255,6 @@ namespace zypp
 
     private:
       const GlobalOptions & _gopts;
-      bool _show_alias;
     };
 
     ///////////////////////////////////////////////////////////////////
index db75307..ebb9cd9 100644 (file)
@@ -191,9 +191,7 @@ void printPkgInfo(Zypper & zypper, const ui::Selectable & s)
   }
 
   cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: "))
-       << (zypper.config().show_alias ?
-           theone.resolvable()->repository().info().alias() :
-           theone.resolvable()->repository().info().name()) << endl;
+       << theone.resolvable()->repository().asUserString() << endl;
 
   printNVA(theone.resolvable());
 
@@ -336,9 +334,7 @@ void printPatternInfo(Zypper & zypper, const ui::Selectable & s)
     return;
 
   cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: "))
-       << (zypper.config().show_alias ?
-           pool_item.resolvable()->repository().info().alias() :
-           pool_item.resolvable()->repository().info().name()) << endl;
+       << pool_item.resolvable()->repository().asUserString() << endl;
 
   printNVA(pool_item.resolvable());
 
@@ -417,9 +413,7 @@ void printProductInfo(Zypper & zypper, const ui::Selectable & s)
   else
   {
     cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: "))
-         << (zypper.config().show_alias ?
-             pool_item.resolvable()->repository().info().alias() :
-             pool_item.resolvable()->repository().info().name()) << endl;
+         << pool_item.resolvable()->repository().asUserString() << endl;
 
     printNVA(pool_item.resolvable());
 
index 3d8c681..85a7803 100644 (file)
@@ -65,7 +65,6 @@ static bool refresh_raw_metadata(Zypper & zypper,
   gData.current_repo = repo;
   bool do_refresh = false;
   string & plabel = zypper.runtimeData().raw_refresh_progress_label;
-  bool show_alias = zypper.config().show_alias;
 
   // reset the gData.current_repo when going out of scope
   struct Bye { ~Bye() { Zypper::instance()->runtimeData().current_repo = RepoInfo(); } } reset __attribute__ ((__unused__));
@@ -78,9 +77,7 @@ static bool refresh_raw_metadata(Zypper & zypper,
     {
       // check whether libzypp indicates a refresh is needed, and if so,
       // print a message
-      zypper.out().info(boost::str(format(
-          _("Checking whether to refresh metadata for %s")) %
-              (show_alias ? repo.alias() : repo.name())),
+      zypper.out().info(boost::str(format( _("Checking whether to refresh metadata for %s")) % repo.asUserString()),
           Out::HIGH);
       if (!repo.baseUrlsEmpty())
       {
@@ -103,14 +100,12 @@ static bool refresh_raw_metadata(Zypper & zypper,
               switch (stat)
               {
               case RepoManager::REPO_UP_TO_DATE:
-                zypper.out().info(boost::str(
-                  format(_("Repository '%s' is up to date.")) %
-                      (show_alias ? repo.alias() : repo.name())));
+                zypper.out().info(boost::str(format(
+                 _("Repository '%s' is up to date.")) % repo.asUserString()));
               break;
               case RepoManager::REPO_CHECK_DELAYED:
-                zypper.out().info(boost::str(
-                  format(_("The up-to-date check of '%s' has been delayed."))
-                      % (show_alias ? repo.alias() : repo.name())), Out::HIGH);
+                zypper.out().info(boost::str(format(
+                 _("The up-to-date check of '%s' has been delayed.")) % repo.asUserString()), Out::HIGH);
               break;
               default:
                 WAR << "new item in enum, which is not covered" << endl;
@@ -139,7 +134,7 @@ static bool refresh_raw_metadata(Zypper & zypper,
     if (do_refresh)
     {
       plabel = str::form(
-          _("Retrieving repository '%s' metadata"), show_alias ? repo.alias().c_str() : repo.name().c_str());
+          _("Retrieving repository '%s' metadata"), repo.asUserString().c_str());
       zypper.out().progressStart("raw-refresh", plabel, true);
 
       manager.refreshMetadata(repo,
@@ -197,10 +192,9 @@ static bool refresh_raw_metadata(Zypper & zypper,
       zypper.out().progressEnd("raw-refresh", plabel, true);
       plabel.clear();
     }
-    zypper.out().error(e,
-        boost::str(format(_("Problem retrieving files from '%s'."))
-            % (show_alias ? repo.alias() : repo.name())),
-        _("Please see the above error message for a hint."));
+    zypper.out().error(e,boost::str(format(
+      _("Problem retrieving files from '%s'.")) % repo.asUserString()),
+      _("Please see the above error message for a hint."));
 
     return true; // error
   }
@@ -212,14 +206,12 @@ static bool refresh_raw_metadata(Zypper & zypper,
       zypper.out().progressEnd("raw-refresh", plabel, true);
       plabel.clear();
     }
-    zypper.out().error(boost::str(
-      format(_("No URIs defined for '%s'."))
-        % (show_alias ? repo.alias() : repo.name())));
+    zypper.out().error(boost::str(format(
+      _("No URIs defined for '%s'.")) % repo.asUserString()));
     if (!repo.filepath().empty())
       zypper.out().info(boost::str(format(
-          // TranslatorExplanation the first %s is a .repo file path
-          _("Please add one or more base URI (baseurl=URI) entries to %s for repository '%s'."))
-          % repo.filepath() % (show_alias ? repo.alias() : repo.name())));
+       // TranslatorExplanation the first %s is a .repo file path
+       _("Please add one or more base URI (baseurl=URI) entries to %s for repository '%s'.")) % repo.filepath() % repo.asUserString()));
 
     return true; // error
   }
@@ -243,10 +235,9 @@ static bool refresh_raw_metadata(Zypper & zypper,
       zypper.out().progressEnd("raw-refresh", plabel, true);
       plabel.clear();
     }
-    zypper.out().error(e,
-        boost::str(format(_("Repository '%s' is invalid."))
-            % (show_alias ? repo.alias() : repo.name())),
-        _("Please check if the URIs defined for this repository are pointing to a valid repository."));
+    zypper.out().error(e, boost::str(format(
+      _("Repository '%s' is invalid.")) % repo.asUserString()),
+      _("Please check if the URIs defined for this repository are pointing to a valid repository."));
 
     return true; // error
   }
@@ -258,12 +249,10 @@ static bool refresh_raw_metadata(Zypper & zypper,
       zypper.out().progressEnd("raw-refresh", plabel, true);
       plabel.clear();
     }
-    zypper.out().error(e,
-        boost::str(format(_("Error retrieving metadata for '%s':"))
-            % (show_alias ? repo.alias() : repo.name())));
+    zypper.out().error(e, boost::str(format(
+      _("Error retrieving metadata for '%s':")) % repo.asUserString()));
     // log untranslated message
-    ERR << format("Error reading repository '%s':")
-        % (show_alias ? repo.alias() : repo.name()) << endl;
+    ERR << format("Error reading repository '%s':") % repo.asUserString() << endl;
 
     return true; // error
   }
@@ -301,14 +290,13 @@ static bool build_cache(Zypper & zypper, const RepoInfo &repo, bool force_build)
   {
     ZYPP_CAUGHT(e);
 
-    zypper.out().error(e,
-        boost::str(format(_("Error parsing metadata for '%s':")) %
-            (zypper.config().show_alias ? repo.alias() : repo.name())),
-        // TranslatorExplanation Don't translate the URL unless it is translated, too
-        _("This may be caused by invalid metadata in the repository,"
-          " or by a bug in the metadata parser. In the latter case,"
-          " or if in doubt, please, file a bug report by following"
-          " instructions at http://en.opensuse.org/Zypper/Troubleshooting"));
+    zypper.out().error(e, boost::str(format(
+      _("Error parsing metadata for '%s':")) % repo.asUserString()),
+      // TranslatorExplanation Don't translate the URL unless it is translated, too
+      _("This may be caused by invalid metadata in the repository,"
+        " or by a bug in the metadata parser. In the latter case,"
+        " or if in doubt, please, file a bug report by following"
+        " instructions at http://en.opensuse.org/Zypper/Troubleshooting"));
 
     // log untranslated message
     ERR << format("Error parsing metadata for '%s':") % repo.alias() << endl;
@@ -318,18 +306,15 @@ static bool build_cache(Zypper & zypper, const RepoInfo &repo, bool force_build)
   catch (const repo::RepoMetadataException & e)
   {
     ZYPP_CAUGHT(e);
-    zypper.out().error(e,
-        boost::str(format(_(
-            "Repository metadata for '%s' not found in local cache."))
-            % (zypper.config().show_alias ? repo.alias() : repo.name())));
+    zypper.out().error(e, boost::str(format(
+      _("Repository metadata for '%s' not found in local cache.")) % repo.asUserString()));
     // this should not happend and is probably a bug, rethrowing
     ZYPP_RETHROW(e);
   }
   catch (const Exception &e)
   {
     ZYPP_CAUGHT(e);
-    zypper.out().error(e,
-        _("Error building the cache:"));
+    zypper.out().error(e, _("Error building the cache:"));
     // log untranslated message
     ERR << "Error writing to cache db" << endl;
 
@@ -544,8 +529,8 @@ void report_unknown_repos(Out & out, list<string> not_found)
 
   if (!not_found.empty())
     out.info(str::form(
-        _("Use '%s' to get the list of defined repositories."),
-        "zypper repos"));
+      _("Use '%s' to get the list of defined repositories."),
+      "zypper repos"));
 }
 
 // ----------------------------------------------------------------------------
@@ -568,7 +553,7 @@ unsigned repo_specs_to_aliases(Zypper & zypper,
       aliases.push_back(it->alias());
     else
       zypper.out().warning(str::form(_("Ignoring disabled repository '%s'"),
-        zypper.config().show_alias ? it->alias().c_str() : it->name().c_str()));
+        it->asUserString().c_str()));
   }
   return aliases.size();
 }
@@ -655,14 +640,14 @@ void do_init_repos(Zypper & zypper, const Container & container)
     {
       zypper.out().info(str::form(
           _("Ignoring repository '%s' because of '%s' option."),
-          (zypper.config().show_alias ? it->alias().c_str() : it->name().c_str()), "no-cd"));
+          it->asUserString().c_str(), "no-cd"));
       gData.repos.erase(it++);
     }
     if (no_remote && it->url().schemeIsDownloading())
     {
       zypper.out().info(str::form(
           _("Ignoring repository '%s' because of '%s' option."),
-          (zypper.config().show_alias ? it->alias().c_str() : it->name().c_str()), "no-remote"));
+          it->asUserString().c_str(), "no-remote"));
       gData.repos.erase(it++);
     }
     else
@@ -692,7 +677,7 @@ void do_init_repos(Zypper & zypper, const Container & container)
         {
           zypper.out().info(boost::str(format(
               _("Disabling repository '%s' because of the above error."))
-              % (zypper.config().show_alias ? repo.alias() : repo.name())), Out::QUIET);
+              % repo.asUserString()), Out::QUIET);
           WAR << format("Disabling repository '%s' because of the above error.")
               % repo.alias() << endl;
 
@@ -711,7 +696,7 @@ void do_init_repos(Zypper & zypper, const Container & container)
           zypper.out().info(boost::str(format(_(
               "Repository '%s' is out-of-date. You can run 'zypper refresh'"
               " as root to update it."))
-              % (zypper.config().show_alias ? repo.alias() : repo.name())));
+              % repo.asUserString()));
 
           MIL << "We're running as non-root, skipping refresh of "
               << repo.alias() << endl;
@@ -729,7 +714,7 @@ void do_init_repos(Zypper & zypper, const Container & container)
         {
           zypper.out().warning(boost::str(format(
               _("Disabling repository '%s' because of the above error."))
-              % (zypper.config().show_alias ? repo.alias() : repo.name())), Out::QUIET);
+              % repo.asUserString()), Out::QUIET);
           WAR << format("Disabling repository '%s' because of the above error.")
               % repo.alias() << endl;
 
@@ -747,13 +732,13 @@ void do_init_repos(Zypper & zypper, const Container & container)
           zypper.out().warning(boost::str(format(_(
               "The metadata cache needs to be built for the '%s' repository."
               " You can run 'zypper refresh' as root to do this."))
-              % (zypper.config().show_alias ? repo.alias() : repo.name())), Out::QUIET);
+              % repo.asUserString()), Out::QUIET);
 
           MIL <<  "We're running as non-root, skipping building of "
             << repo.alias() + "cache" << endl;
 
           zypper.out().info(boost::str(format(_("Disabling repository '%s'."))
-              % (zypper.config().show_alias ? repo.alias() : repo.name())));
+              % repo.asUserString()));
           WAR << "Disabling repository '" << repo.alias() << "'" << endl;
           it->setEnabled(false);
         }
@@ -1259,8 +1244,7 @@ void refresh_repos(Zypper & zypper)
       if (!repo.enabled())
       {
         string msg = boost::str(
-          format(_("Skipping disabled repository '%s'"))
-            % (zypper.config().show_alias ? repo.alias() : repo.name()));
+          format(_("Skipping disabled repository '%s'")) % repo.asUserString());
 
         if (specified.empty())
           zypper.out().info(msg, Out::HIGH);
@@ -1275,8 +1259,7 @@ void refresh_repos(Zypper & zypper)
       if (refresh_repo(zypper, repo))
       {
         zypper.out().error(boost::str(format(
-          _("Skipping repository '%s' because of the above error."))
-            % (zypper.config().show_alias ? repo.alias() : repo.name())));
+          _("Skipping repository '%s' because of the above error.")) % repo.asUserString()));
         ERR << format("Skipping repository '%s' because of the above error.")
             % repo.alias() << endl;
         error_count++;
@@ -1455,8 +1438,7 @@ void clean_repos(Zypper & zypper)
         if( clean_metadata )
        {
            zypper.out().info(boost::str(format(
-               _("Cleaning metadata cache for '%s'."))
-               % (zypper.config().show_alias ? repo.alias() : repo.name())),
+               _("Cleaning metadata cache for '%s'.")) % repo.asUserString()),
                Out::HIGH);
            manager.cleanCache(repo);
        }
@@ -1466,16 +1448,14 @@ void clean_repos(Zypper & zypper)
             if ( ! ( scheme == "cd" || scheme == "dvd" ) )
             {
                 zypper.out().info(boost::str(format(
-                    _("Cleaning raw metadata cache for '%s'."))
-                    % (zypper.config().show_alias ? repo.alias() : repo.name())),
+                    _("Cleaning raw metadata cache for '%s'.")) % repo.asUserString()),
                     Out::HIGH);
                 manager.cleanMetadata(repo);
             }
             else
             {
                 zypper.out().info(boost::str(format(
-                    _("Keeping raw metadata cache for %s '%s'.")) % scheme
-                    % (zypper.config().show_alias ? repo.alias() : repo.name())),
+                    _("Keeping raw metadata cache for %s '%s'.")) % scheme % repo.asUserString()),
                     Out::HIGH);
             }
         }
@@ -1483,8 +1463,7 @@ void clean_repos(Zypper & zypper)
        {
           zypper.out().info(boost::str(format(
               // translators: meaning the cached rpm files
-              _("Cleaning packages for '%s'."))
-              % (zypper.config().show_alias ? repo.alias() : repo.name())),
+              _("Cleaning packages for '%s'.")) % repo.asUserString()),
               Out::HIGH);
          manager.cleanPackages(repo);
        }
@@ -1492,8 +1471,7 @@ void clean_repos(Zypper & zypper)
       catch(...)
       {
         zypper.out().error(boost::str(format(
-            _("Cannot clean repository '%s' because of an error."))
-            % (zypper.config().show_alias ? repo.alias() : repo.name())));
+            _("Cannot clean repository '%s' because of an error.")) % repo.asUserString()));
         ERR << format("Cannot clean repository '%s' because of an error.")
             % repo.alias() << endl;
         error_count++;
@@ -1667,16 +1645,15 @@ void add_repo(Zypper & zypper, RepoInfo & repo)
   }
 
   ostringstream s;
-  s << format(_("Repository '%s' successfully added"))
-      % (zypper.config().show_alias ? repo.alias() : repo.name());
+  s << format(_("Repository '%s' successfully added")) % repo.asUserString();
   s << endl;
 
   if (zypper.globalOpts().is_rug_compatible)
   {
-    s << ( repo.enabled() ? "[x]" : "[ ]" );
-    s << ( repo.autorefresh() ? "* " : "  " );
-    s << (zypper.config().show_alias ? repo.alias() : repo.name());
-    s << " (" << (repo.baseUrlSet() ? repo.url().asString() : (repo.mirrorListUrl().asString().empty() ? "n/a" : repo.mirrorListUrl().asString() )) << ")" << endl;
+    s << ( repo.enabled() ? "[x]" : "[ ]" )
+      << ( repo.autorefresh() ? "* " : "  " )
+      << repo.asUserString()
+      << " (" << (repo.baseUrlSet() ? repo.url().asString() : (repo.mirrorListUrl().asString().empty() ? "n/a" : repo.mirrorListUrl().asString() )) << ")" << endl;
   }
   else
   {
@@ -1705,16 +1682,14 @@ void add_repo(Zypper & zypper, RepoInfo & repo)
     if ( ! copts.count("no-check") )
     {
       zypper.out().info(boost::str(
-       format(_("Reading data from '%s' media"))
-         % (zypper.config().show_alias ? repo.alias() : repo.name())));
+       format(_("Reading data from '%s' media")) % repo.asUserString()));
        bool error = refresh_raw_metadata(zypper, repo, false);
        if (!error)
          error = build_cache(zypper, repo, false);
        if (error)
        {
          zypper.out().error(boost::str(
-           format(_("Problem reading data from '%s' media"))
-             % (zypper.config().show_alias ? repo.alias() : repo.name())),
+           format(_("Problem reading data from '%s' media")) % repo.asUserString()),
                   _("Please check if your installation media is valid and readable."));
                   zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
                   return;
@@ -1722,8 +1697,7 @@ void add_repo(Zypper & zypper, RepoInfo & repo)
     }
     else
     {
-      zypper.out().info( boost::format(_("Reading data from '%s' media is delayed until next refresh."))
-                                       % (zypper.config().show_alias ? repo.alias() : repo.name()),
+      zypper.out().info( boost::format(_("Reading data from '%s' media is delayed until next refresh.")) % repo.asUserString(),
                         " [--no-check]" );
     }
   }
@@ -1831,8 +1805,7 @@ void add_repo_from_file( Zypper & zypper,
     if(repo.baseUrlsEmpty())
     {
       zypper.out().warning(boost::str(format(
-        _("Repository '%s' has no URI defined, skipping."))
-        % (zypper.config().show_alias ? repo.alias() : repo.name())));
+        _("Repository '%s' has no URI defined, skipping.")) % repo.asUserString()));
       continue;
     }
 
@@ -1875,8 +1848,7 @@ void remove_repo(Zypper & zypper, const RepoInfo & repoinfo)
   RepoManager & manager = zypper.repoManager();
   manager.removeRepository(repoinfo);
   zypper.out().info(boost::str(
-    format(_("Repository '%s' has been removed."))
-      % (zypper.config().show_alias ? repoinfo.alias() : repoinfo.name())));
+    format(_("Repository '%s' has been removed.")) % repoinfo.asUserString()));
   MIL << format("Repository '%s' has been removed.") % repoinfo.alias() << endl;
 }
 
@@ -2683,8 +2655,7 @@ void add_service(Zypper & zypper, const ServiceInfo & service)
   }
 
   zypper.out().info(boost::str(
-    format(_("Service '%s' has been successfully added."))
-      % (zypper.config().show_alias ? service.alias() : service.name())));
+    format(_("Service '%s' has been successfully added.")) % service.asUserString()));
   MIL << format("Service '%s' has been added.") % service.alias() << endl;
 }
 
@@ -2723,12 +2694,10 @@ void remove_service(Zypper & zypper, const ServiceInfo & service)
   RepoManager & manager = zypper.repoManager();
 
   zypper.out().info(boost::str(
-    format(_("Removing service '%s':"))
-      % (zypper.config().show_alias ? service.alias() : service.name())));
+    format(_("Removing service '%s':")) % service.asUserString()));
   manager.removeService(service);
   zypper.out().info(boost::str(
-    format(_("Service '%s' has been removed."))
-      % (zypper.config().show_alias ? service.alias() : service.name())));
+    format(_("Service '%s' has been removed.")) % service.asUserString()));
   MIL << format("Service '%s' has been removed.") % service.alias() << endl;
 }
 
@@ -2744,33 +2713,26 @@ static bool refresh_service(Zypper & zypper, const ServiceInfo & service)
   try
   {
     zypper.out().info(
-        str::form(_("Refreshing service '%s'."),
-          (zypper.config().show_alias ? service.alias().c_str() : service.name().c_str())));
+        str::form(_("Refreshing service '%s'."), service.asUserString().c_str()));
     manager.refreshService(service);
     error = false;
   }
   catch ( const repo::ServicePluginInformalException & e )
   {
     ZYPP_CAUGHT(e);
-    zypper.out().error(e,
-      str::form(
-        _("Problem retrieving the repository index file for service '%s':"),
-         (zypper.config().show_alias ? service.alias().c_str() : service.name().c_str())));
-    zypper.out().warning(
-      str::form(
-        _("Skipping service '%s' because of the above error."),
-        (zypper.config().show_alias ? service.alias().c_str() : service.name().c_str())));
+    zypper.out().error(e, str::form(
+        _("Problem retrieving the repository index file for service '%s':"), service.asUserString().c_str()));
+    zypper.out().warning( str::form(
+        _("Skipping service '%s' because of the above error."), service.asUserString().c_str()));
     // this is just an informal note. The service will be used as is (usually empty)
     error = false;
   }
   catch (const MediaException & e)
   {
     ZYPP_CAUGHT(e);
-    zypper.out().error(e,
-      str::form(
-        _("Problem retrieving the repository index file for service '%s':"),
-         (zypper.config().show_alias ? service.alias().c_str() : service.name().c_str())),
-      _("Check if the URI is valid and accessible."));
+    zypper.out().error(e, str::form(
+        _("Problem retrieving the repository index file for service '%s':"), service.asUserString().c_str()),
+        _("Check if the URI is valid and accessible."));
     zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
   }
 
@@ -2828,8 +2790,7 @@ void refresh_services(Zypper & zypper)
       if (!service_ptr->enabled())
       {
         string msg = boost::str(
-          format(_("Skipping disabled service '%s'"))
-            % (zypper.config().show_alias ? service_ptr->alias() : service_ptr->name()));
+          format(_("Skipping disabled service '%s'")) % service_ptr->asUserString());
         DBG << "skipping disabled service '" << service_ptr->alias() << "'" << endl;
 
         if (specified.empty())
@@ -2866,7 +2827,7 @@ void refresh_services(Zypper & zypper)
         {
           DBG << str::form(
               "Skipping non-index service '%s' because '%s' is used.",
-              zypper.config().show_alias ? service_ptr->alias().c_str() : service_ptr->name().c_str(), "--no-repos");
+              service_ptr->asUserString().c_str(), "--no-repos");
           continue;
         }
         error = refresh_repo(zypper, *dynamic_pointer_cast<RepoInfo>(service_ptr));
@@ -2875,8 +2836,7 @@ void refresh_services(Zypper & zypper)
       if (error)
       {
         zypper.out().error(boost::str(format(
-          _("Skipping service '%s' because of the above error."))
-            % (zypper.config().show_alias ? service_ptr->alias().c_str() : service_ptr->name().c_str())));
+          _("Skipping service '%s' because of the above error.")) % service_ptr->asUserString().c_str()));
         ERR << format("Skipping service '%s' because of the above error.")
             % service_ptr->alias() << endl;
         ++error_count;
@@ -3236,28 +3196,25 @@ void load_repo_resolvables(Zypper & zypper)
 
       if (!error && !manager.isCached(repo))
       {
-        zypper.out().info(boost::str(
-          format(_("Repository '%s' not cached. Caching...")) % repo.name()));
+        zypper.out().info(boost::str(format(
+         _("Repository '%s' not cached. Caching...")) % repo.name()));
         error = build_cache(zypper, repo, false);
       }
 
       if (error)
       {
         zypper.out().error(boost::str(format(
-        _("Problem loading data from '%s'"))
-        % (zypper.config().show_alias ? repo.alias() : repo.name())));
+         _("Problem loading data from '%s'")) % repo.asUserString()));
 
         if (geteuid() != 0 && !zypper.globalOpts().changedRoot && manager.isCached(repo))
         {
           zypper.out().warning(boost::str(format(
-            _("Repository '%s' could not be refreshed. Using old cache."))
-            % (zypper.config().show_alias ? repo.alias() : repo.name())));
+            _("Repository '%s' could not be refreshed. Using old cache.")) % repo.asUserString()));
         }
         else
         {
           zypper.out().error(boost::str(format(
-          _("Resolvables from '%s' not loaded because of error."))
-          % (zypper.config().show_alias ? repo.alias() : repo.name())));
+           _("Resolvables from '%s' not loaded because of error.")) % repo.asUserString()));
           continue;
         }
       }
@@ -3276,26 +3233,21 @@ void load_repo_resolvables(Zypper & zypper)
       {
 
        zypper.out().warning(boost::str(format(
-              _("Repository '%s' appears to be outdated. Consider using a different mirror or server."))
-              % (zypper.config().show_alias ? repo.alias() : repo.name())), Out::QUIET);
-          WAR << format("Repository '%s' seems to be outdated")
-              % repo.alias() << endl;
+        _("Repository '%s' appears to be outdated. Consider using a different mirror or server.")) % repo.asUserString()), Out::QUIET);
+       WAR << format("Repository '%s' seems to be outdated") % repo.alias() << endl;
 
       }
     }
     catch (const Exception & e)
     {
       ZYPP_CAUGHT(e);
-      zypper.out().error(e,
-          boost::str(format(_("Problem loading data from '%s'"))
-              % (zypper.config().show_alias ? repo.alias() : repo.name())),
-          // translators: the first %s is 'zypper refresh' and the second 'zypper clean -m'
-          boost::str(format(_("Try '%s', or even '%s' before doing so."))
-            % "zypper refresh" % "zypper clean -m")
+      zypper.out().error(e, boost::str(format(
+       _("Problem loading data from '%s'")) % repo.asUserString()),
+       // translators: the first %s is 'zypper refresh' and the second 'zypper clean -m'
+       boost::str(format(_("Try '%s', or even '%s' before doing so.")) % "zypper refresh" % "zypper clean -m")
       );
       zypper.out().info(boost::str(format(
-        _("Resolvables from '%s' not loaded because of error."))
-          % (zypper.config().show_alias ? repo.alias() : repo.name())));
+       _("Resolvables from '%s' not loaded because of error.")) % repo.asUserString()));
     }
   }
 }
index bc802a3..a020065 100644 (file)
@@ -29,7 +29,6 @@ FillSearchTableSolvable::FillSearchTableSolvable(
   : _table( &table )
   , _gopts(Zypper::instance()->globalOpts())
   , _inst_notinst(inst_notinst)
-  , _show_alias(Zypper::instance()->config().show_alias)
 {
   Zypper & zypper = *Zypper::instance();
   if (zypper.cOpts().find("repo") != zypper.cOpts().end())
@@ -139,7 +138,7 @@ bool FillSearchTableSolvable::addPicklistItem( const ui::Selectable::constPtr &
     row
     << ( pi->isSystem()
        ? _("System Packages")
-       : (_show_alias ? pi->repository().info().alias() : pi->repository().info().name() ) )
+       : pi->repository().asUserString() )
     << ""
     << pi->name()
     << pi->edition().asString()
@@ -154,7 +153,7 @@ bool FillSearchTableSolvable::addPicklistItem( const ui::Selectable::constPtr &
     << pi->arch().asString()
     << ( pi->isSystem()
        ? (string("(") + _("System Packages") + ")")
-       : (_show_alias ? pi->repository().info().alias() : pi->repository().info().name()));
+       : pi->repository().asUserString() );
   }
 
   *_table << row;
@@ -338,7 +337,6 @@ FillPatchesTable::FillPatchesTable( Table & table, zypp::TriBool inst_notinst )
   : _table( &table )
   , _gopts(Zypper::instance()->globalOpts())
   , _inst_notinst(inst_notinst)
-  , _show_alias(Zypper::instance()->config().show_alias)
 {
   TableHeader header;
 
@@ -369,8 +367,7 @@ bool FillPatchesTable::operator()(const zypp::PoolItem & pi) const
   zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>(pi.resolvable());
 
   row
-    << (_show_alias ?
-        pi->repository().info().alias() : pi->repository().info().name())
+    << pi->repository().asUserString()
     << pi->name()
     << pi->edition().asString()
     << patch->category()
index 65b24af..8186694 100644 (file)
@@ -27,7 +27,6 @@ struct FillSearchTableSolvable
   /** Aliases of repos specified as --repo */
   std::set<std::string> _repos;
   zypp::TriBool _inst_notinst;
-  bool _show_alias;
 
   FillSearchTableSolvable(
       Table & table,
@@ -76,7 +75,6 @@ struct FillPatchesTable
   Table * _table;
   const GlobalOptions & _gopts;
   zypp::TriBool _inst_notinst;
-  bool _show_alias;
 
   FillPatchesTable( Table & table,
       zypp::TriBool inst_notinst = zypp::indeterminate );
index 7a075f4..a4f67f9 100755 (executable)
@@ -584,8 +584,6 @@ void solve_and_commit (Zypper & zypper)
     else
       summary.unsetViewOption(Summary::SHOW_UNSUPPORTED);
 
-    summary.setShowRepoAlias(zypper.config().show_alias);
-
     if (get_download_option(zypper, true) == DownloadOnly)
       summary.setDownloadOnly(true);
 
index f6123c8..4c76e04 100755 (executable)
@@ -288,7 +288,7 @@ static bool list_patch_updates(Zypper & zypper)
       // table
       {
         TableRow tr (cols);
-        tr << (zypper.config().show_alias ? patch->repoInfo().alias() : patch->repoInfo().name());
+        tr << patch->repoInfo().asUserString();
         tr << res->name () << res->edition ().asString();
         tr << patch->category();
         tr << (it->isBroken() ? _("needed") : _("not needed"));
@@ -521,7 +521,7 @@ void list_updates(Zypper & zypper, const ResKindSet & kinds, bool best_effort)
       TableRow tr (cols);
       tr << "v";
       if (!hide_repo) {
-        tr << (zypper.config().show_alias ?  res->repoInfo().alias() : res->repoInfo().name());
+        tr << res->repoInfo().asUserString();
       }
       if (zypper.globalOpts().is_rug_compatible)
         tr << "";               // Bundle