Remove deprecated old History parser API
authorMichael Andres <ma@suse.de>
Wed, 15 May 2013 12:24:08 +0000 (14:24 +0200)
committerMichael Andres <ma@suse.de>
Wed, 15 May 2013 12:24:08 +0000 (14:24 +0200)
tests/parser/HistoryLogReader_test.cc
zypp/CMakeLists.txt
zypp/HistoryLogData.cc
zypp/HistoryLogData.h
zypp/parser/HistoryLogReader.cc
zypp/parser/HistoryLogReader.h

index ad9c247..7300ab3 100644 (file)
@@ -1,35 +1,9 @@
 #include "TestSetup.h"
-#define WITH_DEPRECATED_HISTORYITEM_API
 #include "zypp/parser/HistoryLogReader.h"
 #include "zypp/parser/ParseException.h"
 
 using namespace zypp;
 
-#if defined(WITH_DEPRECATED_HISTORYITEM_API)
-namespace
-{
-  bool OldApi_ProcessItem( const HistoryItem::Ptr & ptr )
-  {
-    DBG << ptr << endl;
-    return true;
-  }
-}
-
-BOOST_AUTO_TEST_CASE(OldApi_basic)
-{
-  parser::HistoryLogReader parser( TESTS_SRC_DIR "/parser/HistoryLogReader_test.dat",
-                                  OldApi_ProcessItem );
-
-  BOOST_CHECK_EQUAL( parser.ignoreInvalidItems(), false );
-  BOOST_CHECK_THROW( parser.readAll(), parser::ParseException );
-
-  parser.setIgnoreInvalidItems( true );
-  BOOST_CHECK_EQUAL( parser.ignoreInvalidItems(), true );
-  parser.readAll();
-}
-
-#endif // WITH_DEPRECATED_HISTORYITEM_API
-
 namespace
 {
   bool ProcessData( const HistoryLogData::Ptr & ptr )
index b3a0d50..adfd277 100644 (file)
@@ -4,9 +4,6 @@
 
 ADD_DEFINITIONS(-DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale" -DTEXTDOMAIN="zypp" -DZYPP_DLL )
 
-# 2012-12-03: HistoryLogReader: deprecate old API based in HistoryItem; use HistoryLogData based one
-ADD_DEFINITIONS(-DWITH_DEPRECATED_HISTORYITEM_API=1)
-
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
 #FILE(WRITE filename "message to write"... )
 
index 3c73af5..6ad34ce 100644 (file)
@@ -295,239 +295,5 @@ namespace zypp
     Url                HistoryLogDataRepoUrlChange::newUrl()   const { return optionalAt( NEWURL_INDEX ); }
     std::string        HistoryLogDataRepoUrlChange::userdata() const { return optionalAt( USERDATA_INDEX ); }
 
-
-#if defined(WITH_DEPRECATED_HISTORYITEM_API)
-  ///////////////////////////////////////////////////////////////////
-  /// \class HistoryItem
-  /// \deprecated Old unextensible \ref zypp::parser::HistoryLogReader data class.
-  /// They grant direct access to data members, so can not be extended
-  /// without losing binary compatibility.
-  ///////////////////////////////////////////////////////////////////
-  HistoryItem::HistoryItem(FieldVector & fields)
-  {
-    if (fields.size() <= 2)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zd, expected more than %d.",
-          fields.size(), 2)));
-
-    date = Date(fields[0], HISTORY_LOG_DATE_FORMAT);
-    action = HistoryActionID(str::trim(fields[1]));
-  }
-
-  void HistoryItem::dumpTo(ostream & str) const
-  {
-    str << date.form(HISTORY_LOG_DATE_FORMAT) << "|" << action.asString();
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItem & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemInstall (deprecated!)
-  //
-  /////////////////////////////////////////////////////////////////////
-
-  HistoryItemInstall::HistoryItemInstall(FieldVector & fields)
-    : HistoryItem(fields)
-  {
-    if (fields.size() < 8)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zu, expected %u.",
-          fields.size(), 8)));
-
-    name      = fields[2];
-    edition   = Edition(fields[3]);
-    arch      = Arch(fields[4]);
-    reqby     = fields[5];
-    repoalias = fields[6];
-    checksum  = CheckSum::sha(fields[7]);
-  }
-
-  void HistoryItemInstall::dumpTo(ostream & str) const
-  {
-    HistoryItem::dumpTo(str);
-    str << "|"
-      << name << "|"
-      << edition << "|"
-      << arch << "|"
-      << reqby << "|"
-      << repoalias << "|"
-      << checksum;
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItemInstall & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRemove (deprecated!)
-  //
-  /////////////////////////////////////////////////////////////////////
-
-  HistoryItemRemove::HistoryItemRemove(FieldVector & fields)
-    : HistoryItem(fields)
-  {
-    if (fields.size() < 6)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zu, expected %u.",
-          fields.size(), 6)));
-
-    name      = fields[2];
-    edition   = Edition(fields[3]);
-    arch      = Arch(fields[4]);
-    reqby     = fields[5];
-  }
-
-  void HistoryItemRemove::dumpTo(ostream & str) const
-  {
-    HistoryItem::dumpTo(str);
-    str << "|"
-      << name << "|"
-      << edition << "|"
-      << arch << "|"
-      << reqby;
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItemRemove & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRepoAdd (deprecated!)
-  //
-  /////////////////////////////////////////////////////////////////////
-
-  HistoryItemRepoAdd::HistoryItemRepoAdd(FieldVector & fields)
-    : HistoryItem(fields)
-  {
-    if (fields.size() < 4)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zu, expected %u.",
-          fields.size(), 4)));
-
-    alias = fields[2];
-    url = Url(fields[3]);
-  }
-
-  void HistoryItemRepoAdd::dumpTo(ostream & str) const
-  {
-    HistoryItem::dumpTo(str);
-    str << "|"
-      << alias << "|"
-      << url;
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItemRepoAdd & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRepoRemove (deprecated!)
-  //
-  /////////////////////////////////////////////////////////////////////
-
-  HistoryItemRepoRemove::HistoryItemRepoRemove(FieldVector & fields)
-    : HistoryItem(fields)
-  {
-    if (fields.size() < 3)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zu, expected %u.",
-          fields.size(), 3)));
-
-    alias = fields[2];
-  }
-
-  void HistoryItemRepoRemove::dumpTo(ostream & str) const
-  {
-    HistoryItem::dumpTo(str);
-    str << "|" << alias;
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItemRepoRemove & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRepoAliasChange (deprecated!)
-  //
-  /////////////////////////////////////////////////////////////////////
-
-  HistoryItemRepoAliasChange::HistoryItemRepoAliasChange(FieldVector & fields)
-    : HistoryItem(fields)
-  {
-    if (fields.size() < 4)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zu, expected %u.",
-          fields.size(), 4)));
-
-    oldalias = fields[2];
-    newalias = fields[3];
-  }
-
-  void HistoryItemRepoAliasChange::dumpTo(ostream & str) const
-  {
-    HistoryItem::dumpTo(str);
-    str << "|" << oldalias << "|" << newalias;
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItemRepoAliasChange & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRepoUrlChange (deprecated!)
-  //
-  /////////////////////////////////////////////////////////////////////
-
-  HistoryItemRepoUrlChange::HistoryItemRepoUrlChange(FieldVector & fields)
-    : HistoryItem(fields)
-  {
-    if (fields.size() < 4)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zu, expected %u.",
-          fields.size(), 4)));
-
-    alias = fields[2];
-    newurl = Url(fields[3]);
-  }
-
-  void HistoryItemRepoUrlChange::dumpTo(ostream & str) const
-  {
-    HistoryItem::dumpTo(str);
-    str << "|" << alias << "|" << newurl;
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItemRepoUrlChange & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-#endif // WITH_DEPRECATED_HISTORYITEM_API
-
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
index 2ef5e21..0428589 100644 (file)
@@ -382,179 +382,6 @@ namespace zypp
     std::string        userdata()      const;  ///< userdata/transactionID
   };
 
