Using The Bazaar Version Control System (VCS) On Ubuntu 7.10Author sahabdeen
Bazaar is a distributed version control system (VCS) available under the GPL; it's similar to Subversion (svn). Bazaar is sponsored by Canonical, Ltd., the company that develops the Ubuntu Linux distribution, and therefore the Ubuntu project is the most prominent user of Bazaar. This article explains how to set up and use Bazaar on a Ubuntu 7.10 system, and how to configure an SFTP server to host your Bazaar repository.
1 Preliminary NoteIP address 192.168.1.36: the server that will keep the Bazaar repository and that offers SFTP services; I'll refer to it as server in this article.
I will use the username is "bazaar"
The workstation where Bazaar will be installed and software will be developed (that will be managed by Bazaar). I use the user is default system user. But I have added the group name is "bazaar" and change the group name of the project development folder to bazaar.
sahab@sahab-desktop:/$ sudo mkdir /Project
sahab@sahab-desktop:/Project$ groupadd bazaar
sahab@sahab-desktop:/$sudo chown sahab:bazaar /Project/
sahab@sahab-desktop:~$ chmod -R 775 /Project/
sahab@sahab-desktop:/$ ls -al /Project/
drwxr-xr-x 2 sahab bazaar 4096 2008-03-08 11:22 .
drwxr-xr-x 30 root root 4096 2008-03-08 11:22 .
2 Installing SFTP On The ServerServer:
(All the steps in this chapter have to be done as the root user!)
Let's install SFTP on the server:apt-get install ssh openssh-server
Next we create a user account - bazaar in this case - that uses the /usr/lib/sftp-server shell instead of /bin/bash or any other shell:
useradd -m -s /usr/lib/sftp-server bazaar
This creates the user bazaar with the home directory /home/bazaar
Assign a password to bazaar:
Then make /usr/lib/sftp-server a valid login shell by adding it to /etc/shells:
echo '/usr/lib/sftp-server' >> /etc/shells
3 Installing Bazaar On The Workstationworkstation:
Run the following command as root:
apt-get install bzr python-paramiko
4 Using Bazaar
Now log in as the normal user, or, if you are logged in as root, run
to become the normal user (in this case sahab).
Then go to your home directory:
The following examples are more or less taken from http://doc.bazaar-vcs.org/latest/en/mini-tutorial/index.html.>
First, tell Bazaar who you are:
bzr whoami sahab
Check that Bazaar has correctly stored your identity:
bzr whoamisahab@sahab-desktop:/$ bzr whoami
Now let's create a test directory with some test files:(Note: The Project directory group name should be "bazaar" otherwise it will make permission issue when we push the revision to the server)
sahab@sahab-desktop:/$ cd /Project/
touch test1.txt test2.txt test3.txt subdirectory/test4.txt
The myproject directory is the base folder for our software project that we want to manage with Bazaar. It's important that you run all bzr commands in that directory! If you are not sure in which directory you are, run
Bazaar must initialize itself in the project directory:
This creates some hidden files that Bazaar needs to manage your project. You can see the hidden folder .bzr in the myproject directory when you run
sahab@sahab-desktop:/Project/myproject$ ls -la
drwxr-xr-x 3 sahab sahab 4096 2008-03-08 11:56 .
drwxrwxr-x 4 sahab bazaar 4096 2008-03-08 11:56 ..
drwxr-xr-x 2 sahab sahab 4096 2008-03-08 11:56 subdirectory
-rw-r--r-- 1 sahab sahab 0 2008-03-08 11:56 test1.txt
-rw-r--r-- 1 sahab sahab 0 2008-03-08 11:56 test2.txt
-rw-r--r-- 1 sahab sahab 0 2008-03-08 11:56 test3.txt
to make all files/directories in the myproject folder versioned. The output is as follows:
sahab@sahab-desktop:/Project/myproject$ bzr add
Next add the files/directories to your branch (with a small comment so that you know what this commit is about):
bzr commit -m "Initial import"
The output is as follows:
sahab@sahab-desktop:/Project/myproject$ bzr commit -m "Initial import"
Committed revision 1.
Now let's modify the (yet empty) file test1.txt:
bzr diffsahab@sahab-desktop:/Project/myproject$ bzr diff
=== modified file 'myproject/test1.txt'
--- myproject/test1.txt 2008-03-08 06:29:52 +0000
+++ myproject/test1.txt 2008-03-08 07:42:59 +0000
@@ -0,0 +1,1 @@
To commit the changes (again with a comment), run
bzr commit -m "Added first line of text"sahab@sahab-desktop:/Project/myproject$ bzr commit -m "Added first line of text"
Committed revision 2.
displays a history of the latest actions:sahab@sahab-desktop:/Project/myproject$ bzr log
branch nick: Project
timestamp: Sat 2008-03-08 13:16:08 +0530
Added first line of text
branch nick: Project
timestamp: Sat 2008-03-08 11:59:52 +0530
Now let's publish the project to our server (using SFTP):
bzr push --create-prefix sftp://firstname.lastname@example.org/home/bazaar/myproject
sahab@sahab-desktop:/Project/myproject$ bzr push --create-prefix sftp://email@example.com/home/bazaar/myproject
Pushed up to revision 2.
After you have published the project, you can delete your working copy (if you want - you can as well leave it as it is):
rm -fr myproject/
Now anyone can download a copy of your branch. To test this, we create the directory test/ and download a copy of the branch to it:cd ~
bzr branch sftp://firstname.lastname@example.org/home/bazaar/myproject
Branched 2 revision(s).
While you're working on your copy, it's possible that other people commit their changes to the server. To merge these changes into your working copy, runsahab@sahab-desktop:~/test$ ls
sahab@sahab-desktop:~/test$ cd myproject/
sahab@sahab-desktop:~/test/myproject$ bzr merge
Merging from remembered location sftp://email@example.com/home/bazaar/myproject/
Nothing to do.
To check what exactly has changed, run
Now you can change your working copy, e.g.:
Take a look at the changes:
sahab@sahab-desktop:~/test/myproject/$ bzr diff
=== modified file 'myproject/test1.txt'
--- myproject/test1.txt 2008-03-08 07:46:08 +0000
+++ myproject/test1.txt 2008-03-08 07:57:12 +0000
@@ -1,1 +1,2 @@
When you're finished, commit your changes:
bzr commit -m "Some changes"
sahab@sahab-desktop:~/test/myproject/$ bzr commit -m "Some changes"
Committed revision 3.
Afterwards, upload the changes to the server:
sahab@sahab-desktop:~/test/myproject/$bzr push --create-prefix sftp://firstname.lastname@example.org/home/bazaar/myproject
Pushed up to revision 3.
Afterwards, you can (if you like) delete your working copy again. To find out what else you can do with Bazaar, take a look at
sahab@sahab-desktop:~/test/myproject/$ bzr help
Bazaar -- a free distributed version-control tool
bzr init makes this directory a versioned branch
bzr branch make a copy of another branch
bzr add make files or directories versioned
bzr ignore ignore a file or pattern
bzr mv move or rename a versioned file
bzr status summarize changes in working copy
bzr diff show detailed diffs
bzr merge pull in changes from another branch
bzr commit save some or all changes
bzr log show history of changes
bzr check validate storage
bzr help init more help on e.g. init command
bzr help commands list all commands
bzr help topics list all help topics
bzr help commands
sahab@sahab-desktop:~/test/myproject/$ bzr help commands
add Add specified files or directories.
annotate Show the origin of each line in a file.
baz-import Import an Arch or Baz archive into a bzr repository. [bzrtools]
baz-import-branch Import an Arch or Baz branch into a bzr branch. [bzrtools]
bind Convert the current branch into a checkout of the supplied branch.
branch Create a new copy of a branch.
branch-history Display the development history of a branch. [bzrtools]
branch-mark Add, view or list branch markers
branches Scan a location for branches [bzrtools]
break-lock Break a dead lock on a repository, branch or working directory.
builddeb Builds a Debian package from a branch. [builddeb]
cat Write the contents of a file as of a given revision to standard output.
cbranch Create a new checkout, associated with a new repository branch. [bzrtools]
cdiff A color version of bzr's diff [bzrtools]
check Validate consistency of branch history.
checkout Create a new checkout of an existing branch.
clean-tree Remove unwanted files from working tree. [bzrtools]
commit Commit changes into a new revision.
conflicts List files with conflicts.
deleted List files deleted in the working tree.
diff Show differences in the working tree or between revisions.
export Export current or past revision to a destination directory or archive.
fetch-ghosts Attempt to retrieve ghosts from another branch. [bzrtools]
gannotate GTK+ annotate. [gtk]
gbranch GTK+ branching. [gtk]
gcheckout GTK+ checkout. [gtk]
gcommit GTK+ commit dialog [gtk]
gconflicts GTK+ conflicts. [gtk]
gdiff Show differences in working tree in a GTK+ Window. [gtk]
gmissing GTK+ missing revisions dialog. [gtk]
gpreferences GTK+ preferences dialog. [gtk]
gpush GTK+ push. [gtk]
graph-ancestry Produce ancestry graphs using dot. [bzrtools]
gselftest Version of selftest that displays a notification at the end [gtk]
gstatus GTK+ status dialog [gtk]
help Show help on a command or other topic.
ignore Ignore specified files or patterns.
ignored List ignored files and the patterns that matched them.
import Import sources from a directory, tarball or zip file [bzrtools]
import-dsc Import a series of source packages. [builddeb]
info Show information about a working tree, branch or repository.
init Make a directory into a versioned branch.
init-repository Create a shared repository to hold branches.
log Show log of a branch, file, or directory.
ls List files in a tree.
merge Perform a three-way merge.
merge-upstream Merges a new upstream version into the current branch. [builddeb]
missing Show unmerged/unpulled revisions between two branches.
mkdir Create a new versioned directory.
multi-pull Pull all the branches under a location, e.g. a repository. [bzrtools]
mv Move or rename a file.
nick Print or set the branch nickname.
pack Compress the data within a repository.
patch Apply a named patch to the current tree. [bzrtools]
plugins List the installed plugins.
pqm-submit Submit the parent tree to the pqm. [pqm]
pull Turn this branch into a mirror of another branch.
push Update a mirror of this branch.
reconcile Reconcile bzr metadata in a branch.
register-branch Register a branch with launchpad.net. [launchpad]
remerge Redo a merge.
remove Remove files or directories.
remove-tree Remove the working tree from a given branch/checkout.
renames Show list of renamed files.
resolve Mark a conflict as resolved.
revert Revert files to a previous revision.
revno Show current revision number.
root Show the tree root directory.
rspush Upload this branch to another location using rsync. [bzrtools]
send Create a merge-directive for submiting changes.
serve Run the bzr server.
shelf Perform various operations on your shelved patches. See also shelve. [bzrtools]
shell Begin an interactive shell tailored for bzr. [bzrtools]
shelve Temporarily set aside some changes from the current tree. [bzrtools]
sign-my-commits Sign all commits by a given committer.
status Display status summary.
svn-branching-scheme Show or change the branching scheme for a Subversion repository. [svn]
svn-import Convert a Subversion repository to a Bazaar repository. [svn]
svn-push Push revisions to Subversion, creating a new branch if necessary. [svn]
svn-upgrade Upgrade revisions mapped from Subversion in a Bazaar branch. [svn]
switch Set the branch of a lightweight checkout and update. [bzrtools]
tag Create, remove or modify a tag naming a revision.
tags List tags.
testament Show testament (signing-form) of a revision.
unbind Convert the current checkout into a regular branch.
uncommit Remove the last committed revision.
unshelve Restore shelved changes. [bzrtools]
update Update a tree to have the latest code committed to its branch.
upgrade Upgrade branch storage to current format.
version Show version of bzr.
version-info Show version information about this tree.
visualise Graphically visualise this branch. [gtk]
whoami Show or set bzr user id.
zap Remove a lightweight checkout, if it can be done safely. [bzrtools]