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 |
|
6 |
Overview |
|
7 |
======== |
|
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
8 |
|
9 |
This document describes a possible workflow for using Bazaar_. That of |
|
10 |
using Bazaar_, the distributed version control system, in a centralized |
|
11 |
manner. Bazaar_ is designed to be very flexible and allows several |
|
12 |
different workflows, from fully decentralized to mostly centralized. The |
|
13 |
workflow used here is meant to ease a new user into more advanced usage of |
|
|
2293.1.3
by Brad Crittenden
Updated version_info.txt for grammar changes |
14 |
Bazaar_, and allow them to work in a mix of centralized and decentralized |
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
15 |
operations. |
16 |
||
17 |
In general, this document is meant for users coming from a background of |
|
18 |
centralized version control systems such as CVS or subversion. It is |
|
19 |
common in work settings to have a single central server hosting the |
|
20 |
codebase, with several people working on this codebase, keeping their work |
|
21 |
in sync. This workflow is also applicable to a single developer working |
|
22 |
on several different machines. |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
23 |
|
24 |
.. _Bazaar: http://bazaar-vcs.org |
|
25 |
||
|
2098.2.4
by John Arbash Meinel
Include a table-of-contents. |
26 |
.. contents:: |
27 |
||
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
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 |
|
|
2293.1.6
by Brad Crittenden
post review changes |
57 |
The best way to do this is to create a `Shared Repository`_. In |
58 |
general, branches will share their storage if they exist in a |
|
59 |
subdirectory of a `Shared Repository`_. So let's set up a `Shared |
|
60 |
Repository`_ in our home directory, thus all branches we create |
|
61 |
underneath will share their history storage. |
|
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
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 |
|
|
2293.1.3
by Brad Crittenden
Updated version_info.txt for grammar changes |
88 |
subversion repository. The {{{--no-trees}}} option tells bzr to not
|
|
2293.1.6
by Brad Crittenden
post review changes |
89 |
populate the directory with a working tree. This is appropriate, |
90 |
since no one will be making changes directly in the branches within |
|
91 |
the central repository. |
|
92 |
||
93 |
||
94 |
Migrating an existing project to Bazaar |
|
|
2293.1.3
by Brad Crittenden
Updated version_info.txt for grammar changes |
95 |
======================================= |
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
96 |
|
97 |
Now that we have a repository, let's create a versioned project. Most of |
|
98 |
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 |
99 |
that you now want to version using Bazaar_. If the code was originally |
|
2293.1.6
by Brad Crittenden
post review changes |
100 |
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 |
101 |
without losing any history. However, this is outside the scope of this |
102 |
document. See `Tracking Upstream`_ for some possibilities (section |
|
103 |
"Converting and keeping history"). |
|
104 |
||
105 |
.. _Tracking Upstream: http://bazaar-vcs.org/TrackingUpstream |
|
106 |
||
107 |
.. |
|
108 |
XXX: We really need a different document for discussing conversion of a |
|
109 |
project. Right now TrackingUpstream is the best we have, though. |
|
110 |
||
111 |
||
|
2098.2.3
by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections. |
112 |
Developer 1: Creating the first revision |
113 |
---------------------------------------- |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
114 |
|
115 |
So first, we want to create a branch in our remote Repository, where we |
|
|
2293.1.3
by Brad Crittenden
Updated version_info.txt for grammar changes |
116 |
want to host the project. Let's assume we have a project named |
117 |
"sigil" that we want to put under version control. |
|
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
118 |
|
119 |
:: |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
120 |
|
121 |
% bzr init sftp://centralhost/srv/bzr/sigil |
|
122 |
||
123 |
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 |
124 |
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 |
125 |
|
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
126 |
I prefer working in a subdirectory of my home directory to avoid collisions with all |
127 |
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 |
128 |
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 |
129 |
working on. |
130 |
||
131 |
:: |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
132 |
|
133 |
% cd ~ |
|
134 |
% mkdir work |
|
135 |
% cd work |
|
136 |
% mkdir sigil |
|
137 |
% cd sigil |
|
138 |
% bzr checkout sftp://centralhost/srv/bzr/sigil dev |
|
139 |
% cd dev |
|
140 |
% cp -ar ~/sigil/* . |
|
141 |
% bzr add |
|
142 |
% bzr commit -m "Initial import of Sigil" |
|
143 |
||
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
144 |
|
|
2293.1.6
by Brad Crittenden
post review changes |
145 |
In the previous section, we created an empty branch (the ``/sigil`` |
146 |
branch) on ``centralhost``, and then checkout out this empty branch |
|
147 |
onto our workstation to add files from our existing project. There |
|
148 |
are many ways to set up your working directory, but the steps above |
|
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
149 |
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 |
150 |
of the strong points of Bazaar_ is how well it works with branches. |
151 |
||
152 |
At this point, because you have a 'checkout' of the remote branch, any |
|
|
2293.1.6
by Brad Crittenden
post review changes |
153 |
commits you make in ``~/work/sigil/dev/`` will automatically be saved |
154 |
both locally, and on ``centralhost``. |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
155 |
|
156 |
||
|
2098.2.3
by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections. |
157 |
Developer N: Getting a working copy of the project |
158 |
-------------------------------------------------- |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
159 |
|
160 |
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 |
161 |
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. |
162 |
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 |
163 |
|
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
164 |
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 |
165 |
|
166 |
% cd ~/work/sigil |
|
167 |
% bzr checkout sftp://centralhost/srv/bzr/sigil dev |
|
168 |
||
169 |
Now that two people both have a checkout of |
|
170 |
``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 |
171 |
the checkouts will be out of date with the current version. |
172 |
At commit time, Bazaar_ will inform the user of this and prevent them from |
|
173 |
committing. To get up to date, use ``bzr update`` to update the |
|
|
2293.1.3
by Brad Crittenden
Updated version_info.txt for grammar changes |
174 |
tree with the remote changes. This may require resolving conflicts if the |
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
175 |
same files have been modified. |
176 |
||
177 |
||
|
2098.2.3
by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections. |
178 |
Developing on separate branches |
179 |
=============================== |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
180 |
|
181 |
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 |
182 |
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 |
183 |
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 |
184 |
that breaks the codebase, then upon syncing, everyone will get the |
185 |
problem. |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
186 |
|
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
187 |
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 |
188 |
integrate those back into the main branch, once they are stable. This is |
189 |
one of the biggest changes from working with CVS/SVN. They both allow you |
|
190 |
to work on separate branches, but their merging algorithms are fairly |
|
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
191 |
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 |
192 |
what has already been merged, and can even apply changes to files that |
193 |
have been renamed. |
|
194 |
||
195 |
||
|
2098.2.3
by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections. |
196 |
Creating and working on a new branch |
197 |
------------------------------------ |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
198 |
|
199 |
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 |
200 |
aren't quite complete yet. So we will create a new public branch on |
201 |
``centralhost``, and track it locally. |
|
202 |
||
203 |
:: |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
204 |
|
205 |
% cd ~/work/sigil |
|
206 |
% bzr branch sftp://centralhost/srv/bzr/sigil \ |
|
207 |
sftp://centralhost/srv/bzr/sigil/doodle-fixes |
|
208 |
% bzr checkout sftp://centralhost/srv/bzr/sigil/doodle-fixes doodle-fixes |
|
209 |
% cd doodle-fixes |
|
210 |
||
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
211 |
We now have a place to make any fixes we need to ``doodle``. And we would |
212 |
not interrupt people who are working on other parts of the code. Because |
|
213 |
we have a checkout, any commits made in the ``~/work/sigil/doodle-fixes/`` |
|
214 |
will also show up on ``centralhost``. [#nestedbranches]_ It is also |
|
|
2293.1.3
by Brad Crittenden
Updated version_info.txt for grammar changes |
215 |
possible to have two developers collaborate on one of these branches, just |
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
216 |
like they would have collaborated on the ``dev`` branch. [#cbranch]_ |
217 |
||
218 |
.. [#nestedbranches] It may look odd to have a branch in a subdirectory of |
|
219 |
another branch. This is just fine, and you can think of it as a |
|
|
2293.1.3
by Brad Crittenden
Updated version_info.txt for grammar changes |
220 |
hierarchical namespace where the nested branch is derived from the |
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
221 |
outer branch. |
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
222 |
|
223 |
.. [#cbranch] When using lots of independent branches, having to retype |
|
224 |
the full URL all the time takes a lot of typing. We are looking into |
|
225 |
various methods to help with this, such as branch aliases, etc. For |
|
226 |
now, though, the bzrtools_ plugin provides the ``bzr cbranch`` command. |
|
227 |
Which is designed to take a base branch, create a new public branch, |
|
228 |
and create a checkout of that branch, all with much less typing. |
|
229 |
Configuring ``cbranch`` is outside the scope of this document, but the |
|
|
2293.1.3
by Brad Crittenden
Updated version_info.txt for grammar changes |
230 |
final commands are similar to: |
231 |
||
232 |
:: |
|
233 |
||
234 |
% bzr cbranch dev my-feature-branch |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
235 |
|
|
2482.1.1
by Robert Collins
(robertc) Trivially update the location of bzrtools in doc/centralized_workflow.txt |
236 |
.. _bzrtools: http://bazaar-vcs.org/BzrTools |
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
237 |
|
238 |
||
|
2098.2.3
by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections. |
239 |
Merging changes back |
240 |
-------------------- |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
241 |
|
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
242 |
When it is decided that some of the changes in ``doodle-fixes`` are ready |
243 |
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 |
244 |
|
245 |
% cd ~/work/sigil/dev |
|
246 |
% bzr merge ../doodle-fixes |
|
247 |
||
|
2098.2.1
by John Arbash Meinel
Apply changes recommended by Alaa Salman |
248 |
Now the changes are available in the ``dev`` branch, but they have not |
249 |
been committed yet. This is the time when you want to review the final |
|
250 |
changes, and double check the code to make sure it compiles cleanly and |
|
251 |
passes the test suite. The commands ``bzr status`` and ``bzr diff`` are |
|
252 |
good tools to use here. Also, this is the time to resolve any conflicts. |
|
253 |
Bazaar_ will prevent you from committing until you have resolved these |
|
254 |
conflicts. That way you don't accidentally commit the conflict markers. |
|
255 |
The command ``bzr status`` will show the conflicts along with the other |
|
256 |
changes, or you can use ``bzr conflicts`` to just list conflicts. Use |
|
257 |
``bzr resolve file/name`` or ``bzr resolve --all`` once conflicts have |
|
258 |
been handled. [#resolve]_ If you have a conflict that is particularly |
|
259 |
difficult to solve you may want to use the ``bzr remerge`` command. It |
|
260 |
will let you try different merge algorithms, as well as let you see the |
|
261 |
original source lines (``--show-base``). |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
262 |
|
263 |
.. [#resolve] Some systems make you resolve conflicts as part of the merge |
|
264 |
process. We have found that it is usually easier to resolve conflicts |
|
265 |
when you have the view of the entire tree, rather than just a single |
|
266 |
file. It gives you much more context, and also lets you run tests as |
|
267 |
you resolve the problems. |
|
268 |
||
269 |
||
|
2098.2.3
by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections. |
270 |
Recommended Branching |
271 |
--------------------- |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
272 |
|
273 |
One very common way to handle all of these branches is to give each |
|
274 |
developer their own branch, and their own place to work in the central |
|
275 |
location. This can be done with:: |
|
276 |
||
277 |
% bzr branch sftp://centralhost/srv/bzr/sigil \ |
|
278 |
sftp://centralhost/srv/bzr/sigil/user-a |
|
279 |
% bzr branch sftp://centralhost/srv/bzr/sigil \ |
|
280 |
sftp://centralhost/srv/bzr/sigil/user-b |
|
281 |
||
282 |
This gives each developer their own branch to work on. And, they can |
|
|
2293.1.3
by Brad Crittenden
Updated version_info.txt for grammar changes |
283 |
easily create a new feature branch for themselves with just [#cbranch]_ |
284 |
:: |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
285 |
|
286 |
% bzr branch sftp://centralhost/srv/bzr/sigil/user-a \ |
|
287 |
sftp://centralhost/srv/bzr/sigil/user-a/feature |
|
288 |
% cd ~/work/sigil |
|
289 |
% bzr checkout sftp://centralhost/srv/bzr/sigil/user-a/feature myfeature |
|
290 |
||
291 |
||
|
2098.2.3
by John Arbash Meinel
Switch to automatic numbering for sections and sub-sections. |
292 |
Glossary |
293 |
======== |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
294 |
|
295 |
Shared Repository |
|
296 |
----------------- |
|
297 |
||
|
2293.1.3
by Brad Crittenden
Updated version_info.txt for grammar changes |
298 |
Bazaar_ has the concept of a "Shared Repository". This is similar to |
|
2293.1.6
by Brad Crittenden
post review changes |
299 |
the traditional concept of a repository in other RCSs like CVS and |
300 |
Subversion. For example, in Subversion you have a remote repository, |
|
301 |
which is where all of the history is stored, and locally you don't |
|
302 |
have any history information, only a checkout of the working tree |
|
303 |
files. Note that "Shared" in this context means shared between |
|
304 |
branches. It *may* be shared between people, but standalone branches |
|
305 |
can also be shared between people. |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
306 |
|
|
2098.2.2
by John Arbash Meinel
minor cleanup |
307 |
In Bazaar_ terms, a "Shared Repository" is a location where multiple |
|
2293.1.3
by Brad Crittenden
Updated version_info.txt for grammar changes |
308 |
branches can **share** their revision history information. In order to |
309 |
support decentralized workflows, it is possible for every branch to |
|
|
2293.1.6
by Brad Crittenden
post review changes |
310 |
store its own revision history information. But this is often |
|
2293.1.3
by Brad Crittenden
Updated version_info.txt for grammar changes |
311 |
inefficient, since related branches share history, and they might as |
312 |
well share the storage as well. |
|
|
1964.2.1
by John Arbash Meinel
Adding basic documentation about working with a central repository |
313 |
|
314 |
||
315 |
.. |
|
316 |
vim: tw=74 ft=rst spell spelllang=en_us |