diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-10-23 16:22:50 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-10-24 15:17:04 +0000 |
commit | 24e0e1ff64b1bcaede0366f9c0765bc740754da8 (patch) | |
tree | 8cd6f273d95870c20b732879c78c767917d9f3c0 /morphlib/util.py | |
parent | bcb725108c291611d125f8c5048a368dd5cdadb4 (diff) | |
download | morph-24e0e1ff64b1bcaede0366f9c0765bc740754da8.tar.gz |
Fix app.status call in log_dict_diff
This bug was triggered by the fix to CachedRepo.resolve_ref and without
this fix, the resolve_ref fix will break the test suite.
The bug is that log_dict_diff calls the status method with an msg
keyword argument that may contain percentage characters. status
interprets the value of msg as a format string, and the percentage
characters trigger formatting to happen.
The fix for that is to not interpolate the value of key and dictA[key]
and dictB[key] into msg before calling status, but letting status
do that. Thus the msg values are changed to reference %(key)s instead
and passing in a value for key as a separate argument. Ditto for
dictA[key] and dictB[key].
Diffstat (limited to 'morphlib/util.py')
-rw-r--r-- | morphlib/util.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/morphlib/util.py b/morphlib/util.py index 3d9232d4..53a9e283 100644 --- a/morphlib/util.py +++ b/morphlib/util.py @@ -177,7 +177,8 @@ def log_dict_diff(app, cur, pre): # pragma: no cover dictB = pre for key in dictA.keys(): if key not in dictB: - app.status(msg="New environment: %s = %s" % (key, dictA[key]), + app.status(msg="New environment: %(key)s = %(value)s", + key=key, value=dictA[key], chatty=True) elif dictA[key] != dictB[key]: app.status(msg= \ @@ -185,7 +186,8 @@ def log_dict_diff(app, cur, pre): # pragma: no cover % {"key": key, "valA": dictA[key], "valB": dictB[key]}) for key in dictB.keys(): if key not in dictA: - app.status(msg="Environment removed: %s = %s" % (key, dictB[key])) + app.status(msg="Environment removed: %(key)s = %(value)s", + key=key, value=dictB[key]) # This acquired from rdiff-backup which is GPLv2+ and a patch from 2011 |