/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
1
====================
2
Centralized Workflow
3
====================
4
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
5
.. sectnum::
6
7
8
Overview
9
========
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
10
11
This document describes a possible workflow for using Bazaar_. That of
12
using Bazaar_, the distributed version control system, in a centralized
13
manner. Bazaar_ is designed to be very flexible and allows several
14
different workflows, from fully decentralized to mostly centralized.  The
15
workflow used here is meant to ease a new user into more advanced usage of
16
Bazaar_, and allows them to work in a mix of centralized and decentralized
17
operations.
18
19
In general, this document is meant for users coming from a background of
20
centralized version control systems such as CVS or subversion. It is
21
common in work settings to have a single central server hosting the
22
codebase, with several people working on this codebase, keeping their work
23
in sync.  This workflow is also applicable to a single developer working
24
on several different machines.
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
25
26
.. _Bazaar: http://bazaar-vcs.org
27
28
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
29
Initial Setup
30
=============
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
31
32
These are some reasonably simple steps to setup Bazaar_ so that it works
33
well for you.
34
35
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
36
Setting User Email
37
------------------
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
38
39
Your user identity is stored with each commit. While this doesn't have to
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
40
be accurate or unique, it will be used in log messages and
41
annotations, so it is better to have something real.
42
43
::  
44
45
   % bzr whoami "John Doe <jdoe@organization.com>"
46
47
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
48
Setting up a local Repository
49
-----------------------------
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
50
51
Bazaar_ branches generally copy the history information around with them,
52
which is part of how you can work in a fully decentralized manner. As an
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
53
optimization, it is possible for related branches to combine their storage
54
needs so that you do not need to copy around all of this history
55
information whenever you create a new branch.
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
56
57
The best way to do this is to create a `Shared Repository`_. In general,
58
branches will share their storage if they exist in a subdirectory of a
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
59
`Shared Repository`_.  So let's setup a `Shared Repository`_ in our home
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
60
directory, thus all branches we create underneath will share their history
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
61
storage.
62
63
::
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
64
65
  % bzr init-repo --trees ~
66
67
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
68
Setting up a remote Repository
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
69
---------------------------------
70
71
Many times you want a location where data is stored separately from where
72
you do your work. This workflow is required by centralized systems
73
(CVS/SVN).  Usually they are on separate machines, but not always. This is
74
actually a pretty good setup, especially in a work environment. Since it
75
ensures a central location where data can be backed up, and means that if
76
something happens to a developer's machine, no committed work has to be
77
lost.
78
79
So let's set up a shared location for our project on a remote machine
80
called ``centralhost``. Again, we will use a
81
`Shared Repository`_ to optimize disk usage.
82
83
::
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
84
85
  % bzr init-repo --no-trees sftp://centralhost/srv/bzr/
86
87
You can think of this step as similar to setting up a new cvsroot, or
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
88
subversion repository.
89
90
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
91
Versioning an existing project
92
==============================
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
93
94
Now that we have a repository, let's create a versioned project. Most of
95
the time, you will already have some code that you are working with,
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
96
that you now want to version using Bazaar_. If the code was originally
97
in source control, there are many ways to convert the project to Bazaar_
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
98
without losing any history. However, this is outside the scope of this
99
document. See `Tracking Upstream`_ for some possibilities (section
100
"Converting and keeping history").
101
102
.. _Tracking Upstream: http://bazaar-vcs.org/TrackingUpstream
103
104
.. 
105
   XXX: We really need a different document for discussing conversion of a
106
   project. Right now TrackingUpstream is the best we have, though.
107
108
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
109
Developer 1: Creating the first revision
110
----------------------------------------
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
111
112
So first, we want to create a branch in our remote Repository, where we
113
will want to host the project.  Let's assume we have a project named
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
114
"sigil" that we want to start versioning.
115
116
::
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
117
118
  % bzr init sftp://centralhost/srv/bzr/sigil
119
120
This can be thought of as the "HEAD" branch in CVS terms, or as the "trunk"
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
121
in Subversion terms. We will call this the ``dev`` branch.
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
122
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
123
I prefer working in a subdirectory of my home directory to avoid collisions with all
124
the other files that end up there. Also, we will want a project
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
125
directory where we can hold all of the different branches we end up
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
126
working on.
127
128
::
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
129
130
  % cd ~
