a short introduction to subversion and make

38
Version Control with Subversion make Utility A Short Introduction to Subversion and make Miaoqing Huang University of Arkansas Spring 2010 1 / 36

Upload: others

Post on 19-Jan-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

A Short Introduction to Subversion and make

Miaoqing HuangUniversity of Arkansas

Spring 2010

1 / 36

Page 2: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Outline

1 Version Control with SubversionBasic PrincipleBasic Usage

2 make Utility

2 / 36

Page 3: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

Outline

1 Version Control with SubversionBasic PrincipleBasic Usage

2 make Utility

3 / 36

Page 4: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

Share the Information through Repository

All the members in the same team share theinformation through the central repository

The Subversion repository remembers everychange written to it

You are not going to lose any data andinformation once you let Subversion manageyour project

Every successful modification to the repositoryincrease the version by one

The repository will keep the current versionand all previous versions

The copy at the client side is called localworking copy

Check in your modifications to the repositoryCheck out the version in the repository to getthe changes from other clients

4 / 36

Page 5: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

The Big Picture

5 / 36

Page 6: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

Two Categories of Operations (by client)

Check InSubmit the changes in local copy into the repository

Two commandssvn import: import your initial copy into the repository ifthere is no copy theresvn commit: commit the changed in local working copyinto the repository

Check OutGet the changes from the repository to the local workingcopy

Two commandssvn checkout: check out a copy in the repository asyour local working copysvn update: update your local working copy to thecurrent version in the repository

6 / 36

Page 7: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

Two Categories of Operations (by client)

Check InSubmit the changes in local copy into the repository

Two commandssvn import: import your initial copy into the repository ifthere is no copy theresvn commit: commit the changed in local working copyinto the repository

Check OutGet the changes from the repository to the local workingcopy

Two commandssvn checkout: check out a copy in the repository asyour local working copysvn update: update your local working copy to thecurrent version in the repository

7 / 36

Page 8: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

Two Categories of Operations (by client)

Check InSubmit the changes in local copy into the repository

Two commandssvn import: import your initial copy into the repository ifthere is no copy theresvn commit: commit the changed in local working copyinto the repository

Check OutGet the changes from the repository to the local workingcopy

Two commandssvn checkout: check out a copy in the repository asyour local working copysvn update: update your local working copy to thecurrent version in the repository

8 / 36

Page 9: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

Two Categories of Operations (by client)

Check InSubmit the changes in local copy into the repository

Two commandssvn import: import your initial copy into the repository ifthere is no copy theresvn commit: commit the changed in local working copyinto the repository

Check OutGet the changes from the repository to the local workingcopy

Two commandssvn checkout: check out a copy in the repository asyour local working copysvn update: update your local working copy to thecurrent version in the repository

9 / 36

Page 10: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

The Copy-Modify-Merge Method

10 / 36

Page 11: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

The Copy-Modify-Merge Method

11 / 36

Page 12: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

The Copy-Modify-Merge Method

12 / 36

Page 13: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

The Copy-Modify-Merge Method

13 / 36

Page 14: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

The Copy-Modify-Merge Method

14 / 36

Page 15: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

The Copy-Modify-Merge Method

15 / 36

Page 16: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

The Copy-Modify-Merge Method

16 / 36

Page 17: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

The Copy-Modify-Merge Method

17 / 36

Page 18: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

Basic Commands

Initial import and checkoutsvn import, svn checkout

Basic work cycle (once you have a local working copy)1 Update your working copy

svn update2 Make changes

Change existing files, svn add, svn delete, svn copy, svn move3 Examine your changes

svn status, svn diff4 Possibly undo some changes

svn revert5 Resolve conflicts (merge others’ changes)

svn update, svn resolve6 Commit your changes

svn commit

18 / 36

Page 19: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

svn import

svn import mytree svn+ssh://[email protected]/var/svn/CSCE3513/SP10/teamxx/someproject

Copy an unversioned tree of files into a repositoryExample: copy everything under mytree into the repository undersomeproject, recreating intermediate directories if necessary

Generally used when you want to start tracking a new projectthat is parallel to your other working projects

You don’t have to do this step in this class, just use svn checkoutto check out the empty working copy of your team

19 / 36

Page 20: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

svn checkout

svn checkout svn+ssh://[email protected]/var/svn/CSCE3513/SP10/teamxx

Check out a repository and create a working copy on your localmachine or local directory

Example: check out your team project to your local directory,which only consists of a directory, i.e., teamxx

You can check out previous version of the repositorysvn checkout -r xx ...If the version information is not given, the latest version is checkedout

Once you check out the repository, you don’t have to rememberthe long target address of the repository any more

The svn client program is going to remember that for you

20 / 36

Page 21: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

svn update

svn update

Bring your working copy into synchronization with the latestrevision in the repositoryGenerally the first step you do before you resume your work

21 / 36

Page 22: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

Change existing files

Edit the existing files in your working copy using your favorite texteditorDon’t forget commit your changes after you finish. Otherwise,nobody is going to see the changes you made to the files

22 / 36

Page 23: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

svn add

svn add foo

Schedule file, directory or symbolic link foo to be added to therepository

