summaryrefslogtreecommitdiff
diff options
authorRobert C Jennings <robert.jennings@canonical.com>2017-06-26 13:05:34 -0500
committerRobert C Jennings <robert.jennings@canonical.com>2017-06-26 13:05:34 -0500
commit9341aa01743d3abfd6870554aa9e10bc7b8ce0d0 (patch)
treeaad5cd541e329a700ab8cdf820b346b9037eaba7
parent507eab3f66bcc4a4ea557a0c5a68bf51f73a8f5b (diff)
Improve names in print_changelogs and store more to the sources dict
bzr-revno: 18.2.19
-rwxr-xr-xmfdiff73
1 files changed, 35 insertions, 38 deletions
diff --git a/mfdiff b/mfdiff
index eb81cdb..216711a 100755
--- a/mfdiff
+++ b/mfdiff
@@ -412,88 +412,85 @@ def print_changelogs(cache_d, manifest_from, manifest_to, changed):
"""
srcs = {}
- exceptions = []
+ errors = []
cache = get_cache(cache_d)
src2bins = map_source_to_binary(cache, changed)
# Generate changelog data per unique source package
- srcs = {}
- exceptions = []
- cache = get_cache(cache_d)
-
- src2bins = map_source_to_binary(cache, changed)
-
- # Generate changelog data per unique source package
- for src in src2bins:
- srcs[src] = {"changelog_file": "", "changeblocks": []}
+ for source_name in src2bins:
+ srcs[source_name] = {"changelog_file": "", "changeblocks": []}
+ src = srcs[source_name]
# Use the first binary listed for a source package
- binary = src2bins[src][0]
+ binary_name = src2bins[source_name][0]
# Find the source version data for the binary in manifest #2
- binver_to = manifest_to[binary]
try:
- srcver_to = source_version_for_binary(
- cache, binary, binver_to)
+ src['version_to'] = source_version_for_binary(
+ cache, binary_name, manifest_to[binary_name])
except UnknownSourceVersionError as excp:
logging.error(excp.message)
- exceptions.append(excp)
+ errors.append(excp)
continue
# Find the source version data for the binary in manifest #1
- binver_from = manifest_from[binary]
+ binver_from = manifest_from[binary_name]
try:
- srcver_from = source_version_for_binary(
- cache, binary, binver_from)
+ src['version_from'] = source_version_for_binary(
+ cache, binary_name, binver_from)
except UnknownSourceVersionError as excp:
- if binver_to == srcver_to:
+ if manifest_to[binary_name] == src['version_to']:
logging.info('Could not find source version data in apt '
'cache. Assuming source %s version %s from '
- 'binary %s', src, binver_from, binary)
- srcver_from = binver_from
+ 'binary %s', source_name, binver_from,
+ binary_name)
+ src['version_from'] = binver_from
else:
logging.error(excp.message)
- exceptions.append(excp)
+ errors.append(excp)
continue
+ # Check for version regression between manifests
try:
- if version_compare(srcver_from, srcver_to) > 0:
+ if version_compare(src['version_from'], src['version_to']) > 0:
msg = "Package version regression {} -> {}".format(
- srcver_from, srcver_to)
+ src['version_from'], src['version_to'])
raise UnknownSourceVersionError(msg)
except UnknownSourceVersionError as excp:
- exceptions.append(excp)
+ errors.append(excp)
continue
+ # Get the changelog for this source package
try:
- changelog_path = getchangelog(src, srcver_to, cache_d)
+ srcs[source_name]["changelog_file"] = getchangelog(
+ source_name, src['version_to'], cache_d)
except MissingChangelogError as excp:
- exceptions.append(excp)
+ errors.append(excp)
continue
- srcs[src]["changelog_file"] = changelog_path
-
+ # Filter the changelog to a list of blocks between the two versions
try:
- srcs[src]["changeblocks"], incomplete = filter_changelog(
- changelog_path, srcver_from, srcver_to)
+ srcs[source_name]["changeblocks"], incomplete = filter_changelog(
+ srcs[source_name]["changelog_file"], src['version_from'],
+ src['version_to'])
if incomplete:
raise ChangelogMissingVersion(incomplete)
except ChangelogMissingVersion as exp:
- exceptions.append(exp)
+ errors.append(exp)
continue
# Print changelog ranges for changed packages
- for src in sorted(src2bins):
- binlist = sorted(src2bins[src])
+ for source_name in sorted(src2bins):
+ binlist = sorted(src2bins[source_name])
binary = binlist[0]
print("==== %s: %s => %s ====" %
- (src, manifest_from[binary], manifest_to[binary]))
+ (source_name, manifest_from[binary], manifest_to[binary]))
print("==== %s" % ' '.join(binlist))
- print_blocks(srcs[src]["changeblocks"])
+ print_blocks(srcs[source_name]["changeblocks"])
- if exceptions:
+ if errors:
print("**** Errors ****")
- for error in exceptions:
+ for error in errors:
print(error)