Source Control Conceptswith examples in Subversion<br />devlicio.us<br />bennage<br />Christopher Bennage<br />Blue Spire ...
there areSurprising Benefits<br /><ul><li> Communication of intent
 Assistance with fixing bugs
 Liberation
 Encouragement of best practices</li></li></ul><li>Repository<br />File System * Time<br />
Working Copy<br />
worfklow #1Check-out, Edit, Check-in<br />Check out the files to edit<br />Edit them<br />Check them back in<br />
worfklow #2Edit, Merge, Commit<br />Update your working copy<br />Make your edits<br />(Resolve any conflicts)<br />Commit...
but alwaysComment!<br />Comments are the key to understanding your project’s history.<br />
Conflicts will happen<br />Conflicts will happen<br />
what isBranching?<br />r1<br />Begin<br />Development<br />r2<br />r1.01<br />
mergingBranches<br />r1<br />Begin<br />Development<br />r2<br />r1.01<br />bug fixes<br />
Tags<br />Tags mark special moments in the history of the code.<br /><ul><li> official release
 just prior to breaking changes</li></ul>Tags shouldn’t change.<br />
A few other things…<br /><ul><li> head
 revision
 atomic commit
Upcoming SlideShare
Loading in...5
×

Source Control Concepts

2,605

Published on

