[Bitkeeper-users] vim hackers?

Thomas Glanzmann sithglan at stud.uni-erlangen.de
Tue Feb 28 12:51:09 PST 2006


Hello Larry,

> and I was wondering if any has coaxed vim into letting you edit a file
> that has annotations.  I'd love to always be looking at the files with
> full BK history behind them and be able to use that.

I used the following with bitkeeper:

,co => checkes out a file
,ci => checks in a file
,diff => diff against last checked in file
,revert => status quo ante
,log => bk sccslog

where ',' is my LEADER.

you could easily modify the examples below to obtain what you want.

Sincerely,
        Thomas

" BEGIN HANDLE VERSIONING SYSTEM

if(v:version >= 600)
" auto check vor Versioning system
au Bufenter * call CheckForVersioning()

function! HandleModifiable()
	if &readonly == '1'
		setlocal nomodifiable
	else
		setlocal modifiable
	endif
endfunction

function! HandleRCS()
	call HandleModifiable()
	map <buffer> <Leader>ci     :!rcsdiff -u %<Cr>:!ci -u %<Cr>:e!<Cr><Cr>
	map <buffer> <Leader>co     :!co -l %<Cr>:e!<Cr>
	map <buffer> <Leader>diff   :!rcsdiff -u %<Cr>
	map <buffer> <Leader>revert :!co -u %<Cr>:e!<Cr>
	map <buffer> <Leader>log    :call ReadCommandInBuffer("/rlog", "rlog " . expand("%"))<Cr><Cr>
endfunction

function! HandleSCCS()
	call HandleModifiable()
	map <buffer> <Leader>ci     :!bk diffs -u %; bk ci -u %<Cr>:e!<Cr><Cr>
	map <buffer> <Leader>co     :!bk edit %<Cr>:e!<Cr>
	map <buffer> <Leader>diff   :!bk diffs -u %<Cr>
	map <buffer> <Leader>revert :!bk unedit %<Cr>:!bk get %<Cr>:e!<Cr>
	map <buffer> <Leader>log    :call ReadCommandInBuffer("/sccslog", "bk sccslog " . expand("%"))<Cr><Cr>
endfunction

function! HandleGIT()
	map <buffer> <Leader>ci     :!git ci %<Cr>:e!<Cr>
	map <buffer> <Leader>commit :!git diff -c; git commit<Cr>:e!<Cr>
	map <buffer> <Leader>diff   :!git diff %<Cr>
	map <buffer> <Leader>revert :!git revert %<Cr>:e!<Cr>
	map <buffer> <Leader>status :!git status<Cr>
	map <buffer> <Leader>log    :call ReadCommandInBuffer("/log", "git log " . expand("%"))<Cr><Cr>
	map <buffer> g<C-d>         :call ReadCommandInBuffer("/log", "git diff -r " . expand("<cword>"))<Cr><Cr>
endfunction

function! CheckForVersioning()
	if filereadable(expand("%") . ',v')
		call HandleRCS()
	endif
	if filereadable(expand("%:p:h") . '/RCS/' . expand("%:t") .  ',v')
		call HandleRCS()
	endif
	if filereadable(expand("%:p:h") . '/SCCS/' . 's.' .  expand("%:t"))
		call HandleSCCS()
	endif
	if isdirectory(expand("%:p:h") . '/.git')
		call HandleGIT()
	endif
endfunction

" ReadCommandInBuffer
" - bufferName is the name which the new buffer with the command results
"   should have.
" - cmdName is the command to execute.
function! ReadCommandInBuffer(bufferName, cmdName)
	" Modify the shortmess option:
	" A  don't give the "ATTENTION" message when an existing swap file is
	"    found.
	set shortmess+=A

	" If a buffer with the name rlog exists, delete it.
	if bufexists(a:bufferName)
	execute 'bd! ' a:bufferName
	endif

	" Create a new buffer.
	execute 'new ' a:bufferName

	" Execute the command.
	execute '0r!' a:cmdName

	" Make is so that the file can't be edited.
	setlocal nomodified
	setlocal nomodifiable
	setlocal readonly
	setlocal ft=man

	" Go to the beginning of the buffer.
	execute "normal gg"

	" Restore the shortmess option.
	set shortmess-=A
endfunction
endif

" END HANDLE VERSIONING SYSTEM


More information about the Bitkeeper-users mailing list