Emacs + TFS

Emacs + MS Team Foundation Server

 
Do you want to use MS TFS from within Emacs?

Do you wish Emacs had TFS integration? This is a start.

tfs.el is elisp code that provides emacs functions that do basic TFS tasks. The tasks include: checkout, checkin, status, history, diff, properties, get, undo.

If you use emacs, and also use TFS, you probably want to try this out. It's really easy to use.

Next steps:

Why Emacs and TFS?

Team Foundation Server is Microsoft's team development and version control server product. It is nicely integrated with Visual Studio. The Team Foundation Server product also includes a command-line client tool that can connect to the server to perform basic tasks.

Many people use both Visual Studio and emacs when working on .NET projects. Visual Studio has invaluable designers, unit test capability, red squiggles, and many other useful features. On the other hand, Emacs is sometimes much more productive for editing a set of code files all at once, because of its macro support, buffer handling, kill and yank, abbrevs, and so on.

Integrating Emacs with TFS provides obvious benefits. It means you can visit a code file in emacs, then, with a few keystrokes, check it out from TFS and begin editing. You can revert (undo) changes, and release locks. You can perform diffs, and do other basic TFS tasks.

Of course, you can also do all of these things within Visual Studio, using the Source Control Explorer or context menus. The key point is, you can do the TFS work from either environment.

Capabilities of Emacs + TFS
function default key binding description
tf checkout \C-x v o checkout the file currently being visited.
tf checkin \C-x v i checkin edits for the file currently being visited.
tf undo \C-x v u undo (discard) edits for the file currently being visited.
tf diff \C-x v d diff current file against the latest checked-in version
tf rename \C-x v r rename the current file
tf delete \C-x v - delete the file currently being visited, from source control
tf add \C-x v + add the file currently being visited, into the source control system
tf history \C-x v h detailed history of the file currently being visited
tf status \C-x v s status of the project - which files have pending changes.
tf get \C-x v g get the latest version of the file currently being visited, as a readonly copy
Requirements

Theoretically, you should be able to connect to a TFS server from any machine, Windows or not. but I don't have any machine, I have a Windows machine. And I don't know if there's a command-line tool for TFS available on non-Windows platforms. If you know of one, let me know!

It shouldn't be hard to build, as TFS exposes a web services interface between client and server, and third parties have already produced clients using Java.

Features not included in tfs.el

If you are inspired to build any of these things yourself, or if you would like to collaborate on the work, please Send me a message.

How to use tfs.el

These are the steps to setup tfs.el for use:

  1. Download tfs.el and place it in your `load-path'.
  2. In your .emacs file:
            (require 'tfs)
            (setq tfs/tf-exe  "c:\\vs2008\\common7\\ide\\tf.exe")
            (setq tfs/login "/login:domain\\userid,password")
    
  3. also in your .emacs file, set local or global key bindings for tfs commands. Like so:
     
            (global-set-key  "\C-xvo" 'tfs/checkout)
            (global-set-key  "\C-xvi" 'tfs/checkin)
            (global-set-key  "\C-xvp" 'tfs/properties)
            (global-set-key  "\C-xvg" 'tfs/get)
            (global-set-key  "\C-xvh" 'tfs/history)
            (global-set-key  "\C-xvu" 'tfs/undo)
            (global-set-key  "\C-xvd" 'tfs/diff)
            (global-set-key  "\C-xvs" 'tfs/status)
            (global-set-key  "\C-xvr" 'tfs/rename)
            (global-set-key  "\C-xv-" 'tfs/delete)
            (global-set-key  "\C-xv+" 'tfs/add)
    

That's it for setup.

To use it, visit a file that is under source-code-control with TFS. Then use the key-bindings to do your TFS things.

Why is tfs.el not integrated into vc.el?

Emacs has a "pluggable" version control subsystem, implemented in vc.el, which can support numerous "back ends", including GIT, SVN, CVS, RCS, SCCS, and more. There was even, once, a basic Visual Source Safe integration done.

I wanted to produce the tfs backend for vc.el, but I could not find a clear statement of what was necessary in order to plugin to vc.el.

The overall job seemed fairly straightforward to me: run the tf.exe commands necessary for checkout, checkin, and so on, via emacs keybindings. This required the creation of a few emacs functions. But the vc.el code was pretty opaque to me. And I found no documentation guiding me on how to add a new backend to vc.el.

It's been done before, so I know it's possible. I just couldn't figure out how to do it cleanly.

I actually spent more time trying to figure out vc.el, than I did actually implementing the "unintegrated" TFS capability available in today's tfs.el.

The License

The TFS integration for Emacs (Emacs+TFS, referred to as "the software" in the text below) is an add-on to Emacs that provides integration with Microsoft Team Foundation Server. Emacs+TFS and its documentation is distributed under the Microsoft Permissive License, which is spelled out below. This license is also included in the tfs.el file.

Microsoft Permissive License (Ms-PL)
Published: October 12, 2006

This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.

  1. Definitions
    The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.

    A "contribution" is the original software, or any additions or changes to the software.

    A "contributor" is any person that distributes its contribution under this license.

    "Licensed patents" are a contributor's patent claims that read directly on its contribution.

  2. Grant of Rights

    (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.

    (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.

  3. Conditions and Limitations

    (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.

    (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.

    (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.

    (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.

    (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
Download

Before downloading, you may want to view the license.

Download: tfs.el

Contact

Wanna help? Got questions? Suggestions? Contact me

 

(click for a printable page)

 


This page has been accessed 1178 times since 27 July 2009