-
-#if defined(WITH_DEPRECATED_HISTORYITEM_API)
-  ///////////////////////////////////////////////////////////////////
-  /// \class HistoryItem
-  /// \deprecated Old unextensible \ref zypp::parser::HistoryLogReader data class.
-  /// They grant direct access to data members, so can not be extended
-  /// without losing binary compatibility.
-  ///////////////////////////////////////////////////////////////////
-  class HistoryItem
-  {
-  public:
-    typedef shared_ptr<HistoryItem> Ptr;
-    typedef std::vector<std::string> FieldVector;
-
-  public:
-    HistoryItem(FieldVector & fields);
-    virtual ~HistoryItem()
-    {}
-
-    virtual void dumpTo(std::ostream & str) const;
-
-  public:
-    Date date;
-    HistoryActionID action;
-  };
-  /////////////////////////////////////////////////////////////////////
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemInstall
-  //
-  /** \deprecated Old unextensible \ref zypp::parser::HistoryLogReader data class. */
-  class ZYPP_DEPRECATED HistoryItemInstall : public HistoryItem
-  {
-  public:
-    typedef shared_ptr<HistoryItemInstall> Ptr;
-
-    HistoryItemInstall(FieldVector & fields);
-    virtual ~HistoryItemInstall()
-    {}
-
-    virtual void dumpTo(std::ostream & str) const;
-
-  public:
-    std::string   name;
-    Edition       edition;
-    Arch          arch;
-    std::string   reqby; // TODO make this a class ReqBy
-    std::string   repoalias;
-    CheckSum      checksum;
-  };
-  /////////////////////////////////////////////////////////////////////
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRemove
-  //
-  /** \deprecated Old unextensible \ref zypp::parser::HistoryLogReader data class. */
-  class ZYPP_DEPRECATED HistoryItemRemove : public HistoryItem
-  {
-  public:
-    typedef shared_ptr<HistoryItemRemove> Ptr;
-
-    HistoryItemRemove(FieldVector & fields);
-    virtual ~HistoryItemRemove()
-    {}
-
-    virtual void dumpTo(std::ostream & str)  const;
-
-  public:
-    std::string name;
-    Edition     edition;
-    Arch        arch;
-    std::string reqby;
-  };
-  /////////////////////////////////////////////////////////////////////
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRepoAdd
-  //
-  /** \deprecated Old unextensible \ref zypp::parser::HistoryLogReader data class. */
-  class ZYPP_DEPRECATED HistoryItemRepoAdd : public HistoryItem
-  {
-  public:
-    typedef shared_ptr<HistoryItemRepoAdd> Ptr;
-
-    HistoryItemRepoAdd(FieldVector & fields);
-    virtual ~HistoryItemRepoAdd()
-    {}
-
-    virtual void dumpTo(std::ostream & str) const;
-
-  public:
-    std::string alias;
-    Url         url;
-  };
-  /////////////////////////////////////////////////////////////////////
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRepoRemove
-  //
-  /** \deprecated Old unextensible \ref zypp::parser::HistoryLogReader data class. */
-  class ZYPP_DEPRECATED HistoryItemRepoRemove : public HistoryItem
-  {
-  public:
-    typedef shared_ptr<HistoryItemRepoRemove> Ptr;
-
-    HistoryItemRepoRemove(FieldVector & fields);
-    virtual ~HistoryItemRepoRemove()
-    {}
-
-    virtual void dumpTo(std::ostream & str) const;
-
-  public:
-    std::string alias;
-  };
-  /////////////////////////////////////////////////////////////////////
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRepoAliasChange
-  //
-  /** \deprecated Old unextensible \ref zypp::parser::HistoryLogReader data class. */
-  class ZYPP_DEPRECATED HistoryItemRepoAliasChange : public HistoryItem
-  {
-  public:
-    typedef shared_ptr<HistoryItemRepoAliasChange> Ptr;
-
-    HistoryItemRepoAliasChange(FieldVector & fields);
-    virtual ~HistoryItemRepoAliasChange()
-    {}
-
-    virtual void dumpTo(std::ostream & str) const;
-
-  public:
-    std::string oldalias;
-    std::string newalias;
-  };
-  /////////////////////////////////////////////////////////////////////
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRepoUrlChange
-  //
-  /** \deprecated Old unextensible \ref zypp::parser::HistoryLogReader data class. */
-  class ZYPP_DEPRECATED HistoryItemRepoUrlChange : public HistoryItem
-  {
-  public:
-    typedef shared_ptr<HistoryItemRepoUrlChange> Ptr;
-
-    HistoryItemRepoUrlChange(FieldVector & fields);
-    virtual ~HistoryItemRepoUrlChange()
-    {}
-
-    virtual void dumpTo(std::ostream & str) const;
-
-  public:
-    std::string alias;
-    Url newurl;
-  };
-  /////////////////////////////////////////////////////////////////////
-
-  std::ostream & operator<<(std::ostream & str, const HistoryItem & obj);
-#endif // WITH_DEPRECATED_HISTORYITEM_API
-
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
 #endif /* ZYPP_HISTORYLOGDATA_H_ */
