18
13
If you are already familiar with decentralized version control, then
19
please feel free to skip ahead to "Introducing Yourself to Bazaar". If,
14
please feel free to skip ahead to "Introducing Yourself to Breezy". If,
20
15
on the other hand, you are familiar with version control but not
21
16
decentralized version control, then please start at "How DVCS is
22
17
different." Otherwise, get some coffee or tea, get comfortable and get
32
27
deleted the configuration file for your mailserver or perhaps mauled the
33
28
source code for a pet project. Whatever happened, you have just deleted
34
29
important information that you would desperately like to get back. If this
35
has ever happened to you, then you are probably ready for Bazaar.
30
has ever happened to you, then you are probably ready for Breezy.
37
32
Version control systems (which I'll henceforth call VCS) such as
38
Bazaar give you the ability to track changes for a directory by turning
33
Breezy give you the ability to track changes for a directory by turning
39
34
it into something slightly more complicated than a directory that we call
40
35
a **branch**. The branch not only stores how the directory looks right
41
36
now, but also how it looked at various points in the past. Then, when you
84
79
the changes for a directory such as file and subdirectory changes.
85
80
Performing this tracking by hand is a awkward process that over time
86
81
becomes unwieldy. That is, until one considers version control tools such
87
as Bazaar. These tools automate the process of storing data by creating
82
as Breezy. These tools automate the process of storing data by creating
88
83
a **revision** of the directory tree whenever the user asks.
90
Version control software such as Bazaar can do much more than just
91
storage and performing undo. For example, with Bazaar a developer can
85
Version control software such as Breezy can do much more than just
86
storage and performing undo. For example, with Breezy a developer can
92
87
take the modifications in one branch of software and apply them to a
93
88
related branch -- even if those changes exist in a branch owned by
94
89
somebody else. This allows developers to cooperate without giving
95
90
write access to the repository.
97
Bazaar remembers the ''ancestry'' of a revision: the previous revisions
92
Breezy remembers the ''ancestry'' of a revision: the previous revisions
98
93
that it is based upon. A single revision may have more than one direct
99
94
descendant, each with different changes, representing a divergence in the
100
evolution of the tree. By branching, Bazaar allows multiple people to
95
evolution of the tree. By branching, Breezy allows multiple people to
101
96
cooperate on the evolution of a project, without all needing to work in
102
97
strict lock-step. Branching can be useful even for a single developer.
104
Introducing yourself to Bazaar
99
Introducing yourself to Breezy
105
100
==============================
107
Bazaar installs a single new command, **bzr**. Everything else is a
108
subcommand of this. You can get some help with ``bzr help``. Some arguments
109
are grouped in topics: ``bzr help topics`` to see which topics are available.
102
Breezy installs a single new command, **brz**. Everything else is a
103
subcommand of this. You can get some help with ``brz help``. Some arguments
104
are grouped in topics: ``brz help topics`` to see which topics are available.
111
106
One function of a version control system is to keep track of who changed
112
107
what. In a decentralized system, that requires an identifier for each
113
108
author that is globally unique. Most people already have one of these: an
114
email address. Bazaar is smart enough to automatically generate an email
109
email address. Breezy is smart enough to automatically generate an email
115
110
address by looking up your username and hostname. If you don't like the
116
guess that Bazaar makes, then three options exist:
111
guess that Breezy makes, then three options exist:
118
1. Set an email address via ``bzr whoami``. This is the simplest way.
113
1. Set an email address via ``brz whoami``. This is the simplest way.
120
115
To set a global identity, use::
122
% bzr whoami "Your Name <email@example.com>"
117
% brz whoami "Your Name <email@example.com>"
124
119
If you'd like to use a different address for a specific branch, enter
125
120
the branch folder and use::
127
% bzr whoami --branch "Your Name <email@example.com>"
122
% brz whoami --branch "Your Name <email@example.com>"
129
124
#. Setting the email address in the ``~/.bazaar/bazaar.conf`` [1]_ by
130
125
adding the following lines. Please note that ``[DEFAULT]`` is case
144
139
#. Overriding the two previous options by setting the global environment
145
variable ``$BZR_EMAIL`` or ``$EMAIL`` (``$BZR_EMAIL`` will take
140
variable ``$brz_EMAIL`` or ``$EMAIL`` (``$brz_EMAIL`` will take
146
141
precedence) to your full email address.
148
143
.. [1] On Windows, the users configuration files can be found in the
149
144
application data directory. So instead of ``~/.bazaar/branch.conf``
150
145
the configuration file can be found as:
151
``C:\Documents and Settings\<username>\Application Data\Bazaar\2.0\branch.conf``.
146
``C:\Documents and Settings\<username>\Application Data\Breezy\2.0\branch.conf``.
152
147
The same is true for ``locations.conf``, ``ignore``, and the
153
148
``plugins`` directory.
156
151
=================
158
153
History is by default stored in the .bzr directory of the branch. In a
159
future version of Bazaar, there will be a facility to store it in a
154
future version of Breezy, there will be a facility to store it in a
160
155
separate repository, which may be remote.
162
We create a new branch by running ``bzr init`` in an existing directory::
157
We create a new branch by running ``brz init`` in an existing directory::
169
/home/mbp/work/bzr.test/tutorial
164
/home/mbp/work/brz.test/tutorial
178
173
to it will be recorded by the system::
180
175
% echo 'hello world' > hello.txt
191
If you add the wrong file, simply use ``bzr remove`` to make it
186
If you add the wrong file, simply use ``brz remove`` to make it
192
187
unversioned again. This does not delete the working copy in this case,
193
188
though it may in others [2]_.
195
.. [2] ``bzr remove`` will remove the working copy if it is currently
190
.. [2] ``brz remove`` will remove the working copy if it is currently
196
191
versioned, but has no changes from the last committed version. You
197
192
can force the file to always be kept with the ``--keep`` option to
198
``bzr remove``, or force it to always be deleted with ``--force``.
193
``brz remove``, or force it to always be deleted with ``--force``.
203
198
All history is stored in a branch, which is just an on-disk directory
204
199
containing control files. By default there is no separate repository or
205
200
database as used in svn or svk. You can choose to create a repository if
206
you want to (see the ``bzr init-repo`` command). You may wish to do this
201
you want to (see the ``brz init-repo`` command). You may wish to do this
207
202
if you have very large branches, or many branches of a moderately sized
210
205
You'll usually refer to branches on your computer's filesystem just by
211
giving the name of the directory containing the branch. bzr also supports
206
giving the name of the directory containing the branch. brz also supports
212
207
accessing branches over SSH, HTTP and SFTP, amongst other things::
214
% bzr log bzr+ssh://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev/
215
% bzr log http://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev/
216
% bzr log sftp://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev/
209
% brz log brz+ssh://code.launchpad.net/~brz/brz/brz.dev/
210
% brz log http://code.launchpad.net/~brz/brz/brz.dev/
211
% brz log sftp://code.launchpad.net/~brz/brz/brz.dev/
218
By installing bzr plugins you can also access branches using the rsync
213
By installing brz plugins you can also access branches using the rsync
221
216
See the `Publishing your branch`_ section for more about how to put your
233
228
committing what you intend to, and as a chance to rethink your work before
234
229
you permanently record it.
236
Two bzr commands are particularly useful here: **status** and **diff**.
231
Two brz commands are particularly useful here: **status** and **diff**.
241
236
The **status** command tells you what changes have been made to the
242
237
working directory since the last revision::
248
``bzr status`` hides "boring" files that are either unchanged or ignored.
243
``brz status`` hides "boring" files that are either unchanged or ignored.
249
244
The status command can optionally be given the name of some files or
250
245
directories to check.
255
250
The **diff** command shows the full text of changes to all files as a
256
251
standard unified diff. This can be piped through many programs such as
257
252
''patch'', ''diffstat'', ''filterdiff'' and ''colordiff''::
260
255
=== added file 'hello.txt'
261
256
--- hello.txt 1970-01-01 00:00:00 +0000
262
257
+++ hello.txt 2005-10-18 14:23:29 +0000
267
262
With the ``-r`` option, the tree is compared to an earlier revision, or
268
263
the differences between two versions are shown::
270
% bzr diff -r 1000.. # everything since r1000
271
% bzr diff -r 1000..1100 # changes from 1000 to 1100
265
% brz diff -r 1000.. # everything since r1000
266
% brz diff -r 1000..1100 # changes from 1000 to 1100
273
The ``--diff-options`` option causes bzr to run the external diff program,
268
The ``--diff-options`` option causes brz to run the external diff program,
274
269
passing options. For example::
276
% bzr diff --diff-options --side-by-side foo
271
% brz diff --diff-options --side-by-side foo
278
273
Some projects prefer patches to show a prefix at the start of the path
279
274
for old and new files. The ``--prefix`` option can be used to provide
281
As a shortcut, ``bzr diff -p1`` produces a form that works with the
276
As a shortcut, ``brz diff -p1`` produces a form that works with the
282
277
command ``patch -p1``.
310
305
Message from an editor
311
306
----------------------
313
If you use neither the ``-m`` nor the ``-F`` option then bzr will open an
308
If you use neither the ``-m`` nor the ``-F`` option then brz will open an
314
309
editor for you to enter a message. The editor to run is controlled by
315
310
your ``$VISUAL`` or ``$EDITOR`` environment variable, which can be overridden
316
by the ``editor`` setting in ``~/.bazaar/bazaar.conf``; ``$BZR_EDITOR`` will
311
by the ``editor`` setting in ``~/.bazaar/bazaar.conf``; ``$brz_EDITOR`` will
317
312
override either of the above mentioned editor options. If you quit the
318
313
editor without making any changes, the commit will be cancelled.
334
329
Marking bugs as fixed
335
330
---------------------
337
Many changes to a project are as a result of fixing bugs. Bazaar can keep
332
Many changes to a project are as a result of fixing bugs. Breezy can keep
338
333
metadata about bugs you fixed when you commit them. To do this you use the
339
334
``--fixes`` option. This option takes an argument that looks like this::
341
% bzr commit --fixes <tracker>:<id>
336
% brz commit --fixes <tracker>:<id>
343
338
Where ``<tracker>`` is an identifier for a bug tracker and ``<id>`` is an
344
339
identifier for a bug that is tracked in that bug tracker. ``<id>`` is usually
345
a number. Bazaar already knows about a few popular bug trackers. They are
340
a number. Breezy already knows about a few popular bug trackers. They are
346
341
bugs.launchpad.net, bugs.debian.org, and bugzilla.gnome.org. These trackers
347
342
have their own identifiers: lp, deb, and gnome respectively. For example,
348
343
if you made a change to fix the bug #1234 on bugs.launchpad.net, you would
349
344
use the following command to commit your fix::
351
% bzr commit -m "fixed my first bug" --fixes lp:1234
346
% brz commit -m "fixed my first bug" --fixes lp:1234
353
348
For more information on this topic or for information on how to configure
354
349
other bug trackers please read `Bug Tracker Settings`_.
361
356
If you give file or directory names on the commit command line then only
362
357
the changes to those files will be committed. For example::
364
% bzr commit -m "documentation fix" commit.py
359
% brz commit -m "documentation fix" commit.py
366
By default bzr always commits all changes to the tree, even if run from a
361
By default brz always commits all changes to the tree, even if run from a
367
362
subdirectory. To commit from only the current directory down, use::
372
367
Removing uncommitted changes
375
370
If you've made some changes and don't want to keep them, use the
376
371
**revert** command to go back to the previous head version. It's a good
377
idea to use ``bzr diff`` first to see what will be removed. By default the
372
idea to use ``brz diff`` first to see what will be removed. By default the
378
373
revert command reverts the whole tree; if file or directory names are
379
given then only those ones will be affected. ``bzr revert`` also clears the
374
given then only those ones will be affected. ``brz revert`` also clears the
380
375
list of pending merges revisions.
389
384
Many source trees contain some files that do not need to be versioned,
390
385
such as editor backups, object or bytecode files, and built programs. You
391
386
can simply not add them, but then they'll always crop up as unknown files.
392
You can also tell bzr to ignore these files by adding them to a file
387
You can also tell brz to ignore these files by adding them to a file
393
388
called ``.bzrignore`` at the top of the tree.
395
390
This file contains a list of file wildcards (or "globs"), one per line.
424
419
The ``.bzrignore`` file should normally be versioned, so that new copies
425
420
of the branch see the same patterns::
428
% bzr commit -m "Add ignore patterns"
423
% brz commit -m "Add ignore patterns"
434
429
As an alternative to editing the ``.bzrignore`` file, you can use the
435
``bzr ignore`` command. The ``bzr ignore`` command takes filenames and/or
430
``brz ignore`` command. The ``brz ignore`` command takes filenames and/or
436
431
patterns as arguments and then adds them to the ``.bzrignore`` file. If a
437
``.bzrignore`` file does not exist the ``bzr ignore`` command will
432
``.bzrignore`` file does not exist the ``brz ignore`` command will
438
433
automatically create one for you, and implicitly add it to be versioned::
445
440
Just like when editing the ``.bzrignore`` file on your own, you should
446
441
commit the automatically created ``.bzrignore`` file::
448
% bzr commit -m "Added tags to ignore file"
443
% brz commit -m "Added tags to ignore file"
461
456
Examining history
462
457
=================
467
The ``bzr log`` command shows a list of previous revisions. The ``bzr log
462
The ``brz log`` command shows a list of previous revisions. The ``brz log
468
463
--forward`` command does the same in chronological order to get most
469
464
recent revisions printed at last.
471
As with ``bzr diff``, ``bzr log`` supports the ``-r`` argument::
466
As with ``brz diff``, ``brz log`` supports the ``-r`` argument::
473
% bzr log -r 1000.. # Revision 1000 and everything after it
474
% bzr log -r ..1000 # Everything up to and including r1000
475
% bzr log -r 1000..1100 # changes from 1000 to 1100
476
% bzr log -r 1000 # The changes in only revision 1000
468
% brz log -r 1000.. # Revision 1000 and everything after it
469
% brz log -r ..1000 # Everything up to and including r1000
470
% brz log -r 1000..1100 # changes from 1000 to 1100
471
% brz log -r 1000 # The changes in only revision 1000
479
474
Branch statistics
480
475
=================
482
The ``bzr info`` command shows some summary information about the working
477
The ``brz info`` command shows some summary information about the working
483
478
tree and the branch history.
486
481
Versioning directories
487
482
======================
489
bzr versions files and directories in a way that can keep track of renames
484
brz versions files and directories in a way that can keep track of renames
490
485
and intelligently merge them::
493
488
% echo 'int main() {}' > src/simple.c
496
491
added src/simple.c
507
502
directory. This is a bit different to CVS, which requires that you also
508
503
do ``cvs remove``.
510
``bzr remove`` makes the file un-versioned, but may or may not delete the
505
``brz remove`` makes the file un-versioned, but may or may not delete the
511
506
working copy [2]_. This is useful when you add the wrong file, or decide that
512
507
a file should actually not be versioned.
517
% bzr remove -v hello.txt
512
% brz remove -v hello.txt
566
561
Merging from related branches
567
562
=============================
569
If two branches have diverged (both have unique changes) then ``bzr
564
If two branches have diverged (both have unique changes) then ``brz
570
565
merge`` is the appropriate command to use. Merge will automatically
571
566
calculate the changes that exist in the branch you're merging from that
572
567
are not in your branch and attempt to apply them in your branch.
579
574
If there is a conflict during a merge, 3 files with the same basename
600
595
Publishing your branch
601
596
======================
603
You don't need a special server to publish a bzr branch, just a normal web
598
You don't need a special server to publish a brz branch, just a normal web
604
599
server. Just mirror the files to your server, including the .bzr
605
600
directory. One can push a branch (or the changes for a branch) by one of
606
601
the following three methods:
608
* The best method is to use bzr itself to do it.
603
* The best method is to use brz itself to do it.
612
% bzr push bzr+ssh://servername.com/path/to/directory
607
% brz push brz+ssh://servername.com/path/to/directory
614
609
(The destination directory must already exist unless the
615
610
``--create-prefix`` option is used.)
617
* Another option is the ``rspush`` plugin that comes with BzrTools, which
612
* Another option is the ``rspush`` plugin that comes with brzTools, which
618
613
uses rsync to push the changes to the revision history and the working
639
% bzr merge --uncommitted OLDDIR
634
% brz merge --uncommitted OLDDIR
641
636
This will apply all of the uncommitted changes you made in OLDDIR to NEWDIR.
642
637
It will not apply committed changes, even if they could be applied to NEWDIR
643
with a regular merge. The changes will remain in OLDDIR, but you can use ``bzr
638
with a regular merge. The changes will remain in OLDDIR, but you can use ``brz
644
639
revert OLDDIR`` to remove them, once you're satisfied with NEWDIR.
646
641
NEWDIR does not have to be a copy of OLDDIR, but they should be related.