[SM-Commit] GIT changes to devel sorcery by Andrew Stitt (dae12ebf0f9d6aa00f75650dc6f54d7bde5358d6)

Andrew Stitt scm at mail.sourcemage.org
Thu Jun 8 02:20:17 EDT 2006


GIT changes to devel sorcery by Andrew Stitt <astitt at sourcemage.org>:

 ChangeLog                          |    9 +++++
 usr/sbin/gaze                      |   35 +++-------------------
 var/lib/sorcery/modules/libapi     |   15 +++++++++
 var/lib/sorcery/modules/libdepends |   57 ++++++++++++++++++++-----------------
 4 files changed, 61 insertions(+), 55 deletions(-)

New commits:
commit dae12ebf0f9d6aa00f75650dc6f54d7bde5358d6
Author: Andrew Stitt <astitt at sourcemage.org>
Commit: Andrew Stitt <astitt at sourcemage.org>

    fix bug 10297 and re-arrange show_depends/fast_up_depends stuff

diff --git a/ChangeLog b/ChangeLog
index e0b4b45..cf0fdb6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-06-07 Andrew Stitt <astitt at sourcemage.org>
+	* libdepends: replace show_depends with show_up_depends (maybe
+	  we'll have a show_down_depends). Use fast implementation from
+	  fast_up_depends as it is more correct.
+	* gaze: fix bug 10297, and remove fast_up_depends since it is
+	  now the main implementation.
+	* libapi: expose show_up_depends as the spell api for gaze depends
+	  functionality.
+
 2006-06-03 Andrew Stitt <astitt at sourcemage.org>
 	* libdepends: fix bug 12603, optional depends on a provider does not
 	  properly remember defaults of none.
diff --git a/usr/sbin/gaze b/usr/sbin/gaze
index 9bc38a3..84856e1 100755
--- a/usr/sbin/gaze
+++ b/usr/sbin/gaze
@@ -1461,41 +1461,16 @@ function gaze_show_depends() {
         break
     done
     local spell=$1
-    local MAX_DEPTH=$2 #as a global for show_depends.
     codex_does_spell_exist "$spell"  &&
-    if [[ $fast == yes ]] ; then
-      fast_up_depends "$spell" | sort
+    if [[ "$GAZE_VERBOSE" == 0 ]] || [[ "$fast" ]]; then
+      show_up_depends "$1" "$2" "$fast"
     else
-      show_depends "$spell" | sort | uniq
+      show_up_depends  "$1" "$2" |
+      awk -F: '{ printf("%s depends on %s (%s)\n",$1,$2,$4);}'
     fi
-}
 
-#-----
-## Display the spells that depend on the current spell
-## recurses up the dependency tree
-## @param spell to display
-#-----
-function fast_up_depends () { 
-    local i=0
-    function fast_up_depends_sub () { 
-        let i++
-        [[ $MAX_DEPTH ]] && [[ $i -gt $MAX_DEPTH ]] && return
-        for each in $(hash_get foo $1); do
-            if ! [[ $(hash_get done $each) ]] ; then
-                hash_put done $each done
-                echo $each
-                fast_up_depends_sub $each
-            fi
-        done
-    }
-    hash_reset foo
-    hash_reset done
-    compute_reverse_installed_depends foo
-    fast_up_depends_sub "$1"
-    hash_reset foo
-    hash_reset done
-}
 
+}
 
 #-----
 ##
diff --git a/var/lib/sorcery/modules/libapi b/var/lib/sorcery/modules/libapi
index 8e555ab..2cbf515 100755
--- a/var/lib/sorcery/modules/libapi
+++ b/var/lib/sorcery/modules/libapi
@@ -73,6 +73,7 @@ #    runtime_depends        (libdepends)
 #    rm_source_dir          (libgrimoire)
 #    sedit                  (libmisc)       
 #    sub_depends            (libdepends)
+#    show_depends           (libdepends)
 #    spell_exiled           (libstate)
 #    spell_held             (libstate)
 #    spell_installed        (libstate)
@@ -1007,6 +1008,20 @@ function sedit () {
 #---------------------------------------------------------------------
 ## @Type API
 ## @param spell name
+## @param max depth
+## @param fast (optional)
+## @See <@function var.lib.sorcery.modules.libdepends.html,real_show_up_depends> for more details.
+##
+## @stdout recursibely prints out the spell that depend on the specified spell
+#---------------------------------------------------------------------
+function show_up_depends() {
+    debug "libapi" "spell_ok - $*"
+    real_show_up_depends "$@"
+}
+
+#---------------------------------------------------------------------
+## @Type API
+## @param spell name
 ## @See <@function var.lib.sorcery.modules.libstate.html,real_spell_installed> for more details.
 ##
 ## @return 0 if the given spell's status is "installed"
diff --git a/var/lib/sorcery/modules/libdepends b/var/lib/sorcery/modules/libdepends
index 6cee737..fb62b24 100755
--- a/var/lib/sorcery/modules/libdepends
+++ b/var/lib/sorcery/modules/libdepends
@@ -1578,36 +1578,43 @@ function run_spell_config() 
 }
 
 #---------------------------------------------------------------------
-# i dont know if this should be here
+## Output the upward dependencies of the specified spell
+## @Param spell
+## @Param depth (optional)
+## @Param fast -- if set only show spells, not full depends db entries
 #---------------------------------------------------------------------
-function show_depends()  
+function real_show_up_depends()  
 {
-  debug "libdepends" "show_depends() - $@"
-  local DEP_SPELL=`esc_str $1`
-  local DEPTH=$2
-
-  if  !  echo  "$DONE"  |  grep  -q  "$DEP_SPELL";  then
-    DONE="$DONE  $1"
-
-    function ld99()  {
-
-     [[ $MAX_DEPTH ]] && [[ $DEPTH -ge $MAX_DEPTH ]] && return 1
- 
-      SPELL=`echo  $1 |  cut  -d :  -f1`
-      STATUS=`echo  $1  |  cut  -d :  -f3`
-
-      if    [  "$STATUS"  ==  "on"  ]; then
-        echo          $1 
-        show_depends  $SPELL $(( DEPTH + 1 ))
-      fi
-      
+    local i=0
+    local MAX_DEPTH=$2
+    local fast=$3
+    function show_up_depends_sub() {
+        local each
+        let i++
+        [[ $MAX_DEPTH ]] && [[ $i -gt $MAX_DEPTH ]] && return
+        for each in $(hash_get foo $1); do
+            if ! [[ $(hash_get done $each) ]] ; then
+                hash_put done $each done
+                echo $each:$1
+                show_up_depends_sub $each
+            fi
+        done
     }
-    
-    iterate "ld99" $'\n' "$(grep  ":$DEP_SPELL\(([^:]*)\)\?:" $DEPENDS_STATUS)"
-
-  fi
+    hash_reset foo
+    hash_reset done
+    compute_reverse_installed_depends foo
+    if [[ $fast ]] ; then
+      show_up_depends_sub "$1"|cut -f1 -d:
+    else 
+      show_up_depends_sub "$1"|while read line; do
+        grep "$line" "$DEPENDS_STATUS"
+      done
+    fi|sort|uniq
+    hash_reset foo
+    hash_reset done
 }
 
+
 #---------------------------------------------------------------------
 ##=back
 ##



More information about the SM-Commit mailing list