Record extension for Mercurial

Record is an important extension for Mercurial and it ships along with it. It provides the record command, using which you can pick and choose which changes and modified files you want to commit. It feeds you the changes and modified files in an interactive format, so you do not have to type out long paths or other specifications.

You can specify which of the modified files you want to commit to the commit command, but typing out the file paths like that is cumbersome. Also, it does not allow you to pick and choose changes inside a file. I feel that the record command is better for this use case.

To enable the Record extension, add these lines to your hgrc:

[extensions]
record =

Using it is as simple as:

$ hg record

For each change or file it shows, you can provide one of these inputs:

y - record this change
n - skip this change

s - skip remaining changes to this file
f - record remaining changes to this file

d - done, skip remaining changes and files
a - record all changes to all remaining files
q - quit, recording no changes

? - display help

Tried with: Mercurial 2.8.2 and Ubuntu 14.04

Advertisements

How to use hgwatchman extension for Mercurial

hg status command can be very slow on a repository with thousands of files. This is because it has to explicitly check the status of every file. A great method to speed it up is the hgwatchman extension for Mercurial. It uses the Watchman tool which relies on the inotify mechanism of the Linux kernel to be notified directly of only the changes that occurred to the files in a directory. There are no packages of hgwatchman and Watchman for Ubuntu, so we need to build them from source. But it is pretty easy to do:

  • Install the Watchman tool as described here.

  • Download the hgwatchman source code:

$ hg clone https://bitbucket.org/facebook/hgwatchman
  • Build the code:
$ cd hgwatchman
$ make local

If you forget this step, everything seems to be fine until you start seeing this error:

$ hg status
abort: No module named bser!

bser.so is a module that is built by this step.

  • Add these lines to your hgrc:
[extensions]
hgwatchman = /path/to/hgwatchman/hgwatchman

[hgwatchman]
mode = on
  • That is it! You should see a nice improvement in the performance of hg status after using hgwatchman.

Tried with: Watchman 3.0.0, Mercurial. 2.8.3 and Ubuntu 14.04

Referer Control extension for Chrome

Referer is one of the fields in a HTTP request header. It is filled with the domain from where a user clicked a link to get to the new URL. For example, say you clicked a link in a Google search result to get to a MIT webpage. The HTTP header that the MIT web server receives will have google.com in its Referer field.

Referer Control is an extension for Chrome that gives you the power to set this field to anything you want. For example, for all links heading to http://mit.edu/* you can set the Referer to be https://google.com by setting it in the Custom field.

Tried with: Referer Control 0.55, Chrome 39.0.2171.95 (64-bit) and Ubuntu 14.04

HgList extension for Mercurial

When I am at the shell inside a Mercurial repository, I sometimes want to list only those files that are under version control and some details about them. Something like the ls command, but for Mercurial. That is exactly what the HgList extension for Mercurial sets out to do.

It can be installed from PyPI easily:

$ sudo pip install hglist

To enable it, add this line to your global .hgrc:

[extensions]
hglist =

It can be used at any directory inside any Mercurial repository:

$ hg list
$ hg ls
$ hg ls -l -H

Tried with: HgList 0.3, Mercurial 2.8.2 and Ubuntu 14.04

Ballloon extension for Chrome

Ballloon, yes it has three L characters, is one of the many Chrome extensions that allow you to save files from webpages directly to your Dropbox or Google Drive.

After installation, you can see the Dropbox and Google Drive icons at the top right corner of images on webpages. You can also right-click on any link that points to a file and choose Save link to option to save it using Ballloon.

The first time you use it, the extension walks you through the steps of authenticating with the cloud services. It shows a nice status notification while the file save is in progress and after it has finished. I found other extensions lacking in this type of status notification. In Dropbox, the files you saved will be stored in the Ballloon directory.

Tried with: Ballloon 1.5.3.1, Chrome 35.0.1916.153 and Ubuntu 14.04

Download to Dropbox extension for Chrome

Since Dropbox can be used from anywhere, I find it convenient to download and save many files there. I find it especially useful to download files while I am browsing. For example, to save images or podcast MP3 files. The Download to Dropbox extension for Chrome makes this process convenient.

After installation, go to its Options. In the Dropbox Account tab, you need to authenticate this extension with your Dropbox account to give it permissions to write files into your Dropbox. After this, you can right-click on any content on a webpage and choose Upload to Dropbox. The file will be added to the directory Apps/Downloads from Chrome in your Dropbox.

Tried with: Download to Dropbox 0.1.9, Chrome 35.0.1916.153 and Ubuntu 14.04

Octotree extension for Chrome

If you use Github a lot for browsing code, then you will find it irritating that it does not have a project explorer. That is, you want to explore the directory structure of a project and view the source code of the files by clicking through the directory structure. This is a standard feature in all IDEs and most editors.

Octotree provides just this useful feature to Github. This Chrome extension can be installed from here. Its source code is here.

On any Github project page, it gives a sidebar that shows the directory structure and you can click through to view the source code of any file in the project.

Tried with: Octotree 1.3.0, Chrome 35.0.1916.153 and Ubuntu 14.04

Google Dictionary extension for Chrome

I love having the dictionary around everywhere. When I am in the browser I like to use the Google Dictionary extension for Chrome. Install it from here. To see the meaning of any word just double-click it and the meaning appears immediately in a pop-up.

Tried with: Google Dictionary 4.0.2 and Chrome 34.0.1847.132

How to use Activity extension of Mercurial

Display of activities on a Mercurial repository
Display of activities on a Mercurial repository

The Punchcard extension of Mercurial can be used to obtain a calendar chart of your contributions to a repository, as shown in here. If you need to view the classic line graph of activities in a Mercurial repository, then the Activity extension is a great solution.

  • This extension uses Matplotlib and requires a recent version. Matplotlib that ships with Ubuntu is typically ancient, so uninstall that and install the latest using pip:
$ sudo apt-get purge python-matplotlib python-matplotlib-data
$ sudo pip install --upgrade matplotlib
  • Clone the repository of the Activity extension to get the latest source code:
$ hg clone http://sources.freehackers.org/Hgactivity/
  • Add lines to your hgrc to use this extension:
[extensions]
activity=/path/to/Hgactivity/activity
  • To view line graph of activities on your repository in an interactive GUI:
$ hg activity --mode=gui

You can view commits, branches, tags and users. Activities across different files and directories can be viewed by choosing options in the GUI.

  • To generate an image file named activity.png of this line graph:
$ hg activity --mode=file
  • If you find yourself using one of these activity options a lot, you could create an alias for it by adding these lines to your hgrc:
[alias]
gact = activity --mode=gui

After this, you can use the alias instead of the more verbose form:

$ hg gact

Tried with: Mercurial 2.8.2, Matplotlib 1.5.0 and Ubuntu 14.04

How to use Punchcard extension of Mercurial

Punchcard of a Mercurial repository
Punchcard of a Mercurial repository

One of the coolest feature of Github is the calendar chart that is shows for your contributions. You can get a similar chart for any Mercurial repository on your computer using the Punchcard extension.

  • First clone the Punchcard repository in a suitable directory:
$ hg clone https://bitbucket.org/birkenfeld/hgpunchcard
  • Modify your hgrc by adding these lines:
[extensions]
hgpunchcard = /path/to/hgpunchcard.py
  • To generate the punchcard for a repository, try this command from inside any of its directories:
$ hg punchcard

This saves a file named punchcard.png that a chart of your commits to this repository, as shown above.

Tried with: Mercurial 2.8.2 and Ubuntu 14.04