Braindump

Mercurial Cook Book

DJ's Mercurial Cook Book

This cook book features several recipes. Each recipe is a specific solution to a specific problem. They are listed in alphabetical order.

Find revision when a file was deleted

Problem statement: There was once a file foo.txt in this repository. When has it been deleted?

hg log --template '{rev}: {file_dels}\n' | grep "foo.txt"

Inspect changes in a bundle file

Problem statement: I maintain a certain software package. Somebody sent me a Mercurial bundle with changes that fix a bug. How can I see the changes without applying them?

hg incoming new-feature.bundle         # display changeset info
hg incoming -p -g new-feature.bundle   # display diff

See also: http://mercurial.selenic.com/wiki/LookingIntoBundles

Mirror a subversion repository with Mercurial

Problem statement: I'd like to hack on a certain software package. They natively use the Subversion version control system, but I'd like to use Mercurial anyway. How can I work with Mercurial locally and still access their Subversion history?

hg convert --authors=usernames.txt url/to/subversion-repo path/to/hg-repo

For more details (e.g. using svnsync to improve performance) see MirrorSvnRepoWithHg.