You are on page 1of 16

1/31/2014

Subversion Commands and Scripts

Subversion Commands and Scripts


Subversion (SVN) command summary cheat sheet, use, best practices, tips and scripts. This tutorial covers version control with Subversion using the command line interface, GUI clients and scripts which interface Subversion with GUI diff tools.

Tutorial Contents: # Subversion Introduction # Subversion Commands # Subversion content properties # Subversion and Graphical diffs # Subversion GUI interface # Subversion Security Tips # Subversion utility commands and scripts # Subversion Best Practices # Tips # Links # Books

rev 401

rev 402

rev 403

search
Related YoLinux Tutorials: Subversion Server and Trac Server Installation and Configuration Subversion Repository Transfer RabbitVCS client Jenkins Automated Builds and Subversion Cabie Automated Builds and Subversion Software development tools Clearcase Commands Clearcase Client Install Clearcase Server Install Subversion vs Clearcase CVS Intro RCS Intro C++ Info, links

Search

| Home Page | Linux Tutorials | Terms | Privacy Policy | Advertising | Contact |

Subversion Introduction:
Subversion is a software source code "Change Management" (CM) system for collaborative development. It maintains a history of file and directory versions. The files and directories are checked out of the repository and into your local project work area. This called your "working directory". Changes are made to files in your "working directory". After changes are made to the create the next working version, the files are checked into the Subversion CM repository.

Subversion Commands:
Subversion command summary cheat sheet: Command
s v nh e l p s v nh e l pc o m m a n d A l s o :?o rh s v na d df i l e n a m e s v na d dd i r e c t o r y

Description List Subversion commands Help on given "command" Add a file or directory to Subversion CM control. Must also perform: s v nc if i l e n a m e(or s v n c o m m i t ) to upload the file or directory. File will not be available in the repository until a "commit" is performed. If adding a directory, the directory and all of its contents recursively are added. i.e.:
s v nc id i r e c t o r y s v nc o m m i td i r e c t o r y s v nc o m m i t.

s v nb l a m ef i l e n a m e s v nb l a m erR e v i s i o n N u m b e rf i l e n a m e Also: p r a i s e ,a n n o t a t e ,a n n s v nc a tf i l e n a m e

Show file contents with revisions annotated with author information. List contents of file under Subversion control.
1/16

http://www.yolinux.com/TUTORIALS/Subversion.html

1/31/2014
Java on Linux YoLinux Tutorials Index

Subversion Commands and Scripts


s v nc h e c k o u th t t p : / / n o d e n a m e / r e p o s / s v n / t r u n k / p a r e n t P a t h / p a t h

This creates:
p a t h / f i l e 1 p a t h / f i l e 2 . . . s v nc h e c k o u th t t p : / / n o d e n a m e / r e p o s / s v n / t r u n k / p a r e n t P a t h.

Checkout every file from the path and subdirectories specified below. Creates "working" copy of files and directories. Checkout a repository. Use option "-r" to specify a specific revision other than the latest. The URL "svn://" communicates with an SVN server (port 3690) The URL "http://" comunicates with the Apache server and module m o d _ d a v _ s v n(port 80) [more common server]

This creates:
p a t h / f i l e 1 p a t h / f i l e 2 . . . N o t et h ed i f f e r e n c ea" . "m a k e s . s v nc h e c k o u tf i l e : / / / r e p o s / s v n / t r u n k / p a t h / s v nc or4 9 7h t t p : / / n o d e n a m e / r e p o s / s v n / t r u n k / p a t hf i l e n a m e Also: s v nc oh t t p s : / / . . . ,s v n : / / . . . , and s v n + s s h : / / MS/Windows: s v nc o f i l e : / / / c : / r e p o s i t o r y / p r o j e c t / t r u n k s v nc l e a n u p s v nc o m m i tf i l e n a m e s v nc o m m i tm e s s a g e" M e s s a g eg o e sh e r e . " f i l e n a m e s v nc o m m i tm" M e s s a g eg o e sh e r e . "f i l e n a m e s v nc if i l e n a m e 1f i l e n a m e 2f i l e n a m e 3 s v nc i. s v nc o p ys o u r c ed e s t i n a t i o n _ c l o n e Also: s v nc p. . .

Cleanup subversion files resulting from escaped processes and crashed. Check-in (commit) local "working" file, files or directory and contents (recursively) into Subversion repository. Atomic, i.e. all committed or none, no incomplete check-in. Copy file or directory tree. One can copy from one local working copy to another or to repository server URL's. The sources and destinations can be working copies or URLs. Tag a release. Takes a snapshot of the repository and assigns a name. This can be performed at any directory branch. Tag a release. Takes a snapshot of your local working copy and assigns a name. This can be performed at any directory branch.

s v nc o p yh t t p : / / h o s t / r e p o s / p r o j e c t / t r u n k h t t p : / / h o s t / r e p o s / p r o j e c t / t a g s / T a g N a m e 1 . 4 . 5 m" T a gR e l e a s e1 . 4 . 5 " s v nc o p y. h t t p : / / h o s t / r e p o s / p r o j e c t / t a g s / T a g N a m e 1 . 4 . 5 m" T a gR e l e a s e1 . 4 . 5 "

Linux Commands Subversion SVN Repository


Free Information Technology Magazines and Document Downloads

s v nd e l e t ef i l e n a m e Delete file from repository. The UNIX command r m s v nd e l e t ed i r e c t o r y f i l e n a m e . Must perform a "commit" to update the Also: d e l ,r e m o v eor r m repository and local working directory with the s v nr mh t t p : / / h o s t / r e p o s / p r o j e c t / t r u n k / f i l e - changes. i.e.: o r d i r e c t o r y s v nc o m m i t. s v nd i f ff i l e n a m e s v nd if i l e n a m e s v nd i f frr e v 1 : r e v 2f i l e n a m e

