Skip to content

Commit

Permalink
Version 1.1
Browse files Browse the repository at this point in the history
Added TfReview, TfCheckinAll, TfShelve to checkin multiple files, and create shelve sets.  Also fixed several bugs.
  • Loading branch information
Ben Staniford authored and vim-scripts committed Dec 1, 2011
1 parent 59e7e66 commit 9138cfd
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 25 deletions.
7 changes: 6 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ editing files with VIM. It supports TFS with Visual Studio 2005,2008 &
* Looking at the history of the current file
* Diffing the current file against a particular changeset
* Diffing the current file against the latest version
* Creating shelve sets

MAPPINGS

Expand All @@ -21,15 +22,18 @@ default.

Mapping Command Purpose ~
\ta TfAdd Add current file to TFS
\to TfCheckout Check out current file from TFS
\to TfCheckout Check out current file from TFS
\ti TfCheckin Check current file into TFS with comment
\tc TfCheckinAll Check in multiple files to
\tl TfGetLatest Get the latest version of current file
\tr TfRevert Revert local changes to current file
\th TfHistory Get the history of the local file
\tv TfViewVer Preview a specific version of the file
\td TfDiffVer Diff current file against specific version
\tt TfDiffLatest Diff recent changes against latest
\ts TfStatus Show all files which have been modified
\te TfShelve Create a shelve set
\tu TfUnshelve Unshelve a shelve set

OTHER COMMANDS

Expand All @@ -39,4 +43,5 @@ OTHER COMMANDS
TfPt "command line" Run a raw tfpt command
TfPtHelp Help for the tfpt command
TfAnnotate Examine annotated view of current file
TfReview Review changes made to workspace
TfHistoryDetailed See detailed branch history for current file
5 changes: 5 additions & 0 deletions doc/tfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ editing files with VIM.

Author: Ben Staniford <ben at staniford dot net> *tfs-author*
License: Same terms as Vim itself (see |license|)
Version: 1.1 *tfs-version*

INTRODUCTION *tfs*

Expand All @@ -17,6 +18,7 @@ editing files with VIM. It supports TFS with Visual Studio 2005,2008 &
* Looking at the history of the current file
* Diffing the current file against a particular changeset
* Diffing the current file against the latest version
* Creating shelve sets

MAPPINGS *tfs-mappings*

Expand All @@ -27,13 +29,15 @@ default.
\ta TfAdd Add current file to TFS
\to TfCheckout Check out current file from TFS
\ti TfCheckin Check current file into TFS with comment
\tc TfCheckinAll Check in multiple files to
\tl TfGetLatest Get the latest version of current file
\tr TfRevert Revert local changes to current file
\th TfHistory Get the history of the local file
\tv TfViewVer Preview a specific version of the file
\td TfDiffVer Diff current file against specific version
\tt TfDiffLatest Diff recent changes against latest
\ts TfStatus Show all files which have been modified
\te TfShelve Create a shelve set

OTHER COMMANDS *tfs-other-commands*

Expand All @@ -43,5 +47,6 @@ OTHER COMMANDS *tfs-other-commands*
TfPt "command line" Run a raw tfpt command
TfPtHelp Help for the tfpt command
TfAnnotate Examine annotated view of current file
TfReview Review changes made to workspace
TfHistoryDetailed See detailed branch history for current file

68 changes: 44 additions & 24 deletions plugin/tfs.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
" Maintainer: Ben Staniford <ben at staniford dot net> License: Copyright
" (c) 2011 Ben Staniford
"
" Version: 1.0.1
" Version: 1.1
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
Expand All @@ -31,10 +31,6 @@
" current file. The output of the commands is captured in a new scratch window.
"

"TODO
" 1. Check-ins of multiple files?
" 2. Shelf sets?

if has ('win32')

"
Expand All @@ -51,17 +47,17 @@ endif
"
" Work out which versions of tf.exe and tfpt.exe are available
"
if (filereadable('"'.s:pfiles.'\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe"'))
if (filereadable(s:pfiles.'\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe'))
let s:tfs_tf='"'.s:pfiles.'\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe"'
let s:tfs_recurse_command='/recursive'
elseif(filereadable(s:pfiles.'\Microsoft Visual Studio 9.0\Common7\IDE\TF.exe'))
let s:tfs_tf='"'.s:pfiles.'\Microsoft Visual Studio 9.0\Common7\IDE\TF.exe"'
let s:tfs_recurse_command='/recursive'
elseif(filereadable(s:pfiles.'\Microsoft Visual Studio 8.0\Common7\IDE\TF.exe'))
let s:tfs_tf='"'.s:pfiles.'\Microsoft Visual Studio 8.0\Common7\IDE\TF.exe"'
elseif(filereadable(s:pfiles.'\Microsoft Visual Studio 8\Common7\IDE\TF.exe'))
let s:tfs_tf='"'.s:pfiles.'\Microsoft Visual Studio 8\Common7\IDE\TF.exe"'
let s:tfs_recurse_command='/followbranches'
endif
if (filereadable('"'.s:pfiles.'\Microsoft Team Foundation Server 2010 Power Tools\TFPT.exe"'))
if (filereadable(s:pfiles.'\Microsoft Team Foundation Server 2010 Power Tools\TFPT.exe'))
let s:tfs_tfpt='"'.s:pfiles.'\Microsoft Team Foundation Server 2010 Power Tools\TFPT.exe"'
elseif (filereadable(s:pfiles.'\Microsoft Team Foundation Server 2008 Power Tools\TFPT.exe'))
let s:tfs_tfpt='"'.s:pfiles.'\Microsoft Team Foundation Server 2008 Power Tools\TFPT.exe"'
Expand Down Expand Up @@ -267,18 +263,33 @@ endfunction
" -----------------------------------------------------------------------------------------

