<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/8cc972dd98bf3c69bb6dc2e8dce10f9264401538">https://github.com/macports/macports-base/commit/8cc972dd98bf3c69bb6dc2e8dce10f9264401538</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 8cc972dd98bf3c69bb6dc2e8dce10f9264401538
</span>Author: Umesh Singla <umeshksingla@macports.org>
AuthorDate: Sat Aug 5 00:29:44 2017 +0530
<span style='display:block; white-space:pre;color:#404040;'> sorting ports finalized for installation and uninstallation
</span>---
src/macports1.0/migrate.tcl | 104 +++++++++++++++++++++++++++++++-------------
1 file changed, 74 insertions(+), 30 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 333dd91..357a27f 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;'>@@ -50,19 +50,35 @@ namespace eval migrate {
</span> # $portlist
set portlist [registry::entry imaged]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set portlist1 [sort_portlist_by_dependendents $portlist]
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set portlist2 [sort_ports $portlist]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach port $portlist {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #puts [$port name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- puts $portlist
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts $portlist1
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts $portlist2
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts "here"
</span> puts
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ #set portlist1 [sort_portlist_by_dependendents $portlist]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts "here1"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portlist2 [sort_ports $portlist]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts "here2"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # foreach port $portlist1 {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # puts $port
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # puts
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach port $portlist2 {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #puts [lindex $port 0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uninstall_installed $portlist
</span> return 0
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # uninstall_installed $portlist
</span> # sort_ports $portlist
# recover_ports_state $portlist
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -108,10 +124,19 @@ namespace eval migrate {
</span>
foreach port $portlist {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set name [lindex $port 0]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set version [lindex $port 1]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set variants [lindex $port 2]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set active [lindex $port 3]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #puts "in - "
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #puts $port
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set name [$port name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set version [$port version]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set variants [$port variants]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set active 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[$port state] eq "installed"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set active 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #puts "$name $version $variants $active"
</span>
if {![info exists port_in_list($name)]} {
set port_in_list($name) 1
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -124,16 +149,24 @@ namespace eval migrate {
</span> set port_deps(${name},${variants}) [dependenciesForPort $name $variants]
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend newList [list $active $name $variants]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #puts "$port_deps(${name},$variants)"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend newList [list $name $variants $active]
</span> }
set operationList [list]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> while {[llength $newList] > 0} {
set oldLen [llength $newList]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> foreach port $newList {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach {active name variants} $port break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach {name variants active} $port break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #puts "out - "
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #puts "$name $variants $active"
</span>
if {$active && $port_installed($name) < ($port_in_list($name) - 1)} {
continue
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -146,6 +179,7 @@ namespace eval migrate {
</span> }
}
if {$installable} {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ #puts "i'm being installed: $name"
</span> lappend operationList [list $name $variants $active]
incr port_installed($name)
set index [lsearch $newList [list $name $variants $active]]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -153,6 +187,8 @@ namespace eval migrate {
</span> }
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ #puts "lengths: $oldLen [llength $newList]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> if {[llength $newList] == $oldLen} {
return -code error "stuck in loop"
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -161,10 +197,10 @@ namespace eval migrate {
</span> return $operationList
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- proc sort_portlist_by_dependendents { portlist } {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc portlist_sortdependents { portlist } {
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # Sorts a list of port references such that dependents appear before
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # the ports they depend on.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Sorts a list of port references such that dependents come before
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # their dependencies.
</span> #
# Args:
# portlist - the list of port references
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -173,33 +209,35 @@ namespace eval migrate {
</span> # the list in dependency-sorted order
foreach port $portlist {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set portname [$port name]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend ports_for_name($portname) $port
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set pvals $port
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend entries($pvals(name)) $port
</span>
# Avoid adding ports in loop
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![info exists dependents($portname)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set dependents($portname) {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![info exists dependents($pvals(name))]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set dependents($pvals(name)) {}
</span> foreach result [$port dependents] {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend dependents($portname) [$result name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend dependents($pvals(name)) [$result name]
</span> }
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ array unset pvals
</span> }
set ret {}
foreach port $portlist {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- sortdependents_helper $port ports_for_name dependents seen ret
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ portlist_sortdependents_helper $port entries dependents seen ret
</span> }
return $ret
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- proc sortdependents_helper {port up_ports_for_name up_dependents up_seen up_retlist} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc portlist_sortdependents_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:#ffe0e0;'>- upvar 1 $up_ports_for_name ports_for_name $up_dependents dependents $up_retlist retlist
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach dependent $dependents([$port name]) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists ports_for_name($dependent)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach entry $ports_for_name($dependent) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- sortdependents_helper $entry ports_for_name dependents seen retlist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ upvar 1 $up_entries entries $up_dependents dependents $up_retlist retlist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set pvals $p
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach dependent $dependents($pvals(name)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists entries($dependent)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach entry $entries($dependent) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ portlist_sortdependents_helper $entry entries dependents seen retlist
</span> }
}
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -209,7 +247,13 @@ namespace eval migrate {
</span>
proc uninstall_installed { portlist } {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set portlist [sort_portlist_by_dependendents $portlist]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portlist [portlist_sortdependents $portlist]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach port $portlist {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts "[$port name] [$port state]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0
</span>
if {[info exists macports::ui_options(questions_yesno)]} {
</pre><pre style='margin:0'>
</pre>