Show file diffs between SVN repository and your file changes using GNU file diff format. Use GUI diff tools as shown below. Show file diffs between specified versions. Example: s v nd i f fr4 5 6 : 4 5 9s u b f n . c p p Using GUI diff tool: s v nd i f fr4 5 7 : 4 5 9d i f f c m dk d i f f 3f i l e n a m e

s v nd i f ff i l e n a m e>p a t c h f i l e s v ne x p o r td i r e c t o r y s v ne x p o r trR e v N u m b e rh t t p : / / n o d e n a m e / p a t h s v ni m p o r tl o c a l d i r e c t o r y h t t p : / / n o d e / r e p o s / s v n / t r u n k / d i r e c t o r y s v ni n f of i l e n a m e

Generate patch file used by the patch command. Export directory tree to your file system but it will not be a "working directory" under SVN control. Export directory tree of specified version and create local directory tree and files not under SVN control. Add directory (and files in it recursively) to path in repository specified. Display information about file or directory. (Date modified, author, revision, path in repository.) Can not specify a URL. List file or directory of files in repository. Used to
2/16

Free Information Technology Software and Development Magazine Subscriptions and Document Downloads

s v nl i s td i r e c t o r y

http://www.yolinux.com/TUTORIALS/Subversion.html

1/31/2014
18

Subversion Commands and Scripts


s v nl i s tf i l e n a m e

browse repository before checkout. If current directory is given (s v nl i s t. / ), then Subversion will list the repository URL of the current directory. List directory of files in repository in specified revision. Lock file to grant exclusive access to one and forbid all others. A commit will unlock the file (unless the "-no-unlock" option is used). A lock can be removed with the commands: s v nu n l o c kf i l e n a m e ,s v n l o o k and the s v n a d m i ncomands (i.e. List: s v n a d m i n l s l o c k sand remove: s v n a d m i nr m l o c k sf i l e n a m e ). Show the Subversion log messages for a set of revision(s) and/or file(s) and/or all directory contents in repository. List verbose. Includes list of all files in change Shows the file changes associated with revision number. Merge directory changes into your current working directory or merge a file in Subversion into the file in your working directory. If target is not specified, the identical basename or current directory is assumed. Used to incorporate changes checked in which are not accounted for in your file or to merge branches. Example using GUI merge tool:
s v nd i f fr4 5 9 : 4 5 4d i f f c m dk d i f f 3e x t e n s i o n s' m 'f i l e n a m e

Advertisements
HTML Editor

s v nl i s trR e v i s i o n N u m b e rd i r e c t o r y s v nl o c kf i l e n a m em" c o m m e n ta st ow h yi t s l o c k e do rb yw h o m "

HTML 4.0

( C o m m e n ti sn o tr e q u i r e db u ti so f t e n u s e f u l ) s v nl o gf i l e n a m e s v nl o g. s v nl o gh t t p : / / U R L / p a t h / f i l e s v nl o gv. s v nl o grR e v i s i o n N u m b e r h t t p : / / U R L / p a t h / f i l e s v nm e r g eh t t p : / / u r l / p a t h / b r a n c h 1 h t t p : / / u r l / p a t h / b r a n c h 2w o r k i n g l o c a l d i r s v nm e r g ef i l e 1 @ r e v Jf i l e 2 @ r e v K s v nm e r g er4 1 4 : 4 1 1h t t p : / / u r l / p a t h w o r k i n g d i r s v nm e r g er4 1 3 : H E A Df i l e n a m e

Free PHP Tutorial Definition Of HTML Learning HTML Code HTML Class

HTML Language HTML Source Code HTML Tutorial


s v nm e r g ed r y r u nr4 1 4 : 4 1 3 h t t p : / / u r l / p a t h s v nm e r g er4 1 4 : 4 1 3h t t p : / / u r l / p a t h s v nm e r g er4 1 4 : 4 1 3. s v nm k d i rd i r e c t o r y s v nm k d i rh t t p : / / U R L / d i r e c t o r y s v nm o v ed i r e c t o r y 1d i r e c t o r y 2 s v nm vd i r e c t o r y 1d i r e c t o r y 2 s v nm vf i l e o l d n a m ef i l e n e w n a m e

Next, tell subversion that the conflicts have been resolved:


s v nr e s o l v ef i l e n a m e Finally, check-in file: s v nc if i l e n a m e or abort changes: s v nr e v e r tf i l e n a m e

Test merge. No changes are made to your local working copy but shows Subversion feedback as if merge was performed. Undo changes committed in revision 414. Create a new directory under version control. Rename or move a file or directory. Moves/renames file/directory in repository and in local work area. Must perform s v nc if i l e n e w n a m eafter the move for changes to to take place in repository. Undo changes in local work files. Throw away local changes. Run this command after resolving merge conflicts. Next "c o m m i t " your changes. Show status of file changes in current directory and recursively in directories below. Show out of date file info: s v ns t a t u ss h o w u p d a t e s

ads

s v nr e v e r tf i l e n a m e s v nr e s o l v e df i l e n a m e s v ns t a t u s s v ns t a t u su s v ns t a t u su. s v ns t a t u su q.

(equivalent: s v ns t a t u su ) -u: Determines status by comparing your local repository with the server repository. Without this option, the status shown will only be the changes you have made in your local repository. -q: Quiet. Do not print "?: File/directory not under version control" or "!: File/directory missing" extraneous information. First collumn:
http://www.yolinux.com/TUTORIALS/Subversion.html 3/16

1/31/2014

Subversion Commands and Scripts

