Blame SOURCES/0012-Change-behaviour-of-Package-.from-repo.patch

862ba9
From ca06d200d738fd6b23cb05b9776c9fd29288665f Mon Sep 17 00:00:00 2001
862ba9
From: Jaroslav Mracek <jmracek@redhat.com>
862ba9
Date: Wed, 25 Nov 2020 13:00:22 +0100
862ba9
Subject: [PATCH 1/2] Change behaviour of Package().from_repo
862ba9
862ba9
The change makes a difference between private attribute _from_repo and
862ba9
API attribute. _from_repo is required for `dnf info` and we have to keep
862ba9
it, but for API the magic handling behind could be confusing.
862ba9
---
862ba9
 dnf/package.py      | 8 +++++++-
862ba9
 doc/api_package.rst | 5 ++---
862ba9
 2 files changed, 9 insertions(+), 4 deletions(-)
862ba9
862ba9
diff --git a/dnf/package.py b/dnf/package.py
862ba9
index f647df6bff..28ca5ef760 100644
862ba9
--- a/dnf/package.py
862ba9
+++ b/dnf/package.py
862ba9
@@ -73,6 +73,12 @@ def _from_system(self):
862ba9
 
862ba9
     @property
862ba9
     def _from_repo(self):
862ba9
+        """
862ba9
+        For installed packages returns id of repository from which the package was installed
862ba9
+        prefixed with '@' (if such information is available in the history database). Otherwise
862ba9
+        returns id of repository the package belongs to (@System for installed packages of unknown
862ba9
+        origin)
862ba9
+        """
862ba9
         pkgrepo = None
862ba9
         if self._from_system:
862ba9
             pkgrepo = self.base.history.repo(self)
862ba9
@@ -83,7 +89,7 @@ def _from_repo(self):
862ba9
     @property
862ba9
     def from_repo(self):
862ba9
         # :api
862ba9
-        return self._from_repo
862ba9
+        return self.base.history.repo(self)
862ba9
 
862ba9
     @property
862ba9
     def _header(self):
862ba9
diff --git a/doc/api_package.rst b/doc/api_package.rst
862ba9
index a78897babe..634f504ca6 100644
862ba9
--- a/doc/api_package.rst
862ba9
+++ b/doc/api_package.rst
862ba9
@@ -76,9 +76,8 @@
862ba9
 
862ba9
   .. attribute:: from_repo
862ba9
 
862ba9
-    For installed packages returns id of repository from which the package was installed prefixed
862ba9
-    with '@' (if such information is available in the history database). Otherwise returns id of
862ba9
-    repository the package belongs to (@System for installed packages of unknown origin) (string).
862ba9
+    For installed packages returns id of repository from which the package was installed if such
862ba9
+    information is available in the history database. Otherwise returns an empty string (string).
862ba9
 
862ba9
   .. attribute:: group
862ba9
 
862ba9
862ba9
From 895e61a1281db753dd28f01c20816e83c5316cdd Mon Sep 17 00:00:00 2001
862ba9
From: Jaroslav Mracek <jmracek@redhat.com>
862ba9
Date: Thu, 26 Nov 2020 10:02:08 +0100
862ba9
Subject: [PATCH 2/2] fixup! Change behaviour of Package().from_repo
862ba9
862ba9
---
862ba9
 dnf/package.py | 4 +++-
862ba9
 1 file changed, 3 insertions(+), 1 deletion(-)
862ba9
862ba9
diff --git a/dnf/package.py b/dnf/package.py
862ba9
index 28ca5ef760..baef04fa5b 100644
862ba9
--- a/dnf/package.py
862ba9
+++ b/dnf/package.py
862ba9
@@ -89,7 +89,9 @@ def _from_repo(self):
862ba9
     @property
862ba9
     def from_repo(self):
862ba9
         # :api
862ba9
-        return self.base.history.repo(self)
862ba9
+        if self._from_system:
862ba9
+            return self.base.history.repo(self)
862ba9
+        return ""
862ba9
 
862ba9
     @property
862ba9
     def _header(self):