"
" Helper functions
" Run a raw TF/TFTP command
"
function! TfCmd(cmds)
let command = s:tfs_tf.' '.a:cmds
function! TfCmd(exe, cmds)
let command = a:exe.' '.a:cmds
call TfWindow(command, "", "human", s:window_mode_popup, s:bigpopup_size)
endfunction

" -----------------------------------------------------------------------------------------

function! TfPtCmd(cmds)
let command = s:tfs_tfpt.' '.a:cmds
call TfWindow(command, "", "human", s:window_mode_popup, s:bigpopup_size)
" Launch TFS UI command asynchronously
function! TfUiCmd(exe, cmds)

" Set CWD to file path, launch TF/TFPT, restore CWD
let owd = getcwd()
let filepath = expand('%:p:h')
silent! exe 'lcd '.filepath
echo filepath
let command = a:exe.' '.a:cmds

" To debug, switch to cmd /k
silent! exe '! start /min cmd /c '.command
silent! exe 'lcd '.owd

" Give some feedback so user doesn't think it's failed
redraw!
echom "Launching TFS UI..."

endfunction

" -----------------------------------------------------------------------------------------
Expand All @@ -305,15 +316,18 @@ command! TfCheckin :call TfGetCheckinComments()
command! TfRevert :call TfPopup("undo")
command! TfStatus :call TfBigPopup("status")
command! TfAdd :call TfPopup("add")
command! TfHelp :call TfCmd("help")
command! TfHelp :call TfCmd(s:tfs_tf, "help")
command! TfGetLatest :call TfPopup("get")
command! TfShelve :call TfUiCmd(s:tfs_tf, "shelve")
command! TfCheckinAll :call TfUiCmd(s:tfs_tf, "checkin")
command! TfReview :call TfUiCmd(s:tfs_tfpt, "review")
command! TfPtHelp :call TfCmd(s:tfs_tfpt, "help")
command! -complete=file -nargs=1 Tf :call TfCmd(s:tfs_tf, <args>)
command! -complete=file -nargs=1 TfPt :call TfCmd(s:tfs_tfpt, <args>)
command! -nargs=? TfGetVersion :call TfGetVersion(<args>)
command! TfPtHelp :call TfPtCmd("help")
command! -complete=file -nargs=1 Tf :call TfCmd(<args>)
command! -complete=file -nargs=1 TfPt :call TfPtCmd(<args>)
command! TfHistory :call TfWindow(s:tfs_tf.' history '.s:tfs_recurse_command.' #', "", "tfcmd", s:window_mode_popup, s:bigpopup_size)
command! TfHistoryDetailed :call TfWindow(s:tfs_tf.' history /format:detailed '.s:tfs_recurse_command.' #', "", "tfcmd", s:window_mode_popup, s:bigpopup_size)
command! TfAnnotate :call TfWindow(s:tfs_tfpt.' annotate '.expand('%:p'), "", "tfcmd", s:window_mode_popup, s:popup_size)
command! TfAnnotate :call TfUiCmd(s:tfs_tfpt, "annotate ".expand('%:p'))
command! TfDiffLatest :call TfDiffVer("T")
command! -nargs=? TfDiffVer :call TfDiffVer(<args>)
command! -nargs=? TfViewVer :call TfViewVer(<args>)
Expand All @@ -325,18 +339,22 @@ command! -nargs=? TfViewVer :call TfViewVer(<args>)
"
if has('gui') && ( ! exists('g:tfs_menu') || g:tfs_menu != 0 )
amenu <silent> &TFS.&Add :TfAdd<cr>
amenu <silent> &TFS.Check&out :TfCheckout<cr>
amenu <silent> &TFS.Check&in :TfCheckin<cr>
amenu <silent> &TFS.Check-&out :TfCheckout<cr>
amenu <silent> &TFS.Check-&in :TfCheckin<cr>
amenu <silent> &TFS.&Get\ Latest :TfGetLatest<cr>
amenu <silent> &TFS.Get\ &Version :TfGetVersion<cr>
amenu <silent> &TFS.&Revert :TfRevert<cr>
amenu <silent> &TFS.&Status :TfStatus<cr>
amenu <silent> &TFS.&History :TfHistory<cr>
amenu <silent> &TFS.A&nnotations :TfHistory<cr>
amenu <silent> &TFS.A&nnotations :TfAnnotate<cr>
amenu <silent> &TFS.D&etailed\ History :TfHistoryDetailed<cr>
amenu <silent> &TFS.Diff\ with\ &Latest :TfDiffLatest<cr>
amenu <silent> &TFS.View\ Ve&rsion :TfViewVer<cr>
amenu <silent> &TFS.&Diff\ with\ Version :TfDiffVer<cr>
amenu <silent> &TFS.-Sep- :
amenu <silent> &TFS.&Status :TfStatus<cr>
amenu <silent> &TFS.Review :TfReview<cr>
amenu <silent> &TFS.Check-in\ All :TfCheckinAll<cr>
amenu <silent> &TFS.Create\ Shelveset :TfShelve<cr>
endif

"
Expand All @@ -352,5 +370,7 @@ noremap \tv :TfViewVer<cr>
noremap \td :TfDiffVer<cr>
noremap \tt :TfDiffLatest<cr>
noremap \ts :TfStatus<cr>
noremap \tc :TfCheckinAll<cr>
noremap \te :TfShelve<cr>
endif

0 comments on commit 9138cfd

Please sign in to comment.