SteelSeries Zboard Gaming Keyboard SteelSeries New $23.99 D-Link DI-514 Wireless Cable/DSL Rou... D-Link New $59.99 IOGEAR GUC1284B USB to Parallel Adap... IOGEAR New $22.57 D-Link DI-604 Cable/DSL Router, 4-Po... D-Link New $29.95 Sonnet Technologies TSATA SATA PCI A... SONNET TECHNOLOGIE... New $60.24 D-Link DGE-530T 10/100/1000 Gigabit ... D-Link Systems, In... New $21.45 Privacy Information

A: File to be added C: Conflicting changes D: File to be deleted G: File to be merged with updates from server M: File has been modified R: File to be replaced G: File to be merged X: Resource is external to repository (svn:externals) ?: File/directory not under version control !: File/directory missing ~: Versioned item obstructed by some item of a different kind. Second collumn: Modification of properties ' ' no modifications. Working copy is up to date. 'C' Conflicted 'M' Modified '*' Local file different than repository. A newer revision exists on the server. Update will result in merge or possible conflict. Third collumn: Locks ' ' not locked 'L' locked 'S' switched to a branch
s v ns w i t c hh t t p : / / s e r v e r / n e w b r a n c h s v ns w i t c hr e l o c a t eh t t p : / / s e r v e r / o l d p a t h h t t p : / / s e r v e r / n e w p a t h

Switch your local working copy to mirror a new repository branch instead of main trunk or previous branch. Also allows you to point your repository to a new path on the server if the server path changes since you performed a check-out. Migrate all updates from Subversion repository to your local copy (recusively for all files in the current directory and all below it). If there have been updates to the svn repository since you downloaded the files, subversion will give you the opportunity to merge. Status of files will use the coding as stated above for "status". Files marked with a "C" (conflict) should be merged of reverted. If merged then one can perform a "resolve" and then a "check-in". If a file name is specified, only that file is updated. Can also syncronize to a specified revision given by -r. Use --ignore-externals to avoid the slow processing of externals to a potentially slow distant internet server.

Jobs
Softw are/DevOps Engineer New York, NY Sharew ave SDE2 Lead-STBC-Beijing Beijing, Beijing, China Microsoft Need PHP Programmer for Emerging... Kansas City, KS Rx Savings Solutions Window s System Administrator Carrollton, TX MCG - Midw est Consulting Group Linux Expert Hannver, Niedersachsen, Germany Jet Consulting Java Developer - QNX and UNIX -... Frankfurt am Main, Hessen, Germany Optimus Search Limited CAS Softw are Consultant Atlanta, GA Request TechnologyAnthony Honquest Senior Technical

s v nu p d a t e s v nu p d a t ef i l e n a m e s v nu p d a t er 4 5 8f i l e n a m e s v nu p d a t ei g n o r e e x t e r n a l s. /

Where R e v i s i o n N u m b e ris: HEAD: The latest revision in the repository. BASE: The "pristine" revision of an item in a working copy. Matches checked out version before any modifications. COMMITTED: The last revision in which an item changed before (or at) BASE. PREV: The revision just before the last revision in which an item changed. (Technically, COMMITTED - 1.)

