help needed: how to create a commit on not the latest revision in a branch?

John Arbash Meinel john at arbash-meinel.com
Thu Jun 21 16:07:16 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Reinhard Tartler wrote:
> Hi there,
> 
> I want to write a plugin, which does several things. Without going into
> details, I need some help from you to solve the following subproblem:
> 
> Suppose we have a series of commits like this:
> 
> 1 -> 2 -> 3 -> 4
> 
> Now I basically do a 'bzr revert -r 2', do some changes on the tree, and
> want now to create a new commit, having 2 as parent. The end result
> should be a repository which looks like this:
> 
> 1 -> 2 -> 3 -> 4
>   `-> 2.1
> 
> Read: a repository having 2 heads: 4 and 2.1
> 
> I'm still very new to bzrlib and the bzrapi. Can someone please guide me
> how to do such a commit using bzrlib?

First, your text and your description don't line up. I think you want:

  1 -> 2 -> 3 -> 4
       `-> 3.other

Since you at least say that you want it "having 2 as parent".


Well, using bzr I would just:

bzr branch -r 2 existing bugfix
cd bugfix
# do my change
bzr commit -m 'bugfix'

And now you can

cd ../existing
bzr merge ../bugfix
bzr commit -m "merged bugfix"

Which will give you the ancestry of:

  1 -> 2 -> 3 -> 4 -> 5
       `-> 3.other -'

If you want to stay working in the current tree, things get a bit
harder. One of Bazaar's designs is that each *location* is a branch (not
multiple branches per location as some systems do).

Also, I'm not sure if you are using the Bazaar terminology for
"repository". Which is a storage of revisions/old texts/etc. Not "a
location on disk that is versioned". Which is what hg/git (maybe darcs) use.

Because for the above I would have done:

bzr init-repo --trees project
cd project
bzr checkout http://upstream upstream
bzr branch upstream mylocal
# Do my changes in 'mylocal'
bzr branch -r 2 upstream bugfix
# do a specific bugfix in a new branch based off of the mainline
# revno 2

Is this being helpful or just confusing? I'm happy to go more
interactive in IRC if you prefer.

John
=:->


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGepQkJdeBCYSNAAMRAsJ4AKCFO6CRpBgyw/wKsp3CLHJFz/okUQCghqXB
ZWGlsPmFAdsp6OpMt9x9KwU=
=DXKZ
-----END PGP SIGNATURE-----



More information about the bazaar mailing list