Using Subversion
Distilled for Visual Studio Developers
Contents
• Working Copy
• States: Commit and Update
• Mixed Revisions
• Reviewing Changes
• Creating Conflict
• Resolving Conflict
• Reverting
• Tagging
• Branching
Working Copy
• Local copy of the Repository
• Administrative directory (.svn)
– Contains a “Base” copy of items: the revision at the time of
last update
– Working revision # for each file
– Timestamp of last update
– Don’t touch the contents
• Use “SVN copy” and “SVN move”
– TortoiseSVN: right-drag-and-drop context menu
• If wonky, delete entire directory and update
States: Commit and Update
• Unchanged, and current
– Commit: nothing
– Update: nothing
• Locally changed, and current
– Commit: publish
– Update: nothing
• Unchanged, and out of date
– Commit: nothing
– Update: replace with latest
• Locally changed, and out of date
– Commit: fail with “out of date” error
– Update: merge with latest; potential conflict
Mixed Revisions
• Mixed revisions in a working copy are normal
• Commit
– Committed files have new revision #
– Doesn’t pull down latest changes
• Update
– Working copy is updated to latest revision (Head)
– Effective down the directory tree where the
command was initiated
Reviewing Changes
• TortoiseSVN:
– Check for modifications
– Show log
– Diff
• AnkhSVN:
– Pane: View > Other Windows > Pending Changes
• “Team Foundation Server is not your current Source Control
plug-in.”
– View History
– Show Changes
Creating Conflict
• Update changes clash with local modifications
• Files related to unresolved conflict:
– foo [Working copy with markers]
– [Link] [Working copy without markers]
– foo.r314 [Base revision (before your changes)]
– foo.r478 [Head revision]
• Conflict markers
– Local changes
• <<<<<<< .mine
• =======
– Update’s version
• >>>>>>> .r478
Resolving Conflict
• TortoiseSVN:
– Edit conflicts
– Resolve using theirs
– Resolve using mine
– Revert
• Manual:
– Change foo
• Remove markers and make it right
• Replace foo with one of the revision files (.mine, etc.)
– Delete revision files
– Commit changed file
Reverting
• TortoiseSVN:
– Revert...
• Reverts to Base -- last update revision
– Revert to specific revision:
• Show log
• Right-click revision row > Revert to this revision
• Keeps changes by reverse-merging old revision into
working copy
Tagging
• Tagging and branching is just “SVN Copy”
• Subversion’s copy is “cheap” – only a pointer is
created, not a real copy
• Tag to mark a Named Stable Base
– TortoiseSVN: Repo-browser
– Right-drag-and-drop “/trunk” > Copy and rename
item to here
– Naming convention: “/tags/Sprint_x”
Branching
• Use branching to:
– Create a temporary Development workspace
– Maintain multiple released versions to support patches, etc.
• Before work begins:
– Repo-browser: copy “/trunk” to “/branches/Dev_x” (Version_x)
• If extensive working copy changes make merge very difficult, check in an
exported copy
– Last resort: loses file history
– Create and check out “/branches/Dev_x” directory
• Repo-browser > Create folder… ; check it out or
• Create the directory in working copy’s “/branches” and check in
– Right-drag-and-drop containing directory into Dev_x > “SVN export all items here”
– Commit (adding all files)