The key feature of the centralized mode is that it automatically keeps bound branches synchronized with their master branch. This opens interesting possibilities that can be useful in many situations, regardless of the workflow or the size of a team. To give you some idea here, we briefly introduce a few example use cases.
If you use multiple computers to work on a project, for example, a desktop and a laptop, or computers at different locations, then you probably need a way to synchronize your work done at physically different locations.
Although you can synchronize branches between the two locations by using mirror operations such as bzr push
and bzr pull
, they are not automatic, and thus you may easily find yourself in a situation that you cannot access some changes you did on another computer, because you forgot to run bzr push
before you switched off the machine, for example.
Using the centralized mode can help here, because the synchronization between two branches is automatic, as it takes place at the time of each commit. You can start using the centralized mode by converting the branch you used to push to into a master branch, and binding to it with your other branches.
Let's say you have two computers, computerA
and computerB
, they both can access a branch at some location branchX
, and you work on the branch sometimes by using computerA,
and at other times by using computerB
. (Whether branchX
is hosted on computerA
or computerB
or a third computer doesn't matter, the example will still hold true.)
You can keep your work environments synchronized by using the bzr push
and bzr pull
operations, by adopting the following workflow on both the computers when working on branches you want to share:
branchX
.branchX
.This can be tedious and error-prone; for example, if you forget to push your changes on one computer, then you might not be able to access those changes after switching to the other computer, as it may have been powered down, or be inaccessible directly over the network.
Using the centralized mode would simplify the workflow to only two steps:
branchX
.Not only there is one less step to do, but since in this case branchX
is automatically updated at every commit, the possibility of forgetting to run bzr push
is completely eliminated.
You can convert your existing setup to using centralized mode simply by binding to branchX
on both the computers, and then using the update
command to synchronize. Assuming that both branches have no pending changes and both have been pushed to branchX
as their last operation, you can convert them by using the following commands:
On computerA
:
$ bzr pull $ bzr bind :push
On computerB
:
$ bzr bind :push $ bzr update
After this, you can start using branchX
in the centralized mode, as a cycle of the bzr update
and bzr commit
operations.
An easy way to back up a branch is by pushing it to another location. For example:
$ bzr push BACKUP_URL
BACKUP_URL
can be a path on an external disk, a path on a network share or network filesystem, or any remote URL.
However, the push operation is not automatic; it must be executed manually every time you want to update the backup.
Another way is to bind the branch to the backup location, effectively using it in the centralized mode. In this case, all commits in the bound branch will be automatically applied to its master branch too, keeping the backup up-to-date at all times.
You can convert the branch to this setup, simply by binding to the push
location:
$ bzr bind :push
Since this practically means switching to the centralized mode, it is important to have fast access to BACKUP_URL
, otherwise the delay at every commit might be annoying.
If you need to break out of the centralized mode, for example when the BACKUP_URL
is temporarily unavailable for some reason, then simply run bzr unbind
. And after BACKUP_URL
becomes available again, you can bring the remote branch up-to-date with bzr push
, and re-bind to it by using bzr bind
without additional parameters to return to the centralized mode.
3.144.93.141