2 using source control effectively nothing is ever “gone forever” hoa hoang

57

Upload: buck-carr

Post on 18-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang
Page 2: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

22

Using Source Control effectivelyNothing is ever “gone forever”

Hoa Hoang

Page 3: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

33

AgendaAgenda

Problems

Version Control System

Subversion - Tortoise SVN

7 habits of using SVN

Best Practices

Q & A

Page 4: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

44

ProblemsProblems

Users editing the same file concurrently overwriting each otherUsers editing the same file concurrently overwriting each other

Page 5: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

55

ProblemsProblems

Many copy of source code on file server and local machineMany copy of source code on file server and local machine

Page 6: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

66

ProblemsProblems

index.aspx

Accident of deletion, overwritingAccident of deletion, overwritingData lost forever

Unknown who, how, what, why, when, where files changed

Page 7: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

77

ProblemsProblems

Problem & more…Problem & more…

Page 8: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

88

AgendaAgenda

Problems

Version Control System

Subversion -Tortoise SVN

7 habits of using SVN

Best Practices

Q & A

Page 9: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

99

Version control systemVersion control system

VCS is crucial to engineering and software development projectsVCS is crucial to engineering and software development projectso Repositoryo Team-based collaboration o Record changeso Revision o Historyo Trunko Branches / Tag

Page 10: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

1010

Version control systemVersion control system

Version control server

Repository

Client

Client

Client

Working copy

Working copy

Working copy

Working copy

Client

RepositoryRepositoryCentralized stores of data. In SVN, data stored in the form of a filesystem tree

by a hierarchy of files and directories

Page 11: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

1111

Version control systemVersion control system

Working copyWorking copyo A ordinary directory tree of source

code for projects checkout to your local hard drive. Were you can freely make changes => Creating revision

Page 12: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

1212

Version control systemVersion control system

Team-based collaborationTeam-based collaboration

Page 13: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

1313

Version control systemVersion control system

Team-based collaborationTeam-based collaboration

Page 14: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

1414

Version control systemVersion control system

RevisionRevisionA version number associated with a chain of changes to the contents of a

single or multiple Files/Directories in the Repository

Page 15: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

1515

4

A

B’

C

D

E

F

3

A

B’

C

D

1

A

B

C

0 2

A

B’

C

Version control systemVersion control system

revision 473

Index.html

revision 415revision 430

revision 472

revision 477

RevisionRevision

Page 16: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

1616

Version control systemVersion control system

Record changesRecord changeswho, what, why, when, where files changed

Page 17: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

1717

Version control systemVersion control system

HistoryHistory

Page 18: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

1818

Version control systemVersion control system

ProjectProjectProject = directory

Grouping of files/directories contained within repository

Usually multiple Projects per Repository

Project usually created as a named directory with the following structure

projectbranchestagstrunk

Page 19: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

1919

Version control systemVersion control system

TrunkTrunk

trunk

342

347

421

425 434

branch maintenance

branch

tag

release

merge

426

Page 20: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

2020

Version control systemVersion control system

BranchsBranchsA second copy of your document directory (project), maintaining separately

and worked in parallel to the main codeline (Trunk)

Page 21: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

2121

Version control systemVersion control system

TagTagA labeled snapshot of the directory (project) in time, or a Branch, at a

particular Revision.

Page 22: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

2222

Page 23: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

2323

VCS Work-cycleVCS Work-cycle

Check outCheck outTo retrieve a directory from the Repository to view and/or edit the Resource. Allow to choose resource at a specific point

o Head: Most recent revisiono Revision#: most recent a

specific revision numbero Tag: A revision# marked as tag

(Release) o Date: Specific date

Check Out

Yes

Start

Modify

Update

Commit

Merge

Delete Revert

Conflict

NoBranch

Tag

End

Mark resolved

Rename

Clean up

Add

Page 24: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

2424

Check Out

Yes

Start

Modify

Update

Commit

Merge

Delete Revert

Conflict

NoBranch

Tag

End

Mark resolved

Rename

Clean up

ModifyModifyModify: Doing your work on working

copy

Lock file no nobody else can edit.

Unlock when done

VCS Work-cycleVCS Work-cycle

Add

Page 25: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

2525

Check Out

Yes

Start

Modify

Update

Commit

Merge

Delete Revert

Conflict

NoBranch

Tag

End

Mark resolved

Rename

Clean up

VCS Work-cycleVCS Work-cycle

RevertRevertWhen your changes become messy, want to get the good copy from repository overwrite back to working copy

Add

Page 26: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

2626

Check Out

Yes

Start

Modify

Update

Commit

Merge

Delete Revert

Conflict

NoBranch

Tag

End

Mark resolved

Rename

Clean up

VCS Work-cycleVCS Work-cycle

CleanupCleanup

RenameRename

DeleteDelete

AddAdd

Add

Page 27: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

2727

Check Out

Yes

Start

Modify

Update

