Home > Computers > programming > bzr > BzrTutorial | About
In this tutorial, I'll show how to setup a completly server free workflow using the bazaar distributed version control system (DCVS).
I'll show you all of the possible actions you would ever want to do to your code, like :
- having a branch for developement and keeping a branch for hotfixing the current production version.
- how to give your code to a team mate so that he can start hacking right off
- how to get code from a team mate to integrate into your own
- how to deploy your code to the test server
- how to hotfix something on the test server and then merge it back to the main branch (either dev or prod)
All of this in ridiculously fine-grained atomic steps.
- ) Create machines
- ) Create a local prod repo in my machine
- ) Create the dev branch out of prod
- ) Checkout the dev branch and commit to it
- ) Make sure the commit goes to the REPO as well
- ) Give the code to Emmanuel
- ) Emmanuel and I change the code simultaneously
- ) Code is ready for testing. I ask Emmanuel to give me his copy
- ) I merge his code with mine
- ) I commmit it to the dev branch
- ) I put that branch in the test server
- ) I create the necessary repos in the server
- ) I checkout the repo in the /srv/www/ directory
- ) I make a hotfix in /srv/www/
- ) The hotfix must be merged back to the developers branches
- ) The dev branch itself needs to be merged to the prod branch and tagged
Let's go.
1) Create machines
First, we need to have three machines : my own, my team mate's, and the test server. In reality, I created them inside a directory but let's just pretend they are really on separate physical locations and that there is no network connection between them. Code will be carried from machine to machine using only tarballs. No server operation will ever be needed so that you don't have to expose any of your machines to the Internet 24/7. This case also applies when one of your machines is accessed with difficulty (inside a VPN, requires a specific software to connect to etc.)
Let's lay out the directory structure :
chaouche@fictive ~/TMP $ mkdir BZR-TEST
My username is chaouche, and I'll be doing all my expriments inside a new directory in ~/TMP/BZR-TEST. ~/TMP was already there so I used it.
chaouche@fictive ~/TMP $ cd BZR-TEST/ chaouche@fictive ~/TMP/BZR-TEST $ ls total 0 chaouche@fictive ~/TMP/BZR-TEST $
Let's make 3 directories now, each one will represent a different computer : the TEST computer, my computer (YCHAOUCHE) and my team mate's computer (EMMANUEL)
chaouche@fictive ~/TMP/BZR-TEST $ mkdir TEST chaouche@fictive ~/TMP/BZR-TEST $ mkdir YCHAOUCHE chaouche@fictive ~/TMP/BZR-TEST $ mkdir EMMANUEL chaouche@fictive ~/TMP/BZR-TEST $ ls total 12K drwxr-xr-x 2 chaouche users 4.0K Dec 13 10:39 EMMANUEL drwxr-xr-x 2 chaouche users 4.0K Dec 13 10:38 TEST drwxr-xr-x 2 chaouche users 4.0K Dec 13 10:38 YCHAOUCHE chaouche@fictive ~/TMP/BZR-TEST $
Let's start with my computer. This is where the initial code will be produced :
chaouche@fictive ~/TMP/BZR-TEST $ cd YCHAOUCHE/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE $ ls total 0 chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE $
Let's make the illusion better by creating the directories you'd find in a real machine :
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE $ mkdir -p home/ychaouche/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE $ mkdir -p opt/srv/www chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE $ ls total 8.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 10:41 home drwxr-xr-x 3 chaouche users 4.0K Dec 13 10:42 opt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE $ cd home/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home $ ls total 4.0K drwxr-xr-x 2 chaouche users 4.0K Dec 13 10:41 ychaouche chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home $ cd ychaouche/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ ls total 0 chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche
2) Create local repo in my machine
So, I'm in my simulated home directory. I'll create two directories : One is REPO, the other is CODE. REPO is a local repository. It will contain two branches of the code : the development version and the production version.
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ mkdir REPO chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ mkdir CODE chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ cd REPO/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ ls total 0 chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ bzr init myapp-prod Created a standalone tree (format: 2a) chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $
This will create the myapp-prod repository.
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ cd myapp-prod/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-prod $ ls total 0 chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-prod $ emacs readme.txt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-prod $ bzr add readme.txt adding readme.txt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-prod $ bzr ci Committing to: /home/chaouche/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-prod/ added readme.txt Committed revision 1. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-prod $ ls total 4.0K -rw-r--r-- 1 chaouche users 54 Dec 13 10:57 readme.txt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-prod $
3) Create the dev branche
Good. We have create our first file inside the production branch and commited it to the local repository. From now on, I'll be using only the word repository, ommiting "local" because they're all local, we don't have a server with a main central repository, but we still all work on the same two branches : myapp-prod or myapp-dev.
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-prod $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ ls total 4.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 10:57 myapp-prod chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $
Let's create the developement branch out of the production branch :
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ bzr branch myapp-prod/ myapp-dev Branched 1 revision(s). chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO
4) Checkout the dev branche and commit to it
Good : I have just create the initial setup. Now I'll start coding on my own working directory, not the repository one, to keep things clean.
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ ls total 8.0K drwxr-xr-x 2 chaouche users 4.0K Dec 13 10:42 CODE drwxr-xr-x 4 chaouche users 4.0K Dec 13 10:58 REPO chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ cd CODE/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ ls total 0 chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ ls total 0 chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $
I'll checkout the dev branch :
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ bzr checkout ../REPO/myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ ls total 4.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 10:59 myapp-dev chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ cd myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ ls total 4.0K -rw-r--r-- 1 chaouche users 54 Dec 13 10:59 readme.txt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $
And start coding. Let's pretend I edit readme.txt
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ emacs readme.txt & [1] 4210 chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ bzr ci Committing to: /home/chaouche/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev/ modified readme.txt Committed revision 2. [1]+ Done emacs -fg white -bg black -cr honeydew2 readme.txt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $
5) Make sure the commit goes to the repo as well
Good. I commited my first modification. It should have gone to the repository. Let's make sure that it did:
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ ls total 8.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 10:59 CODE drwxr-xr-x 4 chaouche users 4.0K Dec 13 10:58 REPO chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ cd REPO/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ ls total 8.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 10:58 myapp-dev drwxr-xr-x 3 chaouche users 4.0K Dec 13 10:57 myapp-prod chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ cd myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ ls total 4.0K -rw-r--r-- 1 chaouche users 54 Dec 13 10:58 readme.txt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ bzr info Standalone tree (format: 2a) Location: branch root: . Related branches: parent branch: /home/chaouche/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-prod chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ bzr st working tree is out of date, run 'bzr update' chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $
AHA !
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ bzr update M readme.txt All changes applied successfully. Updated to revision 2 of branch /home/chaouche/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ bzr st chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ ls total 8.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 11:00 myapp-dev drwxr-xr-x 3 chaouche users 4.0K Dec 13 10:57 myapp-prod chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $
6) Give the code to Emmanuel
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ cd ../../../../EMMANUEL/ chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL $ mkdir -p home/emmanuel/ chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL $ mkdir home/emmanuel/REPO chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL $ mkdir home/emmanuel/CODE chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL $ cd home/emmanuel/ chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel $ ls total 8.0K drwxr-xr-x 2 chaouche users 4.0K Dec 13 15:03 CODE drwxr-xr-x 2 chaouche users 4.0K Dec 13 15:03 REPO chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel $ cd .. chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home $ cd .. chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL $ cd ..
What I'll do now is just copy the code from one directory to another but let's pretend Emmanuel got it by email and extracted it to the right directory.
chaouche@fictive ~/TMP/BZR-TEST $ cp -r YCHAOUCHE/home/ychaouche/REPO/myapp-dev/ EMMANUEL/home/emmanuel/REPO/
Now let's pretend I'm Emmanuel :
chaouche@fictive ~/TMP/BZR-TEST $ cd EMMANUEL/home/emmanuel/REPO/ chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/REPO $ ls total 4.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 15:04 myapp-dev chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/REPO $ cd .. chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel $ cd CODE/ chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/CODE $ ls total 0 chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/CODE $ bzr checkout ../REPO/myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/CODE $ ls total 4.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 15:05 myapp-dev chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/CODE $ cd myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/CODE/myapp-dev $ ls total 4.0K -rw-r--r-- 1 chaouche users 122 Dec 13 15:05 readme.txt chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/CODE/myapp-dev
7) Emmanuel and I change the code simultaneously.
Let's start with Emmanuel
chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/CODE/myapp-dev $ emacs readme.txt & [1] 5631 chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/CODE/myapp-dev $ bzr ci Committing to: /home/chaouche/TMP/BZR-TEST/EMMANUEL/home/emmanuel/REPO/myapp-dev/ modified readme.txt Committed revision 3. [1]+ Done emacs -fg white -bg black -cr honeydew2 readme.txt chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/CODE/myapp-dev $ cd .. chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/CODE $ cd .. chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel $ cd REPO/myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/REPO/myapp-dev $ bzr up M readme.txt All changes applied successfully. Updated to revision 3 of branch /home/chaouche/TMP/BZR-TEST/EMMANUEL/home/emmanuel/REPO/myapp-dev chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/REPO/myapp-dev $
Now from my side
chaouche@fictive ~ $ cd TMP/BZR-TEST/YCHAOUCHE/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE $ ls total 8.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 10:41 home drwxr-xr-x 3 chaouche users 4.0K Dec 13 10:42 opt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE $ cd home/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home $ ls total 4.0K drwxr-xr-x 4 chaouche users 4.0K Dec 13 10:42 ychaouche chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home $ cd ychaouche/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ ls total 8.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 10:59 CODE drwxr-xr-x 4 chaouche users 4.0K Dec 13 10:58 REPO chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ cd CODE/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ ls total 4.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 11:00 myapp-dev chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ cd myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ ls total 4.0K -rw-r--r-- 1 chaouche users 122 Dec 13 11:00 readme.txt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ emacs readme.txt & [1] 5701 chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ bzr ci Committing to: /home/chaouche/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev/ modified readme.txt Committed revision 3. [1]+ Done emacs -fg white -bg black -cr honeydew2 readme.txt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ cd REPO/myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ bzr up M readme.txt All changes applied successfully. Updated to revision 3 of branch /home/chaouche/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ bzr info Standalone tree (format: 2a) Location: branch root: . Related branches: parent branch: /home/chaouche/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-prod chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ bzr st chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $
8) Getting Emmanuel's code
Allright. Emmanuel and I have commited code to the dev-branch. Let's now suppose we have come to a point where code is ready to go for tests. First, we need to merge our changes together inside the dev branch and commit it, so that we're all on the same level, and then we take that branch and put it on the test server. Let's do this :
Remember : if you need to give code to someone, allways give the repo, not the checkout.
that's because if you give the checkout, the person you're giving it to can't do merges and branches and stuff.
chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/REPO $ tar cvzf myapp-dev.tgz myapp-dev/ myapp-dev/ myapp-dev/readme.txt myapp-dev/.bzr/ myapp-dev/.bzr/branch-lock/ myapp-dev/.bzr/branch-format myapp-dev/.bzr/checkout/ [...] myapp-dev/.bzr/repository/indices/4529364019e970e86f38f60b93bf5218.tix myapp-dev/.bzr/repository/indices/dab927ec9c7ef53b771a9c9199cfa450.rix myapp-dev/.bzr/repository/lock/ chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/REPO $ ls total 12K drwxr-xr-x 3 chaouche users 4.0K Dec 13 15:42 myapp-dev -rw-r--r-- 1 chaouche users 6.5K Dec 13 15:43 myapp-dev.tgz
Let's pretend that Emmanuel sends me his repo by email and simulate this via a simple copy b/w "machines"
chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/REPO $ cp myapp-dev.tgz ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/ chaouche@fictive ~/TMP/BZR-TEST/EMMANUEL/home/emmanuel/REPO $
9) Merge Emmanuel's code with mine
Now on my side :
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ mkdir emmanuel-dev chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ mv myapp-dev.tgz emmanuel-dev/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ cd emmanuel-dev/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/emmanuel-dev $ ls total 8.0K -rw-r--r-- 1 chaouche users 6.5K Dec 13 15:43 myapp-dev.tgz chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/emmanuel-dev $ tar xzvf myapp-dev.tgz myapp-dev/ myapp-dev/readme.txt myapp-dev/.bzr/ myapp-dev/.bzr/branch-lock/ myapp-dev/.bzr/branch-format [...] myapp-dev/.bzr/repository/lock/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/emmanuel-dev $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ ls total 8.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 16:04 emmanuel-dev drwxr-xr-x 3 chaouche users 4.0K Dec 13 15:41 myapp-dev chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ cd myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ ls total 4.0K -rw-r--r-- 1 chaouche users 206 Dec 13 15:29 readme.txt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ bzr merge ../emmanuel-dev/myapp-dev/ M readme.txt Text conflict in readme.txt 1 conflicts encountered. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ emacs readme.txt& [1] 6269 chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $
10) Commiting to my repository
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ bzr ci Committing to: /home/chaouche/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev/ modified readme.txt Committed revision 4. [1]+ Done emacs readme.txt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $
11) Putting the dev branch in the test server
First, let's make sure that no changes need to be commited on the checkout
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ bzr ci Committing to: /home/chaouche/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev/ bzr: ERROR: No changes to commit. Please 'bzr add' the files you want to commit, or use --unchanged to force an empty commit. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ bzr st chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $
Good. Now we must make sure the repository is uptodate
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ ls total 4.0K -rw-r--r-- 1 chaouche users 286 Dec 13 16:11 readme.txt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ ls total 20K -rw-r--r-- 1 chaouche users 9.9K Dec 13 16:26 dev.tgz drwxr-xr-x 3 chaouche users 4.0K Dec 13 16:04 emmanuel-dev drwxr-xr-x 3 chaouche users 4.0K Dec 13 16:11 myapp-dev chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ ls total 8.0K drwxr-xr-x 4 chaouche users 4.0K Dec 13 16:26 CODE drwxr-xr-x 4 chaouche users 4.0K Dec 13 10:58 REPO chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche $ cd REPO/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ ls total 8.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 15:09 myapp-dev drwxr-xr-x 3 chaouche users 4.0K Dec 13 10:57 myapp-prod chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ cd myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ bzr st working tree is out of date, run 'bzr update' chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $
It's not, let's update it then.
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ bzr up M readme.txt All changes applied successfully. Updated to revision 4 of branch /home/chaouche/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ bzr st chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $
Now I'll simulate a file transfer to the test server.
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $ cp -r myapp-dev/ ~/TMP/BZR-TEST/TEST/opt/repos/myapp/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO $
Remember to always do this two operations
Ensure your checkout hasn't any uncommited modifcations and that your repo is uptodate before sending the tarball to the test server.
13) Checkout the repo to /srv/www/
Why do I need to do this ? why can't I just work with the repo directly ?
Remember that in our example we have two branches : the dev branch and the prod branch. If you work directly with repositories, you have absolutely no way of guessing which branch it is. Even the bzr info command won't give you that information, because the bzr info command give you the name of the containing directory. If you copied the branch from Emmanuel and Emmanuel named his repo "feature34" instead of dev or prod, then bzr info will print feature 34 and you have no clue wether it's the dev branch or the prod branch.
So the reason I'm doing this is to ensure that I can give meaningfull names on the test server inside the /opt/repos/ diretory and then checkout to /srv/www (where code needs to be in order to be run by the webserver for example) so that I know at anytime what's in /srv/www, if it's a checkout from /opt/repos/myapp-dev or a checkout from /opt/repos/myapp-prod.
chaouche@fictive ~/TMP/BZR-TEST/TEST/opt $ ls total 4.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 16:29 repos chaouche@fictive ~/TMP/BZR-TEST/TEST/opt $ cd .. chaouche@fictive ~/TMP/BZR-TEST/TEST $ cd opt/ srv/ chaouche@fictive ~/TMP/BZR-TEST/TEST $ cd srv/www/ chaouche@fictive ~/TMP/BZR-TEST/TEST/srv/www $ bzr checkout ../../opt/repos/myapp/myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/TEST/srv/www $ ls total 4.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 17:29 myapp-dev chaouche@fictive ~/TMP/BZR-TEST/TEST/srv/www $ cd myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/TEST/srv/www/myapp-dev $ ls total 4.0K -rw-r--r-- 1 chaouche users 286 Dec 13 17:29 readme.txt chaouche@fictive ~/TMP/BZR-TEST/TEST/srv/www/myapp-dev $
14) Make a hotfix on the test server
chaouche@fictive ~/TMP/BZR-TEST/TEST/srv/www/myapp-dev $ emacs readme.txt & [1] 6473 chaouche@fictive ~/TMP/BZR-TEST/TEST/srv/www/myapp-dev $ bzr ci Committing to: /home/chaouche/TMP/BZR-TEST/TEST/opt/repos/myapp/myapp-dev/ modified readme.txt Committed revision 5. chaouche@fictive ~/TMP/BZR-TEST/TEST/srv/www/myapp-dev $
15) Merge the hotfix to the developer's branches
I'm going to show you how to do this on my machine. You do the same for Emmanuel's First, let's make sure the repository on the test server is uptodate
chaouche@fictive ~/TMP/BZR-TEST/TEST/opt/repos/myapp/myapp-dev $ bzr up M readme.txt All changes applied successfully. Updated to revision 5 of branch /home/chaouche/TMP/BZR-TEST/TEST/opt/repos/myapp/myapp-dev chaouche@fictive ~/TMP/BZR-TEST/TEST/opt/repos/myapp/myapp-dev $ bzr log ------------------------------------------------------------ revno: 5 committer: Yassine Chaouche <yassine.chaouche@fictive.localhost> branch nick: myapp-dev timestamp: Thu 2012-12-13 17:32:26 +0100 message: Hotfix on the test server. ------------------------------------------------------------ revno: 4 [merge] committer: Yassine Chaouche <yassine.chaouche@fictive.localhost> branch nick: myapp-dev timestamp: Thu 2012-12-13 16:11:11 +0100 message: Merged the changes made by emmanuel. ------------------------------------------------------------ revno: 3 committer: Yassine Chaouche <yassine.chaouche@fictive.localhost> branch nick: myapp-dev timestamp: Thu 2012-12-13 15:09:25 +0100 message: Yassine's second modifcation ------------------------------------------------------------ revno: 2 committer: Yassine Chaouche <yassine.chaouche@fictive.localhost> branch nick: myapp-dev timestamp: Thu 2012-12-13 11:00:14 +0100 message: First modification of readme.txt ------------------------------------------------------------ revno: 1 committer: Yassine Chaouche <yassine.chaouche@fictive.localhost> branch nick: myapp-prod timestamp: Thu 2012-12-13 10:58:00 +0100 message: First commit to the repo's prod directory. ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions. chaouche@fictive ~/TMP/BZR-TEST/TEST/opt/repos/myapp/myapp-dev $ cd .. chaouche@fictive ~/TMP/BZR-TEST/TEST/opt/repos/myapp $ cd .. chaouche@fictive ~/TMP/BZR-TEST/TEST/opt/repos $ cd myapp/ chaouche@fictive ~/TMP/BZR-TEST/TEST/opt/repos/myapp $ ls total 4.0K drwxr-xr-x 3 chaouche users 4.0K Dec 13 17:39 myapp-dev
Let's pretend again that the following is equivalent of sending the branch in tarball and untar it to a proper location on the developer's computer. Remember, always transfer repos, not checkouts.
chaouche@fictive ~/TMP/BZR-TEST/TEST/opt/repos/myapp $ cp -rf myapp-dev/ ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/test-dev chaouche@fictive ~/TMP/BZR-TEST/TEST/opt/repos/myapp $ cd ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/test-dev/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/test-dev $ ls total 4.0K -rw-r--r-- 1 chaouche users 311 Dec 13 17:40 readme.txt chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/test-dev $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ ls total 24K -rw-r--r-- 1 chaouche users 9.9K Dec 13 16:26 dev.tgz drwxr-xr-x 3 chaouche users 4.0K Dec 13 16:04 emmanuel-dev drwxr-xr-x 3 chaouche users 4.0K Dec 13 16:11 myapp-dev drwxr-xr-x 3 chaouche users 4.0K Dec 13 17:40 test-dev chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ cd myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $
We cautiously check that everything is uptodate before doing our merge (always, always do this)
chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ bzr st chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ bzr up Tree is up to date at revision 4 of branch /home/chaouche/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ cd .. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE $ cd myapp-dev/ chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ bzr merge ../test-dev/ M readme.txt All changes applied successfully. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ bzr ci Committing to: /home/chaouche/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/REPO/myapp-dev/ modified readme.txt Committed revision 5. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $ bzr log ------------------------------------------------------------ revno: 5 [merge] committer: Yassine Chaouche <yassine.chaouche@fictive.localhost> branch nick: myapp-dev timestamp: Thu 2012-12-13 17:41:56 +0100 message: Merged the test hotfixes. ------------------------------------------------------------ revno: 4 [merge] committer: Yassine Chaouche <yassine.chaouche@fictive.localhost> branch nick: myapp-dev timestamp: Thu 2012-12-13 16:11:11 +0100 message: Merged the changes made by emmanuel. ------------------------------------------------------------ revno: 3 committer: Yassine Chaouche <yassine.chaouche@fictive.localhost> branch nick: myapp-dev timestamp: Thu 2012-12-13 15:09:25 +0100 message: Yassine's second modifcation ------------------------------------------------------------ revno: 2 committer: Yassine Chaouche <yassine.chaouche@fictive.localhost> branch nick: myapp-dev timestamp: Thu 2012-12-13 11:00:14 +0100 message: First modification of readme.txt ------------------------------------------------------------ revno: 1 committer: Yassine Chaouche <yassine.chaouche@fictive.localhost> branch nick: myapp-prod timestamp: Thu 2012-12-13 10:58:00 +0100 message: First commit to the repo's prod directory. ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions. chaouche@fictive ~/TMP/BZR-TEST/YCHAOUCHE/home/ychaouche/CODE/myapp-dev $
contact : @ychaouche yacinechaouche at yahoocom