• 沒有找到結果。

a Version Control System

N/A
N/A
Protected

Academic year: 2022

Share "a Version Control System"

Copied!
63
0
0

加載中.... (立即查看全文)

全文

(1)

Introduction to Subversion:

a Version Control System

2012/05/19 Che-Hsien Chou

(2)

About Homework #4



Goal: Learn how to use a version control system to maintain software projects.



Detail:

 You should study the concept of version control system, and its server-client model.

 A hands-on test will be used to test your

knowledge of using Subversion to manipulate different versions of a Visual Studio project workspace.

(3)

What is Subversion?

 A free open-source version control system.

 Manage files and directories, and the changes made to them, over time.

 Home Page: http://subversion.tigris.org

 The original subversion project does not provide GUI.

(4)

TortoiseSVN(1/2)

 A Windows GUI version of Subversion.

 We will use TortoiseSVN in the fllowing.

 Download and install TortoiseSVN at http://tortoisesvn.tigris.org

 If successfully installed, right-click anywhere in the explorer will show the svn options.

(5)

TortoiseSVN(2/2)

(6)

Subversion System Architecture

Subversion server

repository

Client A

Client B

Client C

Project Local Working Copy

Local Working Copy

Local Working Copy

sort.c

search.c

retrieve.c

updated

(7)

Subversion’s Features

 Directory versioning

 Track changes to the whole directory trees over time.

 True version history

 Add, delete, copy, and rename both files and directories.

 Atomic commits

 A collection of modifications either goes into the repository completely, or not at all.

 Versioned metadata

 Each file and directory has a set of properties—keys and values associated with it.

 Consistent data handling

 Identically for both text and binary files.

(8)

The Problem of File-Sharing

 The Lock-Modify-Unlock Solution

 Only one person changes a file at a time.

 Administrative problems.

 Unnecessary serialization.

 A false sense of security.

 The Copy-Modify-Merge Solution (Subversion)

 Each user’s client contacts the project repository and creates a personal working copy.

 Users then work simultaneously and independently, modifying their private copies.

 Finally, the private copies are merged into a new, final version.

(9)

Fundamental Concepts of Subversion



The Repository



Working Copies



Revisions

(10)

The Repository

 A central store of data.

 Store information in the form of a filesystem

tree—a typical hierarchy of files and directories.

 Remember every change ever written to it.

 Track changes to data over time.

/

Calc

Paint

Makefile

Button.c Integer.c

Makefile

Brush.c Canvas.c

(11)

Repository: Basics



Subversion uses URLs to identify versioned files and directories in Subversion repositories.



“One repository, one project” or “one repository, multiple projects”



Please refer to Chapter 6 of the book “Version Control with Subversion” for understanding of advanced Subversion server options

.



To practice, we use local directory to create a repository in the following.

† http://svnbook.red-bean.com/index.en.html

(12)

Repository: Create

 To create a new repository, we first create a new directory. eg. C:\repos

 Right-click the new directory C:\repos and press

“Create repository here.”

 Now C:\repos is a new empty repository.

(13)
(14)

Repository: Repository Browser

 We can use the repository browser provided by

TortoiseSVN to browse all projects in a repository.

 To connect to a repository

 Google svnserve server

 http://nctu-20012-spring-ics.googlecode.com/svn/trunk/ nctu- 20012-spring-ics-read-only

 Local repositroy

 file:///C:/repos

(15)
(16)
(17)

Repository: Create Folder

 As an example, we first create three folder in the repository.

 Right-clicking the repository directory in the repository browser show all functions we need to create, add, delete, and import files.

 We now create trunk, branch, and tag folders.

 Note that “add folder” and “add file” adds existing files and folders into the repository. In other hand, “create folder”

creates empty folder in the repository.

(18)
(19)
(20)

Repository: Import and Add

 Let’s assume we have an existing project “CS demo” including some source codes, now we try to add this project into the

repository and put it in the trunk folder. This can be done using either “import” or “add”.

 Import : copy an unversioned tree of files into a repository

 Right-click the “CS demo” folder in your explorer and press import

 Select the trunk folder by pressing the button “…”

 Press “OK”, the importing results will be shown when all operations are done.

 Add file and add folder: add files, directories, or symbolic links

 Open the repository browser.

 Right-click the trunk folder and press “Add file” or “Add folder”

 Select file or folder we want to import.

(21)

Import (1/4)

(22)

Import (2/4)

(23)

Import (3/4)

(24)

Import (4/4)

(25)

Add File (1/2)

(26)

Add File (2/2)

(27)