Commit

Merge

Delete Revert

Conflict

NoBranch

Tag

End

Mark resolved

Rename

Clean up

VCS Work-cycleVCS Work-cycle

UpdateUpdateDownloading and merging all latest changes from repository into your working copy – (prevent conflict)

Add

Page 28: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

2828

Check Out

Yes

Start

Modify

Update

Commit

Merge

Delete Revert

Conflict

NoBranch

Tag

End

Mark resolved

Rename

Clean up

VCS Work-cycleVCS Work-cycle

ConflictConflictResolve conflict: Chose/modify if there some lines editing both by theirs and mine

Add

Page 29: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

2929

Check Out

Yes

Start

Modify

Update

Commit

Merge

Delete Revert

Conflict

NoBranch

Tag

End

Mark resolved

Rename

Clean up

VCS Work-cycleVCS Work-cycle

Merge/DifferentMerge/DifferentMerge: Often automatically done by subversion. If theirs code and mine code change on different line

Add

Page 30: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

3030

VCS Work-cycleVCS Work-cycle

CommitCommitCheck in/Commit: pushing edited files to repository (with a log message saying what you did)

Check Out

Yes

Start

Modify

Update

Commit

Merge

Delete Revert

Conflict

NoBranch

Tag

End

Mark resolved

Rename

Clean up

Add

Page 31: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

3131

VCS Work-cycleVCS Work-cycle

BranchesBranches

TagsTags

ImportImport

ExportExport

Check Out

Yes

Start

Modify

Update

Commit

Merge

Delete Revert

Conflict

NoBranch

Tag

End

Mark resolved

Rename

Clean up

Add

Page 32: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

3232

Revision control softwareRevision control software

SubversionSubversion

Visual SourceSafeVisual SourceSafe

StarTeamStarTeam

CVS CVS

AccuRev AccuRev

……http://en.wikipedia.org/wiki/List_of_revision_control_softwarehttp://en.wikipedia.org/wiki/List_of_revision_control_software

Page 33: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

3333

AgendaAgenda

Problems

Version Control System

Subversion Tortoise SVN

7 habits of using SVN

Best Practices

Q & A

Page 34: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

3434

SubversionSubversion

A version control system, it handles any types of files, A version control system, it handles any types of files, documents, or directories with these featuresdocuments, or directories with these featureso Atomic Commitso Windows-integrated (Tortoise SVN)o Directory base (not project-base)o Import directory (Project)o 2 versioning modelso Copy-Modify-Merge o Lock-Modify-Unlock o Renaming revisiono Branch/Tag/Merge/Different

Page 35: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

3535

SubversionSubversion

