<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch master
in repository macports-base.

</pre>
<p><a href="https://github.com/macports/macports-base/commit/9854bf50cec554b545fdd9cc77cfb21f1dd967a5">https://github.com/macports/macports-base/commit/9854bf50cec554b545fdd9cc77cfb21f1dd967a5</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'>     new 9854bf50c _activate_contents: improve forced activation rollback
</span>9854bf50c is described below

<span style='display:block; white-space:pre;color:#808000;'>commit 9854bf50cec554b545fdd9cc77cfb21f1dd967a5
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Mon Apr 7 10:11:31 2025 +1000

<span style='display:block; white-space:pre;color:#404040;'>    _activate_contents: improve forced activation rollback
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    Delay updating the file information in the registry entries to the
</span><span style='display:block; white-space:pre;color:#404040;'>    second transaction, so that this change will be rolled back if there
</span><span style='display:block; white-space:pre;color:#404040;'>    is a failure in a later step. This also means the first transaction
</span><span style='display:block; white-space:pre;color:#404040;'>    only needs to be a read.
</span>---
 src/registry2.0/portimage.tcl | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/registry2.0/portimage.tcl b/src/registry2.0/portimage.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 8c415ae85..4911dd088 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/registry2.0/portimage.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/registry2.0/portimage.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -721,15 +721,17 @@ proc _activate_contents {port {rename_list {}}} {
</span>     set seendirs [dict create]
     set confirmed_rename_list [list]
     # This is big and hairy and probably could be done better.
<span style='display:block; white-space:pre;background:#ffe0e0;'>-    # First, we need to check the source file, make sure it exists
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    # First, we need to check the source file, make sure it exists.
</span>     # Then we remove the $location from the path of the file in the contents
<span style='display:block; white-space:pre;background:#ffe0e0;'>-    #  list  and check to see if that file exists
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    # Last, if the file exists, and belongs to another port, and force is set
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    #  we remove the file from the file_map, take ownership of it, and
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-    #  clobber it
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    #  list and check to see if that file exists.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    # Last, if the file exists and force is set, we rename the file to a
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    #  non-conflicting name, and update the activated path in the registry
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    #  entry for the current owner (if any) accordingly, which allows
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    #  the port now being activated to create and own the file.
</span>     set todeactivate [dict create]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    set reg_forced_renames [list]
</span>     try {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        registry::write {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        registry::read {
</span>             foreach file $imagefiles {
                 incr progress_step
                 _progress update $progress_step $progress_total_steps
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -774,9 +776,12 @@ proc _activate_contents {port {rename_list {}}} {
</span>                     }
                     if {$owner eq {} || ![dict exists $todeactivate $owner]} {
                         if {$force} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                            # if we're forcing the activation, then we move any existing
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                            # If we're forcing the activation, then we move any existing
</span>                             # files to a backup file, both in the filesystem and in the
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                            # registry
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                            # registry. But we need to do the registry part later in the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                            # write transaction so it will be rolled back if anything
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                            # fails. The filesystem part is rolled back in the on error
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                            # clause of the outermost try statement.
</span>                             if {$owner ne {}} {
                                 # Rename all conflicting files for this owner.
                                 set owner_deactivate_paths [list]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -789,13 +794,13 @@ proc _activate_contents {port {rename_list {}}} {
</span>                                         lappend owner_activate_paths $path
                                         set bakfile ${actual_path}${baksuffix}
                                         lappend owner_backup_paths $bakfile
<span style='display:block; white-space:pre;background:#e0ffe0;'>+                                        _progress intermission
</span>                                         ui_warn "File $actual_path already exists.  Moving to: $bakfile."
                                         ::file rename -force -- $actual_path $bakfile
                                         lappend backups $actual_path
                                     }
                                 }
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                                $owner deactivate $owner_deactivate_paths
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                                $owner activate $owner_activate_paths $owner_backup_paths
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                                lappend reg_forced_renames $owner $owner_deactivate_paths $owner_activate_paths $owner_backup_paths
</span>                             } else {
                                 # Just rename this file.
                                 set bakfile ${file}${baksuffix}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -867,6 +872,14 @@ proc _activate_contents {port {rename_list {}}} {
</span>             # Activate it, and catch errors so we can roll-back
 
             try {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+                if {$force} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    # Update registry to reflect renames of any conflicting files that were found
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    foreach {owner owner_deactivate_paths owner_activate_paths owner_backup_paths} $reg_forced_renames {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                        $owner deactivate $owner_deactivate_paths
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                        $owner activate $owner_activate_paths $owner_backup_paths
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    unset reg_forced_renames
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                }
</span>                 $port activate $imagefiles
                 _activate_directories $directories $extracted_dir
                 _activate_files [lmap f $files {string cat ${extracted_dir}${f}}] \
</pre><pre style='margin:0'>

</pre>