+ prompt=$(svn_url_needs_creation $svn/$module/imports/after-$next)
+ run_prompt $prompt "Backing up into after-$next" \
+ svn copy $svn/$module/$trunk $svn/$module/imports/after-$next
+
+ run_prompt n "Want to rename $import as $import-to-trash" \
+ mv $import $import-totrash
+
+ echo 'Done'
+}
+
+function tag_usage () {
+ echo "Usage: $0 module"
+ exit 1
+}
+
+function tag_module () {
+
+ [[ -z "$@" ]] && tag_usage
+ module=$1; shift
+ tagwork=$HOME/tags/$module
+ tagtrunk=$HOME/tags/$module/trunk
+ [[ -n "$@" ]] && tag_usage
+
+ echo 'Tagging' $module
+
+ run_prompt $(dir_needs_creation $tagwork) "Creating $tagwork" \
+ mkdir -p $tagwork
+
+ run_prompt $(dir_needs_creation $tagtrunk) "Checking out $tagtrunk" \
+ svn co $svn/$module/trunk $tagtrunk
+
+ run_prompt y "Updating $tagtrunk" \
+ svn up $tagtrunk
+
+ run_prompt $(svn_dir_needs_revert $tagtrunk) "Reverting $tagtrunk for safety " \
+ svn revert -R $tagtrunk
+
+ run "cd $tagtrunk" \
+ cd $tagtrunk
+
+ ### extracting current version info
+ spec=$(figure_module_spec $tagtrunk $module)
+ version=$(extract_from_spec $spec version)
+ subversion=$(extract_from_spec $spec subversion)
+ newsubversion=$(($subversion+1))
+
+ message "FOUND spec=$spec version=$version subversion=$subversion"
+
+ # check that the tags relating to subversion and newsubversion does (resp. does not) exist
+ oldtag=$svn/$module/tags/$module-${version}.${subversion}
+ newtag=$svn/$module/tags/$module-${version}.${newsubversion}
+
+ echo -n "Checking tags status ..."
+ old_check=$(svn_url_check $oldtag)
+ if [ -z "$old_check" ] ; then
+ echo "Former tag does not exist -- exiting"
+ echo "URL was $oldtag"
+ exit 1
+ fi
+ echo -n " old tag OK ... "
+
+ new_check=$(svn_url_check $newtag)
+ if [ -n "$new_check" ] ; then
+ echo "New tag does exist -- exiting"
+ echo "URL was $newtag"
+ exit 1
+ fi
+ echo " new tag OK"
+
+ patch_in_spec $spec subversion $newsubversion
+
+ run_loop "Checking differences" \
+ svn diff $tagtrunk
+
+ run_prompt y "Display differences from previous tag" \
+ svn diff $oldtag $svn/$module/trunk
+
+ run_prompt y "Committing changes in $tagtrunk" \
+ svn ci --editor-cmd=vi $tagtrunk
+
+ # putting spaces in the message does not work
+ run_prompt y "Creating tag $newtag" \
+ svn copy --message "$module-${version}.${newsubversion}" $svn/$module/trunk $newtag
+
+ echo "This command does not handle changes in onelab-tags.mk - yet"
+
+
+}
+
+case $0 in
+ *import-module*)
+ import_module $@;;
+ *tag-module*)
+ tag_module $@;;
+ *test*)
+ x=$(figure_module_spec $@) ; echo $x;;
+ *)
+ echo "Unsupported command $0" ; exit 0
+ esac