Example Session: (Assumes that the repository has already been created. For Subversion repository creation and Subversion server configuration, see the (YoLinux Subversion and Trac tutorial)
4/16

http://www.yolinux.com/TUTORIALS/Subversion.html

1/31/2014
Support Application... Chicago, IL Request TechnologyRobyn Honquest Cloud Customer Success Technologist Bangalore, Karnataka, India Informatica SAP Solution Manager Spezialist (m/w ) Walldorf, BadenWrttemberg, Germany emagine POST A JOB >
POWERED BY JOBTHREAD

Subversion Commands and Scripts

Checkout: s v nc h e c k o u th t t p : / / s v n s e r v e r / r e p o s / s v n / t r u n k / P r o j e c t 1 Go to source code directory: c dP r o j e c t 1 / s r c Edit files:


v if i l e 1 . c p p v if i l e 2 . c p p Verify and test: m a k e

We are ready to check-in the files into the Subversion repository. Check repository and report on new revisions and changes others have checked in: s v ns t a t u su
.

After many long hours or days of editing and work, get updates others have made: s v nu p d a t e
Uf i l e . h Cf i l e 1 . c p p Gf i l e 2 . c p p ?a . o u t

You will see: U: File was updated with a newer version checked-in since your checkout. G: Automatically merged with no conflicts. C: Not merged due to conflicts. You made changes to the same section of code as the update made by someone else since your checkout. For each "conflicted" file there will be three new local files generated by "update": f i l e 1 . c p p . m i n e(File - post editing) f i l e 1 . c p p . r o l d(BASE - pre editing) f i l e 1 . c p p . r n e w(HEAD - Updated file from repository) The file f i l e 1 . c p pstill exists but with svn conflict marker strings added in the file. At this point, a check-in will fail until the merge is resolved. Merge options: Edit the file f i l e 1 . c p p Text markers are placed in the file to show the conflicts between the "HEAD" and "mine" versions. OR
t k d i f fc o n f l i c tf i l e 1 . c p p

OR Use a GUI merge tool: k d i f f 3f i l e 1 . c p p . m i n ef i l e 1 . c p p . r n e wof i l e 1 . c p p OR Throw out your changes/abort: s v nr e v e r tf i l e 1 . c p p No resolve or check-in necessary if file is reverted. Verify and test, again: m a k e Notify Subversion that conflicts have been resolved: s v nr e s o l v e df i l e 1 . c p p Note: This also removes the temporary files ".mine" and ".r###". Check-in to Subversion repository: s v nc im" A d dc o m m e n t sh e r e "f i l e 1 . c p p

Subversion Peg revisions:


Peg revisions are used so Subversion can find a previous version of a resource (file or directory) if its' location was different than it is now. Peg revisions are that extra hint Subversion needs to clear up ambiguity.
$s v nc o m m a n drO P E R A T I V E R E Vi t e m @ P E G R E V

The default peg revision is BASE for working copy items and HEAD for repository URLs. When no operative revision is provided, it defaults to being the same revision as the peg revision. The PEG-REV is specified if the resource (file/directory) in question use to appear in a directory which is no longer in the same place or no longer exists. The "peg-revision" must be specified so subversion can look at the directory in that revision so it can find the resource. If a peg revision is specified without an operative revision, then the operative revision is assumed to be the same as the peg revision. For more see: http://svnbook.red-bean.com/en/1.5/svn.advanced.pegrevs.html

Subversion Properties:
http://www.yolinux.com/TUTORIALS/Subversion.html 5/16

1/31/2014

Subversion Commands and Scripts

Files under revision control can include Subversion keywords which properties can be set with the "propset" command. Keywords are substituted with the Subversion properties and will not appear in the file until a commit is performed. Other properties are used to modify the behavior of Subversion. The following properties can be set on entities stored in Subversion: Property svn:ignore
s v ns t a t u s

Description A newline separated list of file patterns to ignore. List of files/directories to be ignored by

svn:keywords Valid RCS style keywords are: HeadURL - The URL for the head version of the object. Also: $URL$ LastChangedBy - The last person to modify the file. Also: $Author$ LastChangedDate - The date/time the object was last modified. Will appear as: $ L a s t C h a n g e d D a t e :2 0 0 5 0 7 2 22 2 : 0 2 : 3 70 7 0 0( F r i ,2 2J u l
2 0 0 5 )$

Also: $Date$ LastChangedRevision - Describes the last known revision. Will appear as: $ L a s t C h a n g e d R e v i s i o n :X X X $where "XXX" is the revision number. Also: $Rev$, Revision $Id$ - A compressed summary of the previous 4 keywords. Example RCS style comment
/ *$ U R L $ $ R e v $ $ A u t h o r $ $ D a t e $ $ I d $ * /

Example Output
/ *$ U R L : h t t p : / / s e r v e r / s v n / p a t h / f i l e . c p p$ $R e v : 2$ $A u t h o r : G r e g$ $D a t e : 2 0 0 6 1 0 1 21 4 : 3 1 : 8 40 4 0 0( T h u , 1 2O c t2 0 0 6 ) $ $I d : f i l e . c p p32 0 0 6 1 0 1 21 8 : 3 1 : 8 4 ZG r e g$ * /

To turn on keyword processing for $URL$ and $Rev$ set the property s v n : k e y w o r d sand commit the file. The property is not assigned until a commit is performed. Subsequent check-outs and updates will have substitution performed on the working file:
s v np r o p s e ts v n : k e y w o r d s" U R LR e v "s o u r c e f i l e . c p p

To turn this substitution off so that one can edit the original keywords. This also requires a check-in:
s v np r o p d e ls v n : k e y w o r d ss o u r c e f i l e . c p p

svn:executable Ensure file attribute is executable. Possible values: ON, OFF Example: s v np r o p s e ts v n : e x e c u t a b l eO Na p p . e x e svn:eol-style One of 'native', 'LF', 'CR', 'CRLF'. Specify and maintain specified line ending for text file. LF: Unix, Linux, standards based OS, proprietary legacy systems, etc. CRLF: DOS and Microsoft OSs CR: Response input scripts, etc Example: f i n d. /n a m e" * . h "e x e cs v np r o p s e ts v n : e o l s t y l eL F{ }\ ; svn:mime-type The mime type of the file:
t e x t / h t m l t e x t / c s s t e x t / p l a i n i m a g e / j p e g

... See file / e t c / m i m e . t y p e sfor a list of mime types.


http://www.yolinux.com/TUTORIALS/Subversion.html 6/16

1/31/2014

Subversion Commands and Scripts

Examples:
s v np r o p s e ts v n : m i m e t y p et e x t / p l a i nf i l e . c p p s v np r o p s e ts v n : m i m e t y p et e x t / h t m lf i l e . h t m l

Web pages rendered from subversion will display as HTML source rather than as a web page unless this mime type is applied. svn:needslock svn:externals Prevents conflicts for files which can not be contextually merged. i.e. photos, binaries, object libraries. List of files or directories pointed to. Locate repository where directory specified should be retrieved. The directive p r o p s e tis not required:
s v np r o p e d i ts v n : e x t e r n a l sl o c a l t a r g e t d i r l o c a l t a r g e t d i rh t t p : / / s e r v e r / s v n / d i r r e m o t e l o c a l t a r g e t d i r / s u b d i rr # # #h t t p : / / s e r v e r / s v n / d i r r e m o t e 2 s v nu p d a t e s v nc o m m i t s v np r o p g e ts v n : e x t e r n a l s. /

The property applies to the directory. Subversion can not list or web browse svn:externals. Check-out ("co"), "export" and "log" can be performed. Must set environment variable "EDITOR", "SVN_EDITOR", "VISUAL" or set the Subversion configuration file (~ / . s u b v e r s i o n / c o n f i g ) attribute e d i t o r c m d . i.e.: e x p o r t
E D I T O R = v i

Note: Subversion 1.6 introduces file externals in addition to directory externals. The files however must reside in the same repository. Also, the file must point to a location which exists in your local working directory. [Potential Pitfall]: Apply svn externals to directories and not files. (version 1.4) [Potential Pitfall]: If generating a tag (branch), one should assign the revision number to the external link to truly snapshot the repository for that tag. This revision number should be specified in the tagged branch version of the svn external. [Potential Pitfall]: The revision numbers shown by s v ni n f owill reflect the version numbers of the repository in which the files are stored. If the files are imported via an svn external directory, the revision numbers will reflect that of the external repository which the external points to and thus from where the files were imported.

Command
s v np r o p d e lP r o p e r t y N a m ef i l e n a m e s v np r o p d e lr e v p r o prR e v i s i o n N a m e h t t p : / / u r l / p a t h Also: p d e l ,p d s v np r o p e d i tP r o p e r t y N a m ef i l e n a m e s v np r o p e d i tr e v p r o prR e v i s i o n N a m e h t t p : / / u r l / p a t h Also: p e d i t ,p e s v np r o p g e tP r o p e r t y N a m ef i l e n a m e s v np r o p g e tr e v p r o prR e v i s i o n N a m e h t t p : / / u r l / p a t h Also: p g e t ,p g s v np r o p l i s tf i l e n a m e s v np r o p l i s t* s v np r o p l i s tr e v p r o prR e v i s i o n N a m e h t t p : / / u r l / p a t h Also: p l i s t ,p l

Description Remove property name from files or directories. Remove properties on file in repository. Edit property name of files or directories. Edit properties on file in repository. Print value of property name of files or directories. Print properties on file in repository. List properties of file, files or directory.

s v np r o p s e tP R O P N A M EP r o p e r t y V a l u ef i l e - Set properties of file or directory. n a m e Set mime type for a file in the repository. Must perform s v np r o p s e tP R O P N A M Er e v p r o pr a commit to upload changes to the repository. R e v i s i o n N a m eP r o p e r t y V a l u eh t t p : / / u r l / p a t h s v np r o p s e ts v n : m i m e t y p et e x t / h t m lf i l e -

Set file properties so that "^M"'s are removed upon

http://www.yolinux.com/TUTORIALS/Subversion.html

7/16

1/31/2014
n a m e . d a t Also: p s e t ,p s

Subversion Commands and Scripts

check-in:
s v np r o p s e ts v n : e o l s t y l eL Ff i l e n a m e . t x t

See YoLinux Subversion server configuration tutorial: No ctrl-M.

Subversion and Graphical diffs for Linux:


Three types of file differences are covered in this section: 1. Show file differences made since checkout was made. This shows the changes you have made. It is usefull to perform this before an update. 2. Show file differences between two files versions stored in Subversion. 3. Show differences / conflicts, choose and merge. Use our bash script svndiffwrapper which integrates into Subversion's file check-in process.

1) File differences since checkout:


