From 7a26634d5d7d02c49dce17b81d8271d509abd4d0 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 9 Sep 2010 09:34:49 -0700 Subject: In update_config_files(), add a comment line showing a package move that has been applied. This is intended to reduce the risk given that /etc/portage is in CONFIG_PROTECT_MASK, as discussed in bug --- pym/portage/update.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pym/portage/update.py b/pym/portage/update.py index 62dbf93f0..37cab2503 100644 --- a/pym/portage/update.py +++ b/pym/portage/update.py @@ -262,7 +262,11 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c for repo_name, update_iter in update_items: for update_cmd in update_iter: for x, contents in file_contents.items(): + skip_next = False for pos, line in enumerate(contents): + if skip_next: + skip_next = False + continue if ignore_line_re.match(line): continue atom = line.split()[0] @@ -274,7 +278,16 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c new_atom = update_dbentry(update_cmd, atom) if atom != new_atom: if match_callback(repo_name, atom, new_atom): - contents[pos] = line.replace(atom, new_atom, 1) + # add a comment with the update command, so + # the user can clearly see what happened + contents[pos] = "# %s\n" % \ + " ".join("%s" % (x,) for x in update_cmd) + contents.insert(pos + 1, + line.replace("%s" % (atom,), + "%s" % (new_atom,), 1)) + # we've inserted an additional line, so we need to + # skip it when it's reached in the next iteration + skip_next = True update_files[x] = 1 sys.stdout.write("p") sys.stdout.flush() -- cgit v1.2.3-1-g7c22