Working Copies

 Come out of the repository.

 An ordinary directory tree on your local system.

 Your own working copy is your own private work area.

 Subversion will never incorporate other people’s changes, nor make your own changes available to others, until you explicitly tell it to do so.

 The working administrative directory (.svn) includes information which helps Subversion recognize

which files contain unpublished changes, and which files are out-of-date with respect to other’s work.

(28)

Revisions

 An svn commit operation publishes changes to any number of files and directories as a single atomic transaction.

 Each time the repository accepts a commit, this creates a new state of the filesystem tree, called a revision.

 Each revision is assigned a unique natural number.

 Subversion’s revision numbers apply to entire trees, not individual files.

(29)

Checkout a Working Copy

 Create a private working copy from remote repository.

 The repository browser also provide the checkout function.

 You can save the local working copy in any directory on your own computer.

 When checking out, you can choose any revision.

 HEAD revision: the latest revision in the repository.

 The “Show log” button shows the revision history and help us to find the revision we want.

(30)

Checkout (1/4)

(31)

Checkout (2/4)

(32)

Checkout (3/4):Show Log

(33)

Checkout (4/4):Complete

(34)

Make Changes



Now we can modify the source code in out own local working copy.

 A modified file has a “!” on it.



Change to your working copy directory

 If we add any new file in the working copy, there will be a “?” on it.

 To add the new file when committing, right-click this file and mark the file as added (a “+” sign

will be shown) by selecting “add”.

(35)
(36)
(37)

Update Your Working Copy

 You can update to the latest version anytime by

right-clicking the project folder and pressing “SVN update”.

 Note that you can also update your working copy to any revision.

 You can also update to an older version by “update to revision.”

 To prevent any error, we should update our local working copy before committing.

(38)

Update

(39)

Conflict

(40)

Why Conflict?

repos

CS demo CS demo1

1.Checkout to CS demo

repos

CS demo CS demo1

2.Checkout to CS demo1

Abc…

Abc…

Abc…

Abc… Abc…

repos

CS demo CS demo1

3.Make changes and Commit

Ade…

Abc… Ade…

repos

CS demo CS demo1

4.Make other changes and Update

Ade…

Acc… Ade…

Conflict

(41)

Merge Others’ Changes

 After “svn update”, you cannot commit if you get a conflict

 A conflict means that others already commit some changes on files which you just modified.

 Deal with a conflict

 Merge the conflicted text “by hand”.

 Copy one of the temporary files on top of your working file.

 Run svn revert filename to throw away all of your local changes.

(42)

TortoiseMerge

 TortoiseMerge is a tool helping us to resolve the conflict

 Right-click the conflict file and select “Edit Conflicts”

 Check the difference between yours and the new version.

 The upper toolbar provides some solutions to resolve the conflict. We can also modify the file by typing in the

“merged” window.

 Note that “diff” and “diff with previous version” functions are also useful to track the difference between versions

(43)

Edit Conflicts

(44)

Tortoise Merge

(45)

Merging conflicts by hand

 Open the source file via any editor

(46)

Commit your changes



After resolving all conflicts, now

we can commit the modified files.

(47)

Commit (1/2)

(48)

Commit (2/2)

(49)

Branching, tagging, and merging

/

trunk

tags

nweb.c client.c

Realease-1.0 Release-1.2

branches

John Mary

(50)

Branching, tagging, and merging

 Trunk: the main line of development is going to take place.

 Branch: a line of development that exists

independently of another line, yet still shares a

common history if you look far enough back in time.

(51)

Branching and Tagging



To create a branch or a tag, select “Branch/tag”

option.



You can specify a

revision to create the

new branch/tag.

(52)

Create a New Branch

(53)
(54)

Switching

 After successfully creating a new branch/tag, any local changes will still commit to the original

position (trunk).

 To work on a specific branch, we should first switch to the branch.

 Now the further changes will be committed to the branch.

(55)

Switch (1/2)

(56)

Switch (2/2)

(57)

Revision Graph (1/2)



The revision graph shows the revision tree, which presents the version history.



The number represents revision, all

branches/tags will be shown and we can

easily see which revision a branch/tag is

created from.

(58)

Revision Graph (2/2)

(59)

Update To An Old Version

 If we want to revert to an older version in the repository, select “update to revision…”

 If you are not sure which revision to use, “show log” may help. You can find what changes have done and some

comments there.

 Note that another function called “Revert” let us revert to pre-modified version in our local records.

(60)

Update To Revision

(61)

Log Manager

(62)

Update to a specific revision

(63)

Recommended Reading



http://www.cs.ubc.ca/~vailen/svn_howto.htm



http://www.shokhirev.com/nikolai/programs/

SVN/svn.html

參考文獻

相關文件