The following scripts will allow you to view the changes you have made since checkout. Use the script before running "s v nu p d a t e " as an update will alter the file with diff chevron (>>>>) markers. After performing a "s v nu p d a t e ", use tkdiff, gtkdiff or kdiff3 as described below instead of the scripts: Use the following bash shell script to use the graphical diff tool "mgdiff" with Subversion. svndiff:
0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 4 0 4 1 4 2 4 3 4 4 4 5 # ! / b i n / b a s h #s v n d i f f1 . 0 #u s a g e :s v n d i f ff i l e #N ol o n g e rv a l i df o rS V N1 . 7a n dl a t e r #( n o. s v n /i ne a c hd i r e c t o r y .N o wo n l ya tt o pd i r e c t o r y ) # i f[ [!d. s v n] ] # t h e n # e c h oE R R O R :Y o ua r en o tw o r k i n gi na nS V Nd i r e c t o r y . # e x i t1 # f i r e v = " r e v i s i o nH E A D " i f[ [!n$ 1] ] t h e n e c h o" U s a g e :s v n d i f f[ o p t i o n ]f i l e " e c h o" O p t i o n s : " e c h o" h D i f fw i t hl a t e s ti nr e p o s i t o r y( H E A D )-D e f a u l t " e c h o" b D i f fw i t hw h a ty o uh a dc h e c k e do u t( B A S E ) " e c h o" c D i f fw i t hC O M M I T T E D ,t h ev e r s i o nb e f o r eB A S E " e c h o" p D i f fw i t hP R E V ,t h ev e r s i o nb e f o r eC O M M I T T E D " e c h o" rr e v n u m D i f fw i t hs p e c i f i e dr e v i s i o n( s p e c i f yi n t e g e r ) " e x i t1 f i w h i l eg e t o p t s" : r : h b c p "O p t i o n d o c a s e$ O p t i o ni n h )r e v = " r e v i s i o nH E A D " ; ; b )r e v = " r e v i s i o nB A S E " ; ; c )r e v = " r e v i s i o nC O M M I T T E D " ; ; p )r e v = " r e v i s i o nP R E V " ; ; r )r e v = " r e v i s i o n$ O P T A R G " ; ; * )e c h o" I n c o r r e c to p t i o ns p e c i f i e d .U s eho rbo rr# " ; ; e s a c d o n e s h i f t$ ( ( $ O P T I N D1 ) ) #D e f i n eg r a p h i c a ld i f ft o o l # #d i f = " / u s r / b i n / k o m p a r e " #T h eg e o m e t r yo p t i o nu s e db yM o t i f ,T c la n dXb a s e dp r o g r a m s

http://www.yolinux.com/TUTORIALS/Subversion.html

8/16

1/31/2014
4 6 4 7 4 8 4 9 5 0 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 6 0 6 1 6 2 6 3 6 4

Subversion Commands and Scripts


g e o m e t r y = " g e o m e t r y1 2 8 0 x 8 0 0 + 0 + 0 " #T h ef o l l o w i n gi sf o rM o t i fd i f f #w :i g n o r ew h i t es p a c e d i f = " m g d i f fa r g sw " f i l e = $ 1 p r e v = $ { f i l e } _ P R E V #T r a pb a s hc o m m a n ds i g n a l s #S I G I N T 2 #S I G Q U I T 3 #S I G T E R M1 5 t r a p" r mf$ p r e v "2 3 1 5 s v nc a t$ r e v$ f i l e> $ p r e v2 > / d e v / n u l l $ d i f$ g e o m e t r y$ p r e v$ f i l e s l e e p1 r mf$ p r e v

