vimdiff and CVS integration
Asked Answered
G

4

6

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.

Gaffe answered 25/8, 2008 at 15:10 Comment(0)
S
3

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!

Skirt answered 25/8, 2008 at 19:45 Comment(1)
I suggest <Leader>d (which I changed in my fork of your script on GitHub ;).Acey
G
1

@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.

Gaffe answered 26/8, 2008 at 19:19 Comment(0)
L
0

You could change the call to cvs to take branches into account. That shouldn't be to hard. It bit harder would to change the whole function and make the branch your working a variable (argument, session, global or otherwise).

Lucialucian answered 25/8, 2008 at 19:1 Comment(0)
S
0

VCSCommand is another actively maintained vim script for VCS integration. It has support for CVS/SVN/SVK/git.

I use it all the time for SVN and never had any complaints. The shortcuts use mapleader, so it is unlikely that they will overwrite existing mappings.

Spada answered 29/12, 2009 at 16:18 Comment(2)
I actually already use VCSCommand, and it's definitely been more reliable than scmdiff for getting diffs (eg if I'm in a directory of checked out code that I got to through a symlink from another set of checked out code), however, so I guess I need to combine the methods from VCSCommand for getting diffs with the methods from scmdiff for displaying them...Gaffe
have you tried VCSVimDiff / <Leader>cv? I think it is a perfect way of displaying diffs..Spada

© 2022 - 2024 — McMap. All rights reserved.