How to revert a branch? / Branch nicks?

Martin Pool mbp at canonical.com
Wed Sep 16 03:44:23 BST 2009


2009/9/15 Marcelo Alves <marcelo.alves at me.com>:
> Hi,
>   (ok, I think I should write two e-mails instead of just once with two
> questions, but they're closely related, trust me)

Hi Marcelo,

> I'm writing some docs to my developers about bzr and the features provided,
> but I cannot answer two questions :
>   1. How to unmerge / revert a branch? and
>   2. Why the -r parameter (help revisionspec) does not accept branch nicks,
> but it accepts branch paths?

In short because branch nicks are used at present only to give you a
clue of the context where a change was made, not to resolve the
location of a branch.  We'll be looking at this issue more as part of
our upcoming user model review.

> Explaining my case in detail :
>   We're using the "Sorted by status" layout[1], and bzr log --forward --n0
> on main/ gave me something like :
> ------------------------------------------------------------
> revno: 1
> [...snip...]
> ------------------------------------------------------------
> revno: 658
> committer: Developer One<developer.one at i-like-spam.cc>
> branch nick: new-feature
> ------------------------------------------------------------
> revno: 659
> committer: Developer One<developer.one at i-like-spam.cc>
> branch nick: new-feature
> ------------------------------------------------------------
> revno: 660 [merge]
> committer: Developer One<developer.one at i-like-spam.cc>
> branch nick: new-feature
>     ------------------------------------------------------------
>     revno: 644.1.8
>     committer: Developer Three<developer.three at i-like-spam.cc>
>     branch nick: main-tree
>     ------------------------------------------------------------
>     revno: 644.1.9 [merge]
>     committer: Developer Three<developer.three at i-like-spam.cc>
>     branch nick: main-tree
>     ------------------------------------------------------------
>     revno: 644.1.10
>     committer: Developer Three<developer.three at i-like-spam.cc>
>     branch nick: main-tree
>     ------------------------------------------------------------
>     revno: 644.1.11
>     committer: Developer Three<developer.three at i-like-spam.cc>
>     branch nick: main-tree
>     ------------------------------------------------------------
>     revno: 644.1.12 [merge]
>     committer: Developer Three<developer.three at i-like-spam.cc>
>     branch nick: main-tree
>         ------------------------------------------------------------
>         revno: 644.2.1
>         committer: Developer Two<developer.two at main-tree.com>
>         branch nick: main-tree
>     ------------------------------------------------------------
>     revno: 644.1.13
>     committer: Developer Two<developer.two at main-tree.com>
>     branch nick: main-tree
>     ------------------------------------------------------------
>     revno: 644.1.14
>     committer: Developer Two<developer.two at main-tree.com>
>     branch nick: main-tree
>     ------------------------------------------------------------
>     revno: 656.1.1 [merge]
>     committer: Developer One<developer.one at i-like-spam.cc>
>     branch nick: the-forgotten-patch
> ------------------------------------------------------------
> revno: 661
> committer: Developer One<developer.one at i-like-spam.cc>
> branch nick: new-feature
> ------------------------------------------------------------
> revno: 662
> committer: Developer One<developer.one at i-like-spam.cc>
> branch nick: new-feature
> ------------------------------------------------------------
> revno: 663 [merge]
> committer: Developer One<developer.one at i-like-spam.cc>
> branch nick: new-feature
>     ------------------------------------------------------------
>     revno: 654.1.1
>     committer: Developer One<developer.one at i-like-spam.cc>
>     branch nick: main-tree
>     ------------------------------------------------------------
>     revno: 654.1.2 [merge]
>     committer: Developer One<developer.one at i-like-spam.cc>
>     branch nick: main-tree
>     ------------------------------------------------------------
>     revno: 654.1.3
>     committer: Developer One<developer.one at i-like-spam.cc>
>     branch nick: emergency-fix
> ------------------------------------------------------------
> revno: 664
> committer: Developer One<developer.one at i-like-spam.cc>
> branch nick: main-tree
> [...snip...]
> Before you scream "You liar, this ain't the 'Sorted by Status' layout!", let
> me explain: we started the sorted by status layout today, and this is part
> of the documentation.

> Now, suppose I'd like to remove the "new-feature" branch nick. What I've
> tried so far, without luck :
>   'bzr revert branch:../new-feature' : it does not work as expected, reverts
> just the last revision (663);
>   'bzr revert ancestor:../new-feature' : same as above;
>   'bzr revert -1000:../new-feature' : reverts to rev 1;
>   'bzr revert 1:../new-feature' : reverts to rev 1 (hmm, documentation error
> ?);
> Of course, I can revert manually all revisions with the "new-feature" branch
> nick, but why not use 'bzr revert branch:../new-feature' ? or better yet,
> why not 'bzr revert branch-nick:new-feature' ?
> [1]: http://doc.bazaar-vcs.org/bzr.dev/en/user-guide/index.html#sorted-by-status-dev-merged-experimental

I don't really understand how those commands could work at all with no
-r option, so I'm assuming you just left it out of the examples you
pasted in here.

If you want to revert the tree to a previous version, you should
probably use "bzr revert -r 657" which will put this branch back to
the form it had in 657, before these merges were done.  Then commit
that and you'll have undone all those merges.  Or if there are
individual changes mixed in, you can do some reverse merges, like

 bzr merge -r663..657

to undo that range.

It would be interesting if we let you select them by nick or summary,
but there's no ui for that at the moment.

-- 
Martin <http://launchpad.net/~mbp/>



More information about the bazaar mailing list