summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2010-05-19 15:40:21 +0200
committerJulian Andres Klode <jak@debian.org>2010-05-19 15:40:21 +0200
commita2564f533b18c3dfc5ce485c2965e9c8fed3c380 (patch)
tree751987648d15a8e27e1629dcafc7ce69974a4c79
parentd55ec0082540e99d520426bb73d3443f2175213b (diff)
downloadpython-apt-a2564f533b18c3dfc5ce485c2965e9c8fed3c380.tar.gz
Add Version.source_version and enhance Sebastian's patch to make use
of it, in order to find the best changelog for the package.
-rw-r--r--apt/package.py30
-rw-r--r--debian/changelog2
2 files changed, 24 insertions, 8 deletions
diff --git a/apt/package.py b/apt/package.py
index fb79d043..228a3385 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -379,6 +379,14 @@ class Version(object):
return self.package.name
@property
+ def source_version(self):
+ """Return the version of the source package."""
+ try:
+ return self._records.source_ver or self._cand.ver_str
+ except IndexError:
+ return self._cand.ver_str
+
+ @property
def priority(self):
"""Return the priority of the package, as string."""
return self._cand.priority_str
@@ -1006,10 +1014,10 @@ class Package(object):
src_section = "main"
# use the section of the candidate as a starting point
section = self.candidate.section
-
- # get the source version, start with the binaries version
- bin_ver = self.candidate.version
- src_ver = self.candidate.version
+
+ # get the source version
+ src_ver = self.candidate.source_version
+
try:
# try to get the source version of the pkg, this differs
# for some (e.g. libnspr4 on ubuntu)
@@ -1020,11 +1028,17 @@ class Package(object):
pass
else:
while src_records.lookup(src_pkg):
- if not src_records.version or \
- apt_pkg.version_compare(bin_ver, src_records.version) > 0:
+ if not src_records.version:
continue
- src_ver = src_records.version
- section = src_records.section
+ if self.candidate.source_version == src_records.version:
+ # Direct match, use it and do not do more lookups.
+ src_ver = src_records.version
+ section = src_records.section
+ break
+ if apt_pkg.version_compare(src_records.version, src_ver) > 0:
+ # The version is higher, it seems to match.
+ src_ver = src_records.version
+ section = src_records.section
section_split = section.split("/", 1)
if len(section_split) > 1:
diff --git a/debian/changelog b/debian/changelog
index 22418888..96f93813 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,8 @@ python-apt (0.7.95) UNRELEASED; urgency=low
- Fix fetch_source() to work when source name = binary name (LP: #552400).
- Merge a patch from Sebastian Heinlein to make get_changelog() only
check sources where source version >= binary version (Closes: #581831).
+ - Add Version.source_version and enhance Sebastian's patch to make use
+ of it, in order to find the best changelog for the package.
* python:
- Return bool instead of int to Python where possible, looks better.
- Document every class, function, property.