<pre style='margin:0'>
Umesh Singla (umeshksingla) pushed a commit to branch gsoc17-migrate
in repository macports-base.

</pre>
<p><a href="https://github.com/macports/macports-base/commit/3df4c764b0db9e80c95a115de09536849970cf58">https://github.com/macports/macports-base/commit/3df4c764b0db9e80c95a115de09536849970cf58</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 3df4c764b0db9e80c95a115de09536849970cf58
</span>Author: umeshksingla <umeshksingla@macports.org>
AuthorDate: Tue Oct 15 11:49:16 2019 +0200

<span style='display:block; white-space:pre;color:#404040;'>    Improve naming and some comments
</span>---
 src/macports1.0/migrate.tcl |  2 +-
 src/macports1.0/restore.tcl | 33 ++++++++++++++++++++-------------
 2 files changed, 21 insertions(+), 14 deletions(-)

<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/migrate.tcl b/src/macports1.0/migrate.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index c4cba52..455ec70 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/migrate.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/migrate.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -127,7 +127,7 @@ namespace eval migrate {
</span>     # @return void on success, raises an error on failure
     proc uninstall_installed {} {
         set options {}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        set portlist [restore::portlist_sort_dependencies_later [registry::entry imaged]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        set portlist [restore::sort_portlist_dependencies_later [registry::entry imaged]]
</span>         foreach port $portlist {
             ui_msg "Uninstalling: [$port name]"
             if {![registry::run_target $port uninstall $options]} {
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/restore.tcl b/src/macports1.0/restore.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index dc86b3c..048c43e 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/restore.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/restore.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -91,7 +91,7 @@ namespace eval restore {
</span>         set snapshot_portlist [$snapshot ports]
 
         ui_msg "Restoring the selected snapshot.."
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        restore_state [$snapshot ports]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        restore_state $snapshot_portlist
</span> 
         return 0
     }
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -108,7 +108,7 @@ namespace eval restore {
</span>         return [registry::snapshot get_all]
     }
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-    proc portlist_sort_dependencies_later {portlist} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    proc sort_portlist_dependencies_later {portlist} {
</span> 
         # Sorts a list of port references such that ports come before
         # their dependencies. Ideal for uninstalling a port.
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -132,12 +132,12 @@ namespace eval restore {
</span>         }
         set ret {}
         foreach port $portlist {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-            portlist_sort_dependencies_later_helper $port entries dependents seen ret
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            sort_portlist_dependencies_later_helper $port entries dependents seen ret
</span>         }
         return $ret
     }
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-    proc portlist_sort_dependencies_later_helper {port up_entries up_dependents up_seen up_retlist} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    proc sort_portlist_dependencies_later_helper {port up_entries up_dependents up_seen up_retlist} {
</span>         upvar 1 $up_seen seen
         if {![info exists seen($port)]} {
             set seen($port) 1
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -146,7 +146,7 @@ namespace eval restore {
</span>             foreach dependent $dependents($name) {
                 if {[info exists entries($dependent)]} {
                     foreach entry $entries($dependent) {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                        portlist_sort_dependencies_later_helper $entry entries dependents seen retlist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                        sort_portlist_dependencies_later_helper $entry entries dependents seen retlist
</span>                     }
                 }
             }
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -155,7 +155,7 @@ namespace eval restore {
</span>     }
 
     proc deactivate_all {} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        set portlist [portlist_sort_dependencies_later [registry::entry imaged]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        set portlist [sort_portlist_dependencies_later [registry::entry imaged]]
</span>         foreach port $portlist {
             ui_msg "Deactivating: [$port name]"
             if {[$port state] eq "installed"} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -166,7 +166,7 @@ namespace eval restore {
</span>         }
     }
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-    proc portlist_sort_dependencies_first {portlist} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    proc sort_portlist_dependencies_first {portlist} {
</span> 
         # Sorts a list of port references such that ports appear after
         # their dependencies. Ideal for installing a port.
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -222,7 +222,7 @@ namespace eval restore {
</span>             }
 
             if {![info exists port_deps(${name},${variants})]} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                set port_deps(${name},${variants}) [portlist_sort_dependencies_first_helper $name $variants]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                set port_deps(${name},${variants}) [sort_portlist_dependencies_first_helper $name $variants]
</span>             }
             lappend new_list [list $name $variants $active]
         }
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -261,7 +261,7 @@ namespace eval restore {
</span>         return $operation_list
     }
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-    proc portlist_sort_dependencies_first_helper {portname variant_info} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    proc sort_portlist_dependencies_first_helper {portname variant_info} {
</span>         set dependency_list [list]
         set port_search_result [mportlookup $portname]
         if {[llength $port_search_result] < 2} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -280,9 +280,13 @@ namespace eval restore {
</span>         set dependency_types { depends_fetch depends_extract depends_build depends_lib depends_run }
         foreach dependency_type $dependency_types {
             if {[info exists portinfo($dependency_type)] && [string length $portinfo($dependency_type)] > 0} {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+                puts "==="
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                puts "dependencies for $portname:"
</span>                 foreach dependency $portinfo($dependency_type) {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                    lappend dependency_list [lindex [split $dependency:] end]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    puts [lindex [split $dependency :] end]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    lappend dependency_list [lindex [split $dependency :] end]
</span>                 }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+                puts "==="
</span>             }
         }
         return $dependency_list
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -297,7 +301,8 @@ namespace eval restore {
</span>             # 1: requested (0/1)
             # 2: state (imaged/installed, i.e. inactive/active)
             # 3: variants
<span style='display:block; white-space:pre;background:#ffe0e0;'>-            if {[lindex $port 1] == 1} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            set requested [lindex $port 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            if {$requested} {
</span>                 # Hide unrequested ports
                 if {[lindex $port 2] eq "installed"} {
                     ui_msg "   [lindex $port 0] [lindex $port 3]"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -307,7 +312,9 @@ namespace eval restore {
</span>             }
         }
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        set sorted_snapshot_portlist [portlist_sort_dependencies_first $snapshot_portlist]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        set sorted_snapshot_portlist [sort_portlist_dependencies_first $snapshot_portlist]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        puts $sorted_snapshot_portlist
</span>         foreach port $sorted_snapshot_portlist {
 
             set name [string trim [lindex $port 0]]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -328,7 +335,7 @@ namespace eval restore {
</span>                 return -code error "lookup of port $name failed: $result"
             }
             if {[llength $res] < 2} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                # not in the index, but we already warned about that earlier
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                # not in the portindex, but we already warned about that earlier
</span>                 continue
             }
             array unset portinfo
</pre><pre style='margin:0'>

</pre>