index bc58561..99a9581 100644 (file)
@@ -50,25 +50,10 @@ namespace zypp
     Pathname _filename;
     Options  _options;
     ProcessData _callback;
-
-#if defined(WITH_DEPRECATED_HISTORYITEM_API)
-    ProcessItem _oldAPICallback;
-  private:
-    HistoryItem::Ptr _oldAPIcreateHistoryItem( HistoryItem::FieldVector & fields );
-    void _oldAPIparseLine(const std::string & line, unsigned int lineNr);
-#endif // WITH_DEPRECATED_HISTORYITEM_API
   };
 
   bool HistoryLogReader::Impl::parseLine( const std::string & line_r, unsigned lineNr_r )
   {
-#if defined(WITH_DEPRECATED_HISTORYITEM_API)
-    if ( _oldAPICallback )
-    {
-      _oldAPIparseLine( line_r, lineNr_r );
-      return true;     // old api did not eavluate callback return value :(
-    }
-#endif // WITH_DEPRECATED_HISTORYITEM_API
-
     // parse into fields
     HistoryLogData::FieldVector fields;
     str::splitEscaped( line_r, std::back_inserter(fields), "|", true );
@@ -205,111 +190,12 @@ namespace zypp
     pd.toMax();
   }
 
-
-#if defined(WITH_DEPRECATED_HISTORYITEM_API)
-  HistoryItem::Ptr HistoryLogReader::Impl::_oldAPIcreateHistoryItem( HistoryItem::FieldVector & fields )
-  {
-    HistoryActionID aid( str::trim( fields[1] ) );
-    switch ( aid.toEnum() )
-    {
-    case HistoryActionID::INSTALL_e:
-      return HistoryItemInstall::Ptr( new HistoryItemInstall( fields ) );
-      break;
-
-    case HistoryActionID::REMOVE_e:
-      return HistoryItemRemove::Ptr( new HistoryItemRemove( fields ) );
-      break;
-
-    case HistoryActionID::REPO_ADD_e:
-      return HistoryItemRepoAdd::Ptr( new HistoryItemRepoAdd( fields ) );
-      break;
-
-    case HistoryActionID::REPO_REMOVE_e:
-      return HistoryItemRepoRemove::Ptr( new HistoryItemRepoRemove( fields ) );
-      break;
-
-    case HistoryActionID::REPO_CHANGE_ALIAS_e:
-      return HistoryItemRepoAliasChange::Ptr( new HistoryItemRepoAliasChange( fields ) );
-      break;
-
-    case HistoryActionID::REPO_CHANGE_URL_e:
-      return HistoryItemRepoUrlChange::Ptr( new HistoryItemRepoUrlChange( fields ) );
-      break;
-
-    case HistoryActionID::NONE_e:
-      break;
-    }
-    return HistoryItem::Ptr();
-  }
-  void HistoryLogReader::Impl::_oldAPIparseLine( const std::string & line, unsigned int lineNr )
-  {
-    // parse into fields
-    HistoryItem::FieldVector fields;
-    str::splitEscaped( line, back_inserter(fields), "|", true );
-
-    if ( fields.size() <= 2 )
-    {
-      if ( ! _options.testFlag( IGNORE_INVALID_ITEMS ) )
-      {
-       ParseException e( str::form( "Error in history log on line #%u.", lineNr ) );
-       e.addHistory( str::form( "Bad number of fields. Got %zd, expected more than %d.", fields.size(), 2 ) );
-       ZYPP_THROW( e );
-      }
-      else
-      {
-       WAR << "Ignoring suspicious non-comment entry on line #" << lineNr << endl;
-       return;
-      }
-    }
-
-    HistoryItem::Ptr item_ptr;
-    try
-    {
-      item_ptr = _oldAPIcreateHistoryItem( fields );
-    }
-    catch ( const Exception & e )
-    {
-      ZYPP_CAUGHT(e);
-      ERR << "Invalid history log entry on line #" << lineNr << " '"<< line << "'" << endl;
-
-      if ( ! _options.testFlag( IGNORE_INVALID_ITEMS ) )
-      {
-        ParseException newe( str::form( "Error in history log on line #%u.", lineNr ) );
-       newe.remember( e );
-       ZYPP_THROW( newe );
-      }
-    }
-
-    if ( item_ptr )
-    {
-      _oldAPICallback( item_ptr );
-    }
-    else if ( ! _options.testFlag( IGNORE_INVALID_ITEMS ) )
-    {
-      ParseException e( str::form( "Error in history log on line #%u.", lineNr ) );
-      e.addHistory( "Unknown entry type." );
-      ZYPP_THROW( e );
-    }
-    else
-    {
-      WAR << "Unknown history log action type: " << fields[1] << " on line #" << lineNr << endl;
-    }
-  }
-#endif // WITH_DEPRECATED_HISTORYITEM_API
-
   /////////////////////////////////////////////////////////////////////
   //
   //   class HistoryLogReader
   //
   /////////////////////////////////////////////////////////////////////
 
