Changeset 455


Ignore:
Timestamp:
10/05/2009 00:20:42 (3 years ago)
Author:
blee
Message:

Merge from trunk bulk operations for create, rmmod, and recipe remove.

Fixes #72

Location:
branches/confman-1.9
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/confman-1.9

  • branches/confman-1.9/confman.8.in

    r418 r455  
    150150Displays the log entires for the file or directory specified by  
    151151.Ar working_copy . 
    152 .It Cm create Ar module 
    153 A new module, named  
    154 .Ar module ,  
    155 will appear as a top-level-directory in your working copy. This change will 
    156 also be committed to the repository at the same time. 
    157 .It Cm rmmod Ar module 
    158 Delete the specified  
     152.It Cm create Ar module [ Ar module Ar ... ] 
     153Creates one or more modules for the 
     154.Ar module 
     155arguments provided.  New modules will appear in the top-level-directory of 
     156your working copy.  This change will also be committed to the repository 
     157at the same time. 
     158.It Cm rmmod Ar module [ Ar module Ar ... ] 
     159Delete the modules corresponding to the specified  
    159160.Ar module  
    160 from your working copy. Follow this action with a revert or commit operation. 
     161arguments from your working copy. Follow this action with a revert or 
     162commit operation. 
    161163.It Cm rename Ar oldmodule newmodule 
    162164Rename  
  • branches/confman-1.9/confman.in

    r448 r455  
    9090    else 
    9191        conf_lock_wcopy 
    92         local module=$1 
    93         conf_create_module $module || exit 1 
     92        conf_create_modules "$@" || exit 1 
    9493        conf_unlock_wcopy 
    9594    fi 
     
    745744 
    746745function rmmod { 
    747     local module=$1 
    748     if [ -z $module ] ; then 
    749         print_usage 1 
    750     fi 
    751     conf_lock_wcopy 
    752     conf_rmmod $module 
    753     conf_unlock_wcopy 
     746    if [ -z "$*" ] ; then 
     747        print_usage 1 
     748    else 
     749        conf_lock_wcopy 
     750        conf_remove_modules "$@" || exit 1 
     751        conf_unlock_wcopy 
     752    fi 
    754753} 
    755754 
     
    918917 
    919918function recipe_remove { 
    920     if [ -z "$1" ] ; then print_usage 1 ; fi 
    921     local recipe="$1" 
    922     conf_remove_recipe "$recipe" 
     919    if [ -z "$*" ] ; then print_usage 1 ; fi 
     920    conf_remove_recipes "$@" || exit 1 
    923921} 
    924922 
  • branches/confman-1.9/confmandoc.sh

    r448 r455  
    4141  $MYNAME audit 
    4242  $MYNAME log [ working_copy ] 
    43   $MYNAME create module 
    44   $MYNAME rmmod module 
     43  $MYNAME create module [ module ... ] 
     44  $MYNAME rmmod module [ module ... ] 
    4545  $MYNAME rename oldmodule newmodule 
    4646  $MYNAME import module livefile 
     
    102102 
    103103Usage: 
    104   $MYNAME create module 
    105  
    106 The create command will cause a new module, named module, to appear as a 
    107 top-level-directory in your working copy. This change will also be made to 
    108 the repositry at the same time.  
     104  $MYNAME create module [ module ... ] 
     105 
     106Creates one or more modules for the module arguments provided. 
     107New modules will appear in the top-level-directory of your work- 
     108ing copy.  This change will also be committed to the repository 
     109at the same time. 
    109110 
    110111EOF 
     
    115116 
    116117Usage: 
    117   $MYNAME rmmod module 
    118 This command will delete the specified module from your working copy. Use with 
    119 care. 
     118  $MYNAME rmmod [ module ... ] 
     119 
     120Delete the modules corresponding to the specified module argu- 
     121ments from your working copy. Follow this action with a revert or 
     122commit operation. 
     123 
    120124EOF 
    121125;; 
  • branches/confman-1.9/confmanlib.sh.in

    r450 r455  
    165165} 
    166166 
     167function conf_create_modules { 
     168    local module 
     169    local newmodules 
     170    local rc=0 
     171 
     172    for module in "$@"; do 
     173        if conf_create_module "$module"; then 
     174            # Keep track of the modules that were successfully created 
     175            # avoid inadvertently committing outstanding changes to 
     176            # pre-existing modules 
     177            if [ -z "$newmodules" ]; then 
     178                newmodules="$module" 
     179            else 
     180                newmodules="$newmodules,$module" 
     181            fi 
     182        else 
     183            rc=1 
     184        fi 
     185    done 
     186 
     187    # $newmodules is in the form foo,bar,baz. This eval trick forces 
     188    # curly brace expansion. 
     189    if echo "$newmodules" | grep -q ','; then 
     190        @SVN@ commit $(eval echo ${WORK_PATH}/{$newmodules}) \ 
     191            $(eval echo ${WORK_PATH}/${REPO_CHECKPTS}/{$newmodules}) -m \ 
     192            "Created directory structure for $newmodules --`whoami`" 
     193    elif [ -n "$newmodules" ]; then 
     194        # We test -n for this case because $newmodules might 
     195        # be empty, i.e. no new modules were created 
     196        @SVN@ commit ${WORK_PATH}/$newmodules \ 
     197            ${WORK_PATH}/${REPO_CHECKPTS}/$newmodules -m \ 
     198            "Created directory structure for $newmodules --`whoami`" 
     199    fi 
     200 
     201    return $rc 
     202} 
     203 
    167204# Assumes that we already have core setup in our work path. 
    168205function conf_create_module { 
     
    177214    @SVN@ mkdir ${WORK_PATH}/$module 
    178215    @SVN@ mkdir ${WORK_PATH}/${REPO_CHECKPTS}/$module 
    179     @SVN@ commit ${WORK_PATH}/${module} \ 
    180         ${WORK_PATH}/${REPO_CHECKPTS}/$module -m \ 
    181         "Created directory structure for ${module} --`whoami`" 
    182216 
    183217    return 0 
     
    680714} 
    681715 
     716function conf_remove_modules { 
     717    local module 
     718    local rc=0 
     719 
     720    for module in "$@"; do 
     721        conf_rmmod "$module" || rc=1 
     722    done 
     723 
     724    return $rc 
     725} 
     726 
    682727function conf_rmmod { 
    683         local module=$1 
    684         @SVN@ rm ${WORK_PATH}/${module} 
    685         @SVN@ rm ${WORK_PATH}/${REPO_CHECKPTS}/${module} 
     728        local module="$1" 
     729    local dir 
     730    local rc=0 
     731 
     732    for dir in ${WORK_PATH}/{,${REPO_CHECKPTS}/}${module}; do 
     733        if ! [ -d "$dir" ]; then 
     734            echo "No such directory: $dir" >&2 
     735            rc=1 
     736        else 
     737            @SVN@ rm $dir || rc=1 
     738        fi 
     739    done 
     740 
     741    return $rc 
    686742} 
    687743 
     
    909965} 
    910966 
     967function conf_remove_recipes { 
     968    local recipe 
     969    local oldrecipes 
     970    local rc=0 
     971 
     972    for recipe in "$@"; do 
     973        if conf_remove_recipe "$recipe"; then 
     974            # Keep track of the recipes that were successfully removed 
     975            # to avoid inadvertent commits 
     976            if [ -z "$oldrecipes" ]; then 
     977                oldrecipes="$recipe" 
     978            else 
     979                oldrecipes="$oldrecipes,$recipe" 
     980            fi 
     981        else 
     982            rc=1 
     983        fi 
     984    done 
     985 
     986    # $oldrecipes is in the form foo,bar,baz. This eval trick forces 
     987    # curly brace expansion. 
     988    if echo "$oldrecipes" | grep -q ','; then 
     989        @SVN@ commit $(eval echo $(conf_recipe_dir)/{$oldrecipes})  
     990    else 
     991        @SVN@ commit "$(conf_recipe_dir)/$oldrecipes" 
     992    fi 
     993 
     994    return $rc 
     995} 
     996 
    911997function conf_remove_recipe { 
    912998    local recipe="$1" 
     
    9161002        return 1 
    9171003    fi 
    918     @SVN@ rm "${recipe_file}" 
    919     @SVN@ commit "${recipe_file}" 
     1004    @SVN@ rm "${recipe_file}" || return 1 
     1005    return 0 
    9201006} 
    9211007 
Note: See TracChangeset for help on using the changeset viewer.