diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo_deleteEntry.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo_deleteEntry.sh index 9c4441c..e03f1fd 100755 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo_deleteEntry.sh +++ b/Scripts/Functions/Help/Backends/Texinfo/texinfo_deleteEntry.sh @@ -25,39 +25,65 @@ function texinfo_deleteEntry { + local ENTRY='' + local ENTRY_DIR='' + local ENTRY_SUBDIR='' + + # Define list of entries to remove using the entry specified in + # the command line. + local ENTRIES=$(${FLAG_BACKEND}_getEntry "${ACTIONVALS[*]}") + + # Define path to directory where repository documentation entries + # are stored in. As reference, take the first non-option argument + # passed to centos-art.sh script. Since all action values point to + # directories inside the working copy, no matter what non-option + # argument do we use as reference to determine the manual chapter + # directory used to store documentation entries in. + local MANUAL_CHAPTER_DIR=$(${FLAG_BACKEND}_getChapterDir "$ENTRIES") + + # Syncronize changes between repository and working copy. At this + # point, changes in the repository are merged in the working copy + # and changes in the working copy committed up to repository. + cli_syncroRepoChanges ${MANUAL_CHAPTER_DIR} + # Print separator line. cli_printMessage '-' --as-separator-line - local ENTRY_SRC=${ENTRY} - local ENTRIES='' - local ENTRY='' - local ENTRY_DEP='' + # Define list of dependen entries. Dependent entries are stored + # inside a directory with the same name of the entry being + # removed. + for ENTRY in $ENTRIES;do - # Initiate list of entries to remove using the entry specified in - # the command line. - ENTRIES=${ENTRY_SRC} + # Define directory where dependent documentation entries are + # stored in. + ENTRY_DIR=$(echo $ENTRY | sed -r "s/\.${FLAG_BACKEND}$//") - # Verify existence of dependent entries. Dependent entries are - # stored inside a directory with the same name of the entry you - # are trying to remove. - if [[ -d ${ENTRY_DIR}/${ENTRY_FILE} ]];then + if [[ -d $ENTRY_DIR ]];then - # Add dependent files to list of entries. - ENTRIES="${ENTRIES} $(cli_getFilesList ${ENTRY_DIR}/${ENTRY_FILE} --pattern=".*\.${FLAG_BACKEND}")" + # Add dependent documentation entries to the list of + # documentation entries that will be deleted. + ENTRIES="${ENTRIES} $(cli_getFilesList ${ENTRY_DIR} --pattern=".*\.${FLAG_BACKEND}")" - # Add dependent directories to list of entries. Be aware of - # nested directories. - for ENTRY in ${ENTRIES};do - ENTRY_DEP=$(echo $ENTRY | sed -r "s/\.${FLAG_BACKEND}$//") - if [[ -d $ENTRY_DEP ]];then - ENTRIES="${ENTRIES} ${ENTRY_DEP}" - fi - done + for ENTRY in $ENTRIES;do - fi + # Define directory name for dependent documentation + # entries which have their own dependent directories. + ENTRY_SUBDIR=$(basename $ENTRY | sed -r "s/\.${FLAG_BACKEND}$//") + + # Add directory paths from dependent documentation + # entries which have their own dependent directories + # to the list of documentation entries that will be + # deleted. + ENTRIES="${ENTRIES} $(cli_getFilesList ${ENTRY_DIR} --pattern=".*/${ENTRY_SUBDIR}" --type='d')" + + done + + fi - # Prepare list of entries for action preamble. - ENTRIES=$(echo ${ENTRIES} | tr ' ' "\n" | sort -r | uniq) + done + + # Sanitate list of documentation entries that will be removed. + ENTRIES=$(echo ${ENTRIES} | tr ' ' "\n" | sort -r | uniq | tr "\n" ' ') # Print action preamble. cli_printActionPreamble $ENTRIES --to-delete @@ -68,16 +94,17 @@ function texinfo_deleteEntry { svn del ${ENTRIES} --quiet # Verify exit status from subversion command to be sure everything - # went well. Otherwhise stop script execution. + # went well. Otherwise stop script execution with an error + # message. if [[ $? -ne 0 ]];then - cli_printMessage "${FUNCDIRNAM}" --as-toknowmore-line + cli_printMessage "`gettext "An error occurred when deleting entries."`" --as-toknowmore-line fi # Print separator line. cli_printMessage '-' --as-separator-line # Print action message. - cli_printMessage "Updating menus, nodes and cross-references." '--as-response-line' + cli_printMessage "`gettext "Updating menus, nodes and cross-references."`" --as-response-line # Process list of entries in order to update menus, nodes and # cross references. Since we are verifying entry status before @@ -92,18 +119,30 @@ function texinfo_deleteEntry { # and cross references in remaining files. for ENTRY in ${ENTRIES};do + # Skip all directories, they are not documentation entries on + # themselves. Use documentation entries only. + if [[ ! $ENTRY =~ "\.${FLAG_BACKEND}$" ]];then + continue + fi + # Update menu and node definitions from manual sections to # reflect the changes. - texinfo_updateMenu "remove-entry" - texinfo_updateNodes + ${FLAG_BACKEND}_updateMenu "remove-entry" + ${FLAG_BACKEND}_updateNodes # Update cross reference definitions from manual to reflect # the changes. - texinfo_deleteCrossReferences + ${FLAG_BACKEND}_deleteCrossReferences done + # Commit changes from working copy to central repository only. At + # this point, changes in the repository are not merged in the + # working copy, but chages in the working copy do are committed up + # to repository. + cli_commitRepoChanges ${MANUAL_CHAPTER_DIR} + # Rebuild output files to propagate recent changes. - texinfo_updateOutputFiles + ${FLAG_BACKEND}_updateOutputFiles }