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

Guided Tour

If you're in your editor writing a commit message and decide that you want to cancel your commit, you can just quit your editor without saving changes. If you've already saved your commit message, simply delete the text and save again.

$ svn commit

Waiting for Emacs...Done

Log message unchanged or not specified a)bort, c)ontinue, e)dit

a

$

The repository doesn't know or care if your changes make any sense as a whole; it only checks to make sure that nobody else has changed any of the same files that you did when you weren't looking. If somebody has done that, the entire commit will fail with a message informing you that one or more of your files is out-of-date:

$ svn commit --message "Add another rule" Sending rules.txt

svn: Commit failed (details follow):

svn: Out of date: 'rules.txt' in transaction 'g'

At this point, you need to run svn update, deal with any merges or conflicts that result, and attempt your commit again.

That covers the basic work cycle for using Subversion. There are many other features in Subversion that you can use to manage your repository and working copy, but you can get by quite easily using only the commands that we've discussed so far in this chapter.

Examining History

As we mentioned earlier, the repository is like a time machine. It keeps a record of every change ever committed, and allows you to explore this history by examining previous versions of files and directories as well as the metadata that accompanies them. With a single Subversion command, you can check out the repository (or restore an existing working copy) exactly as it was at any date or revision number in the past. However, sometimes you just want to peer into the past instead of going into the past.

There are several commands that can provide you with historical data from the repository:

svn log

Shows you broad information: log messages attached to revisions, and which paths changed in each revision.

svn diff

Shows you the specific details of how a file changed over time.

svn cat

This is used to retrieve any file as it existed in a particular revision number and display it on your screen.

svn list

Displays the files in a directory for any given revision.

svn log

To find information about the history of a file or directory, use the svn log command. svn log will provide you with

35

Guided Tour

a record of who made changes to a file or directory, at what revision it changed, the time and date of that revision, and, if it was provided, the log message that accompanied the commit.

$ svn log

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

r3 | sally | Mon, 15 Jul 2002 18:03:46 -0500 | 1 line

Added include lines and corrected # of cheese slices.

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

r2 | harry | Mon, 15 Jul 2002 17:47:57 -0500 | 1 line

Added main() methods.

 

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

r1 | sally | Mon, 15 Jul 2002 17:40:08 -0500

| 1 line

Initial import

 

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

Note that the log messages are printed in reverse chronological order by default. If you wish to see a different range

of revisions in a particular order, or just a single revision, pass the

--revision (-r) switch:

$ svn log

--revision 5:19

# shows

logs 5

through

19

in

chronological

order

$ svn

log

-r

19:5

#

shows

logs 5

through

19

in

reverse order

 

$ svn

log

-r

8

#

shows

log for revision 8

 

 

 

You can also examine the log history of a single file or directory. For example:

$ svn log foo.c

$ svn log http://foo.com/svn/trunk/code/foo.c

These will display log messages only for those revisions in which the working file (or URL) changed.

If you want even more information about a file or directory, svn log also takes a --verbose (-v) switch. Because Subversion allows you to move and copy files and directories, it is important to be able to track path changes in the filesystem, so in verbose mode, svn log will include a list of changed paths in a revision in its output:

$ svn log -r 8 -v

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

r8 | sally | 2002-07-14 08:15:29 -0500 | 1 line Changed paths:

M /trunk/code/foo.c M /trunk/code/bar.h

A /trunk/code/doc/README Frozzled the sub-space winch.

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

Why Does svn log Give Me an Empty Response?

36

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