131
  % mkdir work
132
  % cd work
133
  % mkdir sigil
134
  % cd sigil
135
  % bzr checkout sftp://centralhost/srv/bzr/sigil dev
136
  % cd dev
137
  % cp -ar ~/sigil/* .
138
  % bzr add
139
  % bzr commit -m "Initial import of Sigil"
140
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
141
142
In the example above, we created an empty branch (the ``/sigil`` branch)
143
on ``centralhost``, and then checkout out this empty branch onto our
144
workstation to add files from our existing project.
145
There are many ways to setup your working directory, but the steps above
146
make it easy to handle working with feature/bugfix branches. And one
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
147
of the strong points of Bazaar_ is how well it works with branches.
148
149
At this point, because you have a 'checkout' of the remote branch, any
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
150
commits you make in ``~/work/sigil/dev/`` will automatically be saved both locally,
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
151
and on ``centralhost``.
152
153
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
154
Developer N: Getting a working copy of the project
155
--------------------------------------------------
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
156
157
Since the first developer did all of the work of creating the project,
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
158
all other developers would just checkout that branch. **They should
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
159
still follow** `Setting User Email`_ and `Setting up a local Repository`_.
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
160
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
161
To get a copy of the current development tree::
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
162
163
  % cd ~/work/sigil
164
  % bzr checkout sftp://centralhost/srv/bzr/sigil dev
165
166
Now that two people both have a checkout of
167
``sftp://centralhost/srv/bzr/sigil``, there will be times when one of
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
168
the checkouts will be out of date with the current version.
169
At commit time, Bazaar_ will inform the user of this and prevent them from
170
committing. To get up to date, use ``bzr update`` to update the
171
tree with the remote changes. This may require resolving conflicts, if the
172
same files have been modified.
173
174
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
175
Developing on separate branches
176
===============================
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
177
178
So far everyone is working and committing their changes into the same
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
179
branch. This means that everyone needs to update fairly regularly and
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
180
deal with other people's changes. Also, if one person commits something
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
181
that breaks the codebase, then upon syncing, everyone will get the
182
problem.
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
183
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
184
Usually, it is better to do development on different branches, and then
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
185
integrate those back into the main branch, once they are stable. This is
186
one of the biggest changes from working with CVS/SVN. They both allow you
187
to work on separate branches, but their merging algorithms are fairly
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
188
weak, so it is difficult to keep things synchronized. Bazaar_ tracks
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
189
what has already been merged, and can even apply changes to files that
190
have been renamed.
191
192
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
193
Creating and working on a new branch
194
------------------------------------
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
195
196
We want to keep our changes available for other people, even if they
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
197
aren't quite complete yet. So we will create a new public branch on
198
``centralhost``, and track it locally.
199
200
::
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
201
202
  % cd ~/work/sigil
203
  % bzr branch sftp://centralhost/srv/bzr/sigil \
204
               sftp://centralhost/srv/bzr/sigil/doodle-fixes
205
  % bzr checkout sftp://centralhost/srv/bzr/sigil/doodle-fixes doodle-fixes
206
  % cd doodle-fixes
207
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
208
We now have a place to make any fixes we need to ``doodle``. And we would
209
not interrupt people who are working on other parts of the code.  Because
210
we have a checkout, any commits made in the ``~/work/sigil/doodle-fixes/``
211
will also show up on ``centralhost``. [#nestedbranches]_ It is also
212
possible to have 2 developers collaborate on one of these branches, just
213
like they would have collaborated on the ``dev`` branch. [#cbranch]_
214
215
.. [#nestedbranches] It may look odd to have a branch in a subdirectory of
216
   another branch. This is just fine, and you can think of it as a
217
   heirarchial namespace. Where the nested branch is derived from the
218
   outer branch.
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
219
220
.. [#cbranch] When using lots of independent branches, having to retype
221
   the full URL all the time takes a lot of typing. We are looking into
222
   various methods to help with this, such as branch aliases, etc. For
223
   now, though, the bzrtools_ plugin provides the ``bzr cbranch`` command.
224
   Which is designed to take a base branch, create a new public branch,
225
   and create a checkout of that branch, all with much less typing.
226
   Configuring ``cbranch`` is outside the scope of this document, but the
227
   final commands look like ``bzr cbranch dev my-feature-branch``
228
229
.. _bzrtools: https://launchpad.net/products/bzrtools
230
231
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
232
Merging changes back
233
--------------------
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
234
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
235
When it is decided that some of the changes in ``doodle-fixes`` are ready
236
to be merged into the main branch, simply do::
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
237
238
  % cd ~/work/sigil/dev
239
  % bzr merge ../doodle-fixes
240
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
241
Now the changes are available in the ``dev`` branch, but they have not
242
been committed yet. This is the time when you want to review the final
243
changes, and double check the code to make sure it compiles cleanly and
244
passes the test suite. The commands ``bzr status`` and ``bzr diff`` are
245
good tools to use here. Also, this is the time to resolve any conflicts.
246
Bazaar_ will prevent you from committing until you have resolved these
247
conflicts. That way you don't accidentally commit the conflict markers.
248
The command ``bzr status`` will show the conflicts along with the other
249
changes, or you can use ``bzr conflicts`` to just list conflicts. Use
250
``bzr resolve file/name`` or ``bzr resolve --all`` once conflicts have
251
been handled. [#resolve]_ If you have a conflict that is particularly
252
difficult to solve you may want to use the ``bzr remerge`` command. It
253
will let you try different merge algorithms, as well as let you see the
254
original source lines (``--show-base``).
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
255
256
.. [#resolve] Some systems make you resolve conflicts as part of the merge
257
   process. We have found that it is usually easier to resolve conflicts
258
   when you have the view of the entire tree, rather than just a single
259
   file. It gives you much more context, and also lets you run tests as
260
   you resolve the problems.
261
262
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
263
Recommended Branching
264
---------------------
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
265
266
One very common way to handle all of these branches is to give each
267
developer their own branch, and their own place to work in the central
268
location. This can be done with::
269
270
  % bzr branch sftp://centralhost/srv/bzr/sigil \
271
               sftp://centralhost/srv/bzr/sigil/user-a
272
  % bzr branch sftp://centralhost/srv/bzr/sigil \
273
               sftp://centralhost/srv/bzr/sigil/user-b
274
275
This gives each developer their own branch to work on. And, they can
276
easily create a new feature branch for themselves with just[#cbranch]_::
277
278
  % bzr branch sftp://centralhost/srv/bzr/sigil/user-a \
279
               sftp://centralhost/srv/bzr/sigil/user-a/feature 
280
  % cd ~/work/sigil
281
  % bzr checkout sftp://centralhost/srv/bzr/sigil/user-a/feature myfeature
282
283
2098.2.3 by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections.
284
Glossary
285
========
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
286
287
Shared Repository
288
-----------------
289
2098.2.2 by John Arbash Meinel
minor cleanup
290
Bazaar_ has the concept of a "Shared Repository". This is similar to the
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
291
concept of other RCS's repository. Such as in Subversion, where you have a
292
remote repository, which is where all of the history is stored, and
293
locally you don't have any history information, only a checkout of the
294
working tree files. Note that "Shared" in this context means shared
295
between branches. It *may* be shared between people, but standalone
296
branches can also be shared between people.
297
2098.2.2 by John Arbash Meinel
minor cleanup
298
In Bazaar_ terms, a "Shared Repository" is a location where multiple
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
299
branches can **share** their revision history information. Because Bazaar_
300
wants to support decentralized workflows, it is possible for every branch
301
to maintain its own revision history information. But this is often
2098.2.1 by John Arbash Meinel
Apply changes recommended by Alaa Salman
302
inefficient, since related branches share history, and they might as well
1964.2.1 by John Arbash Meinel
Adding basic documentation about working with a central repository
303
share the storage as well.
304
305
306
.. 
307
   vim: tw=74 ft=rst spell spelllang=en_us