Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vimdiff and CVS integration

Tags:

vim

vimdiff

cvs

I've always wanted to be able to get a reasonably elegant way of getting vimdiff to work with a CVS controlled file. I've found numerous (somewhat hacky) scripts around the internet (best example here) that basically check out the file you are editing from CVS to a temp file, and vimdiff the two. None of these take into account branches, and always assume you're working from MAIN, which for me is completely useless.

So, my question is this: has anyone out there found a decent solution for this that does more than this script?

Or failing that, does anyone have any ideas of how they would implement this, or suggestions for what features you would consider vital for something that does this? My intention is that, if no one can suggest an already built solution to either use or build from, we start building one from here.

like image 972
sanmiguel Avatar asked Aug 25 '08 15:08

sanmiguel


2 Answers

I've been working on a similar script here: http://github.com/ghewgill/vim-scmdiff (in fact, they may have the same ancestry). I haven't used scmdiff with cvs, but it should do a diff against the branch you have checked out. You can also specify that you want to diff against a particular revision (with :D revision). Hopefully this helps, and feel free to contribute if you've got improvements!

like image 173
Greg Hewgill Avatar answered Oct 18 '22 22:10

Greg Hewgill


@Greg Hewgill: thanks for the script! I had a couple of issues with it though, so here's what I'd change:

line 21:

< map <silent> <C-d> :call <SID>scmToggle()<CR>
--
> map <silent> <C-h> :call <SID>scmToggle()<CR>

I use Ctrl-d for page-down (too lazy to move all that way over to PdDn), so had to switch to Ctrl-h.

line 112:

<         let cmd = 'cd ' . g:scmBufPath . ' && ' . g:scmDiffCommand . ' diff ' . g:scmDiffRev . ' ' . expand('%:p') . ' > ' . tmpdiff
--
> if g:scmDiffUseAbsPaths 
>     let cmd = 'cd ' . g:scmBufPath . ' && ' . g:scmDiffCommand . ' diff ' . g:scmDiffRev . ' ' . expand('%:p') . ' > ' . tmpdiff
> else
>     let cmd = g:scmDiffCommand . ' diff ' . g:scmDiffRev . ' ' . bufname('%') . ' > ' . tmpdiff
> endif

I had issues with not being able to use absolute paths with CVS. I don't know if this is a weirdness of our local set up here, or if it's a global CVS thing. So, I've made a configurable variable that you can put in your .vimrc to use relative path instead.

It now seems to work exactly how I wanted, so I'll keep bashing away and see if I can find anything else that breaks, posting fixes as I go.

Edit: Forgot to add: please feel free to add these changes to your script on github if you feel they're worthwhile.

like image 38
sanmiguel Avatar answered Oct 18 '22 21:10

sanmiguel