RSS

Bazaar Part 4: push & pull

Using push/pull with bazaar.  Before I started playing around with bazaar I spent a little bit of time with git.  Since my background has been entirely CVS I thought that push and pull were generally “special” operations in newer vcs systems.  It turns out, in bazaar push and pull do nothing other than manage mirrors of branches.  If I’m sitting in a branch and issue a bzr push command, I’ll end up with a mirror of the current branch in the push target, like so:

[andrew karma] /Users/andrew/Development/BZR/myBranch
>>>>>> bzr push ../myBranch.mirror
Created new branch.

I now have a branch called myBranch.mirror in my BZR directory.  I’m going to take a look at it now.

[andrew karma] /Users/andrew/Development/BZR
>>>>>> ls
total 0
0 myBranch/        0 myBranch.mirror/ 0 myRepository/

[andrew karma] /Users/andrew/Development/BZR/myBranch.mirror
>>>>>> bzr info
Standalone tree (format: pack-0.92)
Location:
branch root: .

Related branches:
parent branch: /Users/andrew/Development/BZR/myRepository/myProject/myBranch

At this point, it appears that a pushed branch is really no different than a branch that you’ve made using the branch command.  You can use push and pull to keep the mirror in sync, as long as the branches have not diverged.  A branch is considered to be diverged if there is a check-in in the dest that is not in the source.  You can work around this by merging the dest onto the source prior to running the push, or by using –overwrite command that will overwrite the information in the target.

One thing I’m starting to notice is that there are many ways to get to the same place with bazaar.  bzr branch/bzr bind is identical to bzr checkout while bzr checkout/bzr unbind is identical to bzr branch.  I suspect that there are options to checkout/branch/bind/unbind that makes the operations a little more convenient but they really aren’t dramatically different commands.  I think that push/pull fall into this camp.  I don’t think they do much that you can’t accomplish with branch/commit/update, but they may let you think about what you’re trying to accomplish in a different way.

Below are a number of other commands that I’ve mentioned but haven’t really talked much about.  I’m not going to go through examples, just describe what they do.

bind/unbind

Bind is used to make a branch behave like a checkout in CVS.  Commits made to the local branch will automatically update the parent branch.  In fact, the commit must succeed on the parent before the commit is allowed to happen locally.  Unbind is the reverse, switch to a mode where all commits are local.  I don’t know what all of the implications are of binding a diverged branch are.  Perhaps I’ll cover that later.

export

This is a neat command that allows you to “publish” your branch to somewhere.  The result is not under version control, it’s just a copy of your branch suitable for distribution.  The neat thing about this command is that it can export directly into a number of different formats.   For example:

[andrew karma] /Users/andrew/Development/BZR/myBranch.branch1
>>>>>> bzr export ../foo.tgz

[andrew karma] /Users/andrew/Development/BZR/myBranch.branch1
>>>>>> cd ..

[andrew karma] /Users/andrew/Development/BZR
>>>>>> ls
total 8
8 foo.tgz           0 myBranch/         0 myBranch.branch1/ 0 myBranch.mirror/  0 myRepository/

[andrew karma] /Users/andrew/Development/BZR
>>>>>> tar ztvf foo.tgz
drwxr-xr-x user/group        0 2009-04-20 22:11:14 foo/myDir/
-rw-r–r– user/group        0 2009-04-20 22:11:14 foo/myDir/test4.txt
-rw-r–r– user/group      142 2009-04-20 22:11:14 foo/test1.txt
-rw-r–r– user/group       60 2009-04-20 22:11:14 foo/test2.txt
-rw-r–r– user/group       30 2009-04-20 22:11:14 foo/test3.txt
-rw-r–r– user/group       20 2009-04-20 22:11:14 foo/test5.txt

This is a pretty neat way to package stuff up for deployment or download.  It appears that the export command understand bz2, tar, tgz, and regular directories.

revno

This command shows you what revision your branch is on.  Unlike CVS, bazaar seems to verion the entire branch rather than files within the branch.   This has been the strangest thing to get used to with bazaar, and it’s really not a huge deal.  When you revert a file to a particular revision, what you are saying is revert this file to it’s state as of version x of the branch.

revert

The revert command allows you to roll back changes in a file.  This command also lets you throw away locally made changes that you don’t want to commit.  bzr help revisionspec contains a ton of information about how to specify a revision in commands that use a full revisionspec (like revert).

I’ve figured out that push/pull really aren’t anything special, and added some information on other commands.  This wasn’t the most detailed post in the world, but I’m short on time, and wanted to get something posted.  Perhaps I’ll tackle repository permissions in my next post.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>