Principles of Software Construction: Objects, Design, and Concurrency
Principles of Software Construction: Objects, Design, and Concurrency
Objects,Design,andConcurrency
VersionControl
JonathanAldrich CharlieGarrod
15214 1
Administrivia
ExtraofficehoursforHW6andexam
Seeonlineschedule
Samplefinalexam comingsoon
ReviewsessionWednesday12/16
24pminDH1112
Final examThursday12/17
8:3011:30inMM103&MMA14
15214 2
LearningGoals
Understandthebenefitsandlimitationsof
versioncontrol(history,paralleldevelopment,
branching,etc)
Abilitytocooperateonacodebaseusing
branchingandmerging;toresolvemerge
conflicts
Distinguishclassesofversioncontrolsystems
(local,central,distributed)
15214 3
HISTORY
15214 4
History
Recordrelevantstepsinthehistoryoftheproject
Supportspartialundo
Labelcohesivedevelopmentsteps
Allowsunderstandingchanges
Explainsrationale
Traceabilitytootherdevelopmentartifacts(bugtrackers,CVEs,
requirements,etc)
Recordwhoperformedchanges
Impliesabackup
Earlylocalsystems:SCCSandRCS
>Versioncontrolsystemsusefulevenwhenusedentirely
locally
15214 5
Eclipse'sLocalHistory
15214 6
RevisionHistory
15214 7
15214 8
RecordingRationaleandTraceability
9
15214 9
Versioningentireprojects
15214 10
VersioningandTags
Versionnumbersforfilesindividuallyvs.per
project
Versionnumbersvs.hashes
Tagstonamespecificstates
15214 11
Whilefilestomanage
Allcodeandnoncodefiles
Javacode
Buildscripts
Documentation
Excludegeneratedfiles(.class,)
Mostversioncontrolsystemshavea
mechanismtoexcludefiles(e.g.,.gitignore)
15214 12
COLLABORATION
15214 13
CollaboratingonFiles
Howtoexchangefiles
Sendchangesbyemail
Manualsynchronizationatprojectmeeting
Allfilesonsharednetworkdirectory
Permissionmodels
Eachfilehasanowner;onlypersonallowedtochange
it
Everybodymaychangeallfiles(collectiveownership)
15214 14
ConcurrentModifications
Allowingconcurrentmodificationsis
challenging
Conflicts(accidentaloverwriting)mayoccur
Commonstrategies
Lockingtochange
Detectingconflicts(optimisticmodel)
15214 15
ChangeConflicts
15214 17
LockingProblems
Howtolock?
Centralsystemvsannouncementonmailinglist
Forgettingtounlockcommon
Unnecesarysequentializing
Cannotworkondifferentconceptsinsamefile
Falsesenseofsecurity
Changingdependantfilescancauseconflictsnot
preventedbylocking
15214 18
Merging(1/2)
15214 19
Merging(2/2)
15214 20
Example
15214 21
Example
15214 22
Example
Einfhrung in die
15214
Systemcannotdecideorder
Softwaretechnik 23
23
3waymerge
Filechangedintwoways
Overlappingchanges>conflicts
Mergecombinesnonconflictingchangesfromboth
Mergingnotalwaysautomatic
difftooltoshowchanges
Manualresolutionofconflictsduringmerge(potentially
requiresadditionalcommunication)
Automaticmergepotentiallydangerous
>syntacticnotionofconflicts
Mergingofbinaryfilesdifficult
Inpractice:mostmergesareconflictfree
15214 24
BRANCHING
15214 25
Branching
Parallelcopiesofthesourcetree
Canbechangedindependently,versioned
separately,andmergedlater(orleftseparate)
Oftenusedforexploratorychangesortoisolate
developmentactivities
Manyusagepatterns,common:
MainbranchformaintenanceORmaindevelopment
Newbranchesforexperimentalfeatures;mergewhen
successful
Newbranchesfornontrivialmaintenancework
Branchesformaintenanceofoldversions
15214 26
Releasemanagementwithbranches
15214 27
VariantsandRevisions
Revision replacespriorrevision(temporal)
Variant coexistswithothervariants
Version describesboth
Release:Publishedandnamedversion
V1.0 V1.1 V2.0 V3.0
[Staples&Hill, APSEC04]
15214 30
Managingvariants
Branchingforvariantsdoesnotscalewell
Requiresspecialplanningortooling
Manysolutions
Configurationfiles
Preprocessors
Buildsystems
DSLs
Softwareproduct
lines
15214 31
CENTRALIZED VERSIONCONTROL
(E.G.,SVN)
15214 32
Classesofversioncontrolsystems
Systemssupportingmergingand/orlocking
Localversioncontrol
Localhistoryoffiles:SCCS(1970s),RCS(1982)
Centralversioncontrol
Versionsstoredoncentralmasterserver
Clientssynchronizewithserver(update,commit)
CVS(1990),SVN(2004),Perforce,VisualSourceSafe
Distributedversioncontrol
Manyrepositories;synchronizationamong
repositories(push,pull)
Git(2005),Mercurial,Bitkeeper,ClearCase
15214 33
CentralizedVersionControl
Client
(version5,
branchM) checkout/ Server
update/ (allversions)
commit
Client access control
(version5,
branchM)
Client
(revision4,
branchB)
15214 34
Typicalworkcycle
Once:Createlocalworkspace
svncheckout
Updateworkspace: Revertchangesinworkspace:
svnupdate svnrevert
Performchangesinworkspace: Updateandmergeconflicts:
svnadd svnupdate
svndelete svnresolved
svncopy Pushworkspacechangesto
svnmove server:
Showworkspacechanges: svncommit
svnstatus
svndiff
Taentzer
15214 35
CVSvs.SVN
CVS SVN
ImprovementoverRCSin Revisionnumbersfor
trackingentiredirectories project
Revisionnumberperfile Atomiccommits(commiting
Textfiles(binaryfiles multiplefilesatonce)
possible) Trackingfilesanddirectories
Supportrenaming
TrackingofMetadata
15214 36
DISTRIBUTEDVERSIONCONTROL
(E.G.,GIT)
15214 37
Git
Distributedversioncontrol
Nocentralservernecessary(butpossible)
Localcopiesofrepositories(containingallhistory)
LocallySVNlikefunctionality:checkout,update,commit,
branch,diff
Nonlineardevelopment:eachlocalcopycanevolve
independently
Synchronizationamongrepositories(push/fetch/pull)
Fastlocaloperations(branch,commit,diff,...)
15214 38
Overview
GH M3
M2 M1
commit
15214 39
DistributedVersions
Versionsnotgloballycoordinated/sorted
UniqueIDsthroughhashes,relationshipstrackedinsuccessorgraph
e.g.,52a0ff44aba8599f43a5d821c421af316cb7305
Possibletomergeselectchanges(cherrypicking)
Possibletorewritethehistoryaslongasnotsharedremotely(git
rebaseetc)
Cloningcreatescopyofrepository(includingallversions)
Trackslateststatewhencloned,relevantforupdatingandmerging
Normalcheckoutandcommitoperationslocally
Commitsdon'tchangeoriginalrepository
Fetchandpullgetmissingversionsfromremoterepository(oneor
more)
Pushoperationssendslocalchangestoremoterepository(oneor
more),givenaccessrights
15214 40
Exampleworkflow
Kernel developer
checkout / update
clone / pull
Linux
commit edit
push
Linux pull & merge
clone
checkout
Linux
commit edit
New developer
15214 41
PullRequests
Kernel developer
checkout / update
clone / pull
Linux
commit edit
push
Linux pull & merge
clone
checkout
Linux
commit edit
New developer
Pullrequest:Githubfeaturetoaskdevelopertopullaspecific
change(alternativetosendingemail);integrationwithTravisCI
15214 42
42
Forks
Kernel developer
checkout / update
clone / pull
Linux push
Linux
(GH) (local)
commit edit
fork pull & merge
Linux push
Caution:
Linux
(local)
(GH) Pleasetonotfork214repositories.
commit edit
fork pull & merge
214CollaborationPolicy:"Herearesomeexamplesofbehaviorthatare
Linux pull & merge
inappropriate:Makingyourworkpubliclyavailableinawaythatother
students(currentorfuture)canaccessyoursolutions,evenifothers
fork clone checkout
accessisaccidentalorincidentaltoyourgoals."
(GH) push Linux
(local)
commit edit
New developer
Fork:GithubfeaturetoclonerepositoryonGithub(owncopy
15214
withfullrights) 44
44
Repositoriesinmustache.js
15214 45
GitHistory
15214 46
GitandCentralRepositories
47
15214 47
SocialCoding
Awareness/
NewsFeeds
15214 48
GitInternals
15214 49
GitInternals
15214 50
GitInternals
15214 51
GitInternals
15214 52
Summary
Versioncontrolhasmanyadvantages
History,traceability,versioning
Collaborativeandparalleldevelopment
Lockingvs.mergingandmergeconflicts
Collaborationwithbranches
Fromlocaltocentraltodistributedversion
control
15214 53