Differences between revisions 6 and 7
Revision 6 as of 2009-06-16 07:39:59
Size: 2642
Editor: abuehl
Comment: move design bits from LocalBranches
Revision 7 as of 2009-06-16 07:41:38
Size: 2646
Editor: abuehl
Comment:
Deletions are marked like this. Additions are marked like this.
Line 18: Line 18:

Additional design notes may be found at LocalBranches
Line 42: Line 40:
Additional design notes may be found at [[LocalBranches]]

Local Branch Extension

This extension is not distributed with Mercurial.

Author: Brendan Cully

Download site: http://hg.kublai.com/mercurial/extensions/localbranch

Overview

This extension provides a new command lbranch, with which you can create and manage in-repository clones. One advantage these have over regular clones is that they share a working directory, so they are cheaper to create. They are also less work to use. Often you have the path to your working directory mentioned in several other locations (external build tools, path, etc), so a full clone requires many other updates. This way everything works against your branch automatically.

lbranch with no arguments lists the local branches in the current repository. lbranch foo switches to local branch foo, creating it if it does not yet exist. lbranch -d foo deletes local branch foo.

You can pull from or push to local branches by their branch name, or by the unambiguous form lbranch://foo (which is often necessary to pull or push to default).

Configuration

Configure your .hgrc to enable the extension by adding following lines:

[extensions]
localbranch = /path/to/localbranch.py

Design

Named branches are nice for long-lived branches (eg stable vs development). But sometimes you want to create short-lived branches, perhaps to develop a feature. Once the code has matured to the point where it is ready for mainline, the history of its development is often just uninteresting clutter. The usual answer is to use Mercurial's nice lightweight clones. But even these require duplication of the working directory for each branch, and often other setup work (configure runs etc).

Local branches are clones that live within a repository, allowing you to share one working directory across several branches, but then to be able to drop those branches trivially when you are done with them.

Mechanism:

  • local branches are clones of .hg/store, residing under .hg/branches.
  • hg lbranch foo will clone the current repo to foo (or switch to an existing clone of that name) and write the branch name to .hg/localbranch
  • hg lbranch without arguments displays the local branches, with a '*' by the currently checked-out branch
  • hg lbranch -d <foo> will delete the local branch foo

  • hg pull/push/incoming/outgoing resolve local branch names to the appropriate subdirectory. You can prefix the target with lbranch:// in case of ambiguity.

Additional design notes may be found at LocalBranches


CategoryExtensionsByOthers

LocalbranchExtension (last edited 2012-11-23 13:02:55 by rcl)