Compares your current local copy with the latest in the repository (Default "-h"). OR Use the following bash shell script to use the graphical diff tool "gvimdiff:" with Subversion: svndiff:
0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0 3 1 # ! / b i n / b a s h #u s a g e :s v n d i f ff i l e #N ol o n g e rv a l i df o rS V N1 . 7a n dl a t e r #( n o. s v n /i ne a c hd i r e c t o r y .N o wo n l ya tt o pd i r e c t o r y ) # i f[ [!d. s v n] ] # t h e n # e c h oE R R O R :Y o ua r en o tw o r k i n gi na nS V Nd i r e c t o r y . # e x i t1 # f i #D e f i n eg r a p h i c a ld i f ft o o l # d i f = " g v i m d i f f\ " + c o l om o r n i n g \ "R " f i l e = $ 1 p r e v = P R E V _ $ { f i l e } #T r a pb a s hc o m m a n ds i g n a l s #S I G I N T 2 #S I G Q U I T 3 #S I G T E R M1 5 t r a p" r mf$ p r e v "2 3 1 5 s v nc a t$ f i l e> $ p r e v2 > / d e v / n u l l $ d i f$ p r e v$ f i l e #S l e e pf o rn o n b l o c k i n ga p p sl i k eg v i m d i f f . #A l l o wg v i m d i f ft or e a df i l eb e f o r ei ti sd e l e t e d . s l e e p2 r mf$ p r e v

Compare your current local copy with the original copy you checked out.

2) File differences between two revisions:


This configuration supports the use of GUI diff tools with Subversion by using the command: s v nd i f fr
4 5 7 : 4 5 9d i f f c m d

Some diff tools are supported with native svn. i.e.: s v nd i f fr4 5 7 : 4 5 9d i f f c m dk d i f f 3f i l e n a m e while others require a wrapper script to arrange the arguments correctly. Subversion configurations and defaults are specified in the file: $ H O M E / . s u b v e r s i o n / c o n f i g
. . . . .

http://www.yolinux.com/TUTORIALS/Subversion.html

9/16

1/31/2014

Subversion Commands and Scripts


[ h e l p e r s ] e d i t o r c m d=g e d i t d i f f c m d=/ o p t / b i n / d i f f S c r i p t d i f f 3 c m d=/ o p t / b i n / d i f f 3 S c r i p t . . . . .

This configuration configures Subversion to execute the script / o p t / b i n / d i f f S c r i p tto launch your own diff toolwith the command: s v nd i f frO l d : N e wU R L . File: / o p t / b i n / d i f f S c r i p t
0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 0 1 1 1 2 # ! / b i n / b a s h L e f t L a b e l = $ 3 R i g h t L a b e l = $ 5 L e f t F i l e = $ 6 R i g h t F i l e = $ 7 # g t k d i f f$ L e f t F i l e$ R i g h t F i l e t k d i f f$ L e f t F i l e$ R i g h t F i l eL" $ L e f t L a b e l "L" $ R i g h t L a b e l "& #w a i tf o rc o m m a n dt of i n i s h w a i t

Note: To debug what is passed as a command line argument to the diff tool, set the d i f f c m dto "e c h o ":
. . . . . [ h e l p e r s ] d i f f c m d=e c h o . . . . .

This configuration echos to the screen the command line arguments being passed to the diff tool when the following command is executed: s v nd i f f. . . . . i.e. u-L d0/f01.cpp (revision 1) -L d0/f01.cpp (working copy) d0/.svn/text-base/f01.cpp.svn-base d0/.svn/empty-file

3) Conflicts, file differences and merge:


tkdiff: Subversion conflict resolution merge: t k d i f fc o n f l i c tf i l e 1 . c p p Select from tkdiff toolbar: "Merge" + "Show Merge Window" to open third results window. kdiff3 diff and merge: s v nd i f fr4 5 7 : 4 5 9d i f f c m dk d i f f 3e x t e n s i o n s' m 'f i l e n a m e svndiffwrapper: Bash script to add options to Merge|Ignore|Accept|Revert etc as a result of a check-in. This script does it all!! Edit file: $ H O M E / . s u b v e r s i o n / c o n f i g
. . . [ h e l p e r s ] d i f f c m d=s v n d i f f w r a p p e r d i f f 3 c m d=s v n d i f f w r a p p e r . . .

http://www.yolinux.com/TUTORIALS/Subversion.html

10/16

1/31/2014

Subversion Commands and Scripts

Use our bash script svndiffwrapper to perform this integrated task. By default, uses kdiff3 for diff tool. Can also specify your own choice of diff tool. Place the script in / o p t / b i n /for global use or $ H O M E / b i n /for private user access and set permissions so that script execution is allowed: c h m o du g o + x/ o p t / b i n / s v n d i f f w r a p p e r

List of graphical diff and merge tools:


tkdiff: [download] Comes with tkcvs Subversion GUI front-end. Examples of Subversion diffs with tkdiff: (See: t k d i f fh e l p )
t k d i f fo l d U R L @ r e v An e w U R L @ r e v B t k d i f fr 4 5 7r 4 5 9f i l e n a m e Note: Use command "s v nl o gf i l e n a m e " to

