Sunteți pe pagina 1din 6

Bazaar in ve minutes

Release 2.3.0dev1

Bazaar Developers
August 13, 2010

Contents
1 2 3 4 5 6 7 8 9 Introduction Installation Introducing yourself Putting les under version control Making changes to your les Viewing the revision log Publishing your branch with sftp Publishing your branch with Launchpad Creating your own copy of another branch i ii ii ii iii iii iv iv iv v v v

10 Updating your branch from the main branch 11 Merging your work into the parent branch 12 Learning more

1 Introduction
Bazaar is a distributed version control system that makes it easier for people to work together on software projects.

Over the next ve minutes, youll learn how to put your les under version control, how to record changes to them, examine your work, publish it and send your work for merger into a projects trunk. If youd prefer a more detailed introduction, take a look at Learning More.

2 Installation
This guide doesnt describe how to install Bazaar but its usually very easy. You can nd installation instructions at: GNU/Linux: Bazaar is probably in your GNU/Linux distribution already. Windows: installation instructions for Windows. Mac OS X: installation instructions for Mac OS X. For other platforms and to install from source code, see the Download and Installation pages.

3 Introducing yourself
Before you start working, it is good to tell Bazaar who you are. That way your work is properly identied in revision logs. Using your name and email address, instead of John Does, type:
$ bzr whoami "John Doe <john.doe@gmail.com>"

Bazaar will now create or modify a conguration le, including your name and email address. Now, check that your name and email address are correctly registered:
$ bzr whoami John Doe <john.doe@gmail.com>

4 Putting les under version control


Lets create a directory and some les to use with Bazaar:
$ $ $ $ mkdir myproject cd myproject mkdir subdirectory touch test1.txt test2.txt test3.txt subdirectory/test4.txt

Note for Windows users: use Windows Explorer to create your directories, then right-click in those directories and select New file to create your les. Now get Bazaar to initialize itself in your project directory:
$ bzr init

If it looks like nothing happened, dont worry. Bazaar has created a branch where it will store your les and their revision histories. The next step is to tell Bazaar which les you want to track. Running bzr add will recursively add everything in the project:

$ bzr added added added added added

add subdirectory test1.txt test2.txt test3.txt subdirectory/test4.txt

Next, take a snapshot of your les by committing them to your branch. Add a message to explain why you made the commit:
$ bzr commit -m "Initial import"

As Bazaar is a distributed version control system, it doesnt need to connect to a central server to make the commit. Instead, Bazaar stores your branch and all its commits inside the directory youre working with; look for the .bzr sub-directory.

5 Making changes to your les


Lets change a le and commit that change to your branch. Edit test1.txt in your favourite editor, then check what have you done:
$ bzr diff === modified file test1.txt --- test1.txt 2007-10-08 17:56:14 +0000 +++ test1.txt 2007-10-08 17:46:22 +0000 @@ -0,0 +1,1 @@ +test test test

Commit your work to the Bazaar branch:


$ bzr commit -m "Added first line of text" Committed revision 2.

6 Viewing the revision log


You can see the history of your branch by browsing its log:
$ bzr log -----------------------------------------------------------revno: 2 committer: John Doe <john.doe@gmail.com> branch nick: myproject timestamp: Mon 2007-10-08 17:56:14 +0000 message: Added first line of text -----------------------------------------------------------revno: 1 committer: John Doe <john.doe@gmail.com> branch nick: myproject timestamp: Mon 2006-10-08 17:46:22 +0000

message: Initial import

7 Publishing your branch with sftp


There are a couple of ways to publish your branch. If you already have an SFTP server or are comfortable setting one up, you can publish your branch to it. Otherwise, skip to the next section to publish with Launchpad, a free hosting service for Bazaar. Lets assume you want to publish your branch at www.example.com/myproject:
$ bzr push --create-prefix sftp://your.name@example.com/~/public_html/myproject 2 revision(s) pushed.

Bazaar will create a myproject directory on the remote server and push your branch to it. Now anyone can create their own copy of your branch by typing:
$ bzr branch http://www.example.com/myproject

Note: to use sftp, you may need to install paramiko and pyCrypto. See http://bazaar-vcs.org/InstallationFaq for details.

8 Publishing your branch with Launchpad


Launchpad is a suite of development and hosting tools for free software projects. You can use it to publish your branch. If you dont have a Launchpad account, follow the account signup guide and register an SSH key in your new Launchpad account. Replacing john.doe with your own Launchpad username, type 1 :
$ bzr push lp:~john.doe/+junk/myproject

Note: +junk means that this branch isnt associated with any particular project in Launchpad. Now, anyone can create their own copy of your branch by typing:
$ bzr branch lp:~john.doe/+junk/myproject

You can also see information about your https://code.launchpad.net/people/+me/+junk/myproject

branch,

including

its

revision

history,

at

9 Creating your own copy of another branch


To work with someone elses code, you can make your own copy of their branch. Lets take a real-world example, Bazaars GTK interface:
1

Use of the lp: URL scheme requires bzr 0.92 or later.

$ bzr branch lp:~bzr/bzr-gtk/trunk bzr-gtk.john Branched 292 revision(s).

Bazaar will download all the les and complete revision history from the bzr-gtk projects trunk branch and create a copy called bzr-gtk.john. Now, you have your own copy of the branch and can commit changes with or without a net connection. You can share your branch at any time by publishing it and, if the bzr-gtk team want to use your work, Bazaar makes it easy for them to merge your branch back into their trunk branch.

10 Updating your branch from the main branch


While you commit changes to your branch, its likely that other people will also continue to commit code to the parent branch. To make sure your branch stays up to date, you should merge changes from the parent into your personal branch:
$ bzr merge Merging from saved parent location: http://bazaar.launchpad.net/~bzr/bzr-gtk/trunk All changes applied successfully.

Check what has changed:


$ bzr diff

If youre happy with the changes, you can commit them to your personal branch:
$ bzr commit -m "Merge from main branch" Committed revision 295.

11 Merging your work into the parent branch


After youve worked on your personal branch of bzr-gtk, you may want to send your changes back upstream to the project. The easiest way is to use a merge directive. A merge directive is a machine-readable request to perform a particular merge. It usually contains a patch preview of the merge and either contains the necessary revisions, or provides a branch where they can be found. Replacing mycode.patch, create your merge directive:
$ bzr send -o mycode.patch Using saved parent location: http://bazaar.launchpad.net/~bzr/bzr-gtk/trunk

You can now email the merge directive to the bzr-gtk project who, if they choose, can use it merge your work back into the parent branch.

12 Learning more
You can nd out more about Bazaar in the Bazaar User Guide. To learn about Bazaar on the command-line:

$ bzr help

To learn about Bazaar commands:


$ bzr help commands

To learn about the foo topic or command:


$ bzr help foo

S-ar putea să vă placă și