Rename a Named Branch in mercurial?

Steve Borho steve at borho.org
Mon Jan 7 14:03:45 CST 2008


On Mon, 2008-01-07 at 13:30 -0600, Sean Kelley wrote:
> Here are some steps that do not work well:
> 
> On Jan 7, 2008 12:57 PM, Sean Kelley <svk.sweng at gmail.com> wrote:
> > Hello,
> >
> > What is the correct way to rename named branches in Mercurial?  Is
> > there a file in .hg at the repository level or is there a way to do it
> > with commands?
> 
> Given:
> 
> default
> release
> 
> I want to rename release to release-2.x.  This is the way I came up
> with it that I hope is clean:
> 
> 
>   $ hg clone ssh://hg.server.com//data/hg/platforms/kernel/linux
>   $ cd linux
>   $ hg checkout -C release
>   $ hg branch release-2.x
>   $ hg commit (empty commit to force a new changeset)
> 
> Your branches are:
> 
>   $ hg branches
> release-2.x                835:f97d01fc45da
> default                            834:ed70e3f05b7d
> release                       830:a49103cae61a (inactive)
> 
> Your heads are:
> 
>    $ hg heads
> 
> changeset:   835:f97d01fc45da
> branch:      release-2.x
> tag:         tip
> parent:      830:a49103cae61a
> user:        svk at server.com
> date:        Mon Jan 07 13:22:48 2008 -0600
> summary:     New branch.
> 
> changeset:   834:ed70e3f05b7d
> user:        Ross <ross at server.com>
> date:        Thu Jan 03 11:54:04 2008 -0600
> summary:     Added tag beta-1.45 for changeset 2bcd22bed0d8
> 
> Thoughts?
> 
> That way the old branch is now inactive and the new branch is now the
> head of the old one.  It seems like the most 'Mercurial' way of
> handling it.

That looks right.

Named branches in Mercurial are intended to be permanent fixtures of
your repository.  The "Mercurial way" to maintain a short-lived
(disposable) feature branch is to make a local clone and then either
pull or transplant the resultant changes into the upstream repository.

Or if you prefer, you can just do the development in the same repository
and on a new head and merge the results when you are done or use MQ to
rebase your changes onto the tip.

-- 
Steve Borho (steve at borho.org)
http://www.borho.org/~steve/steve.asc
Key fingerprint = 2D08 E7CF B624 624C DE1F  E2E4 B0C2 5292 F2C6 2C8C



More information about the Mercurial mailing list