foo will be added into the repository in you next commitIf foo is a directory, everything underneath foo will be scheduledfor additionfoo has to exist in your working copy before you schedule theaddition

23 / 36

Page 24: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

svn delete

svn delete foo

Schedule file, directory or symbolic link foo to be deleted fromthe repository

foo will be deleted from the repository in you next commitIf foo is a file or link, it is immediately deleted from your workingcopyIf foo is a directory, it is scheduled for deletion

Another wayYou manually use rm to delete the file or directory, then use svndelete to schedule the deletion in the repository

24 / 36

Page 25: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

svn copy

svn copy foo bar

Create a new item bar as a duplicate of foo and automaticallyschedule bar for addition

25 / 36

Page 26: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

svn move

svn move foo bar

Same as svn copy foo bar; svn delete fooSchedule bar for addition as a copy of foo, and foo is scheduledfor removal

26 / 36

Page 27: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

svn status

svn status

? scratch.c # file is not under version controlA bloo.h # file is scheduled for additionC lump.c # file has conflicts from an updateD fish.c # file is scheduled for deletionM bar.c # file has local modifications

Get an overview of your changes, in the middle of your work orbefore you commit

C item: the file item is in a state of conflict, which can not beresolved during the update. You must resolve it manually beforecommitting your changes

The changes from the server and your local changes modify thesame statement, e.g., flag_c = xxx;

27 / 36

Page 28: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

svn diff

mqhuang@turing:~/svn/mqhuang$ svn diffIndex: test2.c==============================================--- test2.c (revision 13)+++ test2.c (working copy)@@ -1 +1,2 @@-test1.c+test1.c is modified to+test2.c

Examine the details of your local modificationsExamine the details of different versions

28 / 36

Page 29: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

svn revert

mqhuang@turing:~/svn/mqhuang$ svn revert test2.cReverted ’test2.c’mqhuang@turing:~/svn/mqhuang$ cat test2.ctest1.c

Revert a file to its pre-modified state by overwriting it with thecached copy from the .svn areaIt can undo any scheduled operations

29 / 36

Page 30: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

svn commit

svn commit -m "a short message"

svn commit -F logmsg #logmsg is a file keeping long message

Commit all your modifications and scheduled operationsYou have to provide a log message

30 / 36

Page 31: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

svn log

mqhuang@turing:~/svn/mqhuang$ svn [email protected]’s password:------------------------------------------------------------------------r13 | mqhuang | 2010-02-03 12:23:43 -0600 (Wed, 03 Feb 2010) | 1 line

add test2.c test3.c------------------------------------------------------------------------r12 | mqhuang | 2010-02-03 12:21:58 -0600 (Wed, 03 Feb 2010) | 1 line

add test1.c------------------------------------------------------------------------r11 | mqhuang | 2010-02-03 12:21:23 -0600 (Wed, 03 Feb 2010) | 1 line

delete test3.c

Exam the repository history

31 / 36

Page 32: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

What svn commit and svn update do?

svn commit svn updateunchanged,current

nothing nothing

locally changed,current

publish your changes nothing

unchanged,out of date

nothing download the changes to yourworking copy

locally changed,out of date

fail try to merge the changes in therepository and your changes; if im-possible, leave the user to solve

CurrentThe version of working copy = the version in the repository

Out of dateThe version of working copy < the version in the repository

32 / 36

Page 33: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Basic PrincipleBasic Usage

Demo

A short live demonstration......If you have problem to access your team svn account, pleasedirect your email to [email protected], including your name,your UARK ID

33 / 36

Page 34: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

Outline

1 Version Control with SubversionBasic PrincipleBasic Usage

2 make Utility

34 / 36

Page 35: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

make

make is a utility for automatically building executable programsand libraries from source code

The compilation process is defined in Makefile(s)

All projects developed under Unix or Linux come with MakefilesWhen you type ’make’ in command line, the make utility looks forthe file called “Makefile”

35 / 36

Page 36: A Short Introduction to Subversion and make

Version Control with Subversionmake Utility

A Simple Example

# I am a comment, and I want to say that the variable CC will be# the compiler to use.CC=g++# Hey!, I am comment number 2. I want to say that CFLAGS will be the# options I’ll pass to the compiler.CFLAGS=-c -Wall

all: hello

hello: main.o factorial.o hello.o$(CC) main.o factorial.o hello.o -o hello

main.o: main.cpp$(CC) $(CFLAGS) main.cpp

factorial.o: factorial.cpp$(CC) $(CFLAGS) factorial.cpp

hello.o: hello.cpp$(CC) $(CFLAGS) hello.cpp

clean:rm -rf *.o hello

36 / 36

Page 37: A Short Introduction to Subversion and make

Summary

Outline

3 Summary

37 / 36

Page 38: A Short Introduction to Subversion and make

Summary

Summary

SubversionSubversion (SVN) is a version-control systemDevelopers use Subversion to maintain current and historicalversions of files such as source code, web pages, anddocumentationYou are supposed to let Subversion to manage your project fromDay 1

Windows is supported too, e.g., TortoiseSVN

makemake is a utility for automatically building executable programs andlibraries from source code

38 / 36