Blame Scripts/Bash/Cli/Functions/Manual/manual_deleteEntry.sh

4c79b5
#!/bin/bash
4c79b5
#
742c46
# manual_deleteEntry.sh -- This function removes a documentation entry
5285d6
# from documentation directory structure.
4c79b5
#
9f5f2e
# Copyright (C) 2009-2011 Alain Reguera Delgado
4c79b5
# 
7cd8e9
# This program is free software; you can redistribute it and/or
7cd8e9
# modify it under the terms of the GNU General Public License as
7cd8e9
# published by the Free Software Foundation; either version 2 of the
7cd8e9
# License, or (at your option) any later version.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
742c46
function manual_deleteEntry {
4c79b5
3385aa
    local ENTRY_SRC=${ENTRY}
4c79b5
    local ENTRIES=''
3385aa
    local ENTRY=''
3385aa
    local ENTRY_DEP=''
4c79b5
449927
    # Initiate list of entries to remove using the entry specified in
449927
    # the command line.
3385aa
    ENTRIES=${ENTRY_SRC}
449927
449927
    # Verify existence of dependent entries.  Dependent entries are
449927
    # stored inside a directory with the same name of the entry you
449927
    # are trying to remove.
449927
    if [[ -d ${ENTRY_DIR}/${ENTRY_FILE} ]];then
449927
3385aa
        # Add dependent files to list of entries. 
449927
        ENTRIES="${ENTRIES} $(cli_getFilesList "${ENTRY_DIR}/${ENTRY_FILE}" ".*\.texi")"
449927
3385aa
        # Add dependent directories to list of entries. Be aware of
3385aa
        # nested directories.
3385aa
        for ENTRY in ${ENTRIES};do
3385aa
            ENTRY_DEP=$(echo $ENTRY | sed -r "s/\.texi$//")
3385aa
            if [[ -d $ENTRY_DEP ]];then
3385aa
                ENTRIES="${ENTRIES} ${ENTRY_DEP}"
3385aa
            fi
3385aa
        done
4c79b5
4c79b5
    fi
4c79b5
449927
    # Prepare list of entries for action preamble.
3385aa
    ENTRIES=$(echo ${ENTRIES} | tr ' ' "\n" | sort -r | uniq)
5285d6
    
638bf8
    # Print action preamble.
638bf8
    cli_printActionPreamble "$ENTRIES" 'doDelete' 'AsResponseLine'
638bf8
3385aa
    # Remove documentation entry using regular subversion commands.
3385aa
    # Do not use regular rm command here, use subversion del command
3385aa
    # instead. Otherwise, even the file is removed, it will be brought
3385aa
    # back when the final cli_commitRepoChange be executed. Remember
3385aa
    # there is a subversion update there, no matter what you remove
3385aa
    # using regular commands, when you do update the directory
3385aa
    # structure on the working copy the removed files (not removed in
3385aa
    # the repository, nor marked to be removed) are brought down to
3385aa
    # the working copy again.
3385aa
    svn del ${ENTRIES} --quiet
136786
    if [[ $? -ne 0 ]];then
136786
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
136786
    fi
4456e8
449927
    # Print separator line.
449927
    cli_printMessage '-' 'AsSeparatorLine'
449927
449927
    # Print action message.
3385aa
    cli_printMessage "Updating manual menus, nodes and cross-references." 'AsResponseLine'
449927
449927
    # Process list of entries in order to update menus, nodes and
449927
    # cross references. Since we are verifying entry status before
449927
    # remove the we cannot update the information in the same loop we
449927
    # remove files. This would modify some file before be removed and
449927
    # that would stop script execution. Similary, if we do update
449927
    # menus, nodes and cross references before removing files it would
449927
    # be needed to remove farther status verification in order for the
449927
    # script to continue its execution. Thereby, I can't see a
449927
    # different way but removing files first using status verification
449927
    # and later go through entities list again to update menus, nodes
449927
    # and cross references from remaining files.
3385aa
    for ENTRY in ${ENTRIES};do
3385aa
3385aa
        # Use entry files only. Directories are used to store
3385aa
        # dependent entries. Directories are not considered entries on
3385aa
        # themselves.
3385aa
        if [[ ! -f $ENTRY ]];then
3385aa
            continue
3385aa
        fi
4456e8
449927
        # Update menu and node definitions from manual sections to
449927
        # reflect the changes.
4de5d4
        manual_updateMenu "remove-entry"
4de5d4
        manual_updateNodes
4456e8
449927
        # Update cross reference definitions from manual to reflect
449927
        # the changes.
742c46
        manual_deleteCrossReferences
f8fb31
4456e8
    done
4456e8
 
449927
    # Remove entry menus and nodes from chapter definition to reflect
449927
    # the fact it has been removed.  This is mainly applied when one
449927
    # of the chapters (e.g., trunk/, tags/, or branches/) is removed.
7f7f8f
    if [[ ! -d $MANUAL_CHAPTER_DIR ]];then
4de5d4
        manual_updateChaptersMenu 'remove-entry'
4de5d4
        manual_updateChaptersNodes
4c79b5
    fi
4c79b5
4c79b5
}