Emacs has integrated version control support for numerous VC backends, including Git and Perforce. It gives a set of generic commands that you can use to interact with each version control system the same way. I’ve been using this for vc commands that don’t involve submitting or changelists. Modifying changelists I just do through a shell buffer, and I tend to go to an external shell to do commits, and I haven’t ever gotten emacsclient working properly.
The emacs package that synchronizes with The following is just a list of some of the more useful VC functions. I don’t use all of them, but a lot of them I do and I should probably use the others more than I do. Many of them have keybindings, which are suggested when you perform the command with M-x. Since Perforce is non-free, Emacs doesn’t come with a wrapper for it, but you can download them from here.
vc-annotate - This will display the current file in a new buffer. This buffer will have the revision each line came from, and the user who added that line. Additionally, the buffer will be color-coded according to how old lines are.
vc-annotate-find-revision-at-line - When in a buffer generated from vc-annotate, this will create a buffer containing the contents of the file at whatever revision the current line came from.
vc-annotate-show-changeset-diff-revision-at-line - When in vc-annotate, this will show the diff of the checkin that added the current line.
vc-annotate-show-diff-revision-at-line - When in vc-annotate, this will shown the diff *for this particular file* of the checkin that added the current line.
vc-annotate-show-log-revision-at-line - When in vc-annotate, this will show the checkin message for the commit that added the current line.
vc-create-repo - This will prompt you for a type of repository (svn, bzr, git, etc) and create a new repository in the current directory.
vc-delete-file - This will delete a file and remove it from the repos - for example, it will issue a ’svn rm’.
vc-diff - This will open a buffer containing a diff of the current file with the current file at last revision.
vc-dir - This will show the status of files in the prompted directory in a new buffer. It will tell you which files are unregistered, edited, or added - files in the repository that have not been changed seem to not be displayed. This is much like a ’svn status’ command.
vc-merge - This will merge changes between revisions/branches, bound to C-x v m.
vc-next-action - This will perform what it thinks the next action will be. If in an unchecked file, it will add it to the repos. If you’ve edited the file, it will perform a checkin on that file.
vc-print-log - This will open a buffer with all the checklist comments that apply to the current file.
vc-register - This will add a file to the version control system in the directory - will perform a ’svn add’, ‘p4 add’, etc.
vc-rename-file - This command renames a file in the version control.
vc-resolve-conflicts - vc-resolve-conflicts invokes ediff to resolve conflicts for the current file.
vc-revert - This will revert the current file, losing all changes you’ve made since the last checkin.
vc-revision-other-window - This asks for a revision and then displays that revision of the current file in another window.
vc-update - This will update your copy of the repository to the current status . Essentially, performs a ’svn up’ or ‘p4 sync’.
vc-version-diff - This will prompt for two revisions of the current file and display the diff of those two revisions.
Tags: emacs
For people who prefer ediff over diff, there’s also ediff-revision.
Thanks for the quick tour, I didn’t know about the (new?) vc-annotate-* commands.
I should perhaps mention that I’ve branched Jonathan Kamens’ vc-p4 to improve it for Emacs 23, including multi-file support for some commands, and vc-dir support:
http://public.perforce.com:8080/@md=d&cd=//guest/magnus_henoch/&c=gbd@//guest/magnus_henoch/vc-p4/?ac=83