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