From e027e02efe57706de5867d42505ea01fb8d494de Mon Sep 17 00:00:00 2001
From: Jan Kolarik <jkolarik@redhat.com>
Date: Tue, 13 Sep 2022 13:55:35 +0200
Subject: [PATCH] Add support for rollback of group upgrade rollback
 (RhBug:2016070)

= changelog =
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2016070

Conflict:NA
Reference:https://github.com/rpm-software-management/dnf/commit/e027e02efe57706de5867d42505ea01fb8d494de
---
 dnf/transaction_sr.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/dnf/transaction_sr.py b/dnf/transaction_sr.py
index 5d403a3..cf74b80 100644
--- a/dnf/transaction_sr.py
+++ b/dnf/transaction_sr.py
@@ -553,9 +553,11 @@ class TransactionReplay(object):
 
                 if action == "Install":
                     self._swdb_group_install(group_id, pkg_types, group_data["packages"])
-                elif action == "Upgrade":
+                # Groups are not versioned, but a reverse transaction could be applied,
+                # therefore we treat both actions the same way
+                elif action == "Upgrade" or action == "Upgraded":
                     self._swdb_group_upgrade(group_id, pkg_types, group_data["packages"])
-                elif action == "Downgraded":
+                elif action == "Downgrade" or action == "Downgraded":
                     self._swdb_group_downgrade(group_id, pkg_types, group_data["packages"])
                 elif action == "Removed":
                     self._swdb_group_remove(group_id, pkg_types, group_data["packages"])
@@ -584,9 +586,11 @@ class TransactionReplay(object):
 
                 if action == "Install":
                     self._swdb_environment_install(env_id, pkg_types, env_data["groups"])
-                elif action == "Upgrade":
+                # Environments are not versioned, but a reverse transaction could be applied,
+                # therefore we treat both actions the same way
+                elif action == "Upgrade" or action == "Upgraded":
                     self._swdb_environment_upgrade(env_id, pkg_types, env_data["groups"])
-                elif action == "Downgraded":
+                elif action == "Downgrade" or action == "Downgraded":
                     self._swdb_environment_downgrade(env_id, pkg_types, env_data["groups"])
                 elif action == "Removed":
                     self._swdb_environment_remove(env_id, pkg_types, env_data["groups"])
-- 
2.27.0