BenefitBenefito Better binary file supporto File/directory renamingo Metadata versioningo Better bandwidth usageo Multiple protocal (svn://, http://)o Efficient branching and taggingo Many client tool & add-in support Eclipse, AnkSVN, InterliJ Idea, Visual

Studio…Tortoise SVNo Ignoringo Revert/Cleanupo Comparing/Different

Page 36: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

3636

SubversionSubversion

Repository ViewRepository Viewo Connecting to repositoryo Browsingo Making revision linko Checking out

Synchronize ViewSynchronize Viewo Updatingo Committingo Revertingo Conflict resolution

History ViewHistory Viewo Reviewing changes

Page 37: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

3737

SubversionSubversion

Apache base serverApache base servero http://linuxtwo:8080/repository/ABCProject

SVN base serverSVN base servero svn://linuxtwo/repository/ABCProject

File system base serverFile system base servero file:///D:/repository/ABCProject

Page 38: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

3838

Tortoise SVNTortoise SVN

Status of version controlled files/foldersStatus of version controlled files/foldersGreen checkmark: normal status, under control

Red exclamation: file has been modified since last update and needs to be committed.

Yellow exclamation: a conflict occurs during an update.

Grey checkmark: this file needs to be locked first before editing.

Locked lock: file is locked. Need to unlock for other to commit.

Red deletion: missing file or file to be deleted under version control.

Blue plus: File to be added to version control.

Page 39: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

3939

DemoDemo

Page 40: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

4040

AgendaAgenda

Problems

Version Control System

Subversion - Tortoise SVN

7 habits of using SVN

Best Practices

Q & A

Page 41: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

4141

7 habits of using SVN7 habits of using SVN

11Update/Commit source code every good changesUpdate/Commit source code every good changes

Give comments for the commitGive comments for the commit

Page 42: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

4242

7 habits of using SVN7 habits of using SVN

22Update/Merge/Resolve conflict before CommitUpdate/Merge/Resolve conflict before Commit

Page 43: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

4343

7 habits of using SVN7 habits of using SVN

33 Do not shy, do not stupid, do not blame when conflict. Quickly find Do not shy, do not stupid, do not blame when conflict. Quickly find

‘theirs’ and resolve together‘theirs’ and resolve together

Page 44: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

4444

7 habits of using SVN7 habits of using SVN

44Use TortoiseSVN commands (delete, rename, copy) Do not use the Use TortoiseSVN commands (delete, rename, copy) Do not use the

Windows Explorer commands.Windows Explorer commands.

Donot changes or remove the added svn files/foldersDonot changes or remove the added svn files/folders

Page 45: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

4545

7 habits of using SVN7 habits of using SVN

55Delete your working copy and checkout new source every MondayDelete your working copy and checkout new source every Monday

Page 46: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

4646

7 habits of using SVN7 habits of using SVN

66Don’t versioning by yourself Don’t versioning by yourself

Page 47: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

4747

7 habits of using SVN7 habits of using SVN

77Use revert and cleanup when thing are messyUse revert and cleanup when thing are messy

Make ignore garbage files/directories before commitMake ignore garbage files/directories before commit

Page 48: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

4848

AgendaAgenda

Problems

Version Control System

Subversion - Tortoise SVN

7 habits of using SVN

Best Practices

Q & A

Page 49: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

4949

Best PracticesBest Practices

Commit Often!Commit Often!The less time you spend with code you haven't committed, the less likely

someone will edit a line you’ve not committed.

Commit in small chunks!Commit in small chunks!The less code you change and don’t commit, the less likely someone will edit

a line you’ve not committed.

Split your project into more than one file!Split your project into more than one file!You should be doing this anyways ?

Avoiding ConflictsAvoiding Conflicts

Page 50: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

5050

Best PracticesBest Practices

Don’t commit broken codeDon’t commit broken codeIf someone else updates, they will have broken code too and will be unable to work

unless they fix your mess

Don’t commit temporary/binary filesDon’t commit temporary/binary filesWe don’t need files like vore.vcproj.SNOWFIRE.philipd.user or any .exe or .obj files.

They waste space!You MAY commit graphics as long as they aren’t too big.Binary files don’t get merged.

Don’t commit ginourmous filesDon’t commit ginourmous filesRemember, if you put it in the repository you force people to download it!A good alternative for optional files that are big is to put them on a web server –

particularly if they don’t change

What not to do…What not to do…

Page 51: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

5151

Best PracticesBest Practices

When you commit, describe in the log as succinctly and clearly When you commit, describe in the log as succinctly and clearly what you changed as possiblewhat you changed as possibleThis information will help others know what you did to the code

Add your new filesAdd your new filesIf you make a new file, make sure to right click and add it to source control. If

you don’t, others won’t be able to get it.

EXAMPLE: In a game, you add a bitmap file. If you forget to add it to the subversion, when others synchronize, they download your code but not the bitmap. Now when they run the game, it crashes because it can’t find your file.

What to do..What to do..

Page 52: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

5252

AgendaAgenda

Problems

Version Control System

Subversion - Tortoise SVN

7 habits of using SVN

Best Practices

Q & A

Page 53: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

5353

Q & AQ & A

How to obtain a “clean” working copy (original sources only) and How to obtain a “clean” working copy (original sources only) and exclude .svn folders. exclude .svn folders. Select working copy>right-click>TortoiseSVN>ExportProvide the destination folder for the “clean” working copy

How to leave (ignore) the files/folders not in source controlHow to leave (ignore) the files/folders not in source controlSelect files/folders in working copy not in source controlRight-click>TortoiseSVN>Add to ignore list

How to add “free” files/folders (in working copy) into source How to add “free” files/folders (in working copy) into source controlcontrolSelect fils/folders>right-click>TortoiseSVN>AddCommit the working copy

Page 54: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

5454

Q & AQ & A

How to break/steal lockHow to break/steal lockThis is to break the locking on file by override the locking author.

Check for modifications>select locked files>break lock, OR

Right click>TortoiseSVN>Get lock, check the Steal option, OK.

Recommend: should not use this function unless you have agreement of the PM.

Cannot login because of wrong SSL cache: clear cacheCannot login because of wrong SSL cache: clear cacheFirst login to a wrong/forbidden link failed => wrong SSL is cached

Later login (to correct link) also failed because the TortoiseSVN use the wrong cached SSL.

Solution: right click>TortoiseSVN>Settings>Saved data>Authentication Data>Clear

Page 55: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

5555

Q & AQ & A

How to check out an SVN directory (recursively) to local existing How to check out an SVN directory (recursively) to local existing folder? (Similar to get latest version in VSS & overwrite all local)folder? (Similar to get latest version in VSS & overwrite all local)Should checkout to an empty working copy.Existing working copy may cause file conflict or leave files not under source

control.

How to get specific version of code from SVN? How to get specific version of code from SVN? Select file/folder in the working copyTortoiseSVN>Update to revision…Select the option Revision, input desired revisionYou can Show log to know the log message.

Page 56: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

5656

More question?More question?

Page 57: 2 Using Source Control effectively Nothing is ever “gone forever” Hoa Hoang

5757

Thank you !!!