-#if defined(WITH_DEPRECATED_HISTORYITEM_API)
-  HistoryLogReader::HistoryLogReader( const Pathname & historyFile,
-                                      const ProcessItem & callback )
-  : _pimpl(new HistoryLogReader::Impl( historyFile, Options(), ProcessData() ) )
-  { _pimpl->_oldAPICallback = callback; }
-#endif // WITH_DEPRECATED_HISTORYITEM_API
-
   HistoryLogReader::HistoryLogReader( const Pathname & historyFile_r, const Options & options_r, const ProcessData & callback_r )
   : _pimpl( new HistoryLogReader::Impl( historyFile_r, options_r, callback_r ) )
   {}
index e174039..b23f037 100644 (file)
 
 #include "zypp/HistoryLogData.h"
 
-#if defined(WITH_DEPRECATED_HISTORYITEM_API)
-#warning Support for HistoryItem based parsing will be removed in the future.
-#warning Switch to the new HistoryLogData based HistoryLogReader API.
-#endif // WITH_DEPRECATED_HISTORYITEM_API
-
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 {
@@ -67,20 +62,6 @@ namespace zypp
   /// \endcode
   /// \see \ref HistoryLogData for how to access the individual data fields.
   ///
-#if defined(WITH_DEPRECATED_HISTORYITEM_API)
-  /// \note The old API based in HistoryItem instead of HistoryLogData
-  /// is deprecated and may vanish in the future. The new API no longer
-  /// allows direct access to data members, you have to call access methods
-  /// instead.
-  /// \code
-  ///   - // old style
-  ///   - HistoryItem::Ptr ptr;
-  ///   - Date d = ptr->date;
-  ///   + // new style
-  ///   + HistoryLogData::Ptr ptr;
-  ///   + Date d = ptr->date();
-  /// \endcode
-#endif // WITH_DEPRECATED_HISTORYITEM_API
   ///////////////////////////////////////////////////////////////////
   class HistoryLogReader
   {
@@ -162,17 +143,6 @@ namespace zypp
     /** Implementation */
     class Impl;
     RW_pointer<Impl,rw_pointer::Scoped<Impl> > _pimpl;
-
-#if defined(WITH_DEPRECATED_HISTORYITEM_API)
-  public:
-    /** \deprecated Old unextensible \ref zypp::parser::HistoryLogReader data class. */
-    typedef function< bool( const HistoryItem::Ptr & )> ProcessItem;
-    /** \deprecated Old unextensible \ref zypp::parser::HistoryLogReader data class.
-     * They grant direct access to data members, so can not be extended
-     * without losing binary compatibility.
-     */
-    HistoryLogReader( const Pathname & repo_file, const ProcessItem & callback ) ZYPP_DEPRECATED;
-#endif // WITH_DEPRECATED_HISTORYITEM_API
   };
 
   /** \relates HistoryLogReader::Options */