view valid revision numbers for the file. Referencing invalid revision numbers as input to tkdiff will not work. gtkdiff: Has diff3 and merge features. Written with GTK+. After gtkdiff-0.8.0, GNOME desktop required. diffUse: Diff/merge GUI tool. Good line matching features. Supports Unicode. kdiff3: Graphical directory and file diff, merge and edit. KDE3/Qt based. Supports drag and drop. Comes with S.u.S.E. distro. (Cross platform) MS/Windows download available. A very good directory and file diff and merge tool. Difference: k d i f f 3f i l e 1f i l e 2 Difference: k d i f f 3f i l e 1f i l e 2f i l e 3 Difference of two files: k d i f f 3d i r e c t o r y 1 / f i l ed i r e c t o r y 2 Difference: k d i f f 3d i r e c t o r y 1d i r e c t o r y 2 Merge: k d i f f 3d i r e c t o r y 1d i r e c t o r y 2od e s t d i r e c t o r y Merge: k d i f f 3f i l e 1f i l e 2m Merge: k d i f f 3f i l e 1f i l e 2oo u t p u t f i l e Diff with SVN: s v nd i f fr4 5 7 : 4 5 9d i f f c m dk d i f f 3f i l e n a m e Kompare: Ships with (RHEL6/RHEL5/RHEL4/FC3+) KDE SDK. [manual] Included in RPM package "kdesdk". [Potential Pitfall]: RPM installation error:
e r r o r :F a i l e dd e p e n d e n c i e s : p e r l ( D C O P )i sn e e d e db yk d e s d k 3 . 5 . 4 3 . e l 5 . i 3 8 6

Solution: Install the dependency package "kdebindings". mgdiff: Motif-based graphical file difference browser and merge. Comes with S.u.S.E. distro. Meld: Compare, edit and merge. xxdiff: Compare 2 or 3 files and merge. Also compares directories. gvim and gvimdiff Beyond Compare - commercial tool (cross platform)

Subversion GUI interfaces for Linux:


TkSVN / TkCVS: Tcl/Tk based GUI. A very good Unix/Linux and MS/Windows GUI front-end to Subversion. Simple to install (requires tk). Supports GUI diff/merge, branching, tagging, editing, check-in/check-out, ... Installation to / u s r / l o c a l / b i nand l i b(Add to your path.): (requires RPM: t kversion 8.4+)
t a rx z ft k c v s _ 8 _ 0 _ 3 . t a r . g z c dt k c v s _ 8 _ 0 _ 3 . / d o i n s t a l l . t c ln o x/ o p t Configuration: (See: ~ / . t k c v s )

Set default editor and diff tool:


. . . s e tc v s c f g ( e d i t o r )" x t e r mev i m " s e tc v s c f g ( t k d i f f )" t k d i f f "

Also see default config file: / o p t / l i b / t k c v s / t k c v s _ d e f . t c l Sets default editors for various file types. Set editor to "gedit" for rookies. If you want to run TkSVN / TkCVS on MS/Windows, download Tk for MS/Windows. It can also be run from the Cygwin environment using Tk provided in the Cygwin shell. Tigris.org: RapidSVN: Dependent on wxWidgets cross platform C++ GUI API.
http://www.yolinux.com/TUTORIALS/Subversion.html 11/16

1/31/2014

Subversion Commands and Scripts

Download RPMs from RpmForge.org: rapidsvn-0.7.2-1.2.el4.rf.i386.rpm wxGTK-2.4.2-5.2.el4.rf.i386.rpm pysvn: Python subversion front-end. (cross platform) [download] eSVN: qt based GUI. Mediocre. KdeSvn: KDE front-end. Subcommander: Subversion GUI client with visual diff and merge tool with support for different text encodings Subview: GTK based subversion (1.3+) client. JSVN: Java SVN client Syncro SVN Client - Commercial product. Editor, diff tool and SVN client in one integrated tool. Web Clients: Kamikaze-qscm: Web based front-end similar to Mozilla Bonsai. ViewSVN: PHP4 Easy SVN: PERL cgi Plug-ins: Rabbitvcs: GNOME Nautilus file browser SVN plug-in. Google code project to develop TortoiseSVN clone in Linux Nautilus file manager. Best prospect for my next favorite SVN client. Will also support other Gnome applications. YoLinux RabbitVCS tutorial NaughtySVN: GNOME Nautilus file browser SVN plug-in. Ksvn: Subversion client plugin for the KDE Konqueror browser. Eclipse plug-ins: Tigris.org: subclipse Also see: C/C++ development environment and Eclipse Subversive Note: A Subversion client is built into many of today's development IDEs such as NetBeans. Comparison chart of Subversion clients

Subversion Security Tips:


One should be aware of a possible Subversion client security hole. The Subversion client authentication will cache your login and password in your home directory in non-encrypted clear text. It will have file system security so others can not read the file however, it still is visible by root or by a root user of the file server if one is used for home directories. Here are three solutions to reduce this potential security vulnerability: 1. Don't allow Subversion to cache the password: s v nc o m m i tFf i l e . t x tn o a u t h c a c h e This will request a username and password but will not store it. 2. Set the Subversion configuration file on server to not cache:
[ a u t h ] s t o r e a u t h c r e d s=n o

3. Delete cached files when you logout. Reduces risk but does not eliminate it. This uses the bash shell logout script to perform a clean-up of the authentication files. File: ~/.bash_logout
1 r m~ / . s u b v e r s i o n / a u t h / s v n . s i m p l e / *

Subversion utility commands and scripts:


http://www.yolinux.com/TUTORIALS/Subversion.html 12/16

1/31/2014

Subversion Commands and Scripts

Command svnversion local-path svnchangesince svnlastlog svnlastchange svn-clean

Description This svn admin command will produce a compact version number for a working copy. Lists range of versions, adds "S" if switched, "M" modified. Shows the changes to the subversion repository since the local copy was last updated. Displays the last log message that pertains to the current working copy. Simplified svnlastchange. Displays the last log message and a unified diff of the changes made in the last commit. Removes all the files and directories that are not in Subversion.

