From 57455df96b6dc9f8c90e8d783a2654896ac483e5 Mon Sep 17 00:00:00 2001
From: zhujunhao <zhujunhao11@huawei.com>
Date: Thu, 17 Mar 2022 11:40:59 +0800
Subject: [PATCH] 
 fix-dnf-history-undo-error-when-history-sqlite-missing
 
---
 dnf/cli/commands/__init__.py | 3 +++
 1 file changed, 3 insertions(+)
 
diff --git a/dnf/cli/commands/__init__.py b/dnf/cli/commands/__init__.py
index 86f560b..088e958 100644
--- a/dnf/cli/commands/__init__.py
+++ b/dnf/cli/commands/__init__.py
@@ -954,6 +954,9 @@ class HistoryCommand(Command):
                 s = s[4:]
             transaction_id = int(s)
             if transaction_id <= 0:
+                if not self.output.history.last():
+                    logger.critical("Not found given transaction ID")
+                    raise ValueError
                 transaction_id += self.output.history.last().tid
             return transaction_id
 
-- 
2.27.0
