chantra / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

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

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