Sunday, February 24, 2008

Vim and Perforce

My employer has used Perforce as a VCS for several years now. Perforce itself maintains integration plugins for Eclipse, but of course not for editors like Vim so it's up to the community to do so. Lucky for me, extremely capable Vim scripters like Hari Krishna Dara also use Perforce from time to time :). This is the same author who brought us the genutils.vim plugin as well as many other powerful scripts as his vim profile lists. Among these is a fantastic perforce script set that I downloaded to try about a week ago. It was more than I'd hoped for.

This is a very featureful Perforce integration script with a complete set of menus (although I have menus hidden in my vim) and commands. I'm not sure whether the author still uses it or not however because there was a bug in spec-based commands that broke it pretty badly. Of course, there is the possibility that I'm using it incorrectly too. Regardless, I've "fixed" a couple of these bugs and emailed the author with a patch. I also uncovered a bug in the genutils.vim script that it depends on. The author also mentions this in the script page for the Perforce plugin:

--------------------------------------------------------------------------------
Lately, I am not finding enough time to add features to this, so if anybody is
interested to help me add new features or even take over the responsibility, you
are very much welcome.
--------------------------------------------------------------------------------

Although I sent him a small patch in his Inbox, he may not have the time to make a bug fix release, so I've made a little bazaar branch of the complete script on my own little server here for the time being. This branch includes the fixes for a couple of little bugs, and some extra syntax hinting for pending changelists and closed jobs. Aside from that, it's unaltered. You can get it using this command, assuming you have bzr installed.

$ bzr branch http://arker.homelinux.org/~dcraven/bazaar/vim-perforce vim-perforce

I might add a few features or commands that have been included in the p4 client since his last release of the script at some point too. Depending on his email reply (if he replies) we'll see if he'd like my changes included in his next release or not. My additions unfortunately won't be of the same quality as the stuff he's already written. I'm not exactly a seasoned vim-scriptor...

All in all, it's a fantastic script. Check it out if you use Vim with the Perforce VCS, and big kudos and thanks go out to the original author!

11 comments:

  1. The link to your patches is currently Forbidden... trying to get this working myself, so I'd be interested in the changes you had to make.

    ReplyDelete
  2. Looking at my server logs, it appears you are trying to access the URL via your web browser. It's actually not a website, but bzr repository. See http://bazaar-vcs.org for more info. Cheers, and I hope it works for you too!

    ReplyDelete
  3. All right, thanks. I hadn't considered that that URL was limited based on the app coming, and figured I could get something useful without installing new software.

    Anyway, installed Bazaar, got your changes, installed them, and uninstalled Bazaar. I see at least one of the obvious bugs is gone now... there's still a problem with the menu stuff, which I noted you don't use... maybe I'll take a stab at those myself.

    ReplyDelete
  4. Cool. If you do find a bug, please send me a patch against the bzr tree so I can merge your changes. Might as well have them available for people all in one place :)

    ReplyDelete
  5. I downloaded this to see if it cured the problem I've been seeing for the past 12 months or so - possibly related to an upgrade to vim, but to be honest, I cannot remember :-(

    If I am viewing a readonly file and press anything that initiates an edit, it asks whether I want to open the file for edit and offers Yes/No/Cancel options. However, if I reply yes, then the cursor has moved to the first character of the line it was on and the command I issued is executed there, apparently, rather than where I wanted it. e.g. go to the 4th word on a line, do "dw" and the right number of characters are removed, but from the start of the line.

    I know this is all sounds rather bizarre - I just wondered if other people had seen this behaviour too?

    (Currently using vim 7.1.242 on FC8)

    ReplyDelete
  6. Hey great work! 1 note, it seems that i get an update when updating my help tags. It says theirs a duplicate definition of the tag 'E' in your perforce.txt

    ReplyDelete
  7. no worky...

    >bzr branch http://arker.homelinux.org/~dcraven/bazaar/vim-perforce vim-perforce
    bzr: ERROR: Invalid http response for http://arker.homelinux.org/%7Edcraven/bazaar/vim-perforce/.bzr/branch-format: Bad status line received

    ReplyDelete
  8. bzr: ERROR: Invalid http response for http://arker.homelinux.org/%7Edcraven/bazaar/vim-perforce/.bzr/branch-format: Bad status line received


    Get the above error when i try to checkout

    ReplyDelete
  9. Looks like the bazaar repository/depot disappeared for vim-perforce. Bummer.

    ReplyDelete
  10. Has anyone tried this on a linux machine and had any luck?

    ReplyDelete
  11. hey mr author man : could you post a .patch to the original : http://vim.wikia.com/wiki/Script:240 ?

    ReplyDelete