From 27b2f2ff8f910fb4010f7e29e07ca6249c9918ca Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Fri, 27 Nov 2020 15:48:32 +0900 Subject: [PATCH] Imported Upstream version 17.23.3 --- VERSION.cmake | 4 ++-- package/libzypp.changes | 7 +++++++ zypp/parser/HistoryLogReader.cc | 17 ++++++++++++++++- zypp/parser/HistoryLogReader.h | 12 ++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/VERSION.cmake b/VERSION.cmake index 7da3876..dfada27 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -61,8 +61,8 @@ SET(LIBZYPP_MAJOR "17") SET(LIBZYPP_COMPATMINOR "22") SET(LIBZYPP_MINOR "23") -SET(LIBZYPP_PATCH "2") +SET(LIBZYPP_PATCH "3") # -# LAST RELEASED: 17.23.2 (22) +# LAST RELEASED: 17.23.3 (22) # (The number in parenthesis is LIBZYPP_COMPATMINOR) #======= diff --git a/package/libzypp.changes b/package/libzypp.changes index 84e3947..975bac1 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Wed Mar 25 15:26:14 CET 2020 - ma@suse.de + +- Add HistoryLogReader actionFilter to parse only specific + HistoryActionIDs. +- version 17.23.3 (22) + +------------------------------------------------------------------- Fri Mar 20 12:28:18 CET 2020 - ma@suse.de - RepoVariables: Add safe guard in case the caller does not own a diff --git a/zypp/parser/HistoryLogReader.cc b/zypp/parser/HistoryLogReader.cc index 99a9581..a484d1c 100644 --- a/zypp/parser/HistoryLogReader.cc +++ b/zypp/parser/HistoryLogReader.cc @@ -47,9 +47,18 @@ namespace zypp void readFrom( const Date & date_r, const ProgressData::ReceiverFnc & progress_r ); void readFromTo( const Date & fromDate_r, const Date & toDate_r, const ProgressData::ReceiverFnc & progress_r ); + void addActionFilter( const HistoryActionID & action_r ) + { + if ( action_r == HistoryActionID::NONE ) + _actionfilter.clear(); + else + _actionfilter.insert( action_r.asString() ); + } + Pathname _filename; Options _options; ProcessData _callback; + std::set _actionfilter; }; bool HistoryLogReader::Impl::parseLine( const std::string & line_r, unsigned lineNr_r ) @@ -58,7 +67,10 @@ namespace zypp HistoryLogData::FieldVector fields; str::splitEscaped( line_r, std::back_inserter(fields), "|", true ); if ( fields.size() >= 2 ) - str::trim( fields[1] ); // for whatever reason writer is padding the action field + fields[1] = str::trim( std::move(fields[1]) ); // for whatever reason writer is padding the action field + + if ( !_actionfilter.empty() && !_actionfilter.count( fields[1] ) ) + return true; // move into data class HistoryLogData::Ptr data; @@ -218,6 +230,9 @@ namespace zypp void HistoryLogReader::readFromTo( const Date & fromDate_r, const Date & toDate_r, const ProgressData::ReceiverFnc & progress_r ) { _pimpl->readFromTo( fromDate_r, toDate_r, progress_r ); } + void HistoryLogReader::addActionFilter( const HistoryActionID & action_r ) + { _pimpl->addActionFilter( action_r ); } + } // namespace parser /////////////////////////////////////////////////////////////////// } // namespace zypp diff --git a/zypp/parser/HistoryLogReader.h b/zypp/parser/HistoryLogReader.h index 407834a..bb6dc69 100644 --- a/zypp/parser/HistoryLogReader.h +++ b/zypp/parser/HistoryLogReader.h @@ -139,6 +139,18 @@ namespace zypp */ bool ignoreInvalidItems() const; + + /** Process only specific HistoryActionIDs. + * Call repeatedly to add multiple HistoryActionIDs to process. + * Passing an empty HistoryActionID (HistoryActionID::NONE) clears + * the filter. + */ + void addActionFilter( const HistoryActionID & action_r ); + + /** Clear any HistoryActionIDs. */ + void clearActionFilter() + { addActionFilter( HistoryActionID::NONE ); } + private: /** Implementation */ struct Impl; -- 2.7.4