|
| 1 | + |
| 2 | +if exists("g:loaded_nerdtree_svn_menuitem") |
| 3 | + finish |
| 4 | +endif |
| 5 | +let g:loaded_nerdtree_svn_menuitem = 1 |
| 6 | + |
| 7 | + |
| 8 | +function! NERDTreeSvnDirectoryCheck() |
| 9 | + let curNode = g:NERDTreeFileNode.GetSelected() |
| 10 | + return curNode.path.isDirectory |
| 11 | +endfunction |
| 12 | + |
| 13 | + |
| 14 | +call NERDTreeAddMenuItem({ |
| 15 | + \ 'text': '(w)svn commit', |
| 16 | + \ 'shortcut': 'w', |
| 17 | + \ 'callback': 'NERDTreeSvnCommit', |
| 18 | + \ 'isActiveCallback': 'NERDTreeSvnDirectoryCheck'}) |
| 19 | + |
| 20 | +function! NERDTreeSvnCommit() |
| 21 | + let curNode = g:NERDTreeFileNode.GetSelected() |
| 22 | + let chmodArg = input("commit message: ") |
| 23 | + execute '!svn commit ' . curNode.path.str({'escape': 1}) . ' -m "' . chmodArg . '" ' |
| 24 | + if exists('g:loaded_signify') " signify force to refresh |
| 25 | + execute "SignifyRefresh" |
| 26 | + endif |
| 27 | + call curNode.refresh() |
| 28 | + call NERDTreeRender() |
| 29 | +endfunction |
| 30 | + |
| 31 | + |
| 32 | +call NERDTreeAddMenuItem({ |
| 33 | + \ 'text': '(u)svn update', |
| 34 | + \ 'shortcut': 'u', |
| 35 | + \ 'callback': 'NERDTreeSvnUpdate', |
| 36 | + \ 'isActiveCallback': 'NERDTreeSvnDirectoryCheck'}) |
| 37 | + |
| 38 | +function! NERDTreeSvnUpdate() |
| 39 | + let curNode = g:NERDTreeFileNode.GetSelected() |
| 40 | + execute '!svn update ' . curNode.path.str({'escape': 1}) |
| 41 | + if exists('g:loaded_signify') " signify force to refresh |
| 42 | + execute "SignifyRefresh" |
| 43 | + endif |
| 44 | + call curNode.refresh() |
| 45 | + call NERDTreeRender() |
| 46 | +endfunction |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +call NERDTreeAddMenuItem({ |
| 51 | + \ 'text': '(z)svn sync', |
| 52 | + \ 'shortcut': 'z', |
| 53 | + \ 'callback': 'NERDTreeSvnSyncDirCallback', |
| 54 | + \ 'isActiveCallback': 'NERDTreeSvnDirectoryCheck'}) |
| 55 | + |
| 56 | +function! NERDTreeSvnSyncDirCallback() |
| 57 | + let curNode = g:NERDTreeFileNode.GetSelected() |
| 58 | + let chmodArg = input("commit message: ") |
| 59 | + " Deleted files |
| 60 | + execute "!svn status " . curNode.path.str({'escape': 1}) . "/ | grep '^\\!' | sed 's/\\! *//' | xargs -I\\% svn rm \\%" |
| 61 | + " Add files |
| 62 | + execute '!svn add --force ' . curNode.path.str({'escape': 1}) . ' --auto-props --parents --depth infinity -q' |
| 63 | + " Commit files |
| 64 | + execute '!svn commit ' . curNode.path.str({'escape': 1}) . ' -m "' . chmodArg . '" ' |
| 65 | + " Update files |
| 66 | + execute '!svn update ' . curNode.path.str({'escape': 1}) |
| 67 | + if exists('g:loaded_signify') " signify force to refresh |
| 68 | + execute "SignifyRefresh" |
| 69 | + endif |
| 70 | + call curNode.refresh() |
| 71 | + call NERDTreeRender() |
| 72 | +endfunction |
0 commit comments