Report Generation: Often one will have to generate a report or source list. The following awk script and command will generate a simple source version description report: File: s v d _ r e p o r t . a w k
1 2 3 4 5 6 7 8 B E G I N{R S = " " ; F S=" \ n " ; p r i n t f ( " % 7 5 s% 1 0 s% 1 0 s% 4 5 s \ n " , " P a t h " , " C u rR e v " , " L a s tR e v " , " L a s t C h a n g eD a t e " ) ;} / ^ P a t h : /{n 1=s p l i t ( $ 1 , p a t h , " : " ) ; n 2=s p l i t ( $ 6 , c u r R e v , " : " ) ; n 3=s p l i t ( $ 9 , l a s t R e v , " : " ) ; n 4=s p l i t ( $ 1 0 , c h a n g e D a t e , " :" ) ; p r i n t f ( " % 7 5 s% 8 s% 8 s% 4 5 s \ n " ,p a t h [ 2 ] ,c u r R e v [ 2 ] ,l a s t R e v [ 2 ] , c h a n g e D a t e [ 2 ] ) ;}

Command to generate the report: From working repository: s v ni n f oR*|a w kfs v d _ r e p o r t . a w k From SVN URL: s v ni n f oRh t t p : / / c m . m e g a c o r p . c o m / s v n / P r o j X / t r u n k|a w kf
s v d _ r e p o r t . a w k

The Subversion "info" command will generate a dump of information about all of the files under Subversion control recursively (-R) through all subdirectories. The AWK script will parse the output and generate a simple report. The AWK script views the Subversion output as an AWK record seperated by blank line where the content of each line is deliminated by the ":" (colon). For more information on AWK scripts, see the awk man page This can be used by a web bash CGI script SubversionSVD.cgi to perform this task via the web.

Subversion Best Practices:


ALWAYS compile and test before checking in source code. Subversion revisions should correspond to revisions which compile. Always add check-in comments. Nothing is more obnoxious that looking at a blank log or information history. Monstrous binary files like CD or DVD ISO images are better suited for storage on a file system rather than in Subversion. Subversion will not be able to show differences betwen version and will be slower than a raw filesystem. Don't copy, rename and move directories and files with system shell commands. Use Subversion commands to "rm", "mv", and "add" directories and files and then commit changes when done. Work within Subversion. Commit changes as a single logical changeset for one purpose. Thus all code changes for a single bug fix or enhancement should be checked-in together. This allows one to better follow the history log of changes. Check-in code at the directory level and all changed files, recursively in the directory and subdirectories will be checked in together.
s v nc im" C h e c k i nc o m m e n tg o e sh e r e ". /

http://www.yolinux.com/TUTORIALS/Subversion.html

13/16

1/31/2014

Subversion Commands and Scripts

Check-in files together by specifying them explicitly:


s v nc im" C h e c k i nc o m m e n tg o e sh e r e "f i l e . c p pf i l e 2 . c p p. . .

Tie Bug tracking and Subversion CM together: Use comments when checking-in files into Subversion. Add bug tracking numbers to the comments so Subversion will reference Trac bugs. If using Trac, add trac comments so that links are generated to the Subversion repository by placing the Subversion revision number in square braces (i.e. [1140]) in a Trac comment. In this way, Trac will have a direct URL link to Subversion. If using Trac integrated with Subversion, refer to the Trac ticket in the Subversion check-in comment using a "#" in front of the Trac ticket number (eg. #65) This generates a hyperlink when the Subversion logs are viewed in Trac. Taking code from a Subversion repository for upload to another: Use "s v ne x p o r t " and NOT "s v n c o " if you want files for upload into another CM repository. A checkout (s v nc o ) will create Subversion management directories (. s v n / ) in the local working copy. You will not want to upload this directories into a CM system as they are only for the user's local working directory only. An "export" will not create this directory. The "tags" branches are NOT to be used as working branches but are snapshots of an existing branch. The "tags" are for historical reference such as a release, well tested version or progress milestone. Documentation and related artifacts should not be under the source tree but parallel to it. This isolates the source tree so that email notification triggers sent to developers upon source changes will only go out on source changes or regression build and test systems like Jenkins or Cabie will only rebuild and test on source changes rather than on unrelated documentation changes.

Tips:
Using Eclipse IDE with Subversion: Block Eclipse from viewing the hidden ".svn/" directories so that Eclipse does not intrude or alter their contents: Select the toolbar options: "Project" + "Properties" Select the "Java Build Path" + select the "Source" tab Select the "Excluded" item and select "Edit" In the lower half under "Exclusion patterns:" select "Add..." and enter the pattern **/.svn/* Note that SVN version 1.7 and later generate a single . s v n /directory at the top directory and no longer produce a . s v n /directory in each subdirectory.

http://www.yolinux.com/TUTORIALS/Subversion.html

14/16

1/31/2014

Subversion Commands and Scripts

Links:
YoLinux Tutorial: Subversion Server and Trac Server Installation and Configuration YoLinux Tutorial: Cabie Build System - Installation and Configuration svnbook.red-bean.com: Open Sourced version of O'Reily Book Subversion 1.1 - single page Subversion 1.1 - multi-page Reference card [pdf] Subversionary: Subversion advocacy web site. Integrating JDeveloper and Subversion

Books:
Version Control with Subversion by C. Michael Pilato ISBN #0596004486, O'Reilly Press

Practical Subversion (Expert's Voice in Open Source) Garrett Rooney ISBN #1590592905, Apress

Subversion Version Control: Using the Subversion Version Control System in Development Projects William Nagel ISBN #0131855182, Prentice Hall PTR

http://www.yolinux.com/TUTORIALS/Subversion.html

15/16

1/31/2014

Subversion Commands and Scripts

to top of page YoLinux.com Home Page YoLinux Tutorial Index | Terms Privacy Policy | Advertise with us | Feedback Form | Unauthorized copying or redistribution prohibited. Copyright 2006-2013 by Greg Ippolito

StumbleUpon 18 487

SVN 1.8
www.vercue.com The Free and Most Feature-Rich Automated Subversion 1.8 Client

http://www.yolinux.com/TUTORIALS/Subversion.html

16/16

You might also like