cse 2231 - version controlweb.cse.ohio-state.edu/.../slides/04a.version-control.pdfversion control...

20
Version Control Using Subversion 1 September 2020 OSU CSE 2

Upload: others

Post on 05-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Version Control Using Subversion

1 September 2020 OSU CSE 2

Page 2: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Version Control

• In team projects, software engineers:– Share and extend a common code base (and

comply with standards, coding conventions, comment templates, …)

– Work concurrently with each other• Best practice is for a team to use a

version control system– We will use one called Subversion, but

others are essentially similar

1 September 2020 OSU CSE 3

Page 3: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Version Control

• In team projects, software engineers:– Share and extend a common code base (and

comply with standards, coding conventions, comment templates, …)

– Work concurrently with each other• Best practice is for a team to use a

version control system– We will use one called Subversion, but

others are essentially similar

1 September 2020 OSU CSE 4

This is not limited to code! A version control system can handle

non-code files as well, which makes it handy for other sorts of

team projects, too.

Page 4: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Key Idea: The Repository

• A central repository keeps all files (in our case, Java code) and a history of all modifications to them– A new team member can check out their own

private copy from the repository– Each member can update their own copy to

reflect the latest changes in the repository– Each member can commit changes from

their own private copy to the repository

1 September 2020 OSU CSE 5

Page 5: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Workflow Model: An Example

1 September 2020 OSU CSE 6

Ayesha

Matt

repository

commit

commit

update

update

Page 6: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

How Work Gets Done

• Repository holds master copy of all files– Never edited directly– Stores complete history, too!

• Each team member has a local copy (or working copy) in their own workspace– All file creation, editing, deletion occurs here

• Update and commit commands are used to synchronize local and master copies

1 September 2020 OSU CSE 7

Page 7: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

The “Optimistic” Model

• Any team member can modify their local copy of any file at any time– No “locking” or other synchronization among

team members takes place on local copies• On an update, the latest version from the

repository often can be mergedautomatically into the local copy– This is especially so when team members edit

different files, so conflicts are rare

1 September 2020 OSU CSE 8

Page 8: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 9

updatecommit

Matt

Ayesha

repository

Page 9: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 10

updatecommit

Matt

Ayesha

repository

Matt does an update to get the latest version to work on.

Page 10: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 11

updatecommit

Matt

Ayesha

repository

Ayesha does an update to get the latest version to work on.

Page 11: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 12

updatecommit

Matt

Ayesha

repository

Matt does a commit to put his latest edits into the repository.

Page 12: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 13

updatecommit

Matt

Ayesha

repository

Ayesha does an update to get the latest version before she commits.

Page 13: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 14

updatecommit

Matt

Ayesha

repository

The latest revision in the repository is merged into Ayesha’s copy.

Merge

Page 14: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 15

updatecommit

Matt

Ayesha

repository

Suppose this merge is successful; then Ayesha commits.

Merge

Page 15: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 16

updatecommit

Matt

Ayesha

repository

Matt tries to commit more changes, but has not updated recently.

Merge

Page 16: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 17

updatecommit

Matt

Ayesha

repository

Ayesha has committed recently, and Matt may not do so now.

Merge

Error: workingversionout-of-date

Page 17: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 18

updatecommit

Matt

Ayesha

repository

Matt needs to update first.

Merge

Error: workingversionout-of-date

Page 18: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 19

updatecommit

Matt

Ayesha

repository

Suppose this merge has conflicts; then Matt must resolve them.

Merge

Error: workingversionout-of-date

Conflict:requiresattention

Page 19: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 20

updatecommit

Matt

Ayesha

repository

After Matt resolves conflicts, he can continue and commit his changes.

Merge

Error: workingversionout-of-date

Conflict:requiresattention

Page 20: CSE 2231 - Version Controlweb.cse.ohio-state.edu/.../slides/04a.Version-Control.pdfVersion Control • In team projects, software engineers: – Share and extend a common code base

Some Things That Can Happen

1 September 2020 OSU CSE 21

updatecommit

Matt

Ayesha

repository

Merge

Error: workingversionout-of-date

Conflict:requiresattention

Meanwhile, Ayesha updates and continues with the latest version.