How to work with bazaar on the command line
Alternative: use the GUI for bazaar
If the command line is not your prefered way of doing things, please see How to work with bazaar through the GUI on Windows
Setup your environment
Set your E-Mail address:
bzr whoami "John Doe <email@example.com>"
Create a directory where you want to store all bazaar checkout you are using with openpetra, e.g. C:\openpetra\bzr. Especially when using Windows 7 it is recommended to create a local directory (e.g. on C:) and not one on the network as otherwise compiling with NAnt can give problems.Compiling from a network drive gave the following error on Windows 7:
System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=18.104.22.168, ... failed
Go into this directory and create a shared repository for holding all branches you checkout:
C:\openpetra\bzr>bzr init-repo ./ Shared repository (format: 2a) Location: shared repository: . C:\openpetra\bzr>
Configure your account on Launchpad
You only need to do this once!
- First get an account on Launchpad, which is a service provided by the company Canonical, who develop Ubuntu and Bazaar: https://login.launchpad.net/+new_account
- Create a public and private key on launchpad. This is explained here. It is quite important to execute pageant and to load the private key into pageant.
- In your bazaar, you need to tell your launchpad username:
bzr launchpad-login LAUNCHPADUSERID
Line Ending issues
To avoid problems with the line endings, and the code generators, on Windows create the file
C:\Documents and Settings\My User\Application Data\bazaar\2.0\rules (on Windows 7:
C:\Users\My User\AppData\Roaming\bazaar\2.0\rules) and on Linux
$BZR_HOME/.bazaar/rules with this content:
[name *.cs] eol = native [name *.csproj] eol = native [name *.sln] eol = native [name *.yaml] eol = native [name *.xml] eol = native [name *.config] eol = native [name *.build] eol = native [name *.js] eol = native [name *.html] eol = native [name *.htm] eol = native [name *.sql] eol = native
Create a remote working branch
Go into your shared rep directory created above, and type:
bzr branch lp:openpetraorg lp:~LAUNCHPADUSERID/openpetraorg/mytest20111115
This will create a branch on Launchpad based on the trunk of openpetraorg (lp:openpetraorg), that is associated with the openpetraorg project.
Our naming convention for branches is to use dev_0000<Mantis Issue number>_<keywords to describe the issue>. So for example it could be: dev_0000167_import_cc_hierarchy.
Sometimes you might want to fix multiple issues in the same branch without needing to create a separate branch for each bug. In this case use this naming convention:
dev_date_<keywords to describe the issue> (e.g dev_20160513_Finance_Various).
You could also create branches that are unrelated to the openpetraorg project: eg. lp:~tpokorra/+junk/BRANCHNAME
You can branch on a specific revision by using the -r parameter, eg.
bzr branch lp:openpetraorg -r1026.1.4 lp:~LAUNCHPADUSERID/openpetraorg/mytest20111115_rel_0_2_4
To see all branches in OpenPetra, visit this website:
Create a bound local working branch
Once a remote working branch has been created, create a bound local branch (make sure you are still in the shared repository folder):
bzr branch --bind lp:~LAUNCHPADUSERID/openpetraorg/mytest20111115 mytest20111115
This will create a local directory named mytest20111115 which contains the local branch. The "--bind" commandline switch makes sure, that any commit to your local branch will be automatically commited to your remote branch.
For info about your branch, execute in your local branch directory:
See changed files
Call the explorer in directory of the branch you are interested in:
bzr explorer ./
Rebase branch / Merge from trunk
For this commands you need to be in the directory, where the checkout files are in.
Before doing the merge in your workspace please first commit your changes to your branch at Launchpad. This makes it easier later for the core-development team.
For the first rebase of the branch, you need to add the info, from where to merge:
bzr merge lp:openpetraorg
This information you see on the operation
For the next rebase merges, following command is working:
Checkin the changes:
bzr commit --fixes op:<Mantis Tracker id of the bug that was fixed in this commit>
Summarized the order would be:
- do changes in your local workspace (*)
- commit them to the launchpad-branch
- merge from trunk
- commit trunk changes to the launchpad-branch
- go back to 1.
If you want your changes to be merged into the OpenPetra bzr, use the link Propose for merging on your Launchpad code page. It is recommended to have small branches for each feature that you want to go upstream. You will not be able to reuse a branch, after it has been merged into openpetra trunk, since we want to avoid criss cross merges etc.
(*) If you want to execute OpenPetra for testing your changes then please make sure
to add as well your OpenPetra.build.config file to the branch (if you have one) and create the Database with nant. (without those steps the server won't start) (see also Setup_of_Development_environment#initial_steps)
--Pokorra 07:29, 16 March 2012 (UTC) Do NOT add your OpenPetra.build.config file to your public branch at Launchpad, since it may contain your database password etc. Also it will cause problems with merging your branch into trunk. If you have a private branch, ie. it is on your own bazaar server, and it only contains adjusting changes for a production system, then you can call your config file OpenPetra.build.config.my and add it to that private branch.
Update a branch with the newest info from remote
Needed for the getting the newest changes for trunk or for branches, where more than one person is working on:
Resolve conflicts during merge or update
http://doc.bazaar.canonical.com/bzr.2.2/en/user-reference/conflict-types-help.html and http://doc.bazaar.canonical.com/bzr.2.2/en/user-guide/resolving_conflicts.html include an overview about problems, which could arise and how they are fixed.
shows all conflicts, the command
marks conflicts as resolved.
Back out a commit
Backing out a commit is done by merging. First, you should identify the revision number, e.g. 284. Then you are able to undo the commit by merging the difference between 284 and 283:
bzr merge -r 284..283 ./ bzr commit
Frequently asked questions
Please go to Notes_about_Bazaar#Frequently_asked_questions to see our FAQ for bazaar.