BLOG

Visual Studio buttons for Mercurial

I prefer using the command line myself, but as a shortcut, via Rob at TekPub, here is a great way to use Mercurial through Visual Studio without cumbersome plugins:

  1. Install TortoiseHG
  2. Open Visual Studio
  3. Click Tools » External Tools…
  4. Click Add
  5. Create each one of the items below:

Title: HG Workbench

Command: C:\Program Files\TortoiseHg hgw.exe

Initial Directory: $(SolutionDir)

Title: HG Add Remove


Command: C:\Program Files\TortoiseHg\hg.exe

Arguments: addremove --similarity 100

Initial Directory: $(SolutionDir)

Check the box to Use Output window


Title: HG Commit

Command: C:\Program Files\TortoiseHg\hg.exe

Arguments: commit -m ""

Initial Directory: $(SolutionDir)

Check the box to Prompt for Arguments


Title: HG Pull / Update

Command: C:\Program Files\TortoiseHg\hg.exe

Arguments: pull -u

Initial Directory: $(SolutionDir)

Check the box to Use Output window


Title: HG Push

Command: C:\Program Files\TortoiseHg\hg.exe

Arguments: push

Initial Directory: $(SolutionDir)

Check the box to Use Output window


Then, you’ll see these items show up in your Tools menu.  To take this a step further and add clickable buttons to the Visual Studio toolbar, do the following:

  1. Right-click on the Visual Studio menu bar area, and click “Customize” at the bottom
  2. Under the Toolbars tab, click “New…”
  3. Add a new item titled “Mercurial”
  4. Click over to the “Commands” tab
  5. Select the “Toolbar” radio button
  6. Select your new “Mercurial” toolbar from the dropdown
  7. Click “Add Command”
  8. Add each of the External Commands (one by one unfortunately)

There you go! You should now see a new toolbar with your icons.  Once you have the project loaded, you can click any of those buttons to provide shortcuts to the Mercurial commands as if you were doing it at a command prompt in the root of the Solution folder.

Screenshots below:

calendartwitterfeedenvelopelinkedingithub-altbitbucket