Branch Renaming

A recurring compliant against named branches is that the name is permanent. This page describes a backward-compatible proposal to separate a branch's identity from its name.

1. Visioning Branch Names

An .hgbranches file in the working directory will keep a mapping of branch IDs to their names. When a new branch is created, the changeset's branch field will be set to a unique ID. An entry will then be made in .hgbranches, mapping the branch's ID to its name.

2. Conflicts

If conflicting changes have been made to .hgbranches on different branches, or if it contains conflicting entries, this will be resolved by the same rules that apply to .hgtags.

3. Local Branches

If the user creates a local branch which they do not intend pushing, it can be recorded in .hg/localbranches. Mercurial should warn the user if they attempt to push a changeset whose branch name is recorded in localbranches, and tell them how to move it to .hgbranches.

4. Backwards Compatibility

If a branch ID is not recorded in .hgbranches or .hg/localbranches, the ID will be used as the branch name. Thus, existing branches can be used (and renamed) without any modifications. If the branch is renamed, older clients will continue to use the old name.

5. Forwards Compatibility

Future development could add other fields to .hgbranches, such as description or owner.


CategoryNewFeatures CategoryDeveloper