1" 2" Filename: cream-cream-update.vim 3" Updated: 2004-09-11 23:04:11-0400 4" 5" Cream -- An easy-to-use configuration of the famous Vim text editor 6" [ http://cream.sourceforge.net ] Copyright (C) 2001-2011 Steve Hall 7" 8" License: 9" This program is free software; you can redistribute it and/or modify 10" it under the terms of the GNU General Public License as published by 11" the Free Software Foundation; either version 2 of the License, or 12" (at your option) any later version. 13" [ http://www.gnu.org/licenses/gpl.html ] 14" 15" This program is distributed in the hope that it will be useful, but 16" WITHOUT ANY WARRANTY; without even the implied warranty of 17" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18" General Public License for more details. 19" 20" You should have received a copy of the GNU General Public License 21" along with this program; if not, write to the Free Software 22" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 23" 02111-1307, USA. 24" 25 26" Documentation: {{{1 27" 28" Description: 29" 30" This is a Cream developer module to sychronize a CVS checkout of with CVS. 31" 32" Required: (set in cream-user.vim!) 33" o g:cream_cvs: local path to Cream CVS root (above the modules) 34" * no trailing slash/backslash 35" o $CVS_RSH (example: "ssh") 36" o $CVSROOT (example: "[username]@cvs.sourceforge.net:/cvsroot/cream") 37" o $CREAM 38" o $VIM 39" o $HOME (Unix) for creamrc location 40" 41" Notes: 42" o cvs import -I ! -W "*.bmp -k 'b'" -W "*.png -k 'b'" cream [username] start 43" o cvs update -P (prunes empty directories from working copy) 44" o cvs update -d (bring down directories to working copy) 45" o cvs checkout ... 46" 47" ToDo: 48" o cvs add 49" o cvs remove 50" 51 52" register as Cream add-on {{{1 53if exists("$CREAM") 54 " don't list unless developer 55 if !exists("g:cream_dev") 56 finish 57 endif 58 59 call Cream_addon_register( 60 \ "Update", 61 \ "Update Cream developer package", 62 \ "Update Cream developer package Zip file, generally not for use for anyone but developers. Enables portable transmission of alpha technologies. ;)", 63 \ "Cream Devel.Update", 64 \ "call Cream_update_package()", 65 \ '<Nil>' 66 \ ) 67endif 68 69" Cream_update_package() {{{1 70function! Cream_update_package() 71" main function (decide which action to perform) 72 73 "*** DEBUG: 74 let n = confirm( 75 \ "WARNING!\n" . 76 \ " This routine is strictly developer-only! Do NOT use\n" . 77 \ " unless you've read the code and are prepared for its\n" . 78 \ " consequences!\n" . 79 \ "\n", "&Ok\n&Cancel", 2, "Info") 80 if n != 1 81 return 82 endif 83 "*** 84 85 " validate required vars 86 let error = "" 87 " $CVS_RSH 88 if !exists("$CVS_RSH") 89 let error = error . "$CVS_RSH not found.\n" 90 elseif !executable($CVS_RSH) 91 let error = error . "Value of $CVS_RSH is not an executable.\n" 92 endif 93 " $CVSROOT 94 if !exists("$CVSROOT") 95 let error = error . "$CVSROOT not found.\n" 96 endif 97 " g:cream_cvs 98 if has("win32") && !has("win32unix") 99 let slash = '\' 100 else 101 let slash = '/' 102 endif 103 if !exists("g:cream_cvs") 104 let error = error . "g:cream_cvs not found.\n" 105 endif 106 " cvs 107 if !executable("cvs") 108 let error = error . "cvs program not found.\n" 109 endif 110 " Errors 111 if error != '' 112 call confirm( 113 \ "Error(s):\n\n" . 114 \ error . "\nQuitting...\n" . 115 \ "\n", "&Ok", 1, "Info") 116 return 117 endif 118 119 let g:cream_cvs = Cream_path_addtrailingslash(g:cream_cvs) 120 121 " loop 122 let myreturn = 1 123 while myreturn == 1 124 " stack buttons vertically 125 let sav_go = &guioptions 126 set guioptions+=v 127 " decide what we want to do 128 let n = confirm( 129 \ "Please select an option:\n" . 130 \ "\n", 131 \ "CVS Co&mmit\nCVS &Update\n&Cancel", 1, "Info") 132 " restore button stacking preference 133 let &guioptions = sav_go 134 if n == 1 135 call s:Cream_CVScommit(g:cream_cvs) 136 elseif n == 2 137 call s:Cream_CVSupdate(g:cream_cvs) 138 else 139 let myreturn = 0 140 endif 141 endwhile 142 143endfunction 144 145" Cream_CVScommit() {{{1 146function! s:Cream_CVScommit(path) 147" commit files in {path} 148 149 " Note: cvs doesn't want trailing slash 150 " Tested: Win95, WinXP, GNU/Linux (RH9) 151 152 " get commit message 153 let message = s:Cream_CVSmessage() 154 if message == -1 155 return 156 endif 157 158 " establish quote and slash chars as required 159 if has("win32") && !has("win32unix") 160 let quote = '"' 161 let slash = '\' 162 else 163 let quote = '' 164 let slash = '/' 165 endif 166 167 " don't use silent, we need to enter a password in the shell 168 " Notes: 169 " o Both platforms require a quoted message! 170 " o Unix requires a trailing slash 171 if has("win32") && !has("win32unix") 172 " change directories (requires trailing slash for some reason) 173 execute 'cd ' . quote . a:path . slash . quote 174 execute '!cvs commit -m "' . message . '" ' . quote . a:path . quote 175 else 176 " can't pass absolute path on Unix 177 execute 'cd ' . quote . a:path . quote 178 execute '!cvs commit -m "' . message . '"' 179 endif 180 181endfunction 182 183" Cream_CVSupdate() {{{1 184function! s:Cream_CVSupdate(path) 185" commit files in module {path} 186 187 " establish quote and slash chars as required 188 if has("win32") && !has("win32unix") 189 let quote = '"' 190 else 191 let quote = '' 192 endif 193 194 " don't use silent 195 if has("win32") && !has("win32unix") 196 execute '!cvs update -Pd ' . quote . a:path . quote 197 else 198 " can't pass absolute path on Unix 199 execute 'cd ' . quote . a:path . quote 200 execute '!cvs update -Pd' 201 endif 202 203endfunction 204 205" utility functions {{{1 206 207function! s:Cream_CVSmessage() 208" prompts and returns the CVS log message 209" warns and returns -1 if empty 210 211 let message = inputdialog("Please enter log message:", "") 212 if message == "" 213 call confirm( 214 \ "Can not continue without a log message. Quitting...\n" . 215 \ "\n", "&Ok", 1, "Info") 216 return -1 217 else 218 return escape(message, '"<>|&') 219 endif 220 221endfunction 222 223" 1}}} 224" vim:foldmethod=marker 225