Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Collins-Sussman B.Version control with Subversion 1.1.pdf
Скачиваний:
9
Добавлен:
23.08.2013
Размер:
1.53 Mб
Скачать

Branching and Merging

Of course, these internal mechanics of copying and sharing data are hidden from the user, who simply sees copies of trees. The main point here is that copies are cheap, both in time and space. Make branches as often as you want.

Working with Your Branch

Now that you've created a branch of the project, you can check out a new working copy to start using it:

$ svn checkout http://svn.example.com/repos/calc/branches/my-calc-branch A my-calc-branch/Makefile

A my-calc-branch/integer.c A my-calc-branch/button.c Checked out revision 341.

There's nothing special about this working copy; it simply mirrors a different directory in the repository. When you commit changes, however, Sally won't ever see them when she updates. Her working copy is of /calc/trunk. (Be sure to read the section called “Switching a Working Copy” later in this chapter: the svn switch command is an alternate way of creating a working copy of a branch.)

Let's pretend that a week goes by, and the following commits happen:

You make a change to /calc/branches/my-calc-branch/button.c, which creates revision 342.

You make a change to /calc/branches/my-calc-branch/integer.c, which creates revision 343.

Sally makes a change to /calc/trunk/integer.c, which creates revision 344.

There are now two independent lines of development, shown in Figure 4.4, “The branching of one file's history”, happening on integer.c.

Figure 4.4. The branching of one file's history

Things get interesting when you look at the history of changes made to your copy of integer.c:

$ pwd /home/user/my-calc-branch

46

Branching and Merging

$ svn log --verbose integer.c

------------------------------------------------------------------------

r343 | user | 2002-11-07 15:27:56 -0600 (Thu, 07 Nov 2002) | 2 lines Changed paths:

M/calc/branches/my-calc-branch/integer.c

*integer.c: frozzled the wazjub.

------------------------------------------------------------------------

r341 | user | 2002-11-03 15:27:56 -0600 (Thu, 07 Nov 2002) | 2 lines Changed paths:

A /calc/branches/my-calc-branch (from /calc/trunk:340) Creating a private branch of /calc/trunk.

------------------------------------------------------------------------

r303 | sally | 2002-10-29 21:14:35 -0600 (Tue, 29 Oct 2002) | 2 lines Changed paths:

M/calc/trunk/integer.c

*integer.c: changed a docstring.

------------------------------------------------------------------------

r98 | sally | 2002-02-22 15:35:29 -0600 (Fri, 22 Feb 2002) | 2 lines Changed paths:

M/calc/trunk/integer.c

*integer.c: adding this file to the project.

------------------------------------------------------------------------

Notice that Subversion is tracing the history of your branch's integer.c all the way back through time, even traversing the point where it was copied. It shows the creation of the branch as an event in the history, because integer.c was implicitly copied when all of /calc/trunk/ was copied. Now look what happens when Sally runs the same command on her copy of the file:

$ pwd /home/sally/calc

$ svn log --verbose integer.c

------------------------------------------------------------------------

r344 | sally | 2002-11-07 15:27:56 -0600 (Thu, 07 Nov 2002) | 2 lines Changed paths:

M/calc/trunk/integer.c

*integer.c: fix a bunch of spelling errors.

------------------------------------------------------------------------

r303 | sally | 2002-10-29 21:14:35 -0600 (Tue, 29 Oct 2002) | 2 lines Changed paths:

M/calc/trunk/integer.c

*integer.c: changed a docstring.

------------------------------------------------------------------------

r98 | sally | 2002-02-22 15:35:29 -0600 (Fri, 22 Feb 2002) | 2 lines Changed paths:

M/calc/trunk/integer.c

*integer.c: adding this file to the project.

47

Соседние файлы в предмете Электротехника