if file_contents is not None:
file_contents.extend(changes)
if protect_obj[root].isprotected(file_to_write_to):
- file_to_write_to = new_protect_filename(file_to_write_to)
+ # We want to force new_protect_filename to ensure
+ # that the user will see all our changes via
+ # etc-update, even if file_to_write_to doesn't
+ # exist yet, so we specify force=True.
+ file_to_write_to = new_protect_filename(file_to_write_to,
+ force=True)
try:
write_atomic(file_to_write_to, "".join(file_contents))
except PortageException:
masked = len(pmpath)
return protected > masked
-def new_protect_filename(mydest, newmd5=None):
+def new_protect_filename(mydest, newmd5=None, force=False):
"""Resolves a config-protect filename for merging, optionally
- using the last filename if the md5 matches.
+ using the last filename if the md5 matches. If force is True,
+ then a new filename will be generated even if mydest does not
+ exist yet.
(dest,md5) ==> 'string' --- path_to_target_filename
(dest) ==> ('next', 'highest') --- next_target and most-recent_target
"""
prot_num = -1
last_pfile = ""
- if not os.path.exists(mydest):
+ if not force and \
+ not os.path.exists(mydest):
return mydest
real_filename = os.path.basename(mydest)