dcavalca / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

Blame SOURCES/0020-cli-commands-history-Fix-history-undo-on-a-Reason-Ch.patch

44fffb
From fe87499e6745795b1dc6225fa102a1242eb9ffc8 Mon Sep 17 00:00:00 2001
44fffb
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
44fffb
Date: Thu, 17 Feb 2022 18:46:22 +0100
70e049
Subject: [PATCH] cli/commands/history: Fix history undo on a Reason Change
44fffb
44fffb
The previous reason needs to be fetched from the history db. It's
44fffb
inefficient to parse the nevra after it was serialized in a previous
44fffb
step, but that would need bigger code restructuring.
44fffb
44fffb
= changelog =
44fffb
msg: Fix history undo on a Reason Change
44fffb
type: bugfix
44fffb
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2053014
44fffb
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2010259
44fffb
---
44fffb
 dnf.spec                    |  2 +-
44fffb
 dnf/cli/commands/history.py | 11 +++++++++++
44fffb
 2 files changed, 12 insertions(+), 1 deletion(-)
44fffb
44fffb
diff --git a/dnf.spec b/dnf.spec
44fffb
index 02c8b577..36c3932e 100644
44fffb
--- a/dnf.spec
44fffb
+++ b/dnf.spec
44fffb
@@ -2,7 +2,7 @@
44fffb
 %define __cmake_in_source_build 1
44fffb
 
44fffb
 # default dependencies
44fffb
-%global hawkey_version 0.61.1
44fffb
+%global hawkey_version 0.66.0
44fffb
 %global libcomps_version 0.1.8
44fffb
 %global libmodulemd_version 2.9.3
44fffb
 %global rpm_version 4.14.0
44fffb
diff --git a/dnf/cli/commands/history.py b/dnf/cli/commands/history.py
44fffb
index 293d93fc..21d04a1a 100644
44fffb
--- a/dnf/cli/commands/history.py
44fffb
+++ b/dnf/cli/commands/history.py
44fffb
@@ -223,6 +223,7 @@ class HistoryCommand(commands.Command):
44fffb
             "Reinstall": "Reinstalled",
44fffb
             "Obsoleted": "Install",
44fffb
             "Obsolete": "Obsoleted",
44fffb
+            "Reason Change": "Reason Change",
44fffb
         }
44fffb
 
44fffb
         data = serialize_transaction(trans)
44fffb
@@ -235,6 +236,16 @@ class HistoryCommand(commands.Command):
44fffb
                 if ti["action"] == "Install" and ti.get("reason", None) == "clean":
44fffb
                     ti["reason"] = "dependency"
44fffb
 
44fffb
+                if ti["action"] == "Reason Change" and "nevra" in ti:
44fffb
+                    subj = hawkey.Subject(ti["nevra"])
44fffb
+                    nevra = subj.get_nevra_possibilities(forms=[hawkey.FORM_NEVRA])[0]
44fffb
+                    reason = self.output.history.swdb.resolveRPMTransactionItemReason(
44fffb
+                        nevra.name,
44fffb
+                        nevra.arch,
44fffb
+                        trans.tids()[0] - 1
44fffb
+                    )
44fffb
+                    ti["reason"] = libdnf.transaction.TransactionItemReasonToString(reason)
44fffb
+
44fffb
                 if ti.get("repo_id") == hawkey.SYSTEM_REPO_NAME:
44fffb
                     # erase repo_id, because it's not possible to perform forward actions from the @System repo
44fffb
                     ti["repo_id"] = None
44fffb
-- 
70e049
2.35.1
44fffb