sm-commit AT lists.ibiblio.org
Subject: Source Mage code commit list
List archive
[SM-Commit] GIT changes to master sorcery by Jaka Kranjc (eb31808c70e920bec7ba65c2231568084bde4a52)
- From: Jaka Kranjc <scm AT sourcemage.org>
- To: sm-commit AT lists.ibiblio.org
- Subject: [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (eb31808c70e920bec7ba65c2231568084bde4a52)
- Date: Thu, 28 Aug 2008 06:22:13 -0500
GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx AT sourcemage.org>:
ChangeLog | 7 ++++++
var/lib/sorcery/modules/libdepends | 38
+++++++++++++++++++++++++++++++++----
var/lib/sorcery/modules/libhash | 23 ++++++++++++++++++++++
3 files changed, 64 insertions(+), 4 deletions(-)
New commits:
commit eb31808c70e920bec7ba65c2231568084bde4a52
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
libdepends: improved the cleanup algorithm further, now also the
dependencies of removed dependees will be removed, unless they were
specified to cast manually or if some other spell need them; the
dependencies' dependencies get the same treatment #14668/#7164
anyone not confused yet by the overuse of words with the root dep? :)
Example dep tree:
a1 - b1 - c1 -d1
- b2 - c2
- b3
a2 - - c2
a3
you cast a1 a2 a3 and c1 fails horribly. First c1 and d1 (due to the
crash)
and then b1 and a1 (dependees) will be removed and finally their deps -
b2 and b3, but not c2, since a2 needs it and a2 is fine.
So in the end, you'd get asked about casting: c2, a2, a3
commit 4db8f84a7cd87217a437c4e0a58eda07a8ce896b
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
libhash: added hash_unset_part, the opposite of hash_append
diff --git a/ChangeLog b/ChangeLog
index fae538a..b7279b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-08-28 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * libhash: added hash_unset_part, the opposite of hash_append
+ * libdepends: improved the cleanup algorithm further, now also the
+ dependencies of removed dependees will be removed, unless they were
+ specified to cast manually or if some other spell need them; the
+ dependencies' dependencies get the same treatment #14668/#7164
+
2008-08-27 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* libdepends: improved the cleanup algorithm when a spell fails in the
dependency resolution part of cast - now the dependees are really
diff --git a/var/lib/sorcery/modules/libdepends
b/var/lib/sorcery/modules/libdepends
index f4e5370..21f0d72 100755
--- a/var/lib/sorcery/modules/libdepends
+++ b/var/lib/sorcery/modules/libdepends
@@ -1619,11 +1619,11 @@ function depends_message() {
function private_remove_dependees()
{
local spell=$1
- local dependees dependee
+ local removed_list dependee dependees
message "${PROBLEM_COLOR}Removing dependees of
$SPELL_COLOR$spell$DEFAULT_COLOR"
# take care of the spell
- private_remove_dependees_sub $spell
+ private_discard_spell $spell
# take care of the dependees and their dependees and ...
recurse_remove_dependees() {
@@ -1632,7 +1632,8 @@ function private_remove_dependees()
while uncommitted_upward_depends $spell dependees; do
[[ -z $dependees ]] && break
for dependee in $dependees; do
- private_remove_dependees_sub $dependee
+ private_discard_spell $dependee
+ real_list_add removed_list $dependee
recurse_remove_dependees $dependee
done
done
@@ -1640,16 +1641,45 @@ function private_remove_dependees()
recurse_remove_dependees $spell
+ # take care of dependencies of removed dependees
+ # but don't remove them if they were specified manually or
+ # if they wouldn't be cast at all or
+ # if something else needs them
+ recurse_remove_dependencies() {
+ local spell=$1
+ local dependency dependees ignore dependees2
+ # use BACK_CAST_HASH since we've already cleared CAST_HASH
+ # it is in the form of dependency : dependee1 dependee2 ...
+ for dependency in $(hash_get_table_fields $BACK_CAST_HASH); do
+ hash_get_ref $BACK_CAST_HASH $dependency dependees
+ if real_list_find "$dependees" $spell &&
+ hash_get_ref "depends_looked_at" "$dependency" ignore &&
+ [[ $ignore != ignore ]] &&
+ uncommitted_upward_depends $dependency dependees2 &&
+ [[ -z $dependees2 ]] &&
+ ! real_list_find "$SPELLS" $dependency; then
+ hash_unset_part $BACK_CAST_HASH $dependency $spell
+ private_discard_spell $dependency
+ recurse_remove_dependencies $dependency
+ fi
+ done
+ }
+
+ for dependee in $removed_list; do
+ recurse_remove_dependencies $dependee
+ done
}
#---------------------------------------------------------------------
## @param Spell name
## Does the actual removal
#---------------------------------------------------------------------
-function private_remove_dependees_sub()
+function private_discard_spell()
{
local spell=$1
+ grep -qs $spell $FAILED_LIST && return 0
+
# spell is being removed from cast list, add to FAILED_LIST
echo "$spell" >> $FAILED_LIST
hash_put depends_looked_at $spell failed
diff --git a/var/lib/sorcery/modules/libhash b/var/lib/sorcery/modules/libhash
index c987acf..f73b37b 100755
--- a/var/lib/sorcery/modules/libhash
+++ b/var/lib/sorcery/modules/libhash
@@ -214,6 +214,29 @@ function hash_unset() {
unset ${VARIABLE_NAME}
}
+#---------------------------------------------------------------------
+## @param table name
+## @param field name
+## @param item
+##
+## The reverse of hash_append, it removes an item from the field's value.
+##
+#---------------------------------------------------------------------
+function hash_unset_part() {
+ local VARIABLE_NAME
+ local old_value
+ local item=$3
+ hash_build_variable_name "$1" "$2" VARIABLE_NAME
+ old_value=${!VARIABLE_NAME}
+ if [[ -n $old_value ]] && real_list_find "$old_value" "$item"; then
+ real_list_remove old_value "$item"
+ if [[ -n $old_value ]]; then
+ upvar $VARIABLE_NAME "$old_value"
+ else
+ unset $VARIABLE_NAME
+ fi
+ fi
+}
#---------------------------------------------------------------------
## @param table name
- [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (eb31808c70e920bec7ba65c2231568084bde4a52), Jaka Kranjc, 08/28/2008
Archive powered by MHonArc 2.6.24.