pff: support des filtres à l'intégration
This commit is contained in:
parent
ee3b58354c
commit
13440e2fd9
78
pff
78
pff
|
@ -24,6 +24,7 @@ PFFCONFVARS=(
|
||||||
"PROFILES//Profils définis"
|
"PROFILES//Profils définis"
|
||||||
"ORIGEXTS=//Extensions origines"
|
"ORIGEXTS=//Extensions origines"
|
||||||
"MKDIRS//Répertoires qui doivent toujours exister"
|
"MKDIRS//Répertoires qui doivent toujours exister"
|
||||||
|
"FILTERS//Filtres appliqués aux fichiers lors de l'intégration"
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
|
if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
|
||||||
|
@ -110,7 +111,7 @@ complete -F __pff_completion -o bashdefault -o default pff
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
|
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
|
||||||
urequire DEFAULTS multiconf vcs
|
urequire DEFAULTS multiconf vcs javaproperties
|
||||||
|
|
||||||
function display_help() {
|
function display_help() {
|
||||||
uecho "$scriptname: gestion de modifications locales
|
uecho "$scriptname: gestion de modifications locales
|
||||||
|
@ -528,6 +529,37 @@ function autofix() {
|
||||||
autoselect "$1"
|
autoselect "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Filtres
|
||||||
|
|
||||||
|
function pff_filter_normalize_properties() {
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
__norm_properties
|
||||||
|
else
|
||||||
|
local mode r
|
||||||
|
mode="$(fix_mode "$1")"
|
||||||
|
norm_properties "$1"; r=$?
|
||||||
|
unfix_mode "$1" "$mode"
|
||||||
|
return $r
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function apply_filter() {
|
||||||
|
# Appliquer les filtres définis au fichier $1 dans le projet pff $2
|
||||||
|
# retourner 0 si un filtre a été appliqué avec succès, 1 si une erreur s'est
|
||||||
|
# produite, 2 si aucun filtre n'existe pour ce fichier
|
||||||
|
local pfile="$1" pffdir="$2"
|
||||||
|
local rfile ffile filter r=2
|
||||||
|
setx rfile=get_rfile "$pfile" "$pffdir"
|
||||||
|
for filter in "${FILTERS[@]}"; do
|
||||||
|
splitpair "$filter" ffile filter
|
||||||
|
if [ "$ffile" == "$rfile" ]; then
|
||||||
|
"pff_filter_$filter" "$pfile" && r=0 || r=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return $r
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Commandes
|
# Commandes
|
||||||
|
|
||||||
|
@ -756,12 +788,17 @@ function new_cmd() {
|
||||||
ebegin "Copie des fichiers"
|
ebegin "Copie des fichiers"
|
||||||
r=0
|
r=0
|
||||||
for i in "${creates[@]}"; do
|
for i in "${creates[@]}"; do
|
||||||
mkdirof "$pffdir/$i"; r=$?
|
src="$srcdir/$i"
|
||||||
edot $r "$i"; [ $r == 0 ] || break
|
dest="$pffdir/$i"
|
||||||
cp "$srcdir/$i" "$pffdir/$i"; r=$?
|
mkdirof "$dest"; r=$?
|
||||||
edot $r "$i"; [ $r == 0 ] || break
|
edot $r "mkdirof $i"; [ $r -eq 0 ] || break
|
||||||
|
cp "$src" "$dest"; r=$?
|
||||||
|
edot $r "create $i"; [ $r -eq 0 ] || break
|
||||||
|
apply_filter "$dest" "$pffdir"; r=$?
|
||||||
|
[ $r -eq 0 -o $r -eq 1 ] && edot $r "filter $i"
|
||||||
|
[ $r -eq 2 ] && r=0; [ $r -eq 0 ] || break
|
||||||
done
|
done
|
||||||
[ $r == 0 ] || { eend $r; return 1; }
|
[ $r -eq 0 ] || { eend $r; return 1; }
|
||||||
for i in "${updates[@]}"; do
|
for i in "${updates[@]}"; do
|
||||||
src="$srcdir/$i"
|
src="$srcdir/$i"
|
||||||
dest="$pffdir/$i"
|
dest="$pffdir/$i"
|
||||||
|
@ -771,14 +808,17 @@ function new_cmd() {
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
cat "$src" >"$dest"; r=$?
|
cat "$src" >"$dest"; r=$?
|
||||||
edot $r "$i"; [ $r == 0 ] || break
|
edot $r "update $i"; [ $r -eq 0 ] || break
|
||||||
|
apply_filter "$dest" "$pffdir"; r=$?
|
||||||
|
[ $r -eq 0 -o $r -eq 1 ] && edot $r "filter $i"
|
||||||
|
[ $r -eq 2 ] && r=0; [ $r -eq 0 ] || break
|
||||||
done
|
done
|
||||||
[ $r == 0 ] || { eend $r; return 1; }
|
[ $r -eq 0 ] || { eend $r; return 1; }
|
||||||
if [ -n "$full" ]; then
|
if [ -n "$full" ]; then
|
||||||
# ne faire les suppression qu'en mode full
|
# ne faire les suppression qu'en mode full
|
||||||
for i in "${deletes[@]}"; do
|
for i in "${deletes[@]}"; do
|
||||||
rm "$pffdir/$i"; r=$?
|
rm "$pffdir/$i"; r=$?
|
||||||
edot $r "$i"; [ $r == 0 ] || break
|
edot $r "delete $i"; [ $r -eq 0 ] || break
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
eend $r
|
eend $r
|
||||||
|
@ -847,13 +887,16 @@ function new_cmd() {
|
||||||
src="$srcdir/${losrcs[$i]}"
|
src="$srcdir/${losrcs[$i]}"
|
||||||
dest="$pffdir/$i"
|
dest="$pffdir/$i"
|
||||||
mkdirof "$dest"; r=$?
|
mkdirof "$dest"; r=$?
|
||||||
edot $r "$i"; [ $r == 0 ] || break
|
edot $r "mkdirof $i"; [ $r -eq 0 ] || break
|
||||||
cp "$src" "$dest"; r=$?
|
cp "$src" "$dest"; r=$?
|
||||||
edot $r "$i"; [ $r == 0 ] || break
|
edot $r "create $i"; [ $r -eq 0 ] || break
|
||||||
|
apply_filter "$dest" "$pffdir"; r=$?
|
||||||
|
[ $r -eq 0 -o $r -eq 1 ] && edot $r "filter $i"
|
||||||
|
[ $r -eq 2 ] && r=0; [ $r -eq 0 ] || break
|
||||||
add_global__link "$dest" "$pffdir"
|
add_global__link "$dest" "$pffdir"
|
||||||
edot $r "$i"; [ $r == 0 ] || break
|
edot $r "add_global $i"; [ $r -eq 0 ] || break
|
||||||
done
|
done
|
||||||
[ $r == 0 ] || { eend $r; return 1; }
|
[ $r -eq 0 ] || { eend $r; return 1; }
|
||||||
for i in "${updates[@]}"; do
|
for i in "${updates[@]}"; do
|
||||||
# du fait qu'on intègre fdeletes dans fupdates, il est possible que
|
# du fait qu'on intègre fdeletes dans fupdates, il est possible que
|
||||||
# le fichier n'existe pas dans la source. de plus, l'association
|
# le fichier n'existe pas dans la source. de plus, l'association
|
||||||
|
@ -868,13 +911,16 @@ function new_cmd() {
|
||||||
dest="$pffdir/pff/Base/$vlfile"
|
dest="$pffdir/pff/Base/$vlfile"
|
||||||
if flexists "$src"; then
|
if flexists "$src"; then
|
||||||
mkdirof "$dest"; r=$?
|
mkdirof "$dest"; r=$?
|
||||||
edot $r "$i"; [ $r == 0 ] || break
|
edot $r "mkdirof $vlfile"; [ $r -eq 0 ] || break
|
||||||
cp "$src" "$dest"; r=$?
|
cp "$src" "$dest"; r=$?
|
||||||
edot $r "$i"; [ $r == 0 ] || break
|
edot $r "create $vlfile"; [ $r -eq 0 ] || break
|
||||||
|
apply_filter "$dest" "$pffdir"; r=$?
|
||||||
|
[ $r -eq 0 -o $r -eq 1 ] && edot $r "filter $vlfile"
|
||||||
|
[ $r -eq 2 ] && r=0; [ $r -eq 0 ] || break
|
||||||
array_add vlfiles "$vlfile"
|
array_add vlfiles "$vlfile"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
[ $r == 0 ] || { eend $r; return 1; }
|
[ $r -eq 0 ] || { eend $r; return 1; }
|
||||||
eend $r
|
eend $r
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue