[118304] trunk/base/src

cal at macports.org cal at macports.org
Sat Mar 29 12:21:58 PDT 2014


Revision: 118304
          https://trac.macports.org/changeset/118304
Author:   cal at macports.org
Date:     2014-03-29 12:21:58 -0700 (Sat, 29 Mar 2014)
Log Message:
-----------
base: Delay displaying notes for installed ports until the end of the current operation

Mostly written by Jeremy Lavergne (snc).

Modified Paths:
--------------
    trunk/base/src/macports1.0/macports.tcl
    trunk/base/src/port/port.tcl
    trunk/base/src/port1.0/portactivate.tcl

Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl	2014-03-29 19:20:00 UTC (rev 118303)
+++ trunk/base/src/macports1.0/macports.tcl	2014-03-29 19:21:58 UTC (rev 118304)
@@ -1294,6 +1294,14 @@
         $workername alias ui_progress_download $macports::ui_options(progress_download)
     }
 
+    # notifications callback
+    if {[info exists macports::ui_options(notifications_append)]} {
+        $workername alias ui_notifications_append $macports::ui_options(notifications_append)
+    } else {
+        # provide a no-op if notifications_append wasn't set. See http://wiki.tcl.tk/3044
+        $workername alias ui_notifications_append return -level 0
+    }
+
     $workername alias ui_prefix ui_prefix
     $workername alias ui_channels ui_channels
 

Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl	2014-03-29 19:20:00 UTC (rev 118303)
+++ trunk/base/src/port/port.tcl	2014-03-29 19:21:58 UTC (rev 118304)
@@ -4639,6 +4639,9 @@
             registry::exclusive_unlock
         }
 
+        # Print notifications of just-activated ports.
+        portclient::notifications::display
+
         # semaphore to exit
         if {$action_status == -999} break
     }
@@ -5167,7 +5170,75 @@
     }
 }
 
+namespace eval portclient::notifications {
+    ##
+    # Ports whose notifications to display; these were either installed
+    # or requested to be installed.
+    variable notificationsToPrint
+    array set notificationsToPrint {}
 
+    ##
+    # Add a port to the list for printing notifications.
+    #
+    # @param name
+    #        The name of the port.
+    # @param note
+    #        A list of notes to be stored for the given port.
+    proc append {name notes} {
+        variable notificationsToPrint
+
+        set notificationsToPrint($name) $notes
+    }
+
+    ##
+    # Print port notifications.
+    #
+    proc display {} {
+        global env
+        variable notificationsToPrint
+
+        # Display notes at the end of the activation phase.
+        if {[array size notificationsToPrint] > 0} {
+            ui_notice "--->  Some of the ports you installed have notes:"
+            foreach {name notes} [array get notificationsToPrint] {
+                ui_notice "  $name has the following notes:"
+
+                # If env(COLUMNS) exists, limit each line's width to this width.
+                if {[info exists env(COLUMNS)]} {
+                    set maxlen $env(COLUMNS)
+
+                    foreach note $notes {
+                        foreach line [split $note "\n"] {
+                            set joiner ""
+                            set lines ""
+                            set newline "    "
+
+                            foreach word [split $line " "] {
+                                if {[string length $newline] + [string length $word] >= $maxlen} {
+                                    lappend lines $newline
+                                    set newline "    "
+                                    set joiner ""
+                                }
+                                ::append newline $joiner $word
+                                set joiner " "
+                            }
+                            if {$newline ne {}} {
+                                lappend lines $newline
+                            }
+                            ui_notice [join $lines "\n"]
+                        }
+                    }
+                } else {
+                    foreach note $notes {
+                        ui_notice $note
+                    }
+                }
+            }
+        }
+    }
+}
+
+
 ##########################################
 # Main
 ##########################################
@@ -5222,6 +5293,8 @@
     set ui_options(progress_generic)  portclient::progress::generic
 }
 
+set ui_options(notifications_append) portclient::notifications::append
+
 # Get arguments remaining after option processing
 set remaining_args [lrange $cmd_argv $cmd_argn end]
 

Modified: trunk/base/src/port1.0/portactivate.tcl
===================================================================
--- trunk/base/src/port1.0/portactivate.tcl	2014-03-29 19:20:00 UTC (rev 118303)
+++ trunk/base/src/port1.0/portactivate.tcl	2014-03-29 19:21:58 UTC (rev 118304)
@@ -60,42 +60,11 @@
 }
 
 proc portactivate::activate_main {args} {
-    global env subport version revision portvariants user_options PortInfo startupitem.autostart UI_PREFIX
+    global subport version revision portvariants user_options PortInfo
 
     registry_activate $subport $version $revision $portvariants [array get user_options]
-
-    # Display notes at the end of the activation phase.
-    if {[info exists PortInfo(notes)] && $PortInfo(notes) ne {}} {
-        ui_notice ""
-        foreach note $PortInfo(notes) {
-            # If env(COLUMNS) exists, limit each line's width to this width.
-            if {[info exists env(COLUMNS)]} {
-                set maxlen $env(COLUMNS)
-
-                foreach line [split $note "\n"] {
-                    set joiner ""
-                    set lines ""
-                    set newline ""
-
-                    foreach word [split $line " "] {
-                        if {[string length $newline] + [string length $word] >= $maxlen} {
-                            lappend lines $newline
-                            set newline ""
-                            set joiner ""
-                        }
-                        append newline $joiner $word
-                        set joiner " "
-                    }
-                    if {$newline ne {}} {
-                        lappend lines $newline
-                    }
-                    ui_notice [join $lines "\n"]
-                }
-            } else {
-                ui_notice $note
-            }
-        }
-        ui_notice ""
+    if {[info exists PortInfo(notes)] && [llength $PortInfo(notes)] > 0} {
+        ui_notifications_append $subport $PortInfo(notes)
     }
 
     return 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140329/46efe028/attachment.html>


More information about the macports-changes mailing list