SlideShare a Scribd company logo
Subversion Official Subversion site: http://subversion.tigris.org/ http://svnbook.red-bean.com/ Wikipedia topic: http://en.wikipedia.org/wiki/Subversion_%28software%29 www.intellibitz.com   [email_address]
Repository and Modules Repository are created and maintained by SVN Administrator Modules are imported and updated by Users Many Repositories can exist in a SVN Server Many Modules can exist in a single Repository As an end user we care about modules www.intellibitz.com   [email_address]
Subversion Workflow Create a repository (once) Import or Checkout repository (once) Update and Checkin Merge Commit www.intellibitz.com   [email_address]
User Workflow Step 1 Obtain SVN Repository URL from SVN Admin Ex 1: svn://svn.intellibitz.net/repos/web Ex 2: http://sted.svn.sourceforge.net/viewvc/sted/ Step 2 Checkout SVN module (Repository Copy) to local file system (Working Copy) Step 3 Update, Commit, Branch, Tag etc., www.intellibitz.com   [email_address]
Subversion Architecture www.intellibitz.com   [email_address]
Repository Access As of version 1.4, Subversion repositories can be accessed by the following means: Local filesystem or network filesystem, accessed by client directly. WebDAV/DeltaV (over http or https) using the mod_dav_svn module for Apache 2. Custom "svn" protocol (default port 3690), using plaintext or over SSH. www.intellibitz.com   [email_address]
Subversion Components svn   (this is what you need) The command-line client program . svnadmin  A tool for creating, tweaking or repairing a Subversion repository. svnserve  A custom standalone server program, runnable as a daemon process or invokable by SSH; another way to make your repository available to others over a network. www.intellibitz.com   [email_address]
Repository – Client Usage www.intellibitz.com   [email_address]
Repository URL's Subversion repositories can be accessed through many different methods—on local disk, or through various network protocols, depending on how your administrator has set things up for you. A repository location, however, is always a URL . Schema   Access Method file:///   direct repository access (on local disk) http://   access via WebDAV protocol to Subversion-aware Apache server https://   same as http://, but with SSL encryption. svn://   access via  custom protocol to an svnserve server svn+ssh://   same as svn://, but through an SSH tunnel. www.intellibitz.com   [email_address]
Repository – common layout Subversion allows you to layout your repository any way that you choose, we recommend you create a trunk directory to hold the “main line” of development, a branches directory to contain branch copies, and a tags directory to contain tag copies,  for example: svn list  file:///usr/local/svn/repos /trunk /branches /tags www.intellibitz.com   [email_address]
Understanding Revisions Revision numbers are global across the whole repository Identify how the entire repository looks at that instant in time A commit creates a snapshot of the entire tree in the repository at that revision number Allows users to say, “Hey so-and-so, go get revision 1432 of XYZ and try to compile it.” Before an update, both bar.c and foo.c are at revision 25 Modify bar.c and commit Then update the working copy Now bar.c and foo.c are at revision 26, except that foo.c in revision 25 and 26 are identical No additional space in repository required, i.e. a cheap copy or a symbolic link is made www.intellibitz.com   [email_address]
Understanding Revisions www.intellibitz.com   [email_address]
Import Import - I have the files and I want to put them into the initial repository (Working Copy to Repository) $ svnadmin create /usr/local/svn/newrepos $ svn import mytree file:///usr/local/svn/newrepos/some/project \ -m "Initial import" Adding  mytree/foo.c Adding  mytree/bar.c Adding  mytree/subdir Adding  mytree/subdir/quux.h Committed revision 1. www.intellibitz.com   [email_address]
Checkout Checkout - I want to start working on an existing repository (Repository to Working copy) $ svn checkout http://svn.collab.net/repos/svn/trunk A  trunk/Makefile.in A  trunk/build.conf … Checked out revision 8810. www.intellibitz.com   [email_address]
Basic Work Cycle Update your working copy Make changes Examine your changes Possibly undo some changes Resolve Conflicts (Merge Others' Changes) Commit your changes www.intellibitz.com   [email_address]
Basic Work Cycle Update your working copy svn update Make changes svn add svn delete svn copy svn move Examine your changes svn status svn diff www.intellibitz.com   [email_address]
Basic Work Cycle Possibly undo some changes svn revert Resolve Conflicts (Merge Others' Changes) svn update svn resolved Commit your changes svn commit www.intellibitz.com   [email_address]
Update Update - Updates the local files to match the central repository NOTE: Change to the working folder (the local folder that you have checked out from the repository into your local file system) svn update U  foo.c U  bar.c Updated to revision 2. www.intellibitz.com   [email_address]
Update – Working Copy svn add foo Schedule file, directory, or symbolic link foo to be added to the repository. When you next commit, foo will become a child of its parent directory. Note that if foo is a directory, everything underneath foo will be scheduled for addition. If you only want to add foo itself, pass the --non-recursive (-N) option. www.intellibitz.com   [email_address]
Update – Working Copy svn delete foo Schedule file, directory, or symbolic link foo to be deleted from the repository. If foo is a file or link, it is immediately deleted from your working copy. If foo is a directory, it is not deleted, but Subversion schedules it for deletion. When you commit your changes, foo will be removed from your working copy and the repository. [4] www.intellibitz.com   [email_address]
Update – Working Copy svn copy foo bar Create a new item bar as a duplicate of foo and automatically schedule bar for addition. When bar is added to the repository on the next commit, its copy history is recorded (as having originally come from foo). svn copy does not create intermediate directories. www.intellibitz.com   [email_address]
Update – Working Copy svn move foo bar This command is exactly the same as running svn copy foo bar; svn delete foo. That is, bar is scheduled for addition as a copy of foo, and foo is scheduled for removal. svn move does not create intermediate directories. www.intellibitz.com   [email_address]
Update – Working Copy svn mkdir blort This command is exactly the same as running mkdir blort; svn add blort. That is, a new directory named blort is created and scheduled for addition. www.intellibitz.com   [email_address]
Update Update working copy Update all files and directories to the most current version % svn update Go to a particular older revision for all files and directories % svn update –r 1345 I want an even older version of svn-doc.el % svn update –r 999 svn-doc.el Update output and what it means U  `foo' File `foo' was (U)pdated (received changes from the server.) A  `foo' File or directory `foo' was (A)dded to your working copy. D  `foo' File or directory `foo' was (D)eleted from your working copy. R  `foo' File or directory `foo' was (R)eplaced in your working copy; that is, `foo' was deleted, and a new item with the same name was added.  While they may have the same name, the repository considers them to be distinct objects with distinct histories. G  `foo' File `foo' received new changes, but also had changes of your own to begin with.  The changes did not intersect, however, so Subversion has mer(G)ed the repository's changes into the file without a problem. C  `foo' File `foo' received (C)onflicting changes from the server.  The changes from the server directly overlap your own changes to the file.  No need to panic, though.  This overlap needs to be resolved by a human (you). www.intellibitz.com   [email_address]
Examine Local Changes svn status A  stuff/loot/bloo.h  # file is scheduled for addition C  stuff/loot/lump.c  # file has textual conflicts from an update D  stuff/fish.c  # file is scheduled for deletion M  bar.c  # the content in bar.c has local modifications A item The file, directory, or symbolic link item has been scheduled for addition into the repository. C item The file item is in a state of conflict. That is, changes received from the server during an update overlap with local changes that you have in your working copy. You must resolve this conflict before committing your changes to the repository. D item The file, directory, or symbolic link item has been scheduled for deletion from the repository. M item The contents of the file item have been modified. www.intellibitz.com   [email_address]
Examine Local Changes svn status -u -v M  *  44  23  sally  README M  44  20  harry  bar.c *  44  35  harry  stuff/trout.c D  44  19  ira  stuff/fish.c A  0  ?  ?  stuff/things/bloo.h Status against revision:  46 Notice the two asterisks: if you were to run svn update at this point, you would receive changes to README  and trout.c. This tells you some very useful information—you'll need to update and get the server changes on README before you commit, or the repository will reject your commit for being out-of-date. (More on this subject later.) www.intellibitz.com   [email_address]
Examine Changes in detail svn diff Index: bar.c =================================================================== --- bar.c (revision 3) +++ bar.c (working copy) @@ -1,7 +1,12 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#include <stdio.h> int main(void) { -  printf(&quot;Sixty-four slices of American Cheese...\n&quot;); +  printf(&quot;Sixty-five slices of American Cheese...\n&quot;); return 0; } www.intellibitz.com   [email_address]
Undoing local changes svn revert  ITEM has exactly the same effect as deleting ITEM from your working copy and then running svn update -r BASE ITEM. However, if you're reverting a file, svn revert  has one very noticeable difference—it doesn't have to communicate with the repository to restore your file. $ svn revert README Reverted 'README' www.intellibitz.com   [email_address]
Resolove Conflicts Suppose you run svn update and some interesting things occur: $ svn update U  INSTALL G  README C  bar.c Updated to revision 46. The U and G codes are no cause for concern; those files cleanly absorbed changes from the repository. The files marked with U contained no local changes but were Updated with changes from the repository. The G stands for merGed, which means that the file had local changes to begin with, but the changes coming from the repository didn't overlap with the local changes. But the C stands for conflict. This means that the changes from the server overlapped with your own, and now you have to manually choose between them. www.intellibitz.com   [email_address]
Resolove Conflicts Whenever a conflict occurs, three things typically occur to assist you in noticing and resolving that conflict: Subversion prints a C during the update, and remembers that the file is in a state of conflict. If Subversion considers the file to be mergeable, it places conflict markers—special strings of text which delimit the “sides” of the conflict—into the file to visibly demonstrate the overlapping areas.  For every conflicted file, Subversion places three extra unversioned files in your working copy: filename.mine This is your file as it existed in your working copy before you updated your working copy—that is, without conflict markers. This file has only your latest changes in it. (If Subversion considers the file to be unmergeable, then the .mine file isn't created, since it would be identical to the working file.) filename.rOLDREV This is the file that was the BASE revision before you updated your working copy. That is, the file that you checked out before you made your latest edits. filename.rNEWREV This is the file that your Subversion client just received from the server when you updated your working copy. This file corresponds to the HEAD revision of the repository.  (Here OLDREV is the revision number of the file in your .svn directory and NEWREV is the revision number of the repository HEAD.) www.intellibitz.com   [email_address]
Resolove Conflicts For example, Sally makes changes to the file sandwich.txt in the repository. Harry has just changed the file in his working copy and checked it in. Sally updates her working copy before checking in and she gets a conflict: $ svn update C  sandwich.txt Updated to revision 2. $ ls -1 sandwich.txt sandwich.txt.mine sandwich.txt.r1 sandwich.txt.r2 At this point, Subversion will not allow you to commit the file sandwich.txt until the three temporary files are removed. www.intellibitz.com   [email_address]
Resolove Conflicts $ svn commit -m &quot;Add a few more things&quot; svn: Commit failed (details follow): svn: Aborting commit: '/home/sally/svn-work/sandwich.txt' remains in conflict If you get a conflict, you need to do one of three things: Merge the conflicted text “by hand” (by examining and editing the conflict markers within the file). Copy one of the temporary files on top of your working file. Run svn revert <filename> to throw away all of your local changes. Once you've resolved the conflict, you need to let Subversion know by running svn resolved. This removes the three temporary files and Subversion no longer considers the file to be in a state of conflict.[6] $ svn resolved sandwich.txt Resolved conflicted state of 'sandwich.txt' www.intellibitz.com   [email_address]
Merge We both update the same file at the same time. What happens? Update tells me there is a conflict You checked yours in first I have to merge the two updates together. Before checking in www.intellibitz.com   [email_address]
Merge Conflicts by hand Merging conflicts by hand can be quite intimidating the first time you attempt it, but with a little practice, it can become as easy as falling off a bike. www.intellibitz.com   [email_address] Here's an example. Due to a miscommunication, you and Sally, your collaborator, both edit the file sandwich.txt at the same time. Sally commits her changes, and when you go to update your working copy, you get a conflict and you're going to have to edit sandwich.txt to resolve the conflicts. First, let's take a look at the file: $ cat sandwich.txt Top piece of bread Mayonnaise Lettuce Tomato Provolone <<<<<<< .mine Salami Mortadella Prosciutto ======= Sauerkraut Grilled Chicken >>>>>>> .r2 Creole Mustard Bottom piece of bread
Merge Conflicts by hand The strings of less-than signs, equal signs, and greater-than signs are conflict markers, and are not part of the actual data in conflict. You generally want to ensure that those are removed from the file before your next commit. The text between the first two sets of markers is composed of the changes you made in the conflicting area: <<<<<<< .mine Salami Mortadella Prosciutto ======= The text between the second and third sets of conflict markers is the text from Sally's commit: ======= Sauerkraut Grilled Chicken >>>>>>> .r2 www.intellibitz.com   [email_address] Usually you won't want to just delete the conflict markers and Sally's changes—she's going to be awfully surprised when the sandwich arrives and it's not what she wanted. So this is where you pick up the phone or walk across the office and explain to Sally that you can't get sauerkraut from an Italian deli.[7] Once you've agreed on the changes you will check in, edit your file and remove the conflict markers. Top piece of bread Mayonnaise Lettuce Tomato Provolone Salami Mortadella Prosciutto Creole Mustard Bottom piece of bread
Merge Conflicts by hand Now run svn resolved, and you're ready to commit your changes: $ svn resolved sandwich.txt $ svn commit -m &quot;Go ahead and use my sandwich, discarding Sally's edits.&quot; Note that svn resolved requires an argument. In any case, you want to be careful and only run svn resolved when you're certain that you've fixed the conflict in your file—once the temporary files are removed, Subversion will let you commit the file even if it still contains conflict markers. If you ever get confused while editing the conflicted file, you can always consult the three files that Subversion creates for you in your working copy—including your file as it was before you updated. You can even use a third-party interactive merging tool to examine those three files. www.intellibitz.com   [email_address]
Merge – Copying File Copying a File Onto Your Working File If you get a conflict and decide that you want to throw out your changes, you can merely copy one of the temporary files created by Subversion over the file in your working copy: svn update C  sandwich.txt Updated to revision 2. ls sandwich.* sandwich.txt  sandwich.txt.mine  sandwich.txt.r2  sandwich.txt.r1 cp sandwich.txt.r2 sandwich.txt svn resolved sandwich.txt www.intellibitz.com   [email_address]
Merge – Reverting File Punting: Using svn revert If you get a conflict, and upon examination decide that you want to throw out your changes and start your edits again, just revert your changes: $ svn revert sandwich.txt Reverted 'sandwich.txt' $ ls sandwich.* sandwich.txt Note that when you revert a conflicted file, you don't have to run svn resolved. www.intellibitz.com   [email_address]
Checkin Check-in - Update the central repository to match your local files Always update before checking in (svn enforces this) Always test with the latest update before checking in (not enforced) www.intellibitz.com   [email_address]
Commit svn commit command sends all of your changes to the repository. When you commit a change, you need to supply a log message, describing your change. Your log message will be attached to the new revision you create. Log message can be set in command line using the --message (or -m) switch: $ svn commit -m &quot;Corrected number of cheese slices.&quot; Sending  sandwich.txt Transmitting file data . Committed revision 3. www.intellibitz.com   [email_address]
Examining History Subversion repository keeps a record of every change ever committed, and allows you to explore this history by examining previous versions of files and directories as well as the metadata that accompanies them. With a single Subversion command, you can check out the repository (or restore an existing working copy) exactly as it was at any date or revision number in the past. www.intellibitz.com   [email_address]
Examining History However, sometimes you just want to peer into the past instead of going into the past. svn log Shows you broad information: log messages with date and author information attached to revisions, and which paths changed in each revision. www.intellibitz.com   [email_address] svn diff Shows line-level details of a particular change. svn cat This is used to retrieve any file as it existed in a particular revision number and display it on your screen. svn list Displays the files in a directory for any given revision.
Branching www.intellibitz.com   [email_address]
Branching www.intellibitz.com   [email_address]
Creating a Branch Create a branch by making a copy of the project in the repository using the svn copy command. Subversion is not only able to copy single files, but whole directories as well. svn copy http://svn.example.com/repos/calc/trunk \ http://svn.example.com/repos/calc/branches/my-calc-branch \ -m &quot;Creating a private branch of /calc/trunk.&quot; Committed revision 341. www.intellibitz.com   [email_address]
Creating a Tag A tag is just a “snapshot” of a project in time. In Subversion, this idea already seems to be everywhere. Each repository revision is exactly that—a snapshot of the filesystem after each commit. svn copy http://svn.example.com/repos/calc/trunk \ http://svn.example.com/repos/calc/tags/release-1.0 \ -m &quot;Tagging the 1.0 release of the 'calc' project.&quot; Committed revision 351. www.intellibitz.com   [email_address]
Summary Import / Checkout The first time to add / retrieve module Update Everytime to refresh working copy  Merge Working copy conflicts with repository copy, the repository copy is updated by another user Commit Send local changes to the repository www.intellibitz.com   [email_address]
Resources http://subversion.tigris.org/ http://svnbook.red-bean.com/ www.orcaware.com/svn/Subversion-Blair_Zajac.ppt http://groups.google.com/group/etoe www.intellibitz.com   [email_address]
IntelliBitz Technologies http://training.intellibitz.com http://groups.google.com/group/etoe http://sted.sourceforge.net 168, Medavakkam Main Road, Madipakkam Chennai, 600091, India. +91 44 2247 5106 [email_address] www.intellibitz.com   [email_address]
IntelliBitz Technologies www.intellibitz.com   [email_address] Thank You!

More Related Content

ODP
Svn Basic Tutorial
PPT
Subversion workshop
PPT
SVN Usage & Best Practices
ODP
Nguyễn Vũ Hưng: Subversion best practices
PPT
SVN Tool Information : Best Practices
PDF
Subversion Best Practices
PDF
Introduction to Subversion
PPT
Subversion Overview
Svn Basic Tutorial
Subversion workshop
SVN Usage & Best Practices
Nguyễn Vũ Hưng: Subversion best practices
SVN Tool Information : Best Practices
Subversion Best Practices
Introduction to Subversion
Subversion Overview

What's hot (20)

PDF
Version Control With Subversion
PPTX
SVN Basics
PPTX
Getting Started With Subversion
KEY
SVN Best Practices
PPT
Part 4 - Managing your svn repository using jas forge
PPTX
Subversion on-the-fly replication
PPTX
SVN Best Practices
PPT
Totalsvn Usage And Administration By Gopi
PPT
Introduction to Subversion and Google Project Hosting
PPT
Subversion client
PDF
Version Control with SVN
PDF
Version Control with Subversion
KEY
Introduce to SVN
PPTX
Version Control and Continuous Integration
PPTX
Using svn
PDF
Svn tutorial
PPTX
SVN Tutorial
PPTX
PPT
Subversion
Version Control With Subversion
SVN Basics
Getting Started With Subversion
SVN Best Practices
Part 4 - Managing your svn repository using jas forge
Subversion on-the-fly replication
SVN Best Practices
Totalsvn Usage And Administration By Gopi
Introduction to Subversion and Google Project Hosting
Subversion client
Version Control with SVN
Version Control with Subversion
Introduce to SVN
Version Control and Continuous Integration
Using svn
Svn tutorial
SVN Tutorial
Subversion
Ad

Similar to Subversion User Guide (20)

PPT
Subversion on .Unix
PPT
Subversion on .Unix
ODP
Burlington, VT PHP Users Group Subversion Presentation
PPTX
SVN Information
PDF
Version control with git
PPTX
Subversion
PDF
Svn workflow
ODP
Practical SVN for PHP Developers
PPT
PDF
Git your life for fun & profit
PDF
Git your life for fun & profit
PDF
Digital Fabrication Studio 0.3 Information
PDF
Version control with Subversion
PPT
SVN session from PiTechnologies
PPTX
Subversion
PDF
Digital Fabrication Studio v.0.2: Information
PPTX
Subversion proper renaming and merging as if you’ve read the whole code of co...
PDF
How to use CVS applied to SOLab
PPT
subversion.ppt
PDF
Digital Fabrication Studio.02 _Information @ Aalto Media Factory
Subversion on .Unix
Subversion on .Unix
Burlington, VT PHP Users Group Subversion Presentation
SVN Information
Version control with git
Subversion
Svn workflow
Practical SVN for PHP Developers
Git your life for fun & profit
Git your life for fun & profit
Digital Fabrication Studio 0.3 Information
Version control with Subversion
SVN session from PiTechnologies
Subversion
Digital Fabrication Studio v.0.2: Information
Subversion proper renaming and merging as if you’ve read the whole code of co...
How to use CVS applied to SOLab
subversion.ppt
Digital Fabrication Studio.02 _Information @ Aalto Media Factory
Ad

More from Muthuselvam RS (7)

PDF
UpsilonPiEpsilon-UniversityOfBridgeport-May1997
ODP
Spring User Guide
ODP
Gears User Guide
ODP
Ant User Guide
ODP
CProgrammingTutorial
ODP
PHP Web Programming
ODP
Hibernate Developer Reference
UpsilonPiEpsilon-UniversityOfBridgeport-May1997
Spring User Guide
Gears User Guide
Ant User Guide
CProgrammingTutorial
PHP Web Programming
Hibernate Developer Reference

Recently uploaded (20)

PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation theory and applications.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
A comparative analysis of optical character recognition models for extracting...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Machine Learning_overview_presentation.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Big Data Technologies - Introduction.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
A Presentation on Artificial Intelligence
Encapsulation theory and applications.pdf
sap open course for s4hana steps from ECC to s4
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
A comparative analysis of optical character recognition models for extracting...
The AUB Centre for AI in Media Proposal.docx
“AI and Expert System Decision Support & Business Intelligence Systems”
NewMind AI Weekly Chronicles - August'25-Week II
MYSQL Presentation for SQL database connectivity
Machine Learning_overview_presentation.pptx
Approach and Philosophy of On baking technology
Spectral efficient network and resource selection model in 5G networks
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.pptx

Subversion User Guide

  • 1. Subversion Official Subversion site: http://subversion.tigris.org/ http://svnbook.red-bean.com/ Wikipedia topic: http://en.wikipedia.org/wiki/Subversion_%28software%29 www.intellibitz.com [email_address]
  • 2. Repository and Modules Repository are created and maintained by SVN Administrator Modules are imported and updated by Users Many Repositories can exist in a SVN Server Many Modules can exist in a single Repository As an end user we care about modules www.intellibitz.com [email_address]
  • 3. Subversion Workflow Create a repository (once) Import or Checkout repository (once) Update and Checkin Merge Commit www.intellibitz.com [email_address]
  • 4. User Workflow Step 1 Obtain SVN Repository URL from SVN Admin Ex 1: svn://svn.intellibitz.net/repos/web Ex 2: http://sted.svn.sourceforge.net/viewvc/sted/ Step 2 Checkout SVN module (Repository Copy) to local file system (Working Copy) Step 3 Update, Commit, Branch, Tag etc., www.intellibitz.com [email_address]
  • 6. Repository Access As of version 1.4, Subversion repositories can be accessed by the following means: Local filesystem or network filesystem, accessed by client directly. WebDAV/DeltaV (over http or https) using the mod_dav_svn module for Apache 2. Custom &quot;svn&quot; protocol (default port 3690), using plaintext or over SSH. www.intellibitz.com [email_address]
  • 7. Subversion Components svn (this is what you need) The command-line client program . svnadmin A tool for creating, tweaking or repairing a Subversion repository. svnserve A custom standalone server program, runnable as a daemon process or invokable by SSH; another way to make your repository available to others over a network. www.intellibitz.com [email_address]
  • 8. Repository – Client Usage www.intellibitz.com [email_address]
  • 9. Repository URL's Subversion repositories can be accessed through many different methods—on local disk, or through various network protocols, depending on how your administrator has set things up for you. A repository location, however, is always a URL . Schema Access Method file:/// direct repository access (on local disk) http:// access via WebDAV protocol to Subversion-aware Apache server https:// same as http://, but with SSL encryption. svn:// access via custom protocol to an svnserve server svn+ssh:// same as svn://, but through an SSH tunnel. www.intellibitz.com [email_address]
  • 10. Repository – common layout Subversion allows you to layout your repository any way that you choose, we recommend you create a trunk directory to hold the “main line” of development, a branches directory to contain branch copies, and a tags directory to contain tag copies, for example: svn list file:///usr/local/svn/repos /trunk /branches /tags www.intellibitz.com [email_address]
  • 11. Understanding Revisions Revision numbers are global across the whole repository Identify how the entire repository looks at that instant in time A commit creates a snapshot of the entire tree in the repository at that revision number Allows users to say, “Hey so-and-so, go get revision 1432 of XYZ and try to compile it.” Before an update, both bar.c and foo.c are at revision 25 Modify bar.c and commit Then update the working copy Now bar.c and foo.c are at revision 26, except that foo.c in revision 25 and 26 are identical No additional space in repository required, i.e. a cheap copy or a symbolic link is made www.intellibitz.com [email_address]
  • 13. Import Import - I have the files and I want to put them into the initial repository (Working Copy to Repository) $ svnadmin create /usr/local/svn/newrepos $ svn import mytree file:///usr/local/svn/newrepos/some/project \ -m &quot;Initial import&quot; Adding mytree/foo.c Adding mytree/bar.c Adding mytree/subdir Adding mytree/subdir/quux.h Committed revision 1. www.intellibitz.com [email_address]
  • 14. Checkout Checkout - I want to start working on an existing repository (Repository to Working copy) $ svn checkout http://svn.collab.net/repos/svn/trunk A trunk/Makefile.in A trunk/build.conf … Checked out revision 8810. www.intellibitz.com [email_address]
  • 15. Basic Work Cycle Update your working copy Make changes Examine your changes Possibly undo some changes Resolve Conflicts (Merge Others' Changes) Commit your changes www.intellibitz.com [email_address]
  • 16. Basic Work Cycle Update your working copy svn update Make changes svn add svn delete svn copy svn move Examine your changes svn status svn diff www.intellibitz.com [email_address]
  • 17. Basic Work Cycle Possibly undo some changes svn revert Resolve Conflicts (Merge Others' Changes) svn update svn resolved Commit your changes svn commit www.intellibitz.com [email_address]
  • 18. Update Update - Updates the local files to match the central repository NOTE: Change to the working folder (the local folder that you have checked out from the repository into your local file system) svn update U foo.c U bar.c Updated to revision 2. www.intellibitz.com [email_address]
  • 19. Update – Working Copy svn add foo Schedule file, directory, or symbolic link foo to be added to the repository. When you next commit, foo will become a child of its parent directory. Note that if foo is a directory, everything underneath foo will be scheduled for addition. If you only want to add foo itself, pass the --non-recursive (-N) option. www.intellibitz.com [email_address]
  • 20. Update – Working Copy svn delete foo Schedule file, directory, or symbolic link foo to be deleted from the repository. If foo is a file or link, it is immediately deleted from your working copy. If foo is a directory, it is not deleted, but Subversion schedules it for deletion. When you commit your changes, foo will be removed from your working copy and the repository. [4] www.intellibitz.com [email_address]
  • 21. Update – Working Copy svn copy foo bar Create a new item bar as a duplicate of foo and automatically schedule bar for addition. When bar is added to the repository on the next commit, its copy history is recorded (as having originally come from foo). svn copy does not create intermediate directories. www.intellibitz.com [email_address]
  • 22. Update – Working Copy svn move foo bar This command is exactly the same as running svn copy foo bar; svn delete foo. That is, bar is scheduled for addition as a copy of foo, and foo is scheduled for removal. svn move does not create intermediate directories. www.intellibitz.com [email_address]
  • 23. Update – Working Copy svn mkdir blort This command is exactly the same as running mkdir blort; svn add blort. That is, a new directory named blort is created and scheduled for addition. www.intellibitz.com [email_address]
  • 24. Update Update working copy Update all files and directories to the most current version % svn update Go to a particular older revision for all files and directories % svn update –r 1345 I want an even older version of svn-doc.el % svn update –r 999 svn-doc.el Update output and what it means U `foo' File `foo' was (U)pdated (received changes from the server.) A `foo' File or directory `foo' was (A)dded to your working copy. D `foo' File or directory `foo' was (D)eleted from your working copy. R `foo' File or directory `foo' was (R)eplaced in your working copy; that is, `foo' was deleted, and a new item with the same name was added. While they may have the same name, the repository considers them to be distinct objects with distinct histories. G `foo' File `foo' received new changes, but also had changes of your own to begin with. The changes did not intersect, however, so Subversion has mer(G)ed the repository's changes into the file without a problem. C `foo' File `foo' received (C)onflicting changes from the server. The changes from the server directly overlap your own changes to the file. No need to panic, though. This overlap needs to be resolved by a human (you). www.intellibitz.com [email_address]
  • 25. Examine Local Changes svn status A stuff/loot/bloo.h # file is scheduled for addition C stuff/loot/lump.c # file has textual conflicts from an update D stuff/fish.c # file is scheduled for deletion M bar.c # the content in bar.c has local modifications A item The file, directory, or symbolic link item has been scheduled for addition into the repository. C item The file item is in a state of conflict. That is, changes received from the server during an update overlap with local changes that you have in your working copy. You must resolve this conflict before committing your changes to the repository. D item The file, directory, or symbolic link item has been scheduled for deletion from the repository. M item The contents of the file item have been modified. www.intellibitz.com [email_address]
  • 26. Examine Local Changes svn status -u -v M * 44 23 sally README M 44 20 harry bar.c * 44 35 harry stuff/trout.c D 44 19 ira stuff/fish.c A 0 ? ? stuff/things/bloo.h Status against revision: 46 Notice the two asterisks: if you were to run svn update at this point, you would receive changes to README and trout.c. This tells you some very useful information—you'll need to update and get the server changes on README before you commit, or the repository will reject your commit for being out-of-date. (More on this subject later.) www.intellibitz.com [email_address]
  • 27. Examine Changes in detail svn diff Index: bar.c =================================================================== --- bar.c (revision 3) +++ bar.c (working copy) @@ -1,7 +1,12 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#include <stdio.h> int main(void) { - printf(&quot;Sixty-four slices of American Cheese...\n&quot;); + printf(&quot;Sixty-five slices of American Cheese...\n&quot;); return 0; } www.intellibitz.com [email_address]
  • 28. Undoing local changes svn revert ITEM has exactly the same effect as deleting ITEM from your working copy and then running svn update -r BASE ITEM. However, if you're reverting a file, svn revert has one very noticeable difference—it doesn't have to communicate with the repository to restore your file. $ svn revert README Reverted 'README' www.intellibitz.com [email_address]
  • 29. Resolove Conflicts Suppose you run svn update and some interesting things occur: $ svn update U INSTALL G README C bar.c Updated to revision 46. The U and G codes are no cause for concern; those files cleanly absorbed changes from the repository. The files marked with U contained no local changes but were Updated with changes from the repository. The G stands for merGed, which means that the file had local changes to begin with, but the changes coming from the repository didn't overlap with the local changes. But the C stands for conflict. This means that the changes from the server overlapped with your own, and now you have to manually choose between them. www.intellibitz.com [email_address]
  • 30. Resolove Conflicts Whenever a conflict occurs, three things typically occur to assist you in noticing and resolving that conflict: Subversion prints a C during the update, and remembers that the file is in a state of conflict. If Subversion considers the file to be mergeable, it places conflict markers—special strings of text which delimit the “sides” of the conflict—into the file to visibly demonstrate the overlapping areas. For every conflicted file, Subversion places three extra unversioned files in your working copy: filename.mine This is your file as it existed in your working copy before you updated your working copy—that is, without conflict markers. This file has only your latest changes in it. (If Subversion considers the file to be unmergeable, then the .mine file isn't created, since it would be identical to the working file.) filename.rOLDREV This is the file that was the BASE revision before you updated your working copy. That is, the file that you checked out before you made your latest edits. filename.rNEWREV This is the file that your Subversion client just received from the server when you updated your working copy. This file corresponds to the HEAD revision of the repository. (Here OLDREV is the revision number of the file in your .svn directory and NEWREV is the revision number of the repository HEAD.) www.intellibitz.com [email_address]
  • 31. Resolove Conflicts For example, Sally makes changes to the file sandwich.txt in the repository. Harry has just changed the file in his working copy and checked it in. Sally updates her working copy before checking in and she gets a conflict: $ svn update C sandwich.txt Updated to revision 2. $ ls -1 sandwich.txt sandwich.txt.mine sandwich.txt.r1 sandwich.txt.r2 At this point, Subversion will not allow you to commit the file sandwich.txt until the three temporary files are removed. www.intellibitz.com [email_address]
  • 32. Resolove Conflicts $ svn commit -m &quot;Add a few more things&quot; svn: Commit failed (details follow): svn: Aborting commit: '/home/sally/svn-work/sandwich.txt' remains in conflict If you get a conflict, you need to do one of three things: Merge the conflicted text “by hand” (by examining and editing the conflict markers within the file). Copy one of the temporary files on top of your working file. Run svn revert <filename> to throw away all of your local changes. Once you've resolved the conflict, you need to let Subversion know by running svn resolved. This removes the three temporary files and Subversion no longer considers the file to be in a state of conflict.[6] $ svn resolved sandwich.txt Resolved conflicted state of 'sandwich.txt' www.intellibitz.com [email_address]
  • 33. Merge We both update the same file at the same time. What happens? Update tells me there is a conflict You checked yours in first I have to merge the two updates together. Before checking in www.intellibitz.com [email_address]
  • 34. Merge Conflicts by hand Merging conflicts by hand can be quite intimidating the first time you attempt it, but with a little practice, it can become as easy as falling off a bike. www.intellibitz.com [email_address] Here's an example. Due to a miscommunication, you and Sally, your collaborator, both edit the file sandwich.txt at the same time. Sally commits her changes, and when you go to update your working copy, you get a conflict and you're going to have to edit sandwich.txt to resolve the conflicts. First, let's take a look at the file: $ cat sandwich.txt Top piece of bread Mayonnaise Lettuce Tomato Provolone <<<<<<< .mine Salami Mortadella Prosciutto ======= Sauerkraut Grilled Chicken >>>>>>> .r2 Creole Mustard Bottom piece of bread
  • 35. Merge Conflicts by hand The strings of less-than signs, equal signs, and greater-than signs are conflict markers, and are not part of the actual data in conflict. You generally want to ensure that those are removed from the file before your next commit. The text between the first two sets of markers is composed of the changes you made in the conflicting area: <<<<<<< .mine Salami Mortadella Prosciutto ======= The text between the second and third sets of conflict markers is the text from Sally's commit: ======= Sauerkraut Grilled Chicken >>>>>>> .r2 www.intellibitz.com [email_address] Usually you won't want to just delete the conflict markers and Sally's changes—she's going to be awfully surprised when the sandwich arrives and it's not what she wanted. So this is where you pick up the phone or walk across the office and explain to Sally that you can't get sauerkraut from an Italian deli.[7] Once you've agreed on the changes you will check in, edit your file and remove the conflict markers. Top piece of bread Mayonnaise Lettuce Tomato Provolone Salami Mortadella Prosciutto Creole Mustard Bottom piece of bread
  • 36. Merge Conflicts by hand Now run svn resolved, and you're ready to commit your changes: $ svn resolved sandwich.txt $ svn commit -m &quot;Go ahead and use my sandwich, discarding Sally's edits.&quot; Note that svn resolved requires an argument. In any case, you want to be careful and only run svn resolved when you're certain that you've fixed the conflict in your file—once the temporary files are removed, Subversion will let you commit the file even if it still contains conflict markers. If you ever get confused while editing the conflicted file, you can always consult the three files that Subversion creates for you in your working copy—including your file as it was before you updated. You can even use a third-party interactive merging tool to examine those three files. www.intellibitz.com [email_address]
  • 37. Merge – Copying File Copying a File Onto Your Working File If you get a conflict and decide that you want to throw out your changes, you can merely copy one of the temporary files created by Subversion over the file in your working copy: svn update C sandwich.txt Updated to revision 2. ls sandwich.* sandwich.txt sandwich.txt.mine sandwich.txt.r2 sandwich.txt.r1 cp sandwich.txt.r2 sandwich.txt svn resolved sandwich.txt www.intellibitz.com [email_address]
  • 38. Merge – Reverting File Punting: Using svn revert If you get a conflict, and upon examination decide that you want to throw out your changes and start your edits again, just revert your changes: $ svn revert sandwich.txt Reverted 'sandwich.txt' $ ls sandwich.* sandwich.txt Note that when you revert a conflicted file, you don't have to run svn resolved. www.intellibitz.com [email_address]
  • 39. Checkin Check-in - Update the central repository to match your local files Always update before checking in (svn enforces this) Always test with the latest update before checking in (not enforced) www.intellibitz.com [email_address]
  • 40. Commit svn commit command sends all of your changes to the repository. When you commit a change, you need to supply a log message, describing your change. Your log message will be attached to the new revision you create. Log message can be set in command line using the --message (or -m) switch: $ svn commit -m &quot;Corrected number of cheese slices.&quot; Sending sandwich.txt Transmitting file data . Committed revision 3. www.intellibitz.com [email_address]
  • 41. Examining History Subversion repository keeps a record of every change ever committed, and allows you to explore this history by examining previous versions of files and directories as well as the metadata that accompanies them. With a single Subversion command, you can check out the repository (or restore an existing working copy) exactly as it was at any date or revision number in the past. www.intellibitz.com [email_address]
  • 42. Examining History However, sometimes you just want to peer into the past instead of going into the past. svn log Shows you broad information: log messages with date and author information attached to revisions, and which paths changed in each revision. www.intellibitz.com [email_address] svn diff Shows line-level details of a particular change. svn cat This is used to retrieve any file as it existed in a particular revision number and display it on your screen. svn list Displays the files in a directory for any given revision.
  • 43. Branching www.intellibitz.com [email_address]
  • 44. Branching www.intellibitz.com [email_address]
  • 45. Creating a Branch Create a branch by making a copy of the project in the repository using the svn copy command. Subversion is not only able to copy single files, but whole directories as well. svn copy http://svn.example.com/repos/calc/trunk \ http://svn.example.com/repos/calc/branches/my-calc-branch \ -m &quot;Creating a private branch of /calc/trunk.&quot; Committed revision 341. www.intellibitz.com [email_address]
  • 46. Creating a Tag A tag is just a “snapshot” of a project in time. In Subversion, this idea already seems to be everywhere. Each repository revision is exactly that—a snapshot of the filesystem after each commit. svn copy http://svn.example.com/repos/calc/trunk \ http://svn.example.com/repos/calc/tags/release-1.0 \ -m &quot;Tagging the 1.0 release of the 'calc' project.&quot; Committed revision 351. www.intellibitz.com [email_address]
  • 47. Summary Import / Checkout The first time to add / retrieve module Update Everytime to refresh working copy Merge Working copy conflicts with repository copy, the repository copy is updated by another user Commit Send local changes to the repository www.intellibitz.com [email_address]
  • 48. Resources http://subversion.tigris.org/ http://svnbook.red-bean.com/ www.orcaware.com/svn/Subversion-Blair_Zajac.ppt http://groups.google.com/group/etoe www.intellibitz.com [email_address]
  • 49. IntelliBitz Technologies http://training.intellibitz.com http://groups.google.com/group/etoe http://sted.sourceforge.net 168, Medavakkam Main Road, Madipakkam Chennai, 600091, India. +91 44 2247 5106 [email_address] www.intellibitz.com [email_address]
  • 50. IntelliBitz Technologies www.intellibitz.com [email_address] Thank You!