10

Obviously bzr clone, bzr branch and bzr checkout all do the same thing when given an URL as parameter and executed in a non-bzr directory.

Is there any difference for later Bazaar workflow? i.e. bzr commit, bzr update and friends.

knittl
  • 246,190
  • 53
  • 318
  • 364
  • 5
    Don't use `bzr clone`. Right now it's an alias of `bzr branch` but in the future it could be changed to do different thing. – bialix Jun 05 '10 at 16:38

3 Answers3

14

Branching and cloning are the same, but branching and checkouts are not the same.

$ bzr help branch
...
Aliases:  get, clone
See also: checkout

Looking over the Checkout Tutorial, you'll see that a checkout essentially binds every action you take directly to the branch. So anything you do is essentially pushed when you do it -- obviously that's a huge workflow difference.

Difference between a Branch and a Checkout

Let's start by saying there is nothing you can do with a Checkout that you can't do with plain Branches. A Checkout just enables different defaults and workflow helpers.

What does Checkout do

With a Checkout, whenever you create new entries in a local Branch, it also creates them in a remote Branch. This corresponds to commands like bzr commit and bzr pull. If you attempt to commit a new changes, and the remote Branch has a different state than the local one, it will prevent you, and let you know that you are out of date. You can use bzr update to apply the remote changes locally.

Mark Rushakoff
  • 249,864
  • 45
  • 407
  • 398
  • 1
    so checkout switches bzr to a svn-like mode, losing all the benefits of distributed version control – knittl Jun 29 '10 at 07:28
  • 1
    @knittl: not all, because you can still make another branch of your checkout, for example... And one strong point of Bazaar is that it offers a variety of workflows, the checkout one might reassure people coming from centralized VCSes. – PhiLho Jul 09 '10 at 16:14
  • 1
    In addition to PhiLho's points, checkouts can allow one to have multiple feature branches without needing to have a working tree for each one. By using `bzr switch` rather than `cd ` to switch between branches, the code can always be in the same directory. This can be handy for using tools such as IDEs, or serving up a local version of a web project. – Adam Glauser Sep 29 '11 at 15:04
  • @knittl In addition, you can browse history, annotate, and make diffs while offline. If you want to commit wihtou connection you can unbind (so it instantaneously becomes a regular branch) and then commit. – user334639 Feb 11 '12 at 21:26
4

bzr branch and bzr checkout do very different things. They both give you a working tree, but bzr checkout gives you only a working tree; commits and updates work directly on/from the source repository. bzr branch gives you a working tree of a new branch of the repository; commits on this branch will not be automatically applied to the source branch. I'm not sure on clone.

Update: according to the comment, checkout gives you the full history; that seems right. Semantically, checkout looks and feels like a centralized VCS checkout with the branch locally; it implements this by keeping a local history (which you can browse offline - a plus), but linking it back to the original history so you can only commit when you're up-to-date and commits get automatically pushed. Moreover, it is possible to commit without connection by unbinding the checkout, in which case it becomes a regular branch.

user334639
  • 556
  • 5
  • 10
Michael Ekstrand
  • 28,379
  • 9
  • 61
  • 93
  • 2
    This is wrong. bzr checkout is essentially bzr branch + bzr bind. You do get a full branch and you can for instance browse log, diffs and history while offline. The lightweight checkout is what gives you just a tree. – user334639 Feb 09 '12 at 13:19
0

As the other posters have said, "bzr checkout" is a superset of "bzr clone/branch", in that "bzr checkout" creates a bound branch. Bound branches pull from the source repo whenever an update operation is performed and push to the source repo whenever a commit is performed.

To bind a cloned branch or unbind a checked-out branch, use "bzr bind"/"bzr unbind".

Stavros Korokithakis
  • 4,680
  • 10
  • 35
  • 42