An introduction into the basic concepts of source control. Some specific examples are in Subversion (svn).

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,605
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • SCC – Source Code ControlVC – Version ControlSCM – Software Configuration ManagementMy points here are generally true. Like “root beer is not caffeinated”, then along comes Barq’s.Thanks to Joe Kuemerle (kemerlee) for his presentation on Getting Rid of VSSEric Sink’s excellent blog series
  • There are surprising benefits to using source control.The history and in particular the comment log help communicate what you were thinking when you wrote the codeIf you know something worked in a previous revision, you can compare the code to help isolate the breaking changesYou can make changes with confidence, knowing that you can always revertAutomation (build server, continuous integration) leads to more free time (thus liberation)Many “best practices” make using source control easier and more meaningfulAdditional benefits that aren’t so surprising:Audit trail/tracebilityCentral store, a known location where the canonical code is stored
  • “Repository = File System * Time”Eric Sink, http://www.ericsink.com/scm/scm_repositories.htmlThis means that changes are additive, not destructive. Even when you delete, it’s not really destructive.The repository should be an accurate representation of the history of the code base. Mistakes and all.Optimized for storing text files, not necessarily for binaryTwo popular types of SCC, distributed and server based.
  • aka Working Folder, Working Directory, or SandboxThis is where you put the stuff on your machine.with svn, you would use svn checkoutYou want to keep the value of your working copy low.As you write code and make changes, you are increasing the value of you working copy. When you commit those changes to the repository, you make your working copy worthless again.That’s what you want.You should be able to delete the working copy (or have a crash) and never lose more than a couple of hours of work.Whoa, is that a shift in culture?Let’s move on to workflow…
  • This is the more conservative, traditional model.It is used by VSS. Ugh.Obeys these rules:Working copy is always read-onlyDevs must check out (thus locking) a file in order to edit itCheckouts are exclusiveProsNo chance of conflictsDevs know what other devs are doingConsCan’t work in parallelRequires access to a central server
  • This is the more conservative, traditional model.It is used by CVS, SVN.This is my preferred model.Obeys these rules:Working copy is never read-onlyDevs can edit anything Devs are responsible for resolving conflicts. (Meaning that they must update and resolve before committing).ProsWorks well when offlineAllows parallel workLess mental overhead for devs (80% of the time)ConsNo visibility into what other devs are doingResolving conflicts (not a big deal for 80% of the time)
  • Regardless of the workflow you choose, you should always comment your commits.Why?To reveal the intention of your changes.So write meaningful comments. (It’s easy to be lazy).Also, many issue tracking scan the comments and do cool things. (Like close issues, etc.)
  • Assuming Edit, Merge, Commit model…There will be conflicts.Most tools will perform an “automerge” to resolve conflicts.Do you trust this? My experience has made me say “Yes”.However, sometimes manual intervention is needed.For example, edits to the same line in the same file. Or edits to a binary file.This is when you use a diff tool to merge the file and resolve the conflict.
  • A branch is another line of development that has a common history with the primary line of development.Often the primary line of development is called the “trunk”, or “main” or “master”.You want r2 and r1.01 to have a common history, but you don’t want to pollute the maintenance branch (1.01) with unfinished features from r2.The mechanics and semantics of branches differ on different platforms.Some use “folders” or repository paths to designate branches. (svn,tfs)Other define a “namespace” or “universe” that must be provided. It is not part of the path. (cvs, and maybe git…) I’m also not certain on the proper term for this…But what about the bug fixes from 1.01? We want those back in 2.0, right? How do we do that?
  • Merging a branch is sorta the whole point of creating it…This usually requires developer involvement, but that’s okay. The benefit is worth it.Always review the results of a merge before committing it back to the trunk.Svn and other system have the concept of a “merge history”. If you are doing merges on a regular basis, this can really help out.
  • Creating a tag (or label) is much the same as creating a new branch. At least it is with svn.The difference comes in how you treat the tag. A tag is used to mark a special or significant moment in the history of the code. For example, an RTM or immediately prior to major changes.Give an example of NHProf.Tags, unlike branches, shouldn’t really be added to. You should be confident when you retrieve a tag that it represents what the code really looked like at that moment.Mention the standard repository structure: branches, tags, trunk
  • Head – the most recent changeset on a line of development (trunk, branch, etc.)Revision – a point in repository or a file’s history. In svn, the repository’s revision number is updated after each commit.Atomic commit - all of the changes in a commit or checkin either succeed or fail. This is very important for ensuring a consistent state of the repository.Changeset – the set of changes in a commit. In other words, all of the changes (adds, modifications, deletes) that are part of a single commit or checkin.Blame – a tool that allows you to see who “owned” a given line on given file for a particular revision. Patch – when a user doesn’t have commit rights to a repository, they can create a single file that contains all of the changes that they have made to their working copy. This “patch” is then given to someone with commit rights. The committer “applies” the patch to their working copy, reviews the changes, and makes the commit when appropriate. This is a common practice in the open source community.
  • Bookslinks
  • Source Control Concepts

    1. 1. Source Control Conceptswith examples in Subversion<br />devlicio.us<br />bennage<br />Christopher Bennage<br />Blue Spire Consulting, Inc.<br />Microsoft MVP<br />
    2. 2. there areSurprising Benefits<br /><ul><li> Communication of intent
    3. 3. Assistance with fixing bugs
    4. 4. Liberation
    5. 5. Encouragement of best practices</li></li></ul><li>Repository<br />File System * Time<br />
    6. 6. Working Copy<br />
    7. 7. worfklow #1Check-out, Edit, Check-in<br />Check out the files to edit<br />Edit them<br />Check them back in<br />
    8. 8. worfklow #2Edit, Merge, Commit<br />Update your working copy<br />Make your edits<br />(Resolve any conflicts)<br />Commit the changes<br />
    9. 9. but alwaysComment!<br />Comments are the key to understanding your project’s history.<br />
    10. 10. Conflicts will happen<br />Conflicts will happen<br />
    11. 11. what isBranching?<br />r1<br />Begin<br />Development<br />r2<br />r1.01<br />
    12. 12. mergingBranches<br />r1<br />Begin<br />Development<br />r2<br />r1.01<br />bug fixes<br />
    13. 13. Tags<br />Tags mark special moments in the history of the code.<br /><ul><li> official release
    14. 14. just prior to breaking changes</li></ul>Tags shouldn’t change.<br />
    15. 15. A few other things…<br /><ul><li> head
    16. 16. revision
    17. 17. atomic commit
    18. 18. changeset
    19. 19. blame
    20. 20. patch</li></li></ul><li>Subversion Resources<br />VisualSVNvisualsvn.com<br />easiest way to get started<br />TortoiseSVNtortoisesvn.tigris.org<br />popular UI for svn<br />Subversion subversion.tigris.org<br />svn client and server<br />“Red Bean” Book svnbook.red-bean.com<br />The manual for Subversion<br />Unfuddleunfuddle.com<br />hosted project management with svn<br />
    21. 21. Git Resources<br />msysgitcode.google.com/p/msysgit<br />git for windows<br />Git Extensions sourceforge.net/projects/gitextensions<br />includes a Visual Studio plugin<br />GitHubgithub.com<br />social coding with git<br />Unfuddleunfuddle.com<br />hosted project management with git<br />Git Community Book book.git-scm.com<br />the manual for git<br />
    22. 22. TFS Resources<br />Microsoft msdn.microsoft.com/en-us/teamsystem<br />Team System Home<br />Radio TFS radiotfs.com<br />podcasts about TFS<br />Team System Rocks teamsystemrocks.com<br />community site with tutorials and blogs<br />
    23. 23. General Resources<br />Eric Sink ericsink.com/scm<br />How To guide for Source Control<br />Branching Primer msdn.microsoft.com/library/aa730834<br />primer regarding branching and merging<br />Visual Guide to Version Control<br />betterexplained.com/articles/a-visual-guide-to-version-control<br />An excellent overview of source control<br />
    24. 24. Christopher Bennagedevlicio.us/blogs/christopher_bennage christopher@bluespire.comtwitter.com/bennageMicrosoft MVP<br />

    ×