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

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