Skip to content

Instantly share code, notes, and snippets.

@MWers
Created November 7, 2013 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MWers/7359905 to your computer and use it in GitHub Desktop.
Save MWers/7359905 to your computer and use it in GitHub Desktop.
SVN Presentation

svn update - full

Update all files in your workarea

$ svnupdateall
U    web/public/partners/premium_travel.cfm
U    web/public/premiumlanding/surf_travel_discounts.cfm
U    web/public/xml/inc_rep_data_tides.cfm
U    web/public/xml/allspots.xml
Updated to revision 76999.

svn update - partial

Update files in the current directory

$ cd web/public/surfdata
$ svn update
U    report_userview.cfm
Updated to revision 77007.

svn status

svn status [file or directory]

Print the status of working copy files and directories

$ cd web/public/test/mwalker/mongodb
$ svn status
?       simpletest-prod.cfm
?       save.cfm
?       cfset.cfm
?       prefill_benchmark.cfm

svn add

svn add [file or directory]

Add files or directories to the svn repository

$ cd web/public/test/mwalker/mongodb
$ svn add prefill_benchmark.cfm
A         prefill_benchmark.cfm

svn commit

svn commit -m "comment" [file or directory]

Send changes from your working copy to the svn repository.

$ svn commit -m "Prefill MongoDB with data for benchmarking" prefill_benchmark.cfm
Adding         prefill_benchmark.cfm
Transmitting file data .
Committed revision 77009.

svn commit must be performed after almost all svn operations to finalize them.

Good comments are important! :-)

svn move

svn move source destination

Move a file or directory

$ svn move dsn.cfm dsn_generator.cfm
A         dsn_generator.cfm
D         dsn.cfm
$ svn commit -m "moved dsn to dsn_generator"
Deleting       cf/dsn.cfm
Adding         cf/dsn_generator.cfm

Committed revision 77016.

svn move

Don't use UNIX mv in SVN repo

Don't use FTP directory rename in SVN repo

This will break things :(

svn copy

svn copy source destination

Copy a file or directory

$ svn copy dsn_generator.cfm dsn_generator_for_dev.cfm
A         dsn_generator_for_dev.cfm
$ svn commit -m "new dsn generator for dev coldfusion" dsn_generator_for_dev.cfm
Adding         dsn_generator_for_dev.cfm

Committed revision 77018.

svn copy

Don't use UNIX cp in SVN repo

Don't use FTP copy in SVN repo

This will break things :(

svn delete

svn delete [file or directory]

Delete a file or directory

$ svn delete report.cfm
D         report.cfm
$ svn commit -m "Deleted old version" report.cfm
Deleting       report.cfm

Committed revision 77045.

svn log

svn log [file or directory]

Display commit log messages

$ svn log Application.cfm
------------------------------------------------------------------------
r76957 | mwalker | 2012-02-17 09:55:44 -0800 (Fri, 17 Feb 2012) | 1 line

Added /sitemap.xml to whitelist and changed content-type for xml
------------------------------------------------------------------------
r76880 | mwalker | 2012-02-16 10:25:23 -0800 (Thu, 16 Feb 2012) | 1 line

removed blank line at end of file
------------------------------------------------------------------------
[...]
------------------------------------------------------------------------

svn blame

svn blame [file or directory]

Show author and revision information inline for the specified files

$ svn blame report_hd.cfm
63939       jayv <!-- if no id, redirect -->
46046  christian <cfparam name="url.id" default="">
46046  christian <cfif url.id EQ "">
46046  christian <cfheader name="location" value="/surf-cam
46046  christian <cfheader statuscode="302" statustext="Doc
46046  christian <cfabort>
46046  christian </cfif>
61704       grae
46046  christian <!-- load article -->
46046  christian <cfscript>loadArticle(url.id,'spotData'

svn diff

svn diff [file or directory]

This displays the differences between two revisions

$ svn diff test-using-cfc.cfm
Index: test-using-cfc.cfm
===================================================================
--- test-using-cfc.cfm	(revision 76999)
+++ test-using-cfc.cfm	(working copy)
@@ -22,10 +22,19 @@
 	<strong>get:</strong><br />
-	redis.get("test:commands:nonexistent")<br />
+	redis.get("test:commands:nonexistent"):
 	<cfdump var="#request.redis.get("test:commands:nonexistent")#" label="">

Rolling back files by revision number

  1. Use svn log to determine revision number
  2. Roll back to the old version
  3. svn merge -r HEAD:revision_number [file or directory]
  4. Commit

Rolling back files by revision number

$ svn log report.cfm
[... log messages ...]
$ svn merge -r HEAD:77024 report.cfm
--- Reverse-merging r77025 into 'report.cfm':
U    report.cfm
$ svn commit -m "rolled back to important update" report.cfm
Sending        report.cfm
Transmitting file data .
Committed revision 77026.

Rolling back files by timestamp

  1. Determine time at which file was "good"
  2. Roll back to the old version
  3. svn merge -r HEAD:'{timestamp}' [file or directory]
  4. Commit

Rolling back files by timestamp

$ svn merge -r HEAD:'{2012-02-22 11:16:30}' report.cfm
--- Reverse-merging r77027 through r77024 into 'report.cfm':
U    report.cfm
$ svn commit -m "rolled back to initial revision" report.cfm
Sending        report.cfm
Transmitting file data .
Committed revision 77028.

Resolving conflicts

$ svn update report.cfm
Conflict discovered in 'report.cfm'.
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: df

df - view differences
mc - use your version of the conflicting code and discard their changes
tc - use their version of the conflicting code and discard your changes
e - manually edit file to resolve conflicts
s - show all options with explanations

Caution: p will add both versions to your file with conflict markers, make sure to edit it to resolve conflicts before committing

Command Aliases

  • svnst - svn stat with colored output

  • svnup - svn update with colored logs of changes since last update

  • svndiff - svn diff with colored output

  • svnlog - svn log with colored output

  • svnblame - svn blame with colored output

Resources

Version Control with Subversion

http://svnbook.red-bean.com/

$ svn help
[... list of available svn commands ...]
$ svn help [commandname]
[... command usage info ...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment