~bzr/bzr-migration-docs/trunk

« back to all changes in this revision

Viewing changes to en/survival/bzr-for-svn-users.txt

  • Committer: Ian Clatworthy
  • Date: 2009-10-08 08:15:13 UTC
  • mfrom: (2.2.3 bzr-migration-docs)
  • Revision ID: ian.clatworthy@canonical.com-20091008081513-wfsztfd85zadhusx
merge Neil's great work - a better svn survival guide

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Bazaar for Subversion users
2
2
===========================
3
3
 
4
 
Introduction
5
 
------------
6
 
 
7
 
We've strived to match Subversion terminology wherever it makes sense.
8
 
So terms like "checkout", "repository" and commands like "update",
9
 
"status", "diff" and "commit" should match your expectations.
10
 
 
11
 
Bazaar can be used in centralized and decentralized modes.
12
 
Centralized mode is similar to Subversion while decentralised mode
13
 
is similar to Mercurial.
14
 
 
15
 
In decentralized mode, everyone works in their own branches.
16
 
They can always commit without having to update first.
17
 
In fact, they don't even need 'commit access' or even be online!
18
 
They can merge from each other at any time.
19
 
 
20
 
Bazaar has very strong support for branching and merging.
21
 
Developers who use branches in Subversion often have careful procedures,
22
 
to make sure that branching and merging is done safely.
23
 
These procedures aren't necessary with Bazaar. Its merge tracking
24
 
features mean you'll only get conflicts if two people change the same
25
 
lines at the same time, like svn update. That's rare enough that it's
26
 
better to fix the few conflicts that do occur, rather than trying to
27
 
prevent all conflicts.
28
 
 
29
 
In centralized mode, it's typical to use a central repository,
30
 
like with Subversion. In decentralized mode, you can have a personal
31
 
repository, for maximum storage efficiency. Or you can store the branch
32
 
data in the same directory as the source code, for maximum ease-of-setup.
33
 
 
34
 
Bazaar can be used with almost any web host, because it doesn't require
35
 
a special server to be installed. It can use ftp, sftp, or its own
36
 
special protocol to upload branches. WebDAV support is being developed.
37
 
You can also use a mirroring program like rsync, if you prefer.
38
 
 
 
4
The following is a basic introduction to equivalencies between Bazaar and
 
5
Subversion.  For further information, refer to the `Bazaar documentation`_
 
6
online or use Bazaar's built-in help facilities by doing ``bzr help COMMAND``.
 
7
For further details, get started with ``bzr help topics``.
 
8
 
 
9
.. _`Bazaar documentation`: http://doc.bazaar-vcs.org/latest/en
39
10
 
40
11
Core tasks
41
12
----------
42
13
 
43
 
*"How are common Subversion tasks done in Bazaar?"*
44
 
 
45
 
 
46
 
Getting a checkout
47
 
~~~~~~~~~~~~~~~~~~
48
 
 
49
 
In the SVN world, somebody has already setup a SVN repository and has told
50
 
you a URL to "checkout". You checkout with::
51
 
 
52
 
 $ svn checkout URL
53
 
 
54
 
Usually the URL is a svn:// url, like the below example::
55
 
 
56
 
 $ svn checkout svn://somemachine.com/this/directory/here
57
 
 
58
 
In the Bazaar world, this is usually done with::
59
 
 
60
 
 $ bzr checkout http://somemachine.com/this/directory/here
61
 
 
62
 
 
63
 
Updating a checkout
64
 
~~~~~~~~~~~~~~~~~~~
65
 
 
66
 
In the SVN world you may have done a checkout. From time to time you have
67
 
to get new changes from the repository and apply them to your checkout.
68
 
This usually looks something like this::
69
 
 
70
 
 $ cd codebase/
71
 
 $ svn update
72
 
 
73
 
This looks very similiar in the Bazaar world::
74
 
 
75
 
 $ cd codebase/
76
 
 $ bzr update
77
 
 
78
 
In both the SVN and Bazaar cases this will mean that the changes in the
79
 
repository or branch that you do not yet have in the working tree will
80
 
be applied. You might have to deal with conflicts.
81
 
 
82
 
 
83
 
Seeing how a working tree has changed since the last commit
84
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
85
 
 
86
 
In the SVN world we often want to check how we have changed things since
87
 
we last committed. By checking how the code base has changed, we can see
88
 
what we're about to commit before we actually perform the commit.
89
 
 
90
 
In the SVN world, we would check the changes this way::
91
 
 
92
 
 $ svn status
93
 
 [see a list of files that have changed]
94
 
 $ svn status -u
95
 
 [see a list of new revisions in the repository]
96
 
 $ svn diff
97
 
 [see a diff of how files have changed]
98
 
 
99
 
This is very similar in Bazaar::
100
 
 
101
 
 $ bzr status
102
 
 [see a list of files that have changed]
103
 
 $ bzr missing
104
 
 [see a list of new revisions in the parent branch]
105
 
 $ bzr diff
106
 
 [see a diff of how files have changed]
107
 
 
108
 
The `diff` action in both systems will result in a diff that you can
109
 
review prior to commit.
110
 
 
111
 
 
112
 
Comitting code in a checkout
113
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114
 
 
115
 
In the SVN world you may have made changes to your checkout that need
116
 
to be saved in the repository. One typically does so in this way::
117
 
 
118
 
 $ svn commit -m'some description of whats being committed.'
119
 
 
120
 
Again, this looks very similiar in the Bazaar world::
121
 
 
122
 
 $ bzr commit -m'some description of whats being committed.'
123
 
 
124
 
In both of these cases, the new changes will be saved to either
125
 
the repository (SVN) or branch (Bazaar).
126
 
 
 
14
Checking out a project
 
15
++++++++++++++++++++++
 
16
 
 
17
To get the source of a project located at URL::
 
18
 
 
19
  svn co URL working_directory
 
20
  ====>
 
21
  bzr co --lightweight URL working_directory
 
22
 
 
23
Note that Bazaar cannot check out subdirectories of a working tree, so where
 
24
``svn co URL`` and ``svn co URL/a/sub/directory`` both work, it is only
 
25
possible to do ``bzr co URL``.
 
26
 
 
27
Adding new files
 
28
++++++++++++++++
 
29
 
 
30
To put `file1` and `file2` under version control::
 
31
 
 
32
  svn add file1 file2
 
33
  ====>
 
34
  bzr add file1 file2
 
35
 
 
36
Note that ``bzr add`` will automatically add all unversioned, non-ignored files 
 
37
under the current directory.
 
38
 
 
39
Checking the status
 
40
+++++++++++++++++++
 
41
 
 
42
To check the status of the current directory::
 
43
 
 
44
  svn st
 
45
  ====>
 
46
  bzr st -S .
 
47
 
 
48
Note that Bazaar gives pathnames relative to the top of the working tree while
 
49
Subversion gives pathnames relative to the current directory.
 
50
 
 
51
Committing changes
 
52
++++++++++++++++++
 
53
 
 
54
To commit the current state of the working tree::
 
55
 
 
56
  svn ci -m 'this is a commit message'
 
57
  ====>
 
58
  bzr ci =m 'this is a commit message'
 
59
 
 
60
You can specify certain files to commit in the same way as in Subversion:
 
61
``bzr ci -m 'dont save all things' file1 file2``.
 
62
 
 
63
Viewing history
 
64
+++++++++++++++
 
65
 
 
66
To see the history of the current project::
 
67
 
 
68
  svn log
 
69
  ====>
 
70
  bzr log --short
 
71
 
 
72
or to give verbose information including all of the files changed by each
 
73
revision use the ``-v`` flag.  To see the log for a limited range of
 
74
revisions::
 
75
 
 
76
  svn log -r 10:25
 
77
  ====>
 
78
  bzr log -r 10..25
 
79
 
 
80
Updating to the latest version
 
81
++++++++++++++++++++++++++++++
 
82
 
 
83
When other people have made a change to the project, your working copy may be
 
84
out of date.  To update your working copy::
 
85
 
 
86
  svn up
 
87
  ====>
 
88
  bzr up
 
89
 
 
90
This update may result in conflicts which need to be manually resolved.
 
91
 
 
92
Note that the update (up) command in Bazaar is not used to put the working
 
93
copy in the state of a previous revision as it is in Subversion.
 
94
 
 
95
Changing to a previous revision
 
96
+++++++++++++++++++++++++++++++
 
97
 
 
98
To change the working tree to the state that it had in a previous revision::
 
99
 
 
100
  svn up -r 25
 
101
  ====>
 
102
  bzr revert -r 25
 
103
 
 
104
Note that both of these commands try not to lose uncommitted information
 
105
in the working tree, but they may do so in different ways.  In both cases, use
 
106
of the ``status`` command after the change is recommended.
127
107
 
128
108
 
129
109
Network protocols
130
110
-----------------
131
111
 
132
 
*"How do network URLs differ?"*
133
 
 
134
 
To be completed ...
 
112
Subversion accesses network resources using URLs, as does Bazaar.  Both
 
113
programs have a native server program that runs remotely.  These are svn://
 
114
and bzr:// URLs respectively.  Both of these native protocols can be tunneled
 
115
over SSH to avoid the need to run a persistent program on the remote system on
 
116
a separate port.  This gives svn+ssh:// and bzr+ssh:// URLs.  
 
117
 
 
118
Both Subversion and Bazaar can be accessed over HTTP, but there is a
 
119
difference in how they work with the limitations of that protocol.  Subversion
 
120
runs as a module under Apache and serves repositories using the WebDAV
 
121
extensions to HTTP, thus allowing read/write access over HTTP.  Bazaar
 
122
accesses the repository using the ordinary HTTP protocol.  The relevant
 
123
difference is that Bazaar access over HTTP is read-only.
 
124
 
 
125
Bazaar repositories are also read-write accessible using both
 
126
SFTP and plain FTP, which are *not* used by Subversion.  See
 
127
``bzr help urlspec`` for more information.
135
128
 
136
129
 
137
130
Revisions
138
131
---------
139
132
 
140
 
*How do revision identifiers differ?*
141
 
 
142
 
To be completed ...
 
133
Both Subversion and Bazaar refer to revisions mainly by way of the ``-r``
 
134
option to commands.  The most common way to refer to revisions is as numbers
 
135
starting from 1 and counting up with subsequent commits.  Both Subversion and
 
136
Bazaar provide ways to refer to revisions in other terms as well.  The table
 
137
below should serve as a preliminary guide to the equivalences
 
138
 
 
139
===================== ============== ===============
 
140
Revision desired      Subversion     Bazaar
 
141
===================== ============== ===============
 
142
Revision Range        ARG1:ARG2      ARG1..ARG2
 
143
Specific Date         {2009-06-04}   date:2009-06-04
 
144
Latest Revision       HEAD           -1
 
145
Next-to-last Revision HEAD-1         -2
 
146
===================== ============== ===============
 
147
 
 
148
Due to the distributed nature of Bazaar, sequential revision numbers are
 
149
not authoritative in Bazaar as they are in Subversion.  Due to merging with
 
150
other branches, Bazaar's revision numbers can change.  The most consistent way
 
151
to refer to a revision in Bazaar is a revision id such as
 
152
 
 
153
:: 
 
154
  
 
155
  bzr revert -r revid:nmb@wartburg.edu-20091007045325-5jorn2ca1a4dgqp9
 
156
 
 
157
These ids can be seen using ``bzr log --show-ids``.  There are even more ways
 
158
to refer to related revisions in Bazaar.  See
 
159
``bzr help revspec`` for further possibilities.
143
160
 
144
161
 
145
162
Other commands