How to safely move/rename a branch in a shared repository ?

Asked by Alexandre Garnier

I'd like to reorganize branches in my shared repository but simply using mv on branches folders is not enough. For example:

$ bzr init-repo --no-trees repo
Shared repository (format: pack-0.92)
Location:
  shared repository: repo
$ bzr init repo/branch1
Repository branch (format: pack-0.92)
Location:
  shared repository: repo
  repository branch: repo/branch1
$ bzr branch repo/branch1 repo/branch2
Branched 0 revision(s).
$ bzr info repo/branch1
Repository branch (format: pack-0.92)
Location:
  shared repository: repo
  repository branch: repo/branch1
$ bzr info repo/branch2
Repository branch (format: pack-0.92)
Location:
  shared repository: repo
  repository branch: repo/branch2

Related branches:
  parent branch: repo/branch1
$ mv repo/branch1 repo/branch1_old
$ bzr info repo/branch2
Repository branch (format: pack-0.92)
Location:
  shared repository: repo
  repository branch: repo/branch2

Related branches:
  parent branch: repo/branch1
$ bzr info repo/branch1
Shared repository (format: pack-0.92)
Location:
  shared repository: repo

Moving branch1 into branch1_old seems to break the relation between branch1 and branch2. Adapting parent_location in repo/branch2/.bzr/branch/branch.conf solve the problem.

Am I using the wrong method ? Is there a command to do that ?

Question information

Language:
English Edit question
Status:
Answered
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Dan Watkins (oddbloke) said :
#1

Hi Alexandre,

Thanks for your question.

To answer it briefly, you're doing it in roughly the right way. We store parent locations as URLs, so if there is no longer anything at that URL then the relationship with that branch is broken. As such, you need to instruct bzr as to where it can find the moved branch, which changing parent_location does.

It seems that there should be a way to do this from the UI, the lack of which is a bug. Once I've confirmed that there isn't a way, I'll file a bug to that effect.

Dan

Revision history for this message
Wouter van Heyst (larstiq) said :
#2

On Thu, Oct 16, 2008 at 12:45:05PM -0000, Daniel Watkins wrote:
> Question #48161 on Bazaar changed:
> https://answers.edge.launchpad.net/bzr/+question/48161
>
> Status: Open => Answered
>
> Daniel Watkins proposed the following answer:
> Hi Alexandre,
>
> Thanks for your question.
>
> To answer it briefly, you're doing it in roughly the right way. We
> store parent locations as URLs, so if there is no longer anything at
> that URL then the relationship with that branch is broken. As such, you
> need to instruct bzr as to where it can find the moved branch, which
> changing parent_location does.
>
> It seems that there should be a way to do this from the UI, the lack of
> which is a bug. Once I've confirmed that there isn't a way, I'll file a
> bug to that effect.

Also see https://bugs.edge.launchpad.net/bzr/+bug/276404

Wouter van Heyst

Revision history for this message
thava (thavamuni) said :
#3

It appears there is still no support to rename the branch from bzr command line. Or has this support been added since ?

Revision history for this message
Jelmer Vernooij (jelmer) said :
#4

On Wed, 2010-08-11 at 15:23 +0000, thava wrote:
> Question #48161 on Bazaar changed:
> https://answers.launchpad.net/bzr/+question/48161
>
> thava proposed the following answer:
> It appears there is still no support to rename the branch from bzr
> command line. Or has this support been added since ?
You can rename a branch simply by renaming the directory.

Cheers,

Jelmer

Revision history for this message
thava (thavamuni) said :
#5

> You can rename a branch simply by renaming the directory.
However, the other branches in the same repository may refer to this project using the old name. It will be nice if a command fixes the repository to update all these links too (by updating the relevant branch.conf files, etc).

Revision history for this message
Alexander Belchenko (bialix) said :
#6

Such feature could be useful, and it's possible to have it implemented as plugin. But there is nothing exists yet.

Revision history for this message
André Bachmann (andrebachmann-dd) said :
#7

I just had the same wish from one of my bzr users here. He wants to rename a branch but there don't seem to be a nice, user-friendly way to do this.

Revision history for this message
Martin Pool (mbp) said :
#8

I thought there would be a bug for this, but I don't see one, so I'll create it.

Revision history for this message
Martin Pool (mbp) said :
#9

Well, actually reading this a bit more, there are two things:

One is that it might be nice if you could rename the branch within bzr, rather than by moving the directory; that we can possibly fix.

The other is that there might be other branches, in the same repository or elsewhere on the internet, that refer to the old name. We could fix up the local branches, but it's not going to be possible to find and update branches located somewhere else.

Can you help with this problem?

Provide an answer of your own, or ask Alexandre Garnier for more information if necessary.

To post a message you must log in.