Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

SVN lifecycle

SVN lifecycle

This chapter discusses the lifecycle of a version control system.


Create the repository

The repository is a centralized space for storing all the work results of developers. The repository not only stores files, but also includes the history of each modification, that is, the change history of each file.

The Create operation is used to create a new repository. In most cases this operation is performed only once. When you create a new repository, your version control system will ask you to provide some information to identify the repository, such as the location of creation and the name of the repository.


Checkout

The Checkout operation is used to create a working copy from the repository. The working copy is the developer's private workspace where content can be modified and then committed to the repository.


update

As the name suggests, the update operation is used to update the repository. This operation synchronizes the working copy with the repository. Since the repository is shared by the whole team, your working copy becomes stale after others commit their changes.

Let us assume Tom and Jerry are two developers of a project. They both check out the latest version from the repository and start working at the same time. At this point, the working copies are fully synchronized with the repository. Then, Jerry efficiently completes his work and commits the changes to the repository.

At this point Tom's working copy becomes stale. The update operation will pull Jerry's latest changes from the repository and update Tom's working copy.


Perform changes

After checkout, you can perform many operations to make changes. Editing is the most common operation. You can edit existing files, for example, perform file add/delete operations.

You can add files/directories. But these added files and directories will not immediately become part of the repository; instead they are added to the pending change list, and only become part of the repository after the commit operation is executed.

Likewise you can delete files/directories. The delete operation immediately removes the file from the working copy, but the actual deletion of the file is only added to the pending change list, and is only truly deleted after the commit operation is executed.

The Rename operation can change the name of a file/directory. The "move" operation is used to move a file/directory from one place to another place in the repository.


Review changes

After you check out or update the working copy, your working copy is fully synchronized with the repository. But after you make some modifications to the working copy, your working copy will be newer than the repository. It is a good habit to review your modifications before the commit operation.

The Status operation lists the changes made in the working copy. As we mentioned before, any change you make to the working copy becomes part of the pending change list. The Status operation is used to view this pending change list.

The Status operation only provides a list of changes, but does not provide detailed information about the changes. You can use the diff operation to view the detailed information of these changes.


Fix errors

Let us assume you made many modifications to the working copy, but now you do not want these modifications. At this point, the revert operation will help you.

The Revert operation resets the modifications to the working copy. It can reset one or more files/directories. Of course, it can also reset the entire working copy. In this case, the revert operation will destroy the pending change list and restore the working copy to its original state.


Resolve conflicts

Conflicts may occur during merging. The Merge operation automatically handles things that can be safely merged. Others are treated as conflicts. For example, the "hello.c" file is modified on one branch and deleted on another branch. This situation requires manual handling. The Resolve operation is used to help users find conflicts and tell the repository how to handle them.


Commit changes

The Commit operation is used to transfer changes from the working copy to the repository. This operation modifies the contents of the repository, and other developers can view these modifications by updating their working copies.

Before committing, you must add files/directories to the pending change list. The list records the changes that will be committed. When committing, we usually provide a comment to explain why these changes were made. This comment also becomes part of the repository history. Commit is an atomic operation, meaning either it is fully committed successfully or it fails and rolls back. The user will not see a half-committed success.