CINXE.COM

Version Control with Subversion

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Version Control with Subversion</title><link rel="stylesheet" type="text/css" href="styles.css"></link><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"></meta></head><body><div class="book"><div class="titlepage"><div><div><h1 class="title"><a id="svn"></a>Version Control with Subversion</h1></div><div><h2 class="subtitle">For Subversion 1.7</h2></div><div><h2 class="subtitle">(Compiled from r6066)</h2></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Ben</span> <span class="surname">Collins-Sussman</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Brian W.</span> <span class="surname">Fitzpatrick</span></h3></div><div class="author"><h3 class="author"><span class="firstname">C. Michael</span> <span class="surname">Pilato</span></h3></div></div></div><div><p class="copyright">Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ben Collins-Sussman, Brian W. Fitzpatrick, C. Michael Pilato</p></div><div><div class="legalnotice"><a id="idm33"></a><p>This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit <a class="ulink" href="http://creativecommons.org/licenses/by/2.0/" target="_top">http://creativecommons.org/licenses/by/2.0/</a> or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.</p></div></div></div><hr></hr></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="preface"><a href="#svn.foreword">Foreword</a></span></dt><dt><span class="preface"><a href="#svn.preface">Preface</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.intro.whatis">What Is Subversion?</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.intro.righttool">Is Subversion the Right Tool?</a></span></dt><dt><span class="sect2"><a href="#svn.intro.history">Subversion's History</a></span></dt><dt><span class="sect2"><a href="#svn.intro.architecture">Subversion's Architecture</a></span></dt><dt><span class="sect2"><a href="#svn.intro.components">Subversion's Components</a></span></dt><dt><span class="sect2"><a href="#svn.intro.whatsnew">What's New in Subversion</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.preface.audience">Audience</a></span></dt><dt><span class="sect1"><a href="#svn.preface.howread">How to Read This Book</a></span></dt><dt><span class="sect1"><a href="#svn.preface.organization">Organization of This Book</a></span></dt><dt><span class="sect1"><a href="#svn.preface.free">This Book Is Free</a></span></dt><dt><span class="sect1"><a href="#svn.preface.acks">Acknowledgments</a></span></dt></dl></dd><dt><span class="chapter"><a href="#svn.basic">1. Fundamental Concepts</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.basic.version-control-basics">Version Control Basics</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.basic.repository">The Repository</a></span></dt><dt><span class="sect2"><a href="#svn.basic.working-copy">The Working Copy</a></span></dt><dt><span class="sect2"><a href="#svn.basic.vsn-models">Versioning Models</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.basic.vsn-models.problem-sharing">The problem of file sharing</a></span></dt><dt><span class="sect3"><a href="#svn.basic.vsn-models.lock-unlock">The lock-modify-unlock solution</a></span></dt><dt><span class="sect3"><a href="#svn.basic.vsn-models.copy-merge">The copy-modify-merge solution</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.basic.in-action">Version Control the Subversion Way</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.basic.svn-repositories">Subversion Repositories</a></span></dt><dt><span class="sect2"><a href="#svn.basic.in-action.revs">Revisions</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.reposurls">Addressing the Repository</a></span></dt><dt><span class="sect2"><a href="#svn.basic.in-action.wc">Subversion Working Copies</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.basic.in-action.track-repos">How the working copy works</a></span></dt><dt><span class="sect3"><a href="#svn.basic.in-action.wc-funcdamentals">Fundamental working copy interactions</a></span></dt><dt><span class="sect3"><a href="#svn.basic.in-action.mixedrevs">Mixed-revision working copies</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.basic.summary">Summary</a></span></dt></dl></dd><dt><span class="chapter"><a href="#svn.tour">2. Basic Usage</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.tour.help">Help!</a></span></dt><dt><span class="sect1"><a href="#svn.tour.importing">Getting Data into Your Repository</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.tour.importing.import">Importing Files and Directories</a></span></dt><dt><span class="sect2"><a href="#svn.tour.importing.layout">Recommended Repository Layout</a></span></dt><dt><span class="sect2"><a href="#svn.tour.importing.naming">What's In a Name?</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.tour.initial">Creating a Working Copy</a></span></dt><dt><span class="sect1"><a href="#svn.tour.cycle">Basic Work Cycle</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.tour.cycle.update">Update Your Working Copy</a></span></dt><dt><span class="sect2"><a href="#svn.tour.cycle.edit">Make Your Changes </a></span></dt><dt><span class="sect2"><a href="#svn.tour.cycle.examine">Review Your Changes</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.tour.cycle.examine.status">See an overview of your changes</a></span></dt><dt><span class="sect3"><a href="#svn.tour.cycle.examine.diff">Examine the details of your local modifications</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.tour.cycle.revert">Fix Your Mistakes</a></span></dt><dt><span class="sect2"><a href="#svn.tour.cycle.resolve">Resolve Any Conflicts</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.tour.cycle.resolve.diff">Viewing conflict differences interactively</a></span></dt><dt><span class="sect3"><a href="#svn.tour.cycle.resolve.resolve">Resolving conflict differences interactively</a></span></dt><dt><span class="sect3"><a href="#svn.tour.cycle.resolve.pending">Postponing conflict resolution</a></span></dt><dt><span class="sect3"><a href="#svn.tour.cycle.resolve.byhand">Merging conflicts by hand</a></span></dt><dt><span class="sect3"><a href="#svn.tour.cycle.resolve.theirsfull">Discarding your changes in favor of a newly fetched revision</a></span></dt><dt><span class="sect3"><a href="#svn.tour.cycle.resolve.revert">Punting: using svn revert</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.tour.cycle.commit">Commit Your Changes</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.tour.history">Examining History</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.tour.history.diff">Examining the Details of Historical Changes</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.tour.history.diff.local">Examining local changes</a></span></dt><dt><span class="sect3"><a href="#svn.tour.history.diff.wcrepos">Comparing working copy to repository</a></span></dt><dt><span class="sect3"><a href="#svn.tour.history.diff.reposrepos">Comparing repository revisions</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.tour.history.log">Generating a List of Historical Changes</a></span></dt><dt><span class="sect2"><a href="#svn.tour.history.browsing">Browsing the Repository</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.tour.history.browsing.cat">Displaying file contents</a></span></dt><dt><span class="sect3"><a href="#svn.tour.history.browsing.annotate">Displaying line-by-line change attribution</a></span></dt><dt><span class="sect3"><a href="#svn.tour.history.browsing.list">Listing versioned directories</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.tour.history.snapshots">Fetching Older Repository Snapshots</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.tour.cleanup">Sometimes You Just Need to Clean Up</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.tour.cleanup.disposal">Disposing of a Working Copy</a></span></dt><dt><span class="sect2"><a href="#svn.tour.cleanup.interruption">Recovering from an Interruption</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.tour.treeconflicts">Dealing with Structural Conflicts</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.tour.treeconflicts.example">An Example Tree Conflict</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.tour.summary">Summary</a></span></dt></dl></dd><dt><span class="chapter"><a href="#svn.advanced">3. Advanced Topics</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.tour.revs.specifiers">Revision Specifiers</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.tour.revs.keywords">Revision Keywords</a></span></dt><dt><span class="sect2"><a href="#svn.tour.revs.dates">Revision Dates</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.advanced.pegrevs">Peg and Operative Revisions</a></span></dt><dt><span class="sect1"><a href="#svn.advanced.props">Properties</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.props.why">Why Properties?</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.props.manip">Manipulating Properties</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.props.workflow">Properties and the Subversion Workflow</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.props.auto">Automatic Property Setting</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.advanced.props.file-portability">File Portability</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.props.special.mime-type">File Content Type</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.props.special.executable">File Executability</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.props.special.eol-style">End-of-Line Character Sequences</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.advanced.props.special.ignore">Ignoring Unversioned Items</a></span></dt><dt><span class="sect1"><a href="#svn.advanced.props.special.keywords">Keyword Substitution</a></span></dt><dt><span class="sect1"><a href="#svn.advanced.sparsedirs">Sparse Directories</a></span></dt><dt><span class="sect1"><a href="#svn.advanced.locking">Locking</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.locking.creation">Creating Locks</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.locking.discovery">Discovering Locks</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.locking.break-steal">Breaking and Stealing Locks</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.locking.lock-communication">Lock Communication</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.advanced.externals">Externals Definitions</a></span></dt><dt><span class="sect1"><a href="#svn.advanced.changelists">Changelists</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.changelists.creating">Creating and Modifying Changelists</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.changelists.asfilters">Changelists As Operation Filters</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.changelists.limitations">Changelist Limitations</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.serverconfig.netmodel">Network Model</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.serverconfig.netmodel.reqresp">Requests and Responses</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.netmodel.creds">Client Credentials</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.netmodel.credcache">Caching credentials</a></span></dt><dt><span class="sect3"><a href="#svn.tour.initial.disabling-password-caching">Disabling password caching</a></span></dt><dt><span class="sect3"><a href="#svn.tour.initial.authn-cache-purge">Removing cached credentials</a></span></dt><dt><span class="sect3"><a href="#svn.tour.initial.different-user">Command-line authentication</a></span></dt><dt><span class="sect3"><a href="#svn.tour.initial.authn-wrapup">Authentication wrap-up</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.advanced.summary">Summary</a></span></dt></dl></dd><dt><span class="chapter"><a href="#svn.branchmerge">4. Branching and Merging</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.branchmerge.whatis">What's a Branch?</a></span></dt><dt><span class="sect1"><a href="#svn.branchmerge.using">Using Branches</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.branchmerge.using.create">Creating a Branch</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.using.work">Working with Your Branch</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.using.concepts">The Key Concepts Behind Branching</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.branchmerge.basicmerging">Basic Merging</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.branchmerge.changesets">Changesets</a></span></dt><dt><span class="sect2"><a href="#svn.branchemerge.basicmerging.stayinsync">Keeping a Branch in Sync</a></span></dt><dt><span class="sect2"><a href="#svn.branchemerge.basicmerging.stayinsync.subtree">Subtree Merges and Subtree Mergeinfo</a></span></dt><dt><span class="sect2"><a href="#svn.branchemerge.basicmerging.reintegrate">Reintegrating a Branch</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.basicmerging.mergeinfo">Mergeinfo and Previews</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.basicmerging.undo">Undoing Changes</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.basicmerging.resurrect">Resurrecting Deleted Items</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.branchmerge.advanced">Advanced Merging</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.branchmerge.cherrypicking">Cherrypicking</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.advancedsyntax">Merge Syntax: Full Disclosure</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.nomergedata">Merges Without Mergeinfo</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.mergeconflicts">More on Merge Conflicts</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.blockchanges">Blocking Changes</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.reintegratetwice">Keeping a Reintegrated Branch Alive</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.logblame">Merge-Sensitive Logs and Annotations</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.ancestry">Noticing or Ignoring Ancestry</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.moves">Merges and Moves</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.pre1.5clients">Preventing Naïve Clients from Committing Merges</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.finalword">The Final Word on Merge Tracking</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.branchmerge.switchwc">Traversing Branches</a></span></dt><dt><span class="sect1"><a href="#svn.branchmerge.tags">Tags</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.branchmerge.tags.mksimple">Creating a Simple Tag</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.tags.mkcomplex">Creating a Complex Tag</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.branchmerge.maint">Branch Maintenance</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.branchmerge.maint.layout">Repository Layout</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.maint.lifetime">Data Lifetimes</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.branchmerge.commonpatterns">Common Branching Patterns</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.branchmerge.commonpatterns.release">Release Branches</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.commonpatterns.feature">Feature Branches</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.advanced.vendorbr">Vendor Branches</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.vendorbr.general">General Vendor Branch Management Procedure</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.vendorbr.svn_load_dirs">svn_load_dirs.pl</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.branchmerge.when">To Branch or Not to Branch?</a></span></dt><dt><span class="sect1"><a href="#svn.branchmerge.summary">Summary</a></span></dt></dl></dd><dt><span class="chapter"><a href="#svn.reposadmin">5. Repository Administration</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.reposadmin.basics">The Subversion Repository, Defined</a></span></dt><dt><span class="sect1"><a href="#svn.reposadmin.planning">Strategies for Repository Deployment</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.reposadmin.projects.chooselayout">Planning Your Repository Organization</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.basics.hosting">Deciding Where and How to Host Your Repository</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.basics.backends">Choosing a Data Store</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.reposadmin.basics.backends.bdb">Berkeley DB</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.basics.backends.fsfs">FSFS</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.reposadmin.create">Creating and Configuring Your Repository</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.reposadmin.basics.creating">Creating the Repository</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.create.hooks">Implementing Repository Hooks</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.create.bdb">Berkeley DB Configuration</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.create.fsfs">FSFS Configuration</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.reposadmin.maint">Repository Maintenance</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.reposadmin.maint.tk">An Administrator's Toolkit</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.svnadmin">svnadmin</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.svnlook">svnlook</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.svndumpfilter">svndumpfilter</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.svnrdump">svnrdump</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.svnsync">svnsync</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.fsfsreshard">fsfs-reshard.py</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.bdbutil">Berkeley DB utilities</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.reposadmin.maint.setlog">Commit Log Message Correction</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.maint.diskspace">Managing Disk Space</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.reposadmin.maint.diskspace.deltas">How Subversion saves disk space</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.diskspace.deadtxns">Removing dead transactions</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.diskspace.bdblogs">Purging unused Berkeley DB logfiles</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.diskspace.fsfspacking">Packing FSFS filesystems</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.reposadmin.maint.recovery">Berkeley DB Recovery</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.maint.migrate">Migrating Repository Data Elsewhere</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.reposadmin.maint.migrate.svnadmin">Repository data migration using svnadmin</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.migrate.svnrdump">Repository data migration using svnrdump</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.reposadmin.maint.filtering">Filtering Repository History</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.maint.replication">Repository Replication</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.reposadmin.maint.replication.svnsync">Replication with svnsync</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.replication.svnsync-partial">Partial replication with svnsync</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.replication.svnsync-init-nonempty">A quick trick for mirror creation</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.replication.wrapup">Replication wrap-up</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.reposadmin.maint.backup">Repository Backup</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.maint.uuids">Managing Repository UUIDs</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.reposadmin.maint.moving-and-removing">Moving and Removing Repositories</a></span></dt><dt><span class="sect1"><a href="#svn.reposadmin.summary">Summary</a></span></dt></dl></dd><dt><span class="chapter"><a href="#svn.serverconfig">6. Server Configuration</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.serverconfig.overview">Overview</a></span></dt><dt><span class="sect1"><a href="#svn.serverconfig.choosing">Choosing a Server Configuration</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.serverconfig.choosing.svnserve">The svnserve Server</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.choosing.svn-ssh">svnserve over SSH</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.choosing.apache">The Apache HTTP Server</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.choosing.recommendations">Recommendations</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.serverconfig.svnserve">svnserve, a Custom Server</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.serverconfig.svnserve.invoking">Invoking the Server</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.invoking.daemon">svnserve as daemon</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.invoking.inetd">svnserve via inetd</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.invoking.tunnel">svnserve over a tunnel</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.invoking.winservice">svnserve as a Windows service</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.invoking.launchd">svnserve as a launchd job</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.serverconfig.svnserve.auth">Built-in Authentication and Authorization</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.auth.users">Create a users file and realm</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.auth.general">Set access controls</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.serverconfig.svnserve.sasl">Using <span class="command"><strong>svnserve</strong></span> with SASL</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.sasl.authn">Authenticating with SASL</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.sasl.encryption">SASL encryption</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.serverconfig.svnserve.sshauth">Tunneling over SSH</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.svnserve.sshtricks">SSH Configuration Tricks</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.sshtricks.setup">Initial setup</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.sshtricks.fixedcmd">Controlling the invoked command</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.serverconfig.httpd">httpd, the Apache HTTP Server</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.serverconfig.httpd.prereqs">Prerequisites</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.httpd.basic">Basic Apache Configuration</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.httpd.authn">Authentication Options</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.httpd.authn.basic">Basic authentication</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.authn.digest">Digest authentication</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.serverconfig.httpd.authz">Authorization Options</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.httpd.authz.blanket">Blanket access control</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.authz.perdir">Per-directory access control</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.authz.pathauthzoff">Disabling path-based checks</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.serverconfig.httpd.ssl">Protecting network traffic with SSL</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.httpd.ssl.server">Subversion server SSL certificate configuration</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.ssl.client">Subversion client SSL certificate management</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.serverconfig.httpd.extra">Extra Goodies</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.httpd.extra.browsing">Repository browsing</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.extra.logging">Apache logging</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.extra.writethruproxy">Write-through proxying</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.extra.other">Other Apache features</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.serverconfig.pathbasedauthz">Path-Based Authorization</a></span></dt><dt><span class="sect1"><a href="#svn.serverconfig.operational-logging">High-level Logging</a></span></dt><dt><span class="sect1"><a href="#svn.serverconfig.optimization">Server Optimization</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.serverconfig.optimization.caching">Data Caching</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.optimization.compression">Network Compression of Data</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.serverconfig.multimethod">Supporting Multiple Repository Access Methods</a></span></dt></dl></dd><dt><span class="chapter"><a href="#svn.customization">7. Customizing Your Subversion Experience</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.advanced.confarea">Runtime Configuration Area</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.confarea.layout">Configuration Area Layout</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.confarea.windows-registry">Configuration and the Windows Registry</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.confarea.opts">Configuration Options</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.advanced.confarea.opts.servers">Servers</a></span></dt><dt><span class="sect3"><a href="#svn.advanced.confarea.opts.config">Config</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.advanced.l10n">Localization</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.l10n.understanding">Understanding Locales</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.l10n.svnuse">Subversion's Use of Locales</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.advanced.externaleditors">Using External Editors</a></span></dt><dt><span class="sect1"><a href="#svn.advanced.externaldifftools">Using External Differencing and Merge Tools</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.externaldifftools.diff">External diff</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.externaldifftools.diff3">External diff3</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.externaldifftools.merge">External merge</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.customization.summary">Summary</a></span></dt></dl></dd><dt><span class="chapter"><a href="#svn.developer">8. Embedding Subversion</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.developer.layerlib">Layered Library Design</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.developer.layerlib.repos">Repository Layer</a></span></dt><dt><span class="sect2"><a href="#svn.developer.layerlib.ra">Repository Access Layer</a></span></dt><dt><span class="sect2"><a href="#svn.developer.layerlib.client">Client Layer</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.developer.usingapi">Using the APIs</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.developer.usingapi.apr">The Apache Portable Runtime Library</a></span></dt><dt><span class="sect2"><a href="#svn.developer.usingapi.funcsbatons">Functions and Batons</a></span></dt><dt><span class="sect2"><a href="#svn.developer.usingapi.urlpath">URL and Path Requirements</a></span></dt><dt><span class="sect2"><a href="#svn.developer.usingapi.otherlangs">Using Languages Other Than C and C++</a></span></dt><dt><span class="sect2"><a href="#svn.developer.usingapi.codesamples">Code Samples</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.developer.summary">Summary</a></span></dt></dl></dd><dt><span class="chapter"><a href="#svn.ref">9. Subversion Complete Reference</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.ref.svn">svn—Subversion Command-Line Client</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svn.sw">svn Options</a></span></dt><dt><span class="sect2"><a href="#svn.ref.svn.c">svn Subcommands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.add">svn add</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.blame">svn blame (praise, annotate, ann)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.cat">svn cat</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.changelist">svn changelist (cl)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.checkout">svn checkout (co)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.cleanup">svn cleanup</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.commit">svn commit (ci)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.copy">svn copy (cp)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.delete">svn delete (del, remove, rm)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.diff">svn diff (di)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.export">svn export</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.help">svn help (h, ?)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.import">svn import</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.info">svn info</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.list">svn list (ls)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.lock">svn lock</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.log">svn log</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.merge">svn merge</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.mergeinfo">svn mergeinfo</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.mkdir">svn mkdir</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.move">svn move (mv)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.patch">svn patch</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.propdel">svn propdel (pdel, pd)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.propedit">svn propedit (pedit, pe)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.propget">svn propget (pget, pg)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.proplist">svn proplist (plist, pl)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.propset">svn propset (pset, ps)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.relocate">svn relocate</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.resolve">svn resolve</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.resolved">svn resolved</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.revert">svn revert</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.status">svn status (stat, st)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.switch">svn switch (sw)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.unlock">svn unlock</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.update">svn update (up)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.upgrade">svn upgrade</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.ref.svnadmin">svnadmin—Subversion Repository Administration</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svnadmin.sw">svnadmin Options</a></span></dt><dt><span class="sect2"><a href="#svn.ref.svnadmin.c">svnadmin Subcommands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.crashtest">svnadmin crashtest</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.create">svnadmin create</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.deltify">svnadmin deltify</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.dump">svnadmin dump</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.help">svnadmin help (h, ?)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.hotcopy">svnadmin hotcopy</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.list-dblogs">svnadmin list-dblogs</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.list-unused-dblogs">svnadmin list-unused-dblogs</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.load">svnadmin load</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.lslocks">svnadmin lslocks</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.lstxns">svnadmin lstxns</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.pack">svnadmin pack</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.recover">svnadmin recover</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.rmlocks">svnadmin rmlocks</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.rmtxns">svnadmin rmtxns</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.setlog">svnadmin setlog</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.setrevprop">svnadmin setrevprop</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.setuuid">svnadmin setuuid</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.upgrade">svnadmin upgrade</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.verify">svnadmin verify</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.ref.svnlook">svnlook—Subversion Repository Examination</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svnlook.sw">svnlook Options</a></span></dt><dt><span class="sect2"><a href="#svn.ref.svnlook.c">svnlook Subcommands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.author">svnlook author</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.cat">svnlook cat</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.changed">svnlook changed</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.date">svnlook date</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.diff">svnlook diff</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.dirs-changed">svnlook dirs-changed</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.filesize">svnlook filesize</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.help">svnlook help (h, ?)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.history">svnlook history</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.info">svnlook info</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.lock">svnlook lock</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.log">svnlook log</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.propget">svnlook propget (pget, pg)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.proplist">svnlook proplist (plist, pl)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.tree">svnlook tree</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.uuid">svnlook uuid</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.youngest">svnlook youngest</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.ref.svnsync">svnsync—Subversion Repository Mirroring</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svnsync.sw">svnsync Options</a></span></dt><dt><span class="sect2"><a href="#svn.ref.svnsync.c">svnsync Subcommands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svnsync.c.copy-revprops">svnsync copy-revprops</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnsync.c.help">svnsync help</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnsync.c.info">svnsync info</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnsync.c.init">svnsync initialize (init)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnsync.c.sync">svnsync synchronize (sync)</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.ref.svnrdump">svnrdump—Remote Subversion Repository Data Migration</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svnrdump.sw">svnrdump Options</a></span></dt><dt><span class="sect2"><a href="#svn.ref.svnrdump.c">svnrdump Subcommands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svnrdump.c.dump">svnrdump dump</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnrdump.c.help">svnrdump help</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnrdump.c.load">svnrdump load</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.ref.svnserve">svnserve—Custom Subversion Server</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svnserve.sw">svnserve Options</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.ref.svndumpfilter">svndumpfilter—Subversion History Filtering</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svndumpfilter.options">svndumpfilter Options</a></span></dt><dt><span class="sect2"><a href="#svn.ref.svndumpfilter.c">svndumpfilter Subcommands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svndumpfilter.commands.c.exclude">svndumpfilter exclude</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svndumpfilter.commands.c.include">svndumpfilter include</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svndumpfilter.commands.c.help">svndumpfilter help</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.ref.svnversion">svnversion—Subversion Working Copy Version Info</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svnversion.re">svnversion</a></span><span class="refpurpose"></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.ref.mod_dav_svn">mod_dav_svn—Subversion Apache HTTP Server Module</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.mod_dav_svn.conf">mod_dav_svn Configuration Directives</a></span><span class="refpurpose"></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.ref.mod_authz_svn">mod_authz_svn—Subversion Apache HTTP Authorization Module</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.mod_authz_svn.conf">mod_authz_svn Configuration Directives</a></span><span class="refpurpose"></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.ref.properties">Subversion Properties</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.properties.versioned-props">Versioned Properties</a></span></dt><dt><span class="sect2"><a href="#svn.ref.properties.unversioned-props">Unversioned Properties</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.ref.reposhooks">Repository Hooks</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.start-commit">start-commit</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.pre-commit">pre-commit</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.post-commit">post-commit</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.pre-revprop-change">pre-revprop-change</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.post-revprop-change">post-revprop-change</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.pre-lock">pre-lock</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.post-lock">post-lock</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.pre-unlock">pre-unlock</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.post-unlock">post-unlock</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="appendix"><a href="#svn.intro">A. Subversion Quick-Start Guide</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.intro.install">Installing Subversion</a></span></dt><dt><span class="sect1"><a href="#svn.intro.quickstart">High-Speed Tutorial</a></span></dt></dl></dd><dt><span class="appendix"><a href="#svn.forcvs">B. Subversion for CVS Users</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.forcvs.revnums">Revision Numbers Are Different Now</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.directories">Directory Versions</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.disconnected">More Disconnected Operations</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.status-vs-update">Distinction Between Status and Update</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.forcvs.status-vs-update.status">Status</a></span></dt><dt><span class="sect2"><a href="#svn.forcvs.status-vs-update.update">Update</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.forcvs.branches-and-tags">Branches and Tags</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.properties">Metadata Properties</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.conflicts">Conflict Resolution</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.binary-and-trans">Binary Files and Translation</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.modules">Versioned Modules</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.auth">Authentication</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.convert">Converting a Repository from CVS to Subversion</a></span></dt></dl></dd><dt><span class="appendix"><a href="#svn.webdav">C. WebDAV and Autoversioning</a></span></dt><dd><dl><dt><span class="sect1"><a href="#svn.webdav.basic">What Is WebDAV?</a></span></dt><dt><span class="sect1"><a href="#svn.webdav.autoversioning">Autoversioning</a></span></dt><dt><span class="sect1"><a href="#svn.webdav.clients">Client Interoperability</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.webdav.clients.standalone">Standalone WebDAV Applications</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.webdav.clients.standalone.windows">Microsoft Office, Dreamweaver, Photoshop</a></span></dt><dt><span class="sect3"><a href="#svn.webdav.clients.standalone.free">cadaver, DAV Explorer</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.webdav.clients.file-explorer-extensions">File-Explorer WebDAV Extensions</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.webdav.clients.file-explorer-extensions.windows">Microsoft Web Folders</a></span></dt><dt><span class="sect3"><a href="#svn.webdav.clients.file-explorer-extensions.linux-de">Nautilus, Konqueror</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.webdav.clients.fs-impl">WebDAV Filesystem Implementation</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.webdav.clients.fs-impl.windows">WebDrive, NetDrive</a></span></dt><dt><span class="sect3"><a href="#svn.webdav.clients.fs-impl.macosx">Mac OS X</a></span></dt><dt><span class="sect3"><a href="#svn.webdav.clients.fs-impl.linux">Linux davfs2</a></span></dt></dl></dd></dl></dd></dl></dd><dt><span class="appendix"><a href="#svn.copyright">D. Copyright</a></span></dt><dt><span class="index"><a href="#svn.index">Index</a></span></dt></dl></div><div class="list-of-figures"><p><strong>List of Figures</strong></p><dl><dt>1. <a href="#svn.intro.architecture.dia-1">Subversion's architecture</a></dt><dt>1.1. <a href="#svn.basic.repository.dia-1">A typical client/server system</a></dt><dt>1.2. <a href="#svn.basic.vsn-models.problem-sharing.dia-1">The problem to avoid</a></dt><dt>1.3. <a href="#svn.basic.vsn-models.lock-unlock.dia-1">The lock-modify-unlock solution</a></dt><dt>1.4. <a href="#svn.basic.vsn-models.copy-merge.dia-1">The copy-modify-merge solution</a></dt><dt>1.5. <a href="#svn.basic.vsn-models.copy-merge.dia-2">The copy-modify-merge solution (continued)</a></dt><dt>1.6. <a href="#svn.basic.in-action.revs.dia-1">Tree changes over time</a></dt><dt>1.7. <a href="#svn.basic.in-action.wc.dia-1">The repository's filesystem</a></dt><dt>4.1. <a href="#svn.branchmerge.whatis.dia-1">Branches of development</a></dt><dt>4.2. <a href="#svn.branchmerge.using.dia-1">Starting repository layout</a></dt><dt>4.3. <a href="#svn.branchmerge.using.create.dia-1">Repository with new copy</a></dt><dt>4.4. <a href="#svn.branchmerge.using.work.dia-1">The branching of one file's history</a></dt><dt>8.1. <a href="#svn.developer.layerlib.repos.dia-1">Files and directories in two dimensions</a></dt><dt>8.2. <a href="#svn.developer.layerlib.repos.dia-2">Versioning time—the third dimension!</a></dt></dl></div><div class="list-of-tables"><p><strong>List of Tables</strong></p><dl><dt>1.1. <a href="#svn.basic.in-action.wc.tbl-1">Repository access URLs</a></dt><dt>2.1. <a href="#svn.tour.history.log.tbl-1">Common log requests</a></dt><dt>4.1. <a href="#svn.branchemerge.summary.tbl-1">Branching and merging commands</a></dt><dt>5.1. <a href="#svn.reposadmin.basics.backends.tbl-1">Repository data store comparison</a></dt><dt>6.1. <a href="#svn.serverconfig.overview.tbl-1">Comparison of subversion server options</a></dt><dt>C.1. <a href="#svn.webdav.clients.tbl-1">Common WebDAV clients</a></dt></dl></div><div class="list-of-examples"><p><strong>List of Examples</strong></p><dl><dt>4.1. <a href="#svn.branchmerge.advanced.hook-ex1">Merge-tracking gatekeeper start-commit hook script</a></dt><dt>5.1. <a href="#svn.reposadmin.maint.diskspace.deadtxns.ex-1">txn-info.sh (reporting outstanding transactions)</a></dt><dt>5.2. <a href="#svn.reposadmin.maint.replication.pre-revprop-change">Mirror repository's pre-revprop-change hook script</a></dt><dt>5.3. <a href="#svn.reposadmin.maint.replication.start-commit">Mirror repository's start-commit hook script</a></dt><dt>6.1. <a href="#svn.serverconfig.svnserve.invoking.launchd.ex-1">A sample svnserve launchd job definition</a></dt><dt>6.2. <a href="#svn.serverconfig.httpd.authz.perdir.ex-1">A sample configuration for anonymous access</a></dt><dt>6.3. <a href="#svn.serverconfig.httpd.authz.perdir.ex-2">A sample configuration for authenticated access</a></dt><dt>6.4. <a href="#svn.serverconfig.httpd.authz.perdir.ex-3">A sample configuration for mixed authenticated/anonymous access</a></dt><dt>6.5. <a href="#svn.serverconfig.httpd.authz.pathauthzoff.ex-1">Disabling path checks altogether</a></dt><dt>7.1. <a href="#svn.advanced.confarea.windows-registry.ex-1">Sample registration entries (.reg) file</a></dt><dt>7.2. <a href="#svn.advanced.externaldifftools.diff.ex-1">diffwrap.py</a></dt><dt>7.3. <a href="#svn.advanced.externaldifftools.diff.ex-2">diffwrap.bat</a></dt><dt>7.4. <a href="#svn.advanced.externaldifftools.diff3.ex-1">diff3wrap.py</a></dt><dt>7.5. <a href="#svn.advanced.externaldifftools.diff3.ex-2">diff3wrap.bat</a></dt><dt>7.6. <a href="#svn.advanced.externaldifftools.merge.ex-1">mergewrap.py</a></dt><dt>7.7. <a href="#svn.advanced.externaldifftools.merge.ex-2">mergewrap.bat</a></dt><dt>8.1. <a href="#svn.developer.layerlib.repos.ex-1">Using the repository layer</a></dt><dt>8.2. <a href="#svn.developer.usingapi.otherlangs.ex-1">Using the repository layer with Python</a></dt><dt>8.3. <a href="#svn.developer.usingapi.otherlangs.ex-2">A Python status crawler</a></dt></dl></div><div class="preface"><div class="titlepage"><div><div><h1 class="title"><a id="svn.foreword"></a>Foreword</h1></div><div><div class="author"><h3 class="author"><span class="firstname">Karl</span> <span class="surname">Fogel</span></h3></div></div><div><p class="pubdate">Chicago, March 14, 2004.</p></div></div></div><p>A bad Frequently Asked Questions (FAQ) sheet is one that is composed not of the questions people actually ask, but of the questions the FAQ's author <span class="emphasis"><em>wishes</em></span> people would ask. Perhaps you've seen the type before:</p><div class="blockquote"><blockquote class="blockquote"><p>Q: How can I use Glorbosoft XYZ to maximize team productivity?</p></blockquote></div><div class="blockquote"><blockquote class="blockquote"><p>A: Many of our customers want to know how they can maximize productivity through our patented office groupware innovations. The answer is simple. First, click on the <code class="literal">File</code> menu, scroll down to <code class="literal">Increase Productivity</code>, then…</p></blockquote></div><p>The problem with such FAQs is that they are not, in a literal sense, FAQs at all. No one ever called the tech support line and asked, <span class="quote">“<span class="quote">How can we maximize productivity?</span>”</span> Rather, people asked highly specific questions, such as <span class="quote">“<span class="quote">How can we change the calendaring system to send reminders two days in advance instead of one?</span>”</span> and so on. But it's a lot easier to make up imaginary Frequently Asked Questions than it is to discover the real ones. Compiling a true FAQ sheet requires a sustained, organized effort: over the lifetime of the software, incoming questions must be tracked, responses monitored, and all gathered into a coherent, searchable whole that reflects the collective experience of users in the wild. It calls for the patient, observant attitude of a field naturalist. No grand hypothesizing, no visionary pronouncements here—open eyes and accurate note-taking are what's needed most.</p><p>What I love about this book is that it grew out of just such a process, and shows it on every page. It is the direct result of the authors' encounters with users. It began with Ben Collins-Sussman's observation that people were asking the same basic questions over and over on the Subversion mailing lists: what are the standard workflows to use with Subversion? Do branches and tags work the same way as in other version control systems? How can I find out who made a particular change?</p><p>Frustrated at seeing the same questions day after day, Ben worked intensely over a month in the summer of 2002 to write <em class="citetitle">The Subversion Handbook</em>, a 60-page manual that covered all the basics of using Subversion. The manual made no pretense of being complete, but it was distributed with Subversion and got users over that initial hump in the learning curve. When O'Reilly decided to publish a full-length Subversion book, the path of least resistance was obvious: just expand the Subversion handbook.</p><p>The three coauthors of the new book were thus presented with an unusual opportunity. Officially, their task was to write a book top-down, starting from a table of contents and an initial draft. But they also had access to a steady stream—indeed, an uncontrollable geyser—of bottom-up source material. Subversion was already in the hands of thousands of early adopters, and those users were giving tons of feedback, not only about Subversion, but also about its existing documentation.</p><p>During the entire time they wrote this book, Ben, Mike, and Brian haunted the Subversion mailing lists and chat rooms incessantly, carefully noting the problems users were having in real-life situations. Monitoring such feedback was part of their job descriptions at CollabNet anyway, and it gave them a huge advantage when they set out to document Subversion. The book they produced is grounded firmly in the bedrock of experience, not in the shifting sands of wishful thinking; it combines the best aspects of user manual and FAQ sheet. This duality might not be noticeable on a first reading. Taken in order, front to back, the book is simply a straightforward description of a piece of software. There's the overview, the obligatory guided tour, the chapter on administrative configuration, some advanced topics, and of course, a command reference and troubleshooting guide. Only when you come back to it later, seeking the solution to some specific problem, does its authenticity shine out: the telling details that can only result from encounters with the unexpected, the examples honed from genuine use cases, and most of all the sensitivity to the user's needs and the user's point of view.</p><p>Of course, no one can promise that this book will answer every question you have about Subversion. Sometimes the precision with which it anticipates your questions will seem eerily telepathic; yet occasionally, you will stumble into a hole in the community's knowledge and come away empty-handed. When this happens, the best thing you can do is email <code class="email">&lt;<a class="email" href="mailto:users@subversion.apache.org">users@subversion.apache.org</a>&gt;</code> and present your problem. The authors are still there and still watching, and the authors include not just the three listed on the cover, but many others who contributed corrections and original material. From the community's point of view, solving your problem is merely a pleasant side effect of a much larger project—namely, slowly adjusting this book, and ultimately Subversion itself, to more closely match the way people actually use it. They are eager to hear from you, not only because they can help you, but because you can help them. With Subversion, as with all active free software projects, <span class="emphasis"><em>you are not alone</em></span>.</p><p>Let this book be your first companion.</p></div><div class="preface"><div class="titlepage"><div><div><h1 class="title"><a id="svn.preface"></a>Preface</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.intro.whatis">What Is Subversion?</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.intro.righttool">Is Subversion the Right Tool?</a></span></dt><dt><span class="sect2"><a href="#svn.intro.history">Subversion's History</a></span></dt><dt><span class="sect2"><a href="#svn.intro.architecture">Subversion's Architecture</a></span></dt><dt><span class="sect2"><a href="#svn.intro.components">Subversion's Components</a></span></dt><dt><span class="sect2"><a href="#svn.intro.whatsnew">What's New in Subversion</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.preface.audience">Audience</a></span></dt><dt><span class="sect1"><a href="#svn.preface.howread">How to Read This Book</a></span></dt><dt><span class="sect1"><a href="#svn.preface.organization">Organization of This Book</a></span></dt><dt><span class="sect1"><a href="#svn.preface.free">This Book Is Free</a></span></dt><dt><span class="sect1"><a href="#svn.preface.acks">Acknowledgments</a></span></dt></dl></div><div class="blockquote"><table border="0" class="blockquote" style="width: 100%; cellspacing: 0; cellpadding: 0;" summary="Block quote"><tr><td width="10%" valign="top"> </td><td width="80%" valign="top"><p><span class="quote">“<span class="quote">It is important not to let the perfect become the enemy of the good, even when you can agree on what perfect is. Doubly so when you can't. As unpleasant as it is to be trapped by past mistakes, you can't make any progress by being afraid of your own shadow during design.</span>”</span></p></td><td width="10%" valign="top"> </td></tr><tr><td width="10%" valign="top"> </td><td colspan="2" align="right" valign="top">--<span class="attribution">Greg Hudson, Subversion developer</span></td></tr></table></div><a id="idm69" class="indexterm"></a><a id="idm71" class="indexterm"></a><p>In the world of open source software, the Concurrent Versions System (CVS) was the tool of choice for version control for many years. And rightly so. CVS was open source software itself, and its nonrestrictive modus operandi and support for networked operation allowed dozens of geographically dispersed programmers to share their work. It fit the collaborative nature of the open source world very well. CVS and its semi-chaotic development model have since become cornerstones of open source culture.</p><p>But CVS was not without its flaws, and simply fixing those flaws promised to be an enormous effort. Enter Subversion. Subversion was designed to be a successor to CVS, and its originators set out to win the hearts of CVS users in two ways—by creating an open source system with a design (and <span class="quote">“<span class="quote">look and feel</span>”</span>) similar to CVS, and by attempting to avoid most of CVS's noticeable flaws. While the result wasn't—and isn't—the next great evolution in version control design, Subversion <span class="emphasis"><em>is</em></span> very powerful, very usable, and very flexible.</p><p>This book is written to document the 1.7 series of the Apache Subversion™<a href="#ftn.idm79" class="footnote" id="idm79"><sup class="footnote">[1]</sup></a> version control system. We have made every attempt to be thorough in our coverage. However, Subversion has a thriving and energetic development community, so already a number of features and improvements are planned for future versions that may change some of the commands and specific notes in this book.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.intro.whatis"></a>What Is Subversion?</h2></div></div></div><a id="idm84" class="indexterm"></a><a id="idm87" class="indexterm"></a><a id="idm89" class="indexterm"></a><p>Subversion is a free/open source <em class="firstterm">version control system</em> (VCS). That is, Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data, or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of <span class="quote">“<span class="quote">time machine.</span>”</span></p><p>Subversion can operate across networks, which allows it to be used by people on different computers. At some level, the ability for various people to modify and manage the same set of data from their respective locations fosters collaboration. Progress can occur more quickly without a single conduit through which all modifications must occur. And because the work is versioned, you need not fear that quality is the trade-off for losing that conduit—if some incorrect change is made to the data, just undo that change.</p><a id="idm96" class="indexterm"></a><a id="idm98" class="indexterm"></a><p>Some version control systems are also <em class="firstterm">software configuration management</em> (SCM) systems. These systems are specifically tailored to manage trees of source code and have many features that are specific to software development—such as natively understanding programming languages, or supplying tools for building software. Subversion, however, is not one of these systems. It is a general system that can be used to manage <span class="emphasis"><em>any</em></span> collection of files. For you, those files might be source code—for others, anything from grocery shopping lists to digital video mixdowns and beyond.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.intro.righttool"></a>Is Subversion the Right Tool?</h3></div></div></div><p>If you're a user or system administrator pondering the use of Subversion, the first question you should ask yourself is: "Is this the right tool for the job?" Subversion is a fantastic hammer, but be careful not to view every problem as a nail.</p><p>As a first step, you need to decide if version control in general is required for your purposes. If you need to archive old versions of files and directories, possibly resurrect them, and examine logs of how they've changed over time, then version control tools can do that. If you need to collaborate with people on documents (usually over a network) and keep track of who made which changes, a version control tool can do that, too. In fact, this is why version control tools such as Subversion are so often used in software development environments—working on a development team is an inherently social activity where changes to source code files are constantly being discussed, made, evaluated, and even sometimes unmade. Version control tools facilitate that sort of collaboration.</p><p>There is cost associated with using version control, too. Unless you can outsource the administration of your version control system to a third-party, you'll have the obvious costs of performing that administration yourself. When working with the data on a daily basis, you won't be able to copy, move, rename, or delete files the way you usually do. Instead, you'll have to do all of those things through the version control system.</p><p>Even assuming that you are okay with the cost/benefit tradeoff afforded by a version control system, you shouldn't choose to use one merely because it <span class="emphasis"><em>can</em></span> do what you want. Consider whether your needs are better addressed by other tools. For example, because Subversion replicates data to all the collaborators involved, a common misuse is to treat it as a generic distribution system. People will sometimes use Subversion to distribute huge collections of photos, digital music, or software packages. The problem is that this sort of data usually isn't changing at all. The collection itself grows over time, but the individual files within the collection aren't being changed. In this case, using Subversion is <span class="quote">“<span class="quote">overkill.</span>”</span><a href="#ftn.idm112" class="footnote" id="idm112"><sup class="footnote">[2]</sup></a> There are simpler tools that efficiently replicate data <span class="emphasis"><em>without</em></span> the overhead of tracking changes, such as <span class="command"><strong>rsync</strong></span> or <span class="command"><strong>unison</strong></span>.</p><p>Once you've decided that you need a version control solution, you'll find no shortage of available options. When Subversion was first designed and released, the predominant methodology of version control was <em class="firstterm">centralized version control</em>—a single remote master storehouse of versioned data with individual users operating locally against shallow copies of that data's version history. Subversion quickly emerged after its initial introduction as the clear leader in this field of version control, earning widespread adoption and supplanting installations of many older version control systems. It continues to hold that prominent position today.</p><p>Much has changed since that time, though. In the years since the Subversion project began its life, a newer methodology of version control called <em class="firstterm">distributed version control</em> has likewise garnered widespread attention and adoption. Tools such as Git (<a class="ulink" href="http://git-scm.com/" target="_top">http://git-scm.com/</a>) and Mercurial (<a class="ulink" href="http://mercurial.selenic.com/" target="_top">http://mercurial.selenic.com/</a>) quickly rose to the tops of the distributed version control system (DVCS) ranks. Distributed version control harnesses the growing ubiquity of high-speed network connections and low storage costs to offer an approach which differs from the centralized model in key ways. First and most obvious is the fact that there is no remote, central storehouse of versioned data. Rather, each user keeps and operates against very deep—complete, in a sense—local version history data stores. Collaboration still occurs, but is accomplished by trading <em class="firstterm">changesets</em> (collections of changes made to versioned items) directly between users' local data stores, not via a centralized master data store. In fact, any semblance of a canonical <span class="quote">“<span class="quote">master</span>”</span> source of a project's versioned data is by convention only, a status attributed by the various collaborators on that project.</p><p>There are pros and cons to each version control approach. Perhaps the two biggest benefits delivered by the DVCS tools are incredible performance for day-to-day operations (because the primary data store is locally held) and vastly better support for merging between branches (because merge algorithms serve as the very core of how DVCSes work at all). The downside is that distributed version control is an inherently more complicated model, which can present a non-negligible challenge to comfortable collaboration. Also, DVCS tools do what they do well in part because of a certain degree of control withheld from the user which centalized systems freely offer—the ability to implement path-based access control, the flexibility to update or backdate individual versioned data items, etc. Fortunately, many wise organizations have discovered that this needn't be a religious debate, and that Subversion and a DVCS tool such as Git can be used together harmoniously within the organization, each serving the purposes best suited to the tool.</p><p>Alas, this book is about Subversion, so we'll not attempt a full comparison of Subversion and other tools. Readers who have the option of choosing their version control system are encouraged to research the available options and make the determination that works best for themselves and their fellow collaborators. And if, after doing so, Subversion is the chosen tool, there's <span class="emphasis"><em>plenty</em></span> of detailed information about how to use it successfully in the chapters that follow!</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.intro.history"></a>Subversion's History</h3></div></div></div><a id="idm131" class="indexterm"></a><a id="idm134" class="indexterm"></a><p>In early 2000, CollabNet, Inc. (now known as Digital.ai, <a class="ulink" href="https://digital.ai" target="_top">https://digital.ai</a>) began seeking developers to write a replacement for CVS. CollabNet offered<a href="#ftn.idm138" class="footnote" id="idm138"><sup class="footnote">[3]</sup></a> a collaboration software suite called CollabNet Enterprise Edition (CEE), of which one component was version control. Although CEE used CVS as its initial version control system, CVS's limitations were obvious from the beginning, and CollabNet knew it would eventually have to find something better. Unfortunately, CVS had become the de facto standard in the open source world largely because there <span class="emphasis"><em>wasn't</em></span> anything better, at least not under a free license. So CollabNet determined to write a new version control system from scratch, retaining the basic ideas of CVS, but without the bugs and misfeatures.</p><p>In February 2000, they contacted Karl Fogel, the author of <em class="citetitle">Open Source Development with CVS</em> (Coriolis, 1999), and asked if he'd like to work on this new project. Coincidentally, at the time Karl was already discussing a design for a new version control system with his friend Jim Blandy. In 1995, the two had started Cyclic Software, a company providing CVS support contracts, and although they later sold the business, they still used CVS every day at their jobs. Their frustration with CVS had led Jim to think carefully about better ways to manage versioned data, and he'd already come up with not only the Subversion name, but also the basic design of the Subversion data store. When CollabNet called, Karl immediately agreed to work on the project, and Jim got his employer, Red Hat Software, to essentially donate him to the project for an indefinite period of time. CollabNet hired Karl and Ben Collins-Sussman, and detailed design work began in May 2000. With the help of some well-placed prods from Brian Behlendorf and Jason Robbins of CollabNet, and from Greg Stein (at the time an independent developer active in the WebDAV/DeltaV specification process), Subversion quickly attracted a community of active developers. It turned out that many people had encountered the same frustrating experiences with CVS and welcomed the chance to finally do something about it.</p><p>The original design team settled on some simple goals. They didn't want to break new ground in version control methodology, they just wanted to fix CVS. They decided that Subversion would match CVS's features and preserve the same development model, but not duplicate CVS's most obvious flaws. And although it did not need to be a drop-in replacement for CVS, it should be similar enough that any CVS user could make the switch with little effort.</p><p>After 14 months of coding, Subversion became <span class="quote">“<span class="quote">self-hosting</span>”</span> on August 31, 2001. That is, Subversion developers stopped using CVS to manage Subversion's own source code and started using Subversion instead.</p><p>While CollabNet started the project, and still funds a large chunk of the work (it pays the salaries of a few full-time Subversion developers), Subversion is run like most open source projects, governed by a loose, transparent set of rules that encourage meritocracy. In 2009, CollabNet worked with the Subversion developers towards the goal of integrating the Subversion project into the Apache Software Foundation (ASF), one of the most well-known collectives of open source projects in the world. Subversion's technical roots, community priorities, and development practices were a perfect fit for the ASF, many of whose members were already active Subversion contributors. In early 2010, Subversion was fully adopted into the ASF's family of top-level projects, moved its web presence to <a class="ulink" href="http://subversion.apache.org" target="_top">http://subversion.apache.org</a>, and was rechristened <span class="quote">“<span class="quote">Apache Subversion</span>”</span>.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.intro.architecture"></a>Subversion's Architecture</h3></div></div></div><a id="idm151" class="indexterm"></a><p><a class="xref" href="#svn.intro.architecture.dia-1" title="Figure 1. Subversion's architecture">Figure 1, “Subversion's architecture”</a> illustrates a <span class="quote">“<span class="quote">mile-high</span>”</span> view of Subversion's design.</p><div class="figure"><a id="svn.intro.architecture.dia-1"></a><p class="title"><strong>Figure 1. Subversion's architecture</strong></p><div class="figure-contents"><div><img src="images/ch01dia1.png" alt="Subversion's architecture"></img></div></div></div><br class="figure-break"></br><p>On one end is a Subversion repository that holds all of your versioned data. On the other end is your Subversion client program, which manages local reflections of portions of that versioned data. Between these extremes are multiple routes through a Repository Access (RA) layer, some of which go across computer networks and through network servers which then access the repository, others of which bypass the network altogether and access the repository directly.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.intro.components"></a>Subversion's Components</h3></div></div></div><a id="idm163" class="indexterm"></a><p>Subversion, once installed, has a number of different pieces. The following is a quick overview of what you get. Don't be alarmed if the brief descriptions leave you scratching your head—<span class="emphasis"><em>plenty</em></span> more pages in this book are devoted to alleviating that confusion.</p><div class="variablelist"><a id="idm169" class="indexterm"></a><a id="idm171" class="indexterm"></a><a id="idm173" class="indexterm"></a><a id="idm175" class="indexterm"></a><a id="idm177" class="indexterm"></a><a id="idm179" class="indexterm"></a><a id="idm181" class="indexterm"></a><a id="idm183" class="indexterm"></a><dl class="variablelist"><dt><span class="term">svn</span></dt><dd><p>The command-line client program</p></dd><dt><span class="term">svnversion</span></dt><dd><p>A program for reporting the state (in terms of revisions of the items present) of a working copy</p></dd><dt><span class="term">svnlook</span></dt><dd><p>A tool for directly inspecting a Subversion repository</p></dd><dt><span class="term">svnadmin</span></dt><dd><p>A tool for creating, tweaking, or repairing a Subversion repository</p></dd><dt><span class="term">mod_dav_svn</span></dt><dd><p>A plug-in module for the Apache HTTP Server, used to make your repository available to others over a network</p></dd><dt><span class="term">svnserve</span></dt><dd><p>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</p></dd><dt><span class="term">svndumpfilter</span></dt><dd><p>A program for filtering Subversion repository dump streams</p></dd><dt><span class="term">svnsync</span></dt><dd><p>A program for incrementally mirroring one repository to another over a network</p></dd><dt><span class="term">svnrdump</span></dt><dd><p>A program for performing repository history dumps and loads over a network</p></dd></dl></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.intro.whatsnew"></a>What's New in Subversion</h3></div></div></div><a id="idm223" class="indexterm"></a><p>The first edition of this book was published by O'Reilly Media in 2004, shortly after Subversion had reached 1.0. Since that time, the Subversion project has continued to release new major releases of the software. Here's a quick summary of major new changes since Subversion 1.0. Note that this is not a complete list; for full details, please visit Subversion's web site at <a class="ulink" href="http://subversion.apache.org" target="_top">http://subversion.apache.org</a>.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">Subversion 1.1 (September 2004)</span></dt><dd><p>Release 1.1 introduced FSFS, a flat-file repository storage option for the repository. While the Berkeley DB backend is still widely used and supported, FSFS has since become the default choice for newly created repositories due to its low barrier to entry and minimal maintenance requirements. Also in this release came the ability to put symbolic links under version control, auto-escaping of URLs, and a localized user interface.</p></dd><dt><span class="term">Subversion 1.2 (May 2005)</span></dt><dd><p>Release 1.2 introduced the ability to create server-side locks on files, thus serializing commit access to certain resources. While Subversion is still a fundamentally concurrent version control system, certain types of binary files (e.g. art assets) cannot be merged together. The locking feature fulfills the need to version and protect such resources. With locking also came a complete WebDAV auto-versioning implementation, allowing Subversion repositories to be mounted as network folders. Finally, Subversion 1.2 began using a new, faster binary-differencing algorithm to compress and retrieve old versions of files.</p></dd><dt><span class="term">Subversion 1.3 (December 2005)</span></dt><dd><p>Release 1.3 brought path-based authorization controls to the <span class="command"><strong>svnserve</strong></span> server, matching a feature formerly found only in the Apache server. The Apache server, however, gained some new logging features of its own, and Subversion's API bindings to other languages also made great leaps forward.</p></dd><dt><span class="term">Subversion 1.4 (September 2006)</span></dt><dd><p>Release 1.4 introduced a whole new tool—<span class="command"><strong>svnsync</strong></span>—for doing one-way repository replication over a network. Major parts of the working copy metadata were revamped to no longer use XML (resulting in client-side speed gains), while the Berkeley DB repository backend gained the ability to automatically recover itself after a server crash.</p></dd><dt><span class="term">Subversion 1.5 (June 2008)</span></dt><dd><p>Release 1.5 took much longer to finish than prior releases, but the headliner feature was gigantic: semi-automated tracking of branching and merging. This was a huge boon for users, and pushed Subversion far beyond the abilities of CVS and into the ranks of commercial competitors such as Perforce and ClearCase. Subversion 1.5 also introduced a bevy of other user-focused features, such as interactive resolution of file conflicts, sparse checkouts, client-side management of changelists, powerful new syntax for externals definitions, and SASL authentication support for the <span class="command"><strong>svnserve</strong></span> server.</p></dd><dt><span class="term">Subversion 1.6 (March 2009)</span></dt><dd><p>Release 1.6 continued to make branching and merging more robust by introducing tree conflicts, and offered improvements to several other existing features: more interactive conflict resolution options; de-telescoping and outright exclusion support for sparse checkouts; file-based externals definitions; and operational logging support for <span class="command"><strong>svnserve</strong></span> similar to what <span class="command"><strong>mod_dav_svn</strong></span> offered. Also, the command-line client introduced a new shortcut syntax for referring to Subversion repository URLs.</p></dd><dt><span class="term">Subversion 1.7 (October 2011)</span></dt><dd><p>Release 1.7 was primarily a delivery vehicle for two big plumbing overhauls of existing Subversion components. The largest and most impactful of these was the so-called <span class="quote">“<span class="quote">WC-NG</span>”</span>—a complete rewrite of the <span class="command"><strong>libsvn_wc</strong></span> working copy management library. The second change was the introduction of a sleeker HTTP protocol for Subversion client/server interaction. Subversion 1.7 delivered a handful of additional features, many bug fixes, and some notable performance improvements, too.</p></dd></dl></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.preface.audience"></a>Audience</h2></div></div></div><p>This book is written for computer-literate folk who want to use Subversion to manage their data. While Subversion runs on a number of different operating systems, its primary user interface is command-line-based. That command-line tool (<span class="command"><strong>svn</strong></span>), and some additional auxiliary programs, are the focus of this book.</p><p>For consistency, the examples in this book assume that the reader is using a Unix-like operating system and is relatively comfortable with Unix and command-line interfaces. That said, the <span class="command"><strong>svn</strong></span> program also runs on non-Unix platforms such as Microsoft Windows. With a few minor exceptions, such as the use of backward slashes (<code class="literal">\</code>) instead of forward slashes (<code class="literal">/</code>) for path separators, the input to and output from this tool when run on Windows are identical to that of its Unix counterpart.</p><p>Most readers are probably programmers or system administrators who need to track changes to source code. This is the most common use for Subversion, and therefore it is the scenario underlying all of the book's examples. But Subversion can be used to manage changes to any sort of information—images, music, databases, documentation, and so on. To Subversion, all data is just data.</p><p>While this book is written with the assumption that the reader has never used a version control system, we've also tried to make it easy for users of CVS (and other systems) to make a painless leap into Subversion. Special sidebars may mention other version control systems from time to time, and <a class="xref" href="#svn.forcvs" title="Appendix B. Subversion for CVS Users">Appendix B, <em>Subversion for CVS Users</em></a> summarizes many of the differences between CVS and Subversion.</p><p>Note also that the source code examples used throughout the book are only examples. While they will compile with the proper compiler incantations, they are intended to illustrate a particular scenario and not necessarily to serve as examples of good programming style or practices.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.preface.howread"></a>How to Read This Book</h2></div></div></div><p>Technical books always face a certain dilemma: whether to cater to <em class="firstterm">top-down</em> or to <em class="firstterm">bottom-up</em> learners. A top-down learner prefers to read or skim documentation, getting a large overview of how the system works; only then does she actually start using the software. A bottom-up learner is a <span class="quote">“<span class="quote">learn by doing</span>”</span> person—someone who just wants to dive into the software and figure it out as she goes, referring to book sections when necessary. Most books tend to be written for one type of person or the other, and this book is undoubtedly biased toward top-down learners. (And if you're actually reading this section, you're probably already a top-down learner yourself!) However, if you're a bottom-up person, don't despair. While the book may be laid out as a broad survey of Subversion topics, the content of each section tends to be heavy with specific examples that you can try-by-doing. For the impatient folks who just want to get going, you can jump right to <a class="xref" href="#svn.intro" title="Appendix A. Subversion Quick-Start Guide">Appendix A, <em>Subversion Quick-Start Guide</em></a>.</p><p>Regardless of your learning style, this book aims to be useful to people of widely different backgrounds—from those with no previous experience in version control to experienced system administrators. Depending on your own background, certain chapters may be more or less important to you. The following can be considered a <span class="quote">“<span class="quote">recommended reading list</span>”</span> for various types of readers:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">Experienced system administrators</span></dt><dd><p>The assumption here is that you've probably used version control before and are dying to get a Subversion server up and running ASAP. <a class="xref" href="#svn.reposadmin" title="Chapter 5. Repository Administration">Chapter 5, <em>Repository Administration</em></a> and <a class="xref" href="#svn.serverconfig" title="Chapter 6. Server Configuration">Chapter 6, <em>Server Configuration</em></a> will show you how to create your first repository and make it available over the network. After that's done, <a class="xref" href="#svn.tour" title="Chapter 2. Basic Usage">Chapter 2, <em>Basic Usage</em></a> and <a class="xref" href="#svn.forcvs" title="Appendix B. Subversion for CVS Users">Appendix B, <em>Subversion for CVS Users</em></a> are the fastest routes to learning the Subversion client.</p></dd><dt><span class="term">New users</span></dt><dd><p>Your administrator has probably set up Subversion already, and you need to learn how to use the client. If you've never used a version control system, then <a class="xref" href="#svn.basic" title="Chapter 1. Fundamental Concepts">Chapter 1, <em>Fundamental Concepts</em></a> is a vital introduction to the ideas behind version control. <a class="xref" href="#svn.tour" title="Chapter 2. Basic Usage">Chapter 2, <em>Basic Usage</em></a> is a guided tour of the Subversion client.</p></dd><dt><span class="term">Advanced users</span></dt><dd><p>Whether you're a user or administrator, eventually your project will grow larger. You're going to want to learn how to do more advanced things with Subversion, such as how to use Subversion's property support (<a class="xref" href="#svn.advanced" title="Chapter 3. Advanced Topics">Chapter 3, <em>Advanced Topics</em></a>), how to use branches and perform merges (<a class="xref" href="#svn.branchmerge" title="Chapter 4. Branching and Merging">Chapter 4, <em>Branching and Merging</em></a>), how to configure runtime options (<a class="xref" href="#svn.customization" title="Chapter 7. Customizing Your Subversion Experience">Chapter 7, <em>Customizing Your Subversion Experience</em></a>), and other things. These chapters aren't critical at first, but be sure to read them once you're comfortable with the basics.</p></dd><dt><span class="term">Developers</span></dt><dd><p>Presumably, you're already familiar with Subversion, and now want to either extend it or build new software on top of its many APIs. <a class="xref" href="#svn.developer" title="Chapter 8. Embedding Subversion">Chapter 8, <em>Embedding Subversion</em></a> is just for you.</p></dd></dl></div><p>The book ends with reference material—<a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a> is a reference guide for all Subversion commands, and the appendixes cover a number of useful topics. These are the chapters you're mostly likely to come back to after you've finished the book.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.preface.organization"></a>Organization of This Book</h2></div></div></div><p>The chapters that follow and their contents are listed here:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><a class="xref" href="#svn.basic" title="Chapter 1. Fundamental Concepts">Chapter 1, <em>Fundamental Concepts</em></a></span></dt><dd><p>Explains the basics of version control and different versioning models, along with Subversion's repository, working copies, and revisions.</p></dd><dt><span class="term"><a class="xref" href="#svn.tour" title="Chapter 2. Basic Usage">Chapter 2, <em>Basic Usage</em></a></span></dt><dd><p>Walks you through a day in the life of a Subversion user. It demonstrates how to use a Subversion client to obtain, modify, and commit data.</p></dd><dt><span class="term"><a class="xref" href="#svn.advanced" title="Chapter 3. Advanced Topics">Chapter 3, <em>Advanced Topics</em></a></span></dt><dd><p>Covers more complex features that regular users will eventually come into contact with, such as versioned metadata, file locking, and peg revisions.</p></dd><dt><span class="term"><a class="xref" href="#svn.branchmerge" title="Chapter 4. Branching and Merging">Chapter 4, <em>Branching and Merging</em></a></span></dt><dd><p>Discusses branches, merges, and tagging, including best practices for branching and merging, common use cases, how to undo changes, and how to easily swing from one branch to the next.</p></dd><dt><span class="term"><a class="xref" href="#svn.reposadmin" title="Chapter 5. Repository Administration">Chapter 5, <em>Repository Administration</em></a></span></dt><dd><p>Describes the basics of the Subversion repository, how to create, configure, and maintain a repository, and the tools you can use to do all of this.</p></dd><dt><span class="term"><a class="xref" href="#svn.serverconfig" title="Chapter 6. Server Configuration">Chapter 6, <em>Server Configuration</em></a></span></dt><dd><p>Explains how to configure your Subversion server and offers different ways to access your repository: <code class="literal">HTTP</code>, the <code class="literal">svn</code> protocol, and local disk access. It also covers the details of authentication, authorization and anonymous access.</p></dd><dt><span class="term"><a class="xref" href="#svn.customization" title="Chapter 7. Customizing Your Subversion Experience">Chapter 7, <em>Customizing Your Subversion Experience</em></a></span></dt><dd><p>Explores the Subversion client configuration files, the handling of internationalized text, and how to make external tools cooperate with Subversion.</p></dd><dt><span class="term"><a class="xref" href="#svn.developer" title="Chapter 8. Embedding Subversion">Chapter 8, <em>Embedding Subversion</em></a></span></dt><dd><p>Describes the internals of Subversion, the Subversion filesystem, and the working copy administrative areas from a programmer's point of view. It also demonstrates how to use the public APIs to write a program that uses Subversion.</p></dd><dt><span class="term"><a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a></span></dt><dd><p>Explains in great detail every subcommand of <span class="command"><strong>svn</strong></span>, <span class="command"><strong>svnadmin</strong></span>, and <span class="command"><strong>svnlook</strong></span> with plenty of examples for the whole family!</p></dd><dt><span class="term"><a class="xref" href="#svn.intro" title="Appendix A. Subversion Quick-Start Guide">Appendix A, <em>Subversion Quick-Start Guide</em></a></span></dt><dd><p>For the impatient, a whirlwind explanation of how to install Subversion and start using it immediately. You have been warned.</p></dd><dt><span class="term"><a class="xref" href="#svn.forcvs" title="Appendix B. Subversion for CVS Users">Appendix B, <em>Subversion for CVS Users</em></a></span></dt><dd><p>Covers the similarities and differences between Subversion and CVS, with numerous suggestions on how to break all the bad habits you picked up from years of using CVS. Included are descriptions of Subversion revision numbers, versioned directories, offline operations, <span class="command"><strong>update</strong></span> versus <span class="command"><strong>status</strong></span>, branches, tags, metadata, conflict resolution, and authentication.</p></dd><dt><span class="term"><a class="xref" href="#svn.webdav" title="Appendix C. WebDAV and Autoversioning">Appendix C, <em>WebDAV and Autoversioning</em></a></span></dt><dd><p>Describes the details of WebDAV and DeltaV and how you can configure your Subversion repository to be mounted read/write as a DAV share.</p></dd><dt><span class="term"><a class="xref" href="#svn.copyright" title="Appendix D. Copyright">Appendix D, <em>Copyright</em></a></span></dt><dd><p>A copy of the Creative Commons Attribution License, under which this book is licensed.</p></dd></dl></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.preface.free"></a>This Book Is Free</h2></div></div></div><p>This book started out as bits of documentation written by Subversion project developers, which were then coalesced into a single work and rewritten. As such, it has always been under a free license (see <a class="xref" href="#svn.copyright" title="Appendix D. Copyright">Appendix D, <em>Copyright</em></a>). In fact, the book was written in the public eye, originally as part of the Subversion project itself. This means two things:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>You will always find the latest version of this book in the book's own Subversion repository.</p></li><li class="listitem"><p>You can make changes to this book and redistribute it however you wish—it's under a free license. Your only obligation is to maintain proper attribution to the original authors. Of course, we'd much rather you send feedback and patches to the Subversion developer community, instead of distributing your private version of this book.</p></li></ul></div><p>The online home of this book's development and most of the volunteer-driven translation efforts regarding it is <a class="ulink" href="http://svnbook.red-bean.com" target="_top">http://svnbook.red-bean.com</a>. There you can find links to the latest releases and tagged versions of the book in various formats, as well as instructions for accessing the book's Subversion repository (where its DocBook XML source code lives). Feedback is welcomed—encouraged, even. Please submit all comments, complaints, and patches against the book sources to <code class="email">&lt;<a class="email" href="mailto:svnbook-dev@red-bean.com">svnbook-dev@red-bean.com</a>&gt;</code>.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.preface.acks"></a>Acknowledgments</h2></div></div></div><p>This book would not be possible (nor very useful) if Subversion did not exist. For that, the authors would like to thank Brian Behlendorf and CollabNet for the vision to fund such a risky and ambitious new open source project; Jim Blandy for the original Subversion name and design—we love you, Jim; and Karl Fogel for being such a good friend and a great community leader, in that order.<a href="#ftn.idm405" class="footnote" id="idm405"><sup class="footnote">[4]</sup></a></p><p>Thanks to O'Reilly and the team of professional editors who have helped us polish this text at various stages of its evolution: Chuck Toporek, Linda Mui, Tatiana Apandi, Mary Brady, and Mary Treseler. Your patience and support has been tremendous.</p><p>Finally, we thank the countless people who contributed to this book with informal reviews, suggestions, and patches. An exhaustive listing of those folks' names would be impractical to print and maintain here, but may their names live on forever in this book's version control history!</p></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm79" class="footnote"><p><a href="#idm79" class="para"><sup class="para">[1] </sup></a>We'll refer to it simply as <span class="quote">“<span class="quote">Subversion</span>”</span> throughout this book. You'll thank us when you realize just how much space that saves!</p></div><div id="ftn.idm112" class="footnote"><p><a href="#idm112" class="para"><sup class="para">[2] </sup></a>Or as a friend puts it, <span class="quote">“<span class="quote">swatting a fly with a Buick.</span>”</span></p></div><div id="ftn.idm138" class="footnote"><p><a href="#idm138" class="para"><sup class="para">[3] </sup></a>CollabNet Enterprise Edition has since been replaced by a new product line called CollabNet TeamForge.</p></div><div id="ftn.idm405" class="footnote"><p><a href="#idm405" class="para"><sup class="para">[4] </sup></a>Oh, and thanks, Karl, for being too overworked to write this book yourself.</p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="svn.basic"></a>Chapter 1. Fundamental Concepts</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.basic.version-control-basics">Version Control Basics</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.basic.repository">The Repository</a></span></dt><dt><span class="sect2"><a href="#svn.basic.working-copy">The Working Copy</a></span></dt><dt><span class="sect2"><a href="#svn.basic.vsn-models">Versioning Models</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.basic.vsn-models.problem-sharing">The problem of file sharing</a></span></dt><dt><span class="sect3"><a href="#svn.basic.vsn-models.lock-unlock">The lock-modify-unlock solution</a></span></dt><dt><span class="sect3"><a href="#svn.basic.vsn-models.copy-merge">The copy-modify-merge solution</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.basic.in-action">Version Control the Subversion Way</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.basic.svn-repositories">Subversion Repositories</a></span></dt><dt><span class="sect2"><a href="#svn.basic.in-action.revs">Revisions</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.reposurls">Addressing the Repository</a></span></dt><dt><span class="sect2"><a href="#svn.basic.in-action.wc">Subversion Working Copies</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.basic.in-action.track-repos">How the working copy works</a></span></dt><dt><span class="sect3"><a href="#svn.basic.in-action.wc-funcdamentals">Fundamental working copy interactions</a></span></dt><dt><span class="sect3"><a href="#svn.basic.in-action.mixedrevs">Mixed-revision working copies</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.basic.summary">Summary</a></span></dt></dl></div><p>This chapter is a short, casual introduction to Subversion and its approach to version control. We begin with a discussion of general version control concepts, work our way into the specific ideas behind Subversion, and show some simple examples of Subversion in use.</p><p>Even though the examples in this chapter show people sharing collections of program source code, keep in mind that Subversion can manage any sort of file collection—it's not limited to helping computer programmers.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.basic.version-control-basics"></a>Version Control Basics</h2></div></div></div><a id="idm415" class="indexterm"></a><p>A version control system (or revision control system) is a system that tracks incremental versions (or revisions) of files and, in some cases, directories over time. Of course, merely tracking the various versions of a user's (or group of users') files and directories isn't very interesting in itself. What makes a version control system useful is the fact that it allows you to explore the changes which resulted in each of those versions and facilitates the arbitrary recall of the same.</p><p>In this section, we'll introduce some fairly high-level version control system components and concepts. We'll limit our discussion to modern version control systems—in today's interconnected world, there is very little point in acknowledging version control systems which cannot operate across wide-area networks.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.basic.repository"></a>The Repository</h3></div></div></div><a id="idm421" class="indexterm"></a><p>At the core of the version control system is a repository, which is the central store of that system's data. The repository usually stores information in the form of a <em class="firstterm">filesystem tree</em>—a hierarchy of files and directories. Any number of <em class="firstterm">clients</em> connect to the repository, and then read or write to these files. By writing data, a client makes the information available to others; by reading data, the client receives information from others. <a class="xref" href="#svn.basic.repository.dia-1" title="Figure 1.1. A typical client/server system">Figure 1.1, “A typical client/server system”</a> illustrates this.</p><div class="figure"><a id="svn.basic.repository.dia-1"></a><p class="title"><strong>Figure 1.1. A typical client/server system</strong></p><div class="figure-contents"><div><img src="images/ch02dia1.png" alt="A typical client/server system"></img></div></div></div><br class="figure-break"></br><p>Why is this interesting? So far, this sounds like the definition of a typical file server. And indeed, the repository <span class="emphasis"><em>is</em></span> a kind of file server, but it's not your usual breed. What makes the repository special is that as the files in the repository are changed, the repository remembers each version of those files.</p><p>When a client reads data from the repository, it normally sees only the latest version of the filesystem tree. But what makes a version control client interesting is that it also has the ability to request previous states of the filesystem from the repository. A version control client can ask historical questions such as <span class="quote">“<span class="quote">What did this directory contain last Wednesday?</span>”</span> and <span class="quote">“<span class="quote">Who was the last person to change this file, and what changes did he make?</span>”</span> These are the sorts of questions that are at the heart of any version control system.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.basic.working-copy"></a>The Working Copy</h3></div></div></div><a id="idm438" class="indexterm"></a><p>A version control system's value comes from the fact that it tracks versions of files and directories, but the rest of the software universe doesn't operate on <span class="quote">“<span class="quote">versions of files and directories</span>”</span>. Most software programs understand how to operate only on a <span class="emphasis"><em>single</em></span> version of a specific type of file. So how does a version control user interact with an abstract—and, often, remote—repository full of multiple versions of various files in a concrete fashion? How does his or her word processing software, presentation software, source code editor, web design software, or some other program—all of which trade in the currency of simple data files—get access to such files? The answer is found in the version control construct known as a <em class="firstterm">working copy</em>.</p><p>A working copy is, quite literally, a local copy of a particular version of a user's VCS-managed data upon which that user is free to work. Working copies<a href="#ftn.idm446" class="footnote" id="idm446"><sup class="footnote">[5]</sup></a> appear to other software just as any other local directory full of files, so those programs don't have to be <span class="quote">“<span class="quote">version-control-aware</span>”</span> in order to read from and write to that data. The task of managing the working copy and communicating changes made to its contents to and from the repository falls squarely to the version control system's client software.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.basic.vsn-models"></a>Versioning Models</h3></div></div></div><p>If the primary mission of a version control system is to track the various versions of digital information over time, a very close secondary mission in any modern version control system is to enable collaborative editing and sharing of that data. But different systems use different strategies to achieve this. It's important to understand these different strategies, for a couple of reasons. First, it will help you compare and contrast existing version control systems, in case you encounter other systems similar to Subversion. Beyond that, it will also help you make more effective use of Subversion, since Subversion itself supports a couple of different ways of working.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.basic.vsn-models.problem-sharing"></a>The problem of file sharing</h4></div></div></div><p>All version control systems have to solve the same fundamental problem: how will the system allow users to share information, but prevent them from accidentally stepping on each other's feet? It's all too easy for users to accidentally overwrite each other's changes in the repository.</p><p>Consider the scenario shown in <a class="xref" href="#svn.basic.vsn-models.problem-sharing.dia-1" title="Figure 1.2. The problem to avoid">Figure 1.2, “The problem to avoid”</a>. Suppose we have two coworkers, Harry and Sally. They each decide to edit the same repository file at the same time. If Harry saves his changes to the repository first, it's possible that (a few moments later) Sally could accidentally overwrite them with her own new version of the file. While Harry's version of the file won't be lost forever (because the system remembers every change), any changes Harry made <span class="emphasis"><em>won't</em></span> be present in Sally's newer version of the file, because she never saw Harry's changes to begin with. Harry's work is still effectively lost—or at least missing from the latest version of the file—and probably by accident. This is definitely a situation we want to avoid!</p><div class="figure"><a id="svn.basic.vsn-models.problem-sharing.dia-1"></a><p class="title"><strong>Figure 1.2. The problem to avoid</strong></p><div class="figure-contents"><div><img src="images/ch02dia2.png" alt="The problem to avoid"></img></div></div></div><br class="figure-break"></br></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.basic.vsn-models.lock-unlock"></a>The lock-modify-unlock solution</h4></div></div></div><a id="idm464" class="indexterm"></a><p>Many version control systems use a <em class="firstterm">lock-modify-unlock</em> model to address the problem of many authors clobbering each other's work. In this model, the repository allows only one person to change a file at a time. This exclusivity policy is managed using locks. Harry must <span class="quote">“<span class="quote">lock</span>”</span> a file before he can begin making changes to it. If Harry has locked a file, Sally cannot also lock it, and therefore cannot make any changes to that file. All she can do is read the file and wait for Harry to finish his changes and release his lock. After Harry unlocks the file, Sally can take her turn by locking and editing the file. <a class="xref" href="#svn.basic.vsn-models.lock-unlock.dia-1" title="Figure 1.3. The lock-modify-unlock solution">Figure 1.3, “The lock-modify-unlock solution”</a> demonstrates this simple solution.</p><div class="figure"><a id="svn.basic.vsn-models.lock-unlock.dia-1"></a><p class="title"><strong>Figure 1.3. The lock-modify-unlock solution</strong></p><div class="figure-contents"><div><img src="images/ch02dia3.png" alt="The lock-modify-unlock solution"></img></div></div></div><br class="figure-break"></br><p>The problem with the lock-modify-unlock model is that it's a bit restrictive and often becomes a roadblock for users:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="emphasis"><em>Locking may cause administrative problems.</em></span> Sometimes Harry will lock a file and then forget about it. Meanwhile, because Sally is still waiting to edit the file, her hands are tied. And then Harry goes on vacation. Now Sally has to get an administrator to release Harry's lock. The situation ends up causing a lot of unnecessary delay and wasted time.</p></li><li class="listitem"><p><span class="emphasis"><em>Locking may cause unnecessary serialization.</em></span> What if Harry is editing the beginning of a text file, and Sally simply wants to edit the end of the same file? These changes don't overlap at all. They could easily edit the file simultaneously, and no great harm would come, assuming the changes were properly merged together. There's no need for them to take turns in this situation.</p></li><li class="listitem"><p><span class="emphasis"><em>Locking may create a false sense of security.</em></span> Suppose Harry locks and edits file A, while Sally simultaneously locks and edits file B. But what if A and B depend on one another, and the changes made to each are semantically incompatible? Suddenly A and B don't work together anymore. The locking system was powerless to prevent the problem—yet it somehow provided a false sense of security. It's easy for Harry and Sally to imagine that by locking files, each is beginning a safe, insulated task, and thus they need not bother discussing their incompatible changes early on. Locking often becomes a substitute for real communication.</p></li></ul></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.basic.vsn-models.copy-merge"></a>The copy-modify-merge solution</h4></div></div></div><a id="idm488" class="indexterm"></a><p>Subversion, CVS, and many other version control systems use a <em class="firstterm">copy-modify-merge</em> model as an alternative to locking. In this model, each user's client contacts the project repository and creates a personal working copy. Users then work simultaneously and independently, modifying their private copies. Finally, the private copies are merged together into a new, final version. The version control system often assists with the merging, but ultimately, a human being is responsible for making it happen correctly.</p><p>Here's an example. Say that Harry and Sally each create working copies of the same project, copied from the repository. They work concurrently and make changes to the same file A within their copies. Sally saves her changes to the repository first. When Harry attempts to save his changes later, the repository informs him that his file A is <em class="firstterm">out of date</em>. In other words, file A in the repository has somehow changed since he last copied it. So Harry asks his client to <em class="firstterm">merge</em> any new changes from the repository into his working copy of file A. Chances are that Sally's changes don't overlap with his own; once he has both sets of changes integrated, he saves his working copy back to the repository. <a class="xref" href="#svn.basic.vsn-models.copy-merge.dia-1" title="Figure 1.4. The copy-modify-merge solution">Figure 1.4, “The copy-modify-merge solution”</a> and <a class="xref" href="#svn.basic.vsn-models.copy-merge.dia-2" title="Figure 1.5. The copy-modify-merge solution (continued)">Figure 1.5, “The copy-modify-merge solution (continued)”</a> show this process.</p><div class="figure"><a id="svn.basic.vsn-models.copy-merge.dia-1"></a><p class="title"><strong>Figure 1.4. The copy-modify-merge solution</strong></p><div class="figure-contents"><div><img src="images/ch02dia4.png" alt="The copy-modify-merge solution"></img></div></div></div><br class="figure-break"></br><div class="figure"><a id="svn.basic.vsn-models.copy-merge.dia-2"></a><p class="title"><strong>Figure 1.5. The copy-modify-merge solution (continued)</strong></p><div class="figure-contents"><div><img src="images/ch02dia5.png" alt="The copy-modify-merge solution (continued)"></img></div></div></div><br class="figure-break"></br><a id="idm505" class="indexterm"></a><p>But what if Sally's changes <span class="emphasis"><em>do</em></span> overlap with Harry's changes? What then? This situation is called a <em class="firstterm">conflict</em>, and it's usually not much of a problem. When Harry asks his client to merge the latest repository changes into his working copy, his copy of file A is somehow flagged as being in a state of conflict: he'll be able to see both sets of conflicting changes and manually choose between them. Note that software can't automatically resolve conflicts; only humans are capable of understanding and making the necessary intelligent choices. Once Harry has manually resolved the overlapping changes—perhaps after a discussion with Sally—he can safely save the merged file back to the repository.</p><p>The copy-modify-merge model may sound a bit chaotic, but in practice, it runs extremely smoothly. Users can work in parallel, never waiting for one another. When they work on the same files, it turns out that most of their concurrent changes don't overlap at all; conflicts are infrequent. And the amount of time it takes to resolve conflicts is usually far less than the time lost by a locking system.</p><p>In the end, it all comes down to one critical factor: user communication. When users communicate poorly, both syntactic and semantic conflicts increase. No system can force users to communicate perfectly, and no system can detect semantic conflicts. So there's no point in being lulled into a false sense of security that a locking system will somehow prevent conflicts; in practice, locking seems to inhibit productivity more than anything else.</p><div class="sidebar"><a id="svn.basic.vsn-models.copy-merge.sb-1"></a><div class="titlepage"><div><div><p class="title"><strong>When Locking Is Necessary</strong></p></div></div></div><p>While the lock-modify-unlock model is considered generally harmful to collaboration, sometimes locking is appropriate.</p><p>The copy-modify-merge model is based on the assumption that files are contextually mergeable—that is, that the majority of the files in the repository are line-based text files (such as program source code). But for files with binary formats, such as artwork or sound, it's often impossible to merge conflicting changes. In these situations, it really is necessary for users to take strict turns when changing the file. Without serialized access, somebody ends up wasting time on changes that are ultimately discarded.</p><p>While Subversion is primarily a copy-modify-merge system, it still recognizes the need to lock an occasional file, and thus provides mechanisms for this. We discuss this feature in <a class="xref" href="#svn.advanced.locking" title="Locking">the section called “Locking”</a>.</p></div></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.basic.in-action"></a>Version Control the Subversion Way</h2></div></div></div><p>We've mentioned already that Subversion is a modern, network-aware version control system. As we described in <a class="xref" href="#svn.basic.version-control-basics" title="Version Control Basics">the section called “Version Control Basics”</a> (our high-level version control overview), a repository serves as the core storage mechanism for Subversion's versioned data, and it's via working copies that users and their software programs interact with that data. In this section, we'll begin to introduce the specific ways in which Subversion implements version control.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.basic.svn-repositories"></a>Subversion Repositories</h3></div></div></div><p>Subversion implements the concept of a version control repository much as any other modern version control system would. Unlike a working copy, a Subversion repository is an abstract entity, able to be operated upon almost exclusively by Subversion's own libraries and tools. As most of a user's Subversion interactions involve the use of the Subversion client and occur in the context of a working copy, we spend the majority of this book discussing the Subversion working copy and how to manipulate it. For the finer details of the repository, though, check out <a class="xref" href="#svn.reposadmin" title="Chapter 5. Repository Administration">Chapter 5, <em>Repository Administration</em></a>.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.basic.in-action.revs"></a>Revisions</h3></div></div></div><a id="idm528" class="indexterm"></a><p>A Subversion client commits (that is, communicates the changes made to) any number of files and directories as a single atomic transaction. By atomic transaction, we mean simply this: either all of the changes are accepted into the repository, or none of them is. Subversion tries to retain this atomicity in the face of program crashes, system crashes, network problems, and other users' actions.</p><p>Each time the repository accepts a commit, this creates a new state of the filesystem tree, called a <em class="firstterm">revision</em>. Each revision is assigned a unique natural number, one greater than the number assigned to the previous revision. The initial revision of a freshly created repository is numbered 0 and consists of nothing but an empty root directory.</p><p><a class="xref" href="#svn.basic.in-action.revs.dia-1" title="Figure 1.6. Tree changes over time">Figure 1.6, “Tree changes over time”</a> illustrates a nice way to visualize the repository. Imagine an array of revision numbers, starting at 0, stretching from left to right. Each revision number has a filesystem tree hanging below it, and each tree is a <span class="quote">“<span class="quote">snapshot</span>”</span> of the way the repository looked after a commit.</p><div class="figure"><a id="svn.basic.in-action.revs.dia-1"></a><p class="title"><strong>Figure 1.6. Tree changes over time</strong></p><div class="figure-contents"><div><img src="images/ch02dia7.png" alt="Tree changes over time"></img></div></div></div><br class="figure-break"></br><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Global Revision Numbers</strong></p></div></div></div><a id="idm542" class="indexterm"></a><p>Unlike most version control systems, Subversion's revision numbers apply to <span class="emphasis"><em>the entire repository tree</em></span>, not individual files. Each revision number selects an entire tree, a particular state of the repository after some committed change. Another way to think about it is that revision N represents the state of the repository filesystem after the Nth commit. When Subversion users talk about <span class="quote">“<span class="quote">revision 5 of <code class="filename">foo.c</code>,</span>”</span> they really mean <span class="quote">“<span class="quote"><code class="filename">foo.c</code> as it appears in revision 5.</span>”</span> Notice that in general, revisions N and M of a file do <span class="emphasis"><em>not</em></span> necessarily differ! Many other version control systems use per-file revision numbers, so this concept may seem unusual at first. (Former CVS users might want to see <a class="xref" href="#svn.forcvs" title="Appendix B. Subversion for CVS Users">Appendix B, <em>Subversion for CVS Users</em></a> for more details.)</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.reposurls"></a>Addressing the Repository</h3></div></div></div><a id="idm555" class="indexterm"></a><a id="idm559" class="indexterm"></a><p>Subversion client programs use URLs to identify versioned files and directories in Subversion repositories. For the most part, these URLs use the standard syntax, allowing for server names and port numbers to be specified as part of the URL.</p><div class="informalexample"><div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: disc; "><li class="listitem">http://svn.example.com/svn/project</li><li class="listitem">http://svn.example.com:9834/repos</li></ul></div></div><p>Subversion repository URLs aren't limited to only the <code class="literal">http://</code> variety. Because Subversion offers several different ways for its clients to communicate with its servers, the URLs used to address the repository differ subtly depending on which repository access mechanism is employed. <a class="xref" href="#svn.basic.in-action.wc.tbl-1" title="Table 1.1. Repository access URLs">Table 1.1, “Repository access URLs”</a> describes how different URL schemes map to the available repository access methods. For more details about Subversion's server options, see <a class="xref" href="#svn.serverconfig" title="Chapter 6. Server Configuration">Chapter 6, <em>Server Configuration</em></a>.</p><div class="table"><a id="svn.basic.in-action.wc.tbl-1"></a><p class="title"><strong>Table 1.1. Repository access URLs</strong></p><div class="table-contents"><table class="table" summary="Repository access URLs" border="1"><colgroup><col></col><col></col></colgroup><thead><tr><th>Schema</th><th>Access method</th></tr></thead><tbody><tr><td><code class="literal">file:///</code></td><td>Direct repository access (on local disk)</td></tr><tr><td><code class="literal">http://</code></td><td>Access via WebDAV protocol to Subversion-aware Apache server</td></tr><tr><td><code class="literal">https://</code></td><td>Same as <code class="literal">http://</code>, but with SSL encapsulation (encryption and authentication)</td></tr><tr><td><code class="literal">svn://</code></td><td>Access via custom protocol to an <code class="literal">svnserve</code> server</td></tr><tr><td><code class="literal">svn+ssh://</code></td><td>Same as <code class="literal">svn://</code>, but through an SSH tunnel</td></tr></tbody></table></div></div><br class="table-break"></br><p>Subversion's handling of URLs has some notable nuances. For example, URLs containing the <code class="literal">file://</code> access method (used for local repositories) must, in accordance with convention, have either a server name of <code class="literal">localhost</code> or no server name at all:</p><div class="informalexample"><div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: disc; "><li class="listitem">file:///var/svn/repos</li><li class="listitem">file://localhost/var/svn/repos</li></ul></div></div><p>Also, users of the <code class="literal">file://</code> scheme on Windows platforms will need to use an unofficially <span class="quote">“<span class="quote">standard</span>”</span> syntax for accessing repositories that are on the same machine, but on a different drive than the client's current working drive. Either of the two following URL path syntaxes will work, where <code class="literal">X</code> is the drive on which the repository resides:</p><div class="informalexample"><div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: disc; "><li class="listitem">file:///X:/var/svn/repos</li><li class="listitem">file:///X|/var/svn/repos</li></ul></div></div><p>Note that a URL uses forward slashes even though the native (non-URL) form of a path on Windows uses backslashes. Also note that when using the <code class="literal">file:///<em class="replaceable"><code>X</code></em>|/</code> form at the command line, you need to quote the URL (wrap it in quotation marks) so that the vertical bar character is not interpreted as a pipe.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>You cannot use Subversion's <code class="literal">file://</code> URLs in a regular web browser the way typical <code class="literal">file://</code> URLs can. When you attempt to view a <code class="literal">file://</code> URL in a regular web browser, it reads and displays the contents of the file at that location by examining the filesystem directly. However, Subversion's resources exist in a virtual filesystem (see <a class="xref" href="#svn.developer.layerlib.repos" title="Repository Layer">the section called “Repository Layer”</a>), and your browser will not understand how to interact with that filesystem.</p></td></tr></table></div><p>The Subversion client will automatically encode URLs as necessary, just like a web browser does. For example, the URL <code class="literal">http://host/path with space/project/españa</code> — which contains both spaces and upper-ASCII characters — will be automatically interpreted by Subversion as if you'd provided <code class="literal">http://host/path%20with%20space/project/espa%C3%B1a</code>. If the URL contains spaces, be sure to place it within quotation marks at the command line so that your shell treats the whole thing as a single argument to the program.</p><p>There is one notable exception to Subversion's handling of URLs which also applies to its handling of local paths in many contexts, too. If the final path component of your URL or local path contains an at sign (<code class="literal">@</code>), you need to use a special syntax—described in <a class="xref" href="#svn.advanced.pegrevs" title="Peg and Operative Revisions">the section called “Peg and Operative Revisions”</a>—in order to make Subversion properly address that resource.</p><p>In Subversion 1.6, a new caret (<code class="literal">^</code>) notation was introduced as a shorthand for <span class="quote">“<span class="quote">the URL of the repository's root directory</span>”</span>. For example, you can use the <code class="literal">^/tags/bigsandwich/</code> to refer to the URL of the <code class="filename">/tags/bigsandwich</code> directory in the root of the repository. Note that this URL syntax works only when your current working directory is a working copy—the command-line client knows the repository's root URL by looking at the working copy's metadata. Also note that when you wish to refer precisely to the root directory of the repository, you must do so using <code class="literal">^/</code> (with the trailing slash character), not merely <code class="literal">^</code>.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.basic.in-action.wc"></a>Subversion Working Copies</h3></div></div></div><a id="idm648" class="indexterm"></a><p>A Subversion working copy is an ordinary directory tree on your local system, containing a collection of files. You can edit these files however you wish, and if they're source code files, you can compile your program from them in the usual way. Your working copy is your own private work area: Subversion will never incorporate other people's changes, nor make your own changes available to others, until you explicitly tell it to do so. You can even have multiple working copies of the same project.</p><p>After you've made some changes to the files in your working copy and verified that they work properly, Subversion provides you with commands to <span class="quote">“<span class="quote">publish</span>”</span> your changes to the other people working with you on your project (by writing to the repository). If other people publish their own changes, Subversion provides you with commands to merge those changes into your working copy (by reading from the repository).</p><p>A working copy also contains some extra files, created and maintained by Subversion, to help it carry out these commands. In particular, each working copy contains a subdirectory named <code class="filename">.svn</code>, also known as the working copy's <em class="firstterm">administrative directory</em>. The files in the administrative directory help Subversion recognize which of your versioned files contain unpublished changes, and which files are out of date with respect to others' work.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Prior to version 1.7, Subversion maintained <code class="filename">.svn</code> administrative subdirectories in <span class="emphasis"><em>every</em></span> versioned directory of your working copy. Subversion 1.7 offers a completely new approach to how working copy metadata is stored and maintained, and chief among the visible changes to this approach is that each working copy now has only one <code class="filename">.svn</code> subdirectory which is an immediate child of the root of that working copy.</p></td></tr></table></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>While <code class="filename">.svn</code> is the de facto name of the Subversion administrative directory, Windows users may run into problems with the ASP.NET Web application framework disallowing access to directories whose names begin with a dot (<code class="literal">.</code>). As a special consideration to users in such situations, Subversion will instead use <code class="literal">_svn</code> as the administrative directory name if it finds a variable named <code class="literal">SVN_ASP_DOT_NET_HACK</code> in its operating environment. Throughout this book, any reference you find to <code class="filename">.svn</code> applies also to <code class="literal">_svn</code> when this <span class="quote">“<span class="quote">ASP.NET hack</span>”</span> is in use.</p></td></tr></table></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.basic.in-action.track-repos"></a>How the working copy works</h4></div></div></div><p>For each file in a working directory, Subversion records (among other things) two essential pieces of information:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>What revision your working file is based on (this is called the file's <em class="firstterm">working revision</em>)</p></li><li class="listitem"><p>A timestamp recording when the local copy was last updated by the repository</p></li></ul></div><p>Given this information, by talking to the repository, Subversion can tell which of the following four states a working file is in:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">Unchanged, and current</span></dt><dd><p>The file is unchanged in the working directory, and no changes to that file have been committed to the repository since its working revision. An <span class="command"><strong>svn commit</strong></span> of the file will do nothing, and an <span class="command"><strong>svn update</strong></span> of the file will do nothing.</p></dd><dt><span class="term">Locally changed, and current</span></dt><dd><p>The file has been changed in the working directory, and no changes to that file have been committed to the repository since you last updated. There are local changes that have not been committed to the repository; thus an <span class="command"><strong>svn commit</strong></span> of the file will succeed in publishing your changes, and an <span class="command"><strong>svn update</strong></span> of the file will do nothing.</p></dd><dt><span class="term">Unchanged, and out of date</span></dt><dd><p>The file has not been changed in the working directory, but it has been changed in the repository. The file should eventually be updated in order to make it current with the latest public revision. An <span class="command"><strong>svn commit</strong></span> of the file will do nothing, and an <span class="command"><strong>svn update</strong></span> of the file will fold the latest changes into your working copy.</p></dd><dt><span class="term">Locally changed, and out of date</span></dt><dd><p>The file has been changed both in the working directory and in the repository. An <span class="command"><strong>svn commit</strong></span> of the file will fail with an <span class="quote">“<span class="quote">out-of-date</span>”</span> error. The file should be updated first; an <span class="command"><strong>svn update</strong></span> command will attempt to merge the public changes with the local changes. If Subversion can't complete the merge in a plausible way automatically, it leaves it to the user to resolve the conflict.</p></dd></dl></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.basic.in-action.wc-funcdamentals"></a>Fundamental working copy interactions</h4></div></div></div><p>A typical Subversion repository often holds the files (or source code) for several projects; usually, each project is a subdirectory in the repository's filesystem tree. In this arrangement, a user's working copy will usually correspond to a particular subtree of the repository.</p><p>For example, suppose you have a repository that contains two software projects, <code class="literal">paint</code> and <code class="literal">calc</code>. Each project lives in its own top-level subdirectory, as shown in <a class="xref" href="#svn.basic.in-action.wc.dia-1" title="Figure 1.7. The repository's filesystem">Figure 1.7, “The repository's filesystem”</a>.</p><div class="figure"><a id="svn.basic.in-action.wc.dia-1"></a><p class="title"><strong>Figure 1.7. The repository's filesystem</strong></p><div class="figure-contents"><div><img src="images/ch02dia6.png" alt="The repository's filesystem"></img></div></div></div><br class="figure-break"></br><a id="idm717" class="indexterm"></a><a id="idm721" class="indexterm"></a><a id="idm724" class="indexterm"></a><p>To get a working copy, you must <em class="firstterm">check out</em> some subtree of the repository. (The term <span class="emphasis"><em>check out</em></span> may sound like it has something to do with locking or reserving resources, but it doesn't; it simply creates a working copy of the project for you.) For example, if you check out <code class="filename">/calc</code>, you will get a working copy like this:</p><div class="informalexample"><pre class="screen"> $ svn checkout http://svn.example.com/repos/calc A calc/Makefile A calc/integer.c A calc/button.c Checked out revision 56. $ ls -A calc Makefile button.c integer.c .svn/ $ </pre></div><p>The list of letter <code class="literal">A</code>s in the left margin indicates that Subversion is adding a number of items to your working copy. You now have a personal copy of the repository's <code class="filename">/calc</code> directory, with one additional entry—<code class="filename">.svn</code>—which holds the extra information needed by Subversion, as mentioned earlier.</p><p>Suppose you make changes to <code class="filename">button.c</code>. Since the <code class="filename">.svn</code> directory remembers the file's original modification date and contents, Subversion can tell that you've changed the file. However, Subversion does not make your changes public until you explicitly tell it to. The act of publishing your changes is more commonly known as <em class="firstterm">committing</em> (or <em class="firstterm">checking in</em>) changes to the repository.</p><a id="idm742" class="indexterm"></a><a id="idm746" class="indexterm"></a><a id="idm749" class="indexterm"></a><p>To publish your changes to others, you can use Subversion's <span class="command"><strong>svn commit</strong></span> command:</p><div class="informalexample"><pre class="screen"> $ svn commit button.c -m "Fixed a typo in button.c." Sending button.c Transmitting file data . Committed revision 57. $ </pre></div><p>Now your changes to <code class="filename">button.c</code> have been committed to the repository, with a note describing your change (namely, that you fixed a typo). If another user checks out a working copy of <code class="filename">/calc</code>, she will see your changes in the latest version of the file.</p><p>Suppose you have a collaborator, Sally, who checked out a working copy of <code class="filename">/calc</code> at the same time you did. When you commit your change to <code class="filename">button.c</code>, Sally's working copy is left unchanged; Subversion modifies working copies only at the user's request.</p><a id="idm762" class="indexterm"></a><a id="idm766" class="indexterm"></a><a id="idm769" class="indexterm"></a><p>To bring her project up to date, Sally can ask Subversion to <em class="firstterm">update</em> her working copy, by using the <span class="command"><strong>svn update</strong></span> command. This will incorporate your changes into her working copy, as well as any others that have been committed since she checked it out.</p><div class="informalexample"><pre class="screen"> $ pwd /home/sally/calc $ ls -A Makefile button.c integer.c .svn/ $ svn update Updating '.': U button.c Updated to revision 57. $ </pre></div><p>The output from the <span class="command"><strong>svn update</strong></span> command indicates that Subversion updated the contents of <code class="filename">button.c</code>. Note that Sally didn't need to specify which files to update; Subversion uses the information in the <code class="filename">.svn</code> directory as well as further information in the repository, to decide which files need to be brought up to date.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.basic.in-action.mixedrevs"></a>Mixed-revision working copies</h4></div></div></div><a id="idm783" class="indexterm"></a><p>As a general principle, Subversion tries to be as flexible as possible. One special kind of flexibility is the ability to have a working copy containing files and directories with a mix of different working revision numbers. Subversion working copies do not always correspond to any single revision in the repository; they may contain files from several different revisions. For example, suppose you check out a working copy from a repository whose most recent revision is 4:</p><div class="informalexample"><div class="literallayout"><p><br></br> calc/<br></br>    Makefile:4<br></br>    integer.c:4<br></br>    button.c:4<br></br> </p></div></div><p>At the moment, this working directory corresponds exactly to revision 4 in the repository. However, suppose you make a change to <code class="filename">button.c</code>, and commit that change. Assuming no other commits have taken place, your commit will create revision 5 of the repository, and your working copy will now look like this:</p><div class="informalexample"><div class="literallayout"><p><br></br> calc/<br></br>    Makefile:4<br></br>    integer.c:4<br></br>    button.c:5<br></br> </p></div></div><p>Suppose that, at this point, Sally commits a change to <code class="filename">integer.c</code>, creating revision 6. If you use <span class="command"><strong>svn update</strong></span> to bring your working copy up to date, it will look like this:</p><div class="informalexample"><div class="literallayout"><p><br></br> calc/<br></br>    Makefile:6<br></br>    integer.c:6<br></br>    button.c:6<br></br> </p></div></div><p>Sally's change to <code class="filename">integer.c</code> will appear in your working copy, and your change will still be present in <code class="filename">button.c</code>. In this example, the text of <code class="filename">Makefile</code> is identical in revisions 4, 5, and 6, but Subversion will mark your working copy of <code class="filename">Makefile</code> with revision 6 to indicate that it is still current. So, after you do a clean update at the top of your working copy, it will generally correspond to exactly one revision in the repository.</p><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.basic.in-action.mixedrevs.update-commit"></a>Updates and commits are separate</h5></div></div></div><p>One of the fundamental rules of Subversion is that a <span class="quote">“<span class="quote">push</span>”</span> action does not cause a <span class="quote">“<span class="quote">pull</span>”</span> nor vice versa. Just because you're ready to submit new changes to the repository doesn't mean you're ready to receive changes from other people. And if you have new changes still in progress, <span class="command"><strong>svn update</strong></span> should gracefully merge repository changes into your own, rather than forcing you to publish them.</p><p>The main side effect of this rule is that it means a working copy has to do extra bookkeeping to track mixed revisions as well as be tolerant of the mixture. It's made more complicated by the fact that directories themselves are versioned.</p><p>For example, suppose you have a working copy entirely at revision 10. You edit the file <code class="filename">foo.html</code> and then perform an <span class="command"><strong>svn commit</strong></span>, which creates revision 15 in the repository. After the commit succeeds, many new users would expect the working copy to be entirely at revision 15, but that's not the case! Any number of changes might have happened in the repository between revisions 10 and 15. The client knows nothing of those changes in the repository, since you haven't yet run <span class="command"><strong>svn update</strong></span>, and <span class="command"><strong>svn commit</strong></span> doesn't pull down new changes. If, on the other hand, <span class="command"><strong>svn commit</strong></span> were to automatically download the newest changes, it would be possible to set the entire working copy to revision 15—but then we'd be breaking the fundamental rule of <span class="quote">“<span class="quote">push</span>”</span> and <span class="quote">“<span class="quote">pull</span>”</span> remaining separate actions. Therefore, the only safe thing the Subversion client can do is mark the one file—<code class="filename">foo.html</code>—as being at revision 15. The rest of the working copy remains at revision 10. Only by running <span class="command"><strong>svn update</strong></span> can the latest changes be downloaded and the whole working copy be marked as revision 15.</p></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.basic.in-action.mixedrevs.normal"></a>Mixed revisions are normal</h5></div></div></div><p>The fact is, <span class="emphasis"><em>every time</em></span> you run <span class="command"><strong>svn commit</strong></span> your working copy ends up with some mixture of revisions. The things you just committed are marked as having larger working revisions than everything else. After several commits (with no updates in between), your working copy will contain a whole mixture of revisions. Even if you're the only person using the repository, you will still see this phenomenon. To examine your mixture of working revisions, use the <span class="command"><strong>svn status</strong></span> command with the <code class="option">--verbose</code> (<code class="option">-v</code>) option (see <a class="xref" href="#svn.tour.cycle.examine.status" title="See an overview of your changes">the section called “See an overview of your changes”</a> for more information).</p><p>Often, new users are completely unaware that their working copy contains mixed revisions. This can be confusing, because many client commands are sensitive to the working revision of the item they're examining. For example, the <span class="command"><strong>svn log</strong></span> command is used to display the history of changes to a file or directory (see <a class="xref" href="#svn.tour.history.log" title="Generating a List of Historical Changes">the section called “Generating a List of Historical Changes”</a>). When the user invokes this command on a working copy object, he expects to see the entire history of the object. But if the object's working revision is quite old (often because <span class="command"><strong>svn update</strong></span> hasn't been run in a long time), the history of the <span class="emphasis"><em>older</em></span> version of the object is shown.</p></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.basic.in-action.mixedrevs.useful"></a>Mixed revisions are useful</h5></div></div></div><p>If your project is sufficiently complex, you'll discover that it's sometimes nice to forcibly <em class="firstterm">backdate</em> (or update to a revision older than the one you already have) portions of your working copy to an earlier revision; you'll learn how to do that in <a class="xref" href="#svn.tour" title="Chapter 2. Basic Usage">Chapter 2, <em>Basic Usage</em></a>. Perhaps you'd like to test an earlier version of a submodule contained in a subdirectory, or perhaps you'd like to figure out when a bug first came into existence in a specific file. This is the <span class="quote">“<span class="quote">time machine</span>”</span> aspect of a version control system—the feature that allows you to move any portion of your working copy forward and backward in history.</p></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.basic.in-action.mixedrevs.limits"></a>Mixed revisions have limitations</h5></div></div></div><p>However you make use of mixed revisions in your working copy, there are limitations to this flexibility.</p><p>First, you cannot commit the deletion of a file or directory that isn't fully up to date. If a newer version of the item exists in the repository, your attempt to delete will be rejected to prevent you from accidentally destroying changes you've not yet seen.</p><p>Second, you cannot commit a metadata change to a directory unless it's fully up to date. You'll learn about attaching <span class="quote">“<span class="quote">properties</span>”</span> to items in <a class="xref" href="#svn.advanced" title="Chapter 3. Advanced Topics">Chapter 3, <em>Advanced Topics</em></a>. A directory's working revision defines a specific set of entries and properties, and thus committing a property change to an out-of-date directory may destroy properties you've not yet seen.</p><p>Finally, beginning in Subversion 1.7, you cannot by default use a mixed-revision working copy as the target of a merge operation. (This new requirement was introduced to prevent common problems which stem from doing so.)</p></div></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.basic.summary"></a>Summary</h2></div></div></div><p>We covered a number of fundamental Subversion concepts in this chapter:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>We introduced the notions of the central repository, the client working copy, and the array of repository revision trees.</p></li><li class="listitem"><p>We saw some simple examples of how two collaborators can use Subversion to publish and receive changes from one another, using the <span class="quote">“<span class="quote">copy-modify-merge</span>”</span> model.</p></li><li class="listitem"><p>We talked a bit about the way Subversion tracks and manages information in a working copy.</p></li></ul></div><p>At this point, you should have a good idea of how Subversion works in the most general sense. Armed with this knowledge, you should now be ready to move into the next chapter, which is a detailed tour of Subversion's commands and features.</p></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm446" class="footnote"><p><a href="#idm446" class="para"><sup class="para">[5] </sup></a>The term <span class="quote">“<span class="quote">working copy</span>”</span> can be generally applied to any one file version's local instance. When most folks use the term, though, they are referring to a whole directory tree containing files and subdirectories managed by the version control system.</p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="svn.tour"></a>Chapter 2. Basic Usage</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.tour.help">Help!</a></span></dt><dt><span class="sect1"><a href="#svn.tour.importing">Getting Data into Your Repository</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.tour.importing.import">Importing Files and Directories</a></span></dt><dt><span class="sect2"><a href="#svn.tour.importing.layout">Recommended Repository Layout</a></span></dt><dt><span class="sect2"><a href="#svn.tour.importing.naming">What's In a Name?</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.tour.initial">Creating a Working Copy</a></span></dt><dt><span class="sect1"><a href="#svn.tour.cycle">Basic Work Cycle</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.tour.cycle.update">Update Your Working Copy</a></span></dt><dt><span class="sect2"><a href="#svn.tour.cycle.edit">Make Your Changes </a></span></dt><dt><span class="sect2"><a href="#svn.tour.cycle.examine">Review Your Changes</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.tour.cycle.examine.status">See an overview of your changes</a></span></dt><dt><span class="sect3"><a href="#svn.tour.cycle.examine.diff">Examine the details of your local modifications</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.tour.cycle.revert">Fix Your Mistakes</a></span></dt><dt><span class="sect2"><a href="#svn.tour.cycle.resolve">Resolve Any Conflicts</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.tour.cycle.resolve.diff">Viewing conflict differences interactively</a></span></dt><dt><span class="sect3"><a href="#svn.tour.cycle.resolve.resolve">Resolving conflict differences interactively</a></span></dt><dt><span class="sect3"><a href="#svn.tour.cycle.resolve.pending">Postponing conflict resolution</a></span></dt><dt><span class="sect3"><a href="#svn.tour.cycle.resolve.byhand">Merging conflicts by hand</a></span></dt><dt><span class="sect3"><a href="#svn.tour.cycle.resolve.theirsfull">Discarding your changes in favor of a newly fetched revision</a></span></dt><dt><span class="sect3"><a href="#svn.tour.cycle.resolve.revert">Punting: using svn revert</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.tour.cycle.commit">Commit Your Changes</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.tour.history">Examining History</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.tour.history.diff">Examining the Details of Historical Changes</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.tour.history.diff.local">Examining local changes</a></span></dt><dt><span class="sect3"><a href="#svn.tour.history.diff.wcrepos">Comparing working copy to repository</a></span></dt><dt><span class="sect3"><a href="#svn.tour.history.diff.reposrepos">Comparing repository revisions</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.tour.history.log">Generating a List of Historical Changes</a></span></dt><dt><span class="sect2"><a href="#svn.tour.history.browsing">Browsing the Repository</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.tour.history.browsing.cat">Displaying file contents</a></span></dt><dt><span class="sect3"><a href="#svn.tour.history.browsing.annotate">Displaying line-by-line change attribution</a></span></dt><dt><span class="sect3"><a href="#svn.tour.history.browsing.list">Listing versioned directories</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.tour.history.snapshots">Fetching Older Repository Snapshots</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.tour.cleanup">Sometimes You Just Need to Clean Up</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.tour.cleanup.disposal">Disposing of a Working Copy</a></span></dt><dt><span class="sect2"><a href="#svn.tour.cleanup.interruption">Recovering from an Interruption</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.tour.treeconflicts">Dealing with Structural Conflicts</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.tour.treeconflicts.example">An Example Tree Conflict</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.tour.summary">Summary</a></span></dt></dl></div><p>Theory is useful, but its application is just plain fun. Let's move now into the details of using Subversion. By the time you reach the end of this chapter, you will be able to perform all the tasks you need to use Subversion in a normal day's work. You'll start with getting your files into Subversion, followed by an initial checkout of your code. We'll then walk you through making changes and examining those changes. You'll also see how to bring changes made by others into your working copy, examine them, and work through any conflicts that might arise.</p><p>This chapter will not provide exhaustive coverage of all of Subversion's commands—rather, it's a conversational introduction to the most common Subversion tasks that you'll encounter. This chapter assumes that you've read and understood <a class="xref" href="#svn.basic" title="Chapter 1. Fundamental Concepts">Chapter 1, <em>Fundamental Concepts</em></a> and are familiar with the general model of Subversion. For a complete reference of all commands, see <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>.</p><p>Also, this chapter assumes that the reader is seeking information about how to interact in a basic fashion with an existing Subversion repository. No repository means no working copy; no working copy means not much of interest in this chapter. There are many Internet sites which offer free or inexpensive Subversion repository hosting services. Or, if you'd prefer to set up and administer your own repositories, check out <a class="xref" href="#svn.reposadmin" title="Chapter 5. Repository Administration">Chapter 5, <em>Repository Administration</em></a>. But don't expect the examples in this chapter to work without the user having access to a Subversion repository.</p><p>Finally, any Subversion operation that contacts the repository over a network may potentially require that the user authenticate. For the sake of simplicity, our examples throughout this chapter avoid demonstrating and discussing authentication. Be aware that if you hope to apply the knowledge herein to an existing, real-world Subversion instance, you'll probably be forced to provide at least a username and password to the server. See <a class="xref" href="#svn.serverconfig.netmodel.creds" title="Client Credentials">the section called “Client Credentials”</a> for a detailed description of Subversion's handling of authentication and client credentials.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.tour.help"></a>Help!</h2></div></div></div><a id="idm872" class="indexterm"></a><p>It goes without saying that this book exists to be a source of information and assistance for Subversion users new and old. Conveniently, though, the Subversion command-line is self-documenting, alleviating the need to grab a book off the shelf (wooden, virtual, or otherwise). The <span class="command"><strong>svn help</strong></span> command is your gateway to that built-in documentation:</p><div class="informalexample"><pre class="screen"> $ svn help Subversion command-line client, version 1.7.0. Type 'svn help &lt;subcommand&gt;' for help on a specific subcommand. Type 'svn --version' to see the program version and RA modules or 'svn --version --quiet' to see just the version number. Most subcommands take file and/or directory arguments, recursing on the directories. If no arguments are supplied to such a command, it recurses on the current directory (inclusive) by default. Available subcommands: add blame (praise, annotate, ann) cat … </pre></div><p>As described in the previous output, you can ask for help on a particular subcommand by running <strong class="userinput"><code>svn help <em class="replaceable"><code>SUBCOMMAND</code></em></code></strong>. Subversion will respond with the full usage message for that subcommand, including its syntax, options, and behavior:</p><div class="informalexample"><pre class="screen"> $ svn help help help (?, h): Describe the usage of this program or its subcommands. usage: help [SUBCOMMAND...] Global options: --username ARG : specify a username ARG --password ARG : specify a password ARG … </pre></div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Options and Switches and Flags, Oh My!</strong></p></div></div></div><a id="idm887" class="indexterm"></a><p>The Subversion command-line client has numerous command modifiers. Some folks refer to such things as <span class="quote">“<span class="quote">switches</span>”</span> or <span class="quote">“<span class="quote">flags</span>”</span>—in this book, we'll call them <span class="quote">“<span class="quote">options</span>”</span>. You'll find the options supported by a given <span class="command"><strong>svn</strong></span> subcommand, plus a set of options which are globally supported by all subcommands, listed near the bottom of the built-in usage message for that subcommand.</p><p>Subversion's options have two distinct forms: short options are a single hyphen followed by a single letter, and long options consist of two hyphens followed by several letters and hyphens (e.g., <code class="literal">-s</code> and <code class="literal">--this-is-a-long-option</code>, respectively). Every option has at least one long format. Some, such as the <code class="option">--changelist</code> option, feature an abbreviated long-format alias (<code class="option">--cl</code>, in this case). Only certain options—generally the most-used ones—have an additional short format. To maintain clarity in this book, we usually use the long form in code examples, but when describing options, if there's a short form, we'll provide the long form (to improve clarity) and the short form (to make it easier to remember). Use the form you're more comfortable with when executing your own Subversion commands.</p></div><p>Many Unix-based distributions of Subversion include manual pages of the sort that can be invoked using the <span class="command"><strong>man</strong></span> program, but those tend to carry only pointers to other sources of real help, such as the project's website and to the website which hosts this book. Also, several companies offer Subversion help and support, too, usually via a mixture of web-based discussion forums and fee-based consulting. And of course, the Internet holds a decade's worth of Subversion-related discussions just begging to be located by your favorite search engine. Subversion help is never too far away.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.tour.importing"></a>Getting Data into Your Repository</h2></div></div></div><p>You can get new files into your Subversion repository in two ways: <span class="command"><strong>svn import</strong></span> and <span class="command"><strong>svn add</strong></span>. We'll discuss <span class="command"><strong>svn import</strong></span> now and will discuss <span class="command"><strong>svn add</strong></span> later in this chapter when we review a typical day with Subversion.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.importing.import"></a>Importing Files and Directories</h3></div></div></div><a id="idm911" class="indexterm"></a><p>The <span class="command"><strong>svn import</strong></span> command is a quick way to copy an unversioned tree of files into a repository, creating intermediate directories as necessary. <span class="command"><strong>svn import</strong></span> doesn't require a working copy, and your files are immediately committed to the repository. You typically use this when you have an existing tree of files that you want to begin tracking in your Subversion repository. For example:</p><div class="informalexample"><pre class="screen"> $ svn import /path/to/mytree \ http://svn.example.com/svn/repo/some/project \ -m "Initial import" Adding mytree/foo.c Adding mytree/bar.c Adding mytree/subdir Adding mytree/subdir/quux.h Committed revision 1. $ </pre></div><p>The previous example copied the contents of the local directory <code class="filename">mytree</code> into the directory <code class="filename">some/project</code> in the repository. Note that you didn't have to create that new directory first—<span class="command"><strong>svn import</strong></span> does that for you. Immediately after the commit, you can see your data in the repository:</p><div class="informalexample"><pre class="screen"> $ svn list http://svn.example.com/svn/repo/some/project bar.c foo.c subdir/ $ </pre></div><p>Note that after the import is finished, the original local directory is <span class="emphasis"><em>not</em></span> converted into a working copy. To begin working on that data in a versioned fashion, you still need to create a fresh working copy of that tree.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.importing.layout"></a>Recommended Repository Layout</h3></div></div></div><a id="idm930" class="indexterm"></a><a id="idm932" class="indexterm"></a><a id="idm934" class="indexterm"></a><a id="idm936" class="indexterm"></a><p>Subversion provides the ultimate flexibility in terms of how you arrange your data. Because it simply versions directories and files, and because it ascribes no particular meaning to any of those objects, you may arrange the data in your repository in any way that you choose. Unfortunately, this flexibility also means that it's easy to find yourself <span class="quote">“<span class="quote">lost without a roadmap</span>”</span> as you attempt to navigate different Subversion repositories which may carry completely different and unpredictable arrangements of the data within them.</p><p>To counteract this confusion, we recommend that you follow a repository layout convention (established long ago, in the nascency of the Subversion project itself) in which a handful of strategically named Subversion repository directories convey valuable meaning about the data they hold. Most projects have a recognizable <span class="quote">“<span class="quote">main line</span>”</span>, or <em class="firstterm">trunk</em>, of development; some <em class="firstterm">branches</em>, which are divergent copies of development lines; and some <em class="firstterm">tags</em>, which are named, stable snapshots of a particular line of development. So we first recommend that each project have a recognizable <em class="firstterm">project root</em> in the repository, a directory under which all of the versioned information for that project—and only that project—lives. Secondly, we suggest that each project root contain a <code class="filename">trunk</code> subdirectory for the main development line, a <code class="filename">branches</code> subdirectory in which specific branches (or collections of branches) will be created, and a <code class="filename">tags</code> subdirectory in which specific tags (or collections of tags) will be created. Of course, if a repository houses only a single project, the root of the repository can serve as the project root, too.</p><p>Here are some examples:</p><div class="informalexample"><pre class="screen"> $ svn list file:///var/svn/single-project-repo trunk/ branches/ tags/ $ svn list file:///var/svn/multi-project-repo project-A/ project-B/ $ svn list file:///var/svn/multi-project-repo/project-A trunk/ branches/ tags/ $ </pre></div><p>We talk much more about tags and branches in <a class="xref" href="#svn.branchmerge" title="Chapter 4. Branching and Merging">Chapter 4, <em>Branching and Merging</em></a>. For details and some advice on how to set up repositories when you have multiple projects, see <a class="xref" href="#svn.branchmerge.maint.layout" title="Repository Layout">the section called “Repository Layout”</a>. Finally, we discuss project roots more in <a class="xref" href="#svn.reposadmin.projects.chooselayout" title="Planning Your Repository Organization">the section called “Planning Your Repository Organization”</a>.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.importing.naming"></a>What's In a Name?</h3></div></div></div><p>Subversion tries hard not to limit the type of data you can place under version control. The contents of files and property values are stored and transmitted as binary data, and <a class="xref" href="#svn.advanced.props.special.mime-type" title="File Content Type">the section called “File Content Type”</a> tells you how to give Subversion a hint that <span class="quote">“<span class="quote">textual</span>”</span> operations don't make sense for a particular file. There are a few places, however, where Subversion places restrictions on information it stores.</p><p>Subversion internally handles certain bits of data—for example, property names, pathnames, and log messages—as UTF-8-encoded Unicode. This is not to say that all your interactions with Subversion must involve UTF-8, though. As a general rule, Subversion clients will gracefully and transparently handle conversions between UTF-8 and the encoding system in use on your computer, if such a conversion can meaningfully be done (which is the case for most common encodings in use today).</p><p>In WebDAV exchanges and older versions of some of Subversion's administrative files, paths are used as XML attribute values, and property names in XML tag names. This means that pathnames can contain only legal XML (1.0) characters, and properties are further limited to ASCII characters. Subversion also prohibits <code class="literal">TAB</code>, <code class="literal">CR</code>, and <code class="literal">LF</code> characters in path names to prevent paths from being broken up in diffs or in the output of commands such as <span class="command"><strong>svn log</strong></span> or <span class="command"><strong>svn status</strong></span>.</p><p>While it may seem like a lot to remember, in practice these limitations are rarely a problem. As long as your locale settings are compatible with UTF-8 and you don't use control characters in path names, you should have no trouble communicating with Subversion. The command-line client adds an extra bit of help—to create <span class="quote">“<span class="quote">legally correct</span>”</span> versions for internal use it will automatically escape illegal path characters as needed in URLs that you type.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.tour.initial"></a>Creating a Working Copy</h2></div></div></div><a id="idm972" class="indexterm"></a><p>Most of the time, you will start using a Subversion repository by performing a <em class="firstterm">checkout</em> of your project. Checking out a directory from a repository creates a working copy of that directory on your local machine. Unless otherwise specified, this copy contains the youngest (that is, most recently created or modified) versions of the directory and its children found in the Subversion repository:</p><div class="informalexample"><pre class="screen"> $ svn checkout http://svn.example.com/svn/repo/trunk A trunk/README A trunk/INSTALL A trunk/src/main.c A trunk/src/header.h … Checked out revision 8810. $ </pre></div><p>Although the preceding example checks out the trunk directory, you can just as easily check out a deeper subdirectory of a repository by specifying that subdirectory's URL as the checkout URL:</p><div class="informalexample"><pre class="screen"> $ svn checkout http://svn.example.com/svn/repo/trunk/src A src/main.c A src/header.h A src/lib/helpers.c … Checked out revision 8810. $ </pre></div><p>Since Subversion uses a copy-modify-merge model instead of lock-modify-unlock (see <a class="xref" href="#svn.basic.vsn-models" title="Versioning Models">the section called “Versioning Models”</a>), you can immediately make changes to the files and directories in your working copy. Your working copy is just like any other collection of files and directories on your system. You can edit the files inside it, rename it, even delete the entire working copy and forget about it.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>While your working copy is <span class="quote">“<span class="quote">just like any other collection of files and directories on your system,</span>”</span> you can edit files at will, but you must tell Subversion about <span class="emphasis"><em>everything else</em></span> that you do. For example, if you want to copy or move an item in a working copy, you should use <span class="command"><strong>svn copy</strong></span> or <span class="command"><strong>svn move</strong></span> instead of the copy and move commands provided by your operating system. We'll talk more about them later in this chapter.</p></td></tr></table></div><p>Unless you're ready to commit the addition of a new file or directory or changes to existing ones, there's no need to further notify the Subversion server that you've done anything.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>What Is This .svn Directory?</strong></p></div></div></div><p>The topmost directory of a working copy—and prior to version 1.7, every versioned subdirectory thereof—contains a special administrative subdirectory named <code class="filename">.svn</code>. Usually, your operating system's directory listing commands won't show this subdirectory, but it is nevertheless an important directory. Whatever you do, don't delete or change anything in the administrative area! Subversion uses that directory and its contents to manage your working copy.</p></div><p>Notice that in the previous pair of examples, Subversion chose to create a working copy in a directory named for the final component of the checkout URL. This occurs only as a convenience to the user when the checkout URL is the only bit of information provided to the <span class="command"><strong>svn checkout</strong></span> command. Subversion's command-line client gives you additional flexibility, though, allowing you to optionally specify the local directory name that Subversion should use for the working copy it creates. For example:</p><div class="informalexample"><pre class="screen"> $ svn checkout http://svn.example.com/svn/repo/trunk my-working-copy A my-working-copy/README A my-working-copy/INSTALL A my-working-copy/src/main.c A my-working-copy/src/header.h … Checked out revision 8810. $ </pre></div><p>If the local directory you specify doesn't yet exist, that's okay—<span class="command"><strong>svn checkout</strong></span> will create it for you.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.tour.cycle"></a>Basic Work Cycle</h2></div></div></div><p>Subversion has numerous features, options, bells, and whistles, but on a day-to-day basis, odds are that you will use only a few of them. In this section, we'll run through the most common things that you might find yourself doing with Subversion in the course of a day's work.</p><p>The typical work cycle looks like this:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p><span class="emphasis"><em>Update your working copy.</em></span> This involves the use of the <span class="command"><strong>svn update</strong></span> command.</p></li><li class="listitem"><p><span class="emphasis"><em>Make your changes.</em></span> The most common changes that you'll make are edits to the contents of your existing files. But sometimes you need to add, remove, copy and move files and directories—the <span class="command"><strong>svn add</strong></span>, <span class="command"><strong>svn delete</strong></span>, <span class="command"><strong>svn copy</strong></span>, and <span class="command"><strong>svn move</strong></span> commands handle those sorts of structural changes within the working copy.</p></li><li class="listitem"><p><span class="emphasis"><em>Review your changes.</em></span> The <span class="command"><strong>svn status</strong></span> and <span class="command"><strong>svn diff</strong></span> commands are critical to reviewing the changes you've made in your working copy.</p></li><li class="listitem"><p><span class="emphasis"><em>Fix your mistakes.</em></span> Nobody's perfect, so as you review your changes, you may spot something that's not quite right. Sometimes the easiest way to fix a mistake is start all over again from scratch. The <span class="command"><strong>svn revert</strong></span> command restores a file or directory to its unmodified state.</p></li><li class="listitem"><p><span class="emphasis"><em>Resolve any conflicts (merge others' changes).</em></span> In the time it takes you to make and review your changes, others might have made and published changes, too. You'll want to integrate their changes into your working copy to avoid the potential out-of-dateness scenarios when you attempt to publish your own. Again, the <span class="command"><strong>svn update</strong></span> command is the way to do this. If this results in local conflicts, you'll need to resolve those using the <span class="command"><strong>svn resolve</strong></span> command.</p></li><li class="listitem"><p><span class="emphasis"><em>Publish (commit) your changes.</em></span> The <span class="command"><strong>svn commit</strong></span> command transmits your changes to the repository where, if they are accepted, they create the newest versions of all the things you modified. Now others can see your work, too!</p></li></ol></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.cycle.update"></a>Update Your Working Copy</h3></div></div></div><a id="idm1038" class="indexterm"></a><p>When working on a project that is being modified via multiple working copies, you'll want to update your working copy to receive any changes committed from other working copies since your last update. These might be changes that other members of your project team have made, or they might simply be changes you've made yourself from a different computer. To protect your data, Subversion won't allow you commit new changes to out-of-date files and directories, so it's best to have the latest versions of all your project's files and directories before making new changes of your own.</p><p>Use <span class="command"><strong>svn update</strong></span> to bring your working copy into sync with the latest revision in the repository:</p><div class="informalexample"><pre class="screen"> $ svn update Updating '.': U foo.c U bar.c Updated to revision 2. $ </pre></div><p>In this case, it appears that someone checked in modifications to both <code class="filename">foo.c</code> and <code class="filename">bar.c</code> since the last time you updated, and Subversion has updated your working copy to include those changes.</p><p>When the server sends changes to your working copy via <span class="command"><strong>svn update</strong></span>, a letter code is displayed next to each item to let you know what actions Subversion performed to bring your working copy up to date. To find out what these letters mean, run <strong class="userinput"><code>svn help update</code></strong> or see <a class="xref" href="#svn.ref.svn.c.update" title="svn update (up)">svn update (up)</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.cycle.edit"></a>Make Your Changes </h3></div></div></div><p>Now you can get to work and make changes in your working copy. You can make two kinds of changes to your working copy: <em class="firstterm">file changes</em> and <em class="firstterm">tree changes</em>. You don't need to tell Subversion that you intend to change a file; just make your changes using your text editor, word processor, graphics program, or whatever tool you would normally use. Subversion automatically detects which files have been changed, and in addition, it handles binary files just as easily as it handles text files—and just as efficiently, too. Tree changes are different, and involve changes to a directory's structure. Such changes include adding and removing files, renaming files or directories, and copying files or directories to new locations. For tree changes, you use Subversion operations to <span class="quote">“<span class="quote">schedule</span>”</span> files and directories for removal, addition, copying, or moving. These changes may take place immediately in your working copy, but no additions or removals will happen in the repository until you commit them.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Versioning Symbolic Links</strong></p></div></div></div><p>On non-Windows platforms, Subversion is able to version files of the special type <em class="firstterm">symbolic link</em> (or <span class="quote">“<span class="quote">symlink</span>”</span>). A symlink is a file that acts as a sort of transparent reference to some other object in the filesystem, allowing programs to read and write to those objects indirectly by performing operations on the symlink itself.</p><p>When a symlink is committed into a Subversion repository, Subversion remembers that the file was in fact a symlink, as well as the object to which the symlink <span class="quote">“<span class="quote">points.</span>”</span> When that symlink is checked out to another working copy on a non-Windows system, Subversion reconstructs a real filesystem-level symbolic link from the versioned symlink. But that doesn't in any way limit the usability of working copies on systems such as Windows that do not support symlinks. On such systems, Subversion simply creates a regular text file whose contents are the path to which the original symlink pointed. While that file can't be used as a symlink on a Windows system, it also won't prevent Windows users from performing their other Subversion-related activities.</p></div><p>Here is an overview of the five Subversion subcommands that you'll use most often to make tree changes:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><strong class="userinput"><code>svn add FOO</code></strong></span></dt><dd><a id="idm1074" class="indexterm"></a><p>Use this to schedule the file, directory, or symbolic link <code class="filename">FOO</code> to be added to the repository. When you next commit, <code class="filename">FOO</code> will become a child of its parent directory. Note that if <code class="filename">FOO</code> is a directory, everything underneath <code class="filename">FOO</code> will be scheduled for addition. If you want only to add <code class="filename">FOO</code> itself, pass the <code class="option">--depth=empty</code> option.</p></dd><dt><span class="term"><strong class="userinput"><code>svn delete FOO</code></strong></span></dt><dd><a id="idm1089" class="indexterm"></a><p>Use this to schedule the file, directory, or symbolic link <code class="filename">FOO</code> to be deleted from the repository. If <code class="filename">FOO</code> is a file or link, it is immediately deleted from your working copy. If <code class="filename">FOO</code> is a directory, it is not deleted, but Subversion schedules it for deletion. When you commit your changes, <code class="filename">FOO</code> will be entirely removed from your working copy and the repository.<a href="#ftn.idm1098" class="footnote" id="idm1098"><sup class="footnote">[6]</sup></a></p></dd><dt><span class="term"><strong class="userinput"><code>svn copy FOO BAR</code></strong></span></dt><dd><a id="idm1107" class="indexterm"></a><p>Create a new item <code class="filename">BAR</code> as a duplicate of <code class="filename">FOO</code> and automatically schedule <code class="filename">BAR</code> for addition. When <code class="filename">BAR</code> is added to the repository on the next commit, its copy history is recorded (as having originally come from <code class="filename">FOO</code>). <span class="command"><strong>svn copy</strong></span> does not create intermediate directories unless you pass the <code class="option">--parents</code> option.</p></dd><dt><span class="term"><strong class="userinput"><code>svn move FOO BAR</code></strong></span></dt><dd><a id="idm1123" class="indexterm"></a><p>This command is exactly the same as running <strong class="userinput"><code>svn copy FOO BAR; svn delete FOO</code></strong>. That is, <code class="filename">BAR</code> is scheduled for addition as a copy of <code class="filename">FOO</code>, and <code class="filename">FOO</code> is scheduled for removal. <span class="command"><strong>svn move</strong></span> does not create intermediate directories unless you pass the <code class="option">--parents</code> option.</p></dd><dt><span class="term"><strong class="userinput"><code>svn mkdir FOO</code></strong></span></dt><dd><a id="idm1138" class="indexterm"></a><p>This command is exactly the same as running <strong class="userinput"><code>mkdir FOO; svn add FOO</code></strong>. That is, a new directory named <code class="filename">FOO</code> is created and scheduled for addition.</p></dd></dl></div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Changing the Repository Without a Working Copy</strong></p></div></div></div><p>Subversion <span class="emphasis"><em>does</em></span> offer ways to immediately commit tree changes to the repository without an explicit commit action. In particular, specific uses of <span class="command"><strong>svn mkdir</strong></span>, <span class="command"><strong>svn copy</strong></span>, <span class="command"><strong>svn move</strong></span>, and <span class="command"><strong>svn delete</strong></span> can operate directly on repository URLs as well as on working copy paths. Of course, as previously mentioned, <span class="command"><strong>svn import</strong></span> always makes direct changes to the repository.</p><p>There are pros and cons to performing URL-based operations. One obvious advantage to doing so is speed: sometimes, checking out a working copy that you don't already have solely to perform some seemingly simple action is an overbearing cost. A disadvantage is that you are generally limited to a single, or single type of, operation at a time when operating directly on URLs. Finally, the primary advantage of a working copy is in its utility as a sort of <span class="quote">“<span class="quote">staging area</span>”</span> for changes. You can make sure that the changes you are about to commit make sense in the larger scope of your project before committing them. And, of course, these staged changes can be as complex or as a simple as they need to be, yet result in but a single new revision when committed.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.cycle.examine"></a>Review Your Changes</h3></div></div></div><a id="idm1158" class="indexterm"></a><p>Once you've finished making changes, you need to commit them to the repository, but before you do so, it's usually a good idea to take a look at exactly what you've changed. By examining your changes before you commit, you can compose a more accurate <em class="firstterm">log message</em> (a human-readable description of the committed changes stored alongside those changes in the repository). You may also discover that you've inadvertently changed a file, and that you need to undo that change before committing. Additionally, this is a good opportunity to review and scrutinize changes before publishing them. You can see an overview of the changes you've made by using the <span class="command"><strong>svn status</strong></span> command, and you can dig into the details of those changes by using the <span class="command"><strong>svn diff</strong></span> command.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Look Ma! No Network!</strong></p></div></div></div><p>You can use the commands <span class="command"><strong>svn status</strong></span>, <span class="command"><strong>svn diff</strong></span>, and <span class="command"><strong>svn revert</strong></span> without any network access even if your repository <span class="emphasis"><em>is</em></span> across the network. This makes it easy to manage and review your changes-in-progress when you are working offline or are otherwise unable to contact your repository over the network.</p><a id="idm1171" class="indexterm"></a><a id="idm1173" class="indexterm"></a><p>Subversion does this by keeping private caches of pristine, unmodified versions of each versioned file inside its working copy administrative area (or prior to version 1.7, potentially multiple administrative areas). This allows Subversion to report—and revert—local modifications to those files <span class="emphasis"><em>without network access</em></span>. This cache (called the <em class="firstterm">text-base</em>) also allows Subversion to send the user's local modifications during a commit to the server as a compressed <em class="firstterm">delta</em> (or <span class="quote">“<span class="quote">difference</span>”</span>) against the pristine version. Having this cache is a tremendous benefit—even if you have a fast Internet connection, it's generally much faster to send only a file's changes rather than the whole file to the server.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.cycle.examine.status"></a>See an overview of your changes</h4></div></div></div><a id="idm1182" class="indexterm"></a><p>To get an overview of your changes, use the <span class="command"><strong>svn status</strong></span> command. You'll probably use <span class="command"><strong>svn status</strong></span> more than any other Subversion command.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Because the <span class="command"><strong>cvs status</strong></span> command's output was so noisy, and because <span class="command"><strong>cvs update</strong></span> not only performs an update, but also reports the status of your local changes, most CVS users have grown accustomed to using <span class="command"><strong>cvs update</strong></span> to report their changes. In Subversion, the update and status reporting facilities are completely separate. See <a class="xref" href="#svn.forcvs.status-vs-update" title="Distinction Between Status and Update">the section called “Distinction Between Status and Update”</a> for more details.</p></td></tr></table></div><p>If you run <strong class="userinput"><code>svn status</code></strong> at the top of your working copy with no additional arguments, it will detect and report all file and tree changes you've made.</p><div class="informalexample"><pre class="screen"> $ svn status ? scratch.c A stuff/loot A stuff/loot/new.c D stuff/old.c M bar.c $ </pre></div><p>In its default output mode, <span class="command"><strong>svn status</strong></span> prints seven columns of characters, followed by several whitespace characters, followed by a file or directory name. The first column tells the status of a file or directory and/or its contents. Some of the most common codes that <span class="command"><strong>svn status</strong></span> displays are:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="computeroutput">? item</code></span></dt><dd><p>The file, directory, or symbolic link <code class="filename">item</code> is not under version control.</p></dd><dt><span class="term"><code class="computeroutput">A item</code></span></dt><dd><p>The file, directory, or symbolic link <code class="filename">item</code> has been scheduled for addition into the repository.</p></dd><dt><span class="term"><code class="computeroutput">C item</code></span></dt><dd><p>The file <code class="filename">item</code> 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 (and weren't resolved during the update). You must resolve this conflict before committing your changes to the repository.</p></dd><dt><span class="term"><code class="computeroutput">D item</code></span></dt><dd><p>The file, directory, or symbolic link <code class="filename">item</code> has been scheduled for deletion from the repository.</p></dd><dt><span class="term"><code class="computeroutput">M item</code></span></dt><dd><p>The contents of the file <code class="filename">item</code> have been modified.</p></dd></dl></div><p>If you pass a specific path to <span class="command"><strong>svn status</strong></span>, you get information about that item alone:</p><div class="informalexample"><pre class="screen"> $ svn status stuff/fish.c D stuff/fish.c </pre></div><p><span class="command"><strong>svn status</strong></span> also has a <code class="option">--verbose</code> (<code class="option">-v</code>) option, which will show you the status of <span class="emphasis"><em>every</em></span> item in your working copy, even if it has not been changed:</p><div class="informalexample"><pre class="screen"> $ svn status -v M 44 23 sally README 44 30 sally INSTALL M 44 20 harry bar.c 44 18 ira stuff 44 35 harry stuff/trout.c D 44 19 ira stuff/fish.c 44 21 sally stuff/things A 0 ? ? stuff/things/bloo.h 44 36 harry stuff/things/gloo.c </pre></div><p>This is the <span class="quote">“<span class="quote">long form</span>”</span> output of <span class="command"><strong>svn status</strong></span>. The letters in the first column mean the same as before, but the second column shows the working revision of the item. The third and fourth columns show the revision in which the item last changed, and who changed it.</p><p>None of the prior invocations to <span class="command"><strong>svn status</strong></span> contact the repository—they merely report what is known about the working copy items based on the records stored in the working copy administrative area and on the timestamps and contents of modified files. But sometimes it is useful to see which of the items in your working copy have been modified in the repository since the last time you updated your working copy. For this, <span class="command"><strong>svn status</strong></span> offers the <code class="option">--show-updates</code> (<code class="option">-u</code>) option, which contacts the repository and adds information about items that are out of date:</p><div class="informalexample"><pre class="screen"> $ 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 </pre></div><p>Notice in the previous example the two asterisks: if you were to run <strong class="userinput"><code>svn update</code></strong> at this point, you would receive changes to <code class="filename">README</code> and <code class="filename">trout.c</code>. This tells you some very useful information—because one of those items is also one that you have locally modified (the file <code class="filename">README</code>), you'll need to update and get the servers changes for that file before you commit, or the repository will reject your commit for being out of date. We discuss this in more detail later.</p><p><span class="command"><strong>svn status</strong></span> can display much more information about the files and directories in your working copy than we've shown here—for an exhaustive description of <span class="command"><strong>svn status</strong></span> and its output, run <strong class="userinput"><code>svn help status</code></strong> or see <a class="xref" href="#svn.ref.svn.c.status" title="svn status (stat, st)">svn status (stat, st)</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.cycle.examine.diff"></a>Examine the details of your local modifications</h4></div></div></div><a id="idm1267" class="indexterm"></a><a id="idm1271" class="indexterm"></a><p>Another way to examine your changes is with the <span class="command"><strong>svn diff</strong></span> command, which displays differences in file content. When you run <strong class="userinput"><code>svn diff</code></strong> at the top of your working copy with no arguments, Subversion will print the changes you've made to human-readable files in your working copy. It displays those changes in <em class="firstterm">unified diff</em> format, a format which describes changes as <span class="quote">“<span class="quote">hunks</span>”</span> (or <span class="quote">“<span class="quote">snippets</span>”</span>) of a file's content where each line of text is prefixed with a single-character code: a space, which means the line was unchanged; a minus sign (<code class="literal">-</code>), which means the line was removed from the file; or a plus sign (<code class="literal">+</code>), which means the line was added to the file. In the context of <span class="command"><strong>svn diff</strong></span>, those minus-sign- and plus-sign-prefixed lines show how the lines looked before and after your modifications, respectively.</p><p>Here's an example:</p><div class="informalexample"><pre class="screen"> $ svn diff Index: bar.c =================================================================== --- bar.c (revision 3) +++ bar.c (working copy) @@ -1,7 +1,12 @@ +#include &lt;sys/types.h&gt; +#include &lt;sys/stat.h&gt; +#include &lt;unistd.h&gt; + +#include &lt;stdio.h&gt; int main(void) { - printf("Sixty-four slices of American Cheese...\n"); + printf("Sixty-five slices of American Cheese...\n"); return 0; } Index: README =================================================================== --- README (revision 3) +++ README (working copy) @@ -193,3 +193,4 @@ +Note to self: pick up laundry. Index: stuff/fish.c =================================================================== --- stuff/fish.c (revision 1) +++ stuff/fish.c (working copy) -Welcome to the file known as 'fish'. -Information on fish will be here soon. Index: stuff/things/bloo.h =================================================================== --- stuff/things/bloo.h (revision 8) +++ stuff/things/bloo.h (working copy) +Here is a new file to describe +things about bloo. </pre></div><a id="idm1285" class="indexterm"></a><p>The <span class="command"><strong>svn diff</strong></span> command produces this output by comparing your working files against its pristine text-base. Files scheduled for addition are displayed as files in which every line was added; files scheduled for deletion are displayed as if every line was removed from those files. The output from <span class="command"><strong>svn diff</strong></span> is somehwat compatible with the <span class="command"><strong>patch</strong></span> program—more so with the <span class="command"><strong>svn patch</strong></span> subcommand introduced in Subversion 1.7. Patch processing commands such as these read and apply <em class="firstterm">patch files</em> (or <span class="quote">“<span class="quote">patches</span>”</span>), which are files that describe differences made to one or more files. Because of this, you can share the changes you've made in your working copy with someone else without first committing those changes by creating a patch file from the redirected output of <span class="command"><strong>svn diff</strong></span>:</p><div class="informalexample"><pre class="screen"> $ svn diff &gt; patchfile $ </pre></div><p>Subversion uses its internal diff engine, which produces unified diff format, by default. If you want diff output in a different format, specify an external diff program using <code class="option">--diff-cmd</code> and pass any additional flags that it needs via the <code class="option">--extensions</code> (<code class="option">-x</code>) option. For example, you might want Subversion to defer its difference calculation and display to the GNU <span class="command"><strong>diff</strong></span> program, asking that program to print local modifications made to the file <code class="filename">foo.c</code> in context diff format (another flavor of difference format) while ignoring changes made only to the case of the letters used in the file's contents:</p><div class="informalexample"><pre class="screen"> $ svn diff --diff-cmd /usr/bin/diff -x "-i" foo.c … $ </pre></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.cycle.revert"></a>Fix Your Mistakes</h3></div></div></div><p>Suppose while viewing the output of <span class="command"><strong>svn diff</strong></span> you determine that all the changes you made to a particular file are mistakes. Maybe you shouldn't have changed the file at all, or perhaps it would be easier to make different changes starting from scratch. You could edit the file again and unmake all those changes. You could try to find a copy of how the file looked before you changed it, and then copy its contents atop your modified version. You could attempt to apply those changes to the file again in reverse using <strong class="userinput"><code>patch -R</code></strong>. And there are probably other approaches you could take.</p><a id="idm1310" class="indexterm"></a><p>Fortunately in Subversion, undoing your work and starting over from scratch doesn't require such acrobatics. Just use the <span class="command"><strong>svn revert</strong></span> command:</p><div class="informalexample"><pre class="screen"> $ svn status README M README $ svn revert README Reverted 'README' $ svn status README $ </pre></div><p>In this example, Subversion has reverted the file to its premodified state by overwriting it with the pristine version of the file cached in the text-base area. But note that <span class="command"><strong>svn revert</strong></span> can undo <span class="emphasis"><em>any</em></span> scheduled operation—for example, you might decide that you don't want to add a new file after all:</p><div class="informalexample"><pre class="screen"> $ svn status new-file.txt ? new-file.txt $ svn add new-file.txt A new-file.txt $ svn revert new-file.txt Reverted 'new-file.txt' $ svn status new-file.txt ? new-file.txt $ </pre></div><p>Or perhaps you mistakenly removed a file from version control:</p><div class="informalexample"><pre class="screen"> $ svn status README $ svn delete README D README $ svn revert README Reverted 'README' $ svn status README $ </pre></div><p>The <span class="command"><strong>svn revert</strong></span> command offers salvation for imperfect people. It can save you huge amounts of time and energy that would otherwise be spent manually unmaking changes or, worse, disposing of your working copy and checking out a fresh one just to have a clean slate to work with again.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.cycle.resolve"></a>Resolve Any Conflicts</h3></div></div></div><a id="idm1330" class="indexterm"></a><p>We've already seen how <strong class="userinput"><code>svn status -u</code></strong> can predict conflicts, but dealing with those conflicts is still something that remains to be done. Conflicts can occur any time you attempt to merge or integrate (in a very general sense) changes from the repository into your working copy. By now you know that <span class="command"><strong>svn update</strong></span> creates exactly that sort of scenario—that command's very purpose is to bring your working copy up to date with the repository by merging all the changes made since your last update into your working copy. So how does Subversion report these conflicts to you, and how do you deal with them?</p><p>Suppose you run <strong class="userinput"><code>svn update</code></strong> and you see this sort of interesting output:</p><div class="informalexample"><pre class="screen"> $ svn update Updating '.': U INSTALL G README Conflict discovered in 'bar.c'. Select: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options: </pre></div><p>The <code class="computeroutput">U</code> (which stands for <span class="quote">“<span class="quote">Updated</span>”</span>) and <code class="computeroutput">G</code> (for <span class="quote">“<span class="quote">merGed</span>”</span>) codes are no cause for concern; those files cleanly absorbed changes from the repository. A file marked with <code class="computeroutput">U</code> contains no local changes but was updated with changes from the repository. One marked with <code class="computeroutput">G</code> had local changes to begin with, but the changes coming from the repository didn't overlap with those local changes.</p><p>It's the next few lines which are interesting. First, Subversion reports to you that in its attempt to merge outstanding server changes into the file <code class="filename">bar.c</code>, it has detected that some of those changes clash with local modifications you've made to that file in your working copy but have not yet committed. Perhaps someone has changed the same line of text you also changed. Whatever the reason, Subversion instantly flags this file as being in a state of conflict. It then asks you what you want to do about the problem, allowing you to interactively choose an action to take toward resolving the conflict. The most commonly used options are displayed, but you can see all of the options by typing <em class="replaceable"><code>s</code></em>:</p><div class="informalexample"><pre class="screen"> … Select: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options: s (e) edit - change merged file in an editor (df) diff-full - show all changes made to merged file (r) resolved - accept merged version of file (dc) display-conflict - show all conflicts (ignoring merged version) (mc) mine-conflict - accept my version for all conflicts (same) (tc) theirs-conflict - accept their version for all conflicts (same) (mf) mine-full - accept my version of entire file (even non-conflicts) (tf) theirs-full - accept their version of entire file (same) (p) postpone - mark the conflict to be resolved later (l) launch - launch external tool to resolve conflict (s) show all - show this list Select: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options: </pre></div><p>Let's briefly review each of these options before we go into detail on what each option means.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="computeroutput">(e) edit</code></span></dt><dd><p>Open the file in conflict with your favorite editor, as set in the environment variable <code class="literal">EDITOR</code>.</p></dd><dt><span class="term"><code class="computeroutput">(df) diff-full</code></span></dt><dd><p>Display the differences between the base revision and the conflicted file itself in unified diff format.</p></dd><dt><span class="term"><code class="computeroutput">(r) resolved</code></span></dt><dd><p>After editing a file, tell <span class="command"><strong>svn</strong></span> that you've resolved the conflicts in the file and that it should accept the current contents—basically that you've <span class="quote">“<span class="quote">resolved</span>”</span> the conflict.</p></dd><dt><span class="term"><code class="computeroutput">(dc) display-conflict</code></span></dt><dd><p>Display all conflicting regions of the file, ignoring changes which were successfully merged.</p></dd><dt><span class="term"><code class="computeroutput">(mc) mine-conflict</code></span></dt><dd><p>Discard any newly received changes from the server which conflict with your local changes to the file under review. However, accept and merge all non-conflicting changes received from the server for that file.</p></dd><dt><span class="term"><code class="computeroutput">(tc) theirs-conflict</code></span></dt><dd><p>Discard any local changes which conflict with incoming changes from the server for the file under review. However, preserve all non-conflicting local changes to that file.</p></dd><dt><span class="term"><code class="computeroutput">(mf) mine-full</code></span></dt><dd><p>Discard all newly received changes from the server for the file under review, but preserve all your local changes for that file.</p></dd><dt><span class="term"><code class="computeroutput">(tf) theirs-full</code></span></dt><dd><p>Discard all your local changes to the file under review and use only the newly received changes from the server for that file.</p></dd><dt><span class="term"><code class="computeroutput">(p) postpone</code></span></dt><dd><p>Leave the file in a conflicted state for you to resolve after your update is complete.</p></dd><dt><span class="term"><code class="computeroutput">(l) launch</code></span></dt><dd><p>Launch an external program to perform the conflict resolution. This requires a bit of preparation beforehand.</p></dd><dt><span class="term"><code class="computeroutput">(s) show all</code></span></dt><dd><p>Show the list of all possible commands you can use in interactive conflict resolution.</p></dd></dl></div><p>We'll cover these commands in more detail now, grouping them together by related functionality.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.cycle.resolve.diff"></a>Viewing conflict differences interactively</h4></div></div></div><a id="idm1415" class="indexterm"></a><p>Before deciding how to attack a conflict interactively, odds are that you'd like to see exactly what is in conflict. Two of the commands available at the interactive conflict resolution prompt can assist you here. The first is the <span class="quote">“<span class="quote">diff-full</span>”</span> command (<strong class="userinput"><code>df</code></strong>), which displays all the local modifications to the file in question plus any conflict regions:</p><div class="informalexample"><pre class="screen"> … Select: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options: df --- .svn/text-base/sandwich.txt.svn-base Tue Dec 11 21:33:57 2007 +++ .svn/tmp/tempfile.32.tmp Tue Dec 11 21:34:33 2007 @@ -1 +1,5 @@ -Just buy a sandwich. +&lt;&lt;&lt;&lt;&lt;&lt;&lt; .mine +Go pick up a cheesesteak. +======= +Bring me a taco! +&gt;&gt;&gt;&gt;&gt;&gt;&gt; .r32 … </pre></div><p>The first line of the diff content shows the previous contents of the working copy (the <code class="literal">BASE</code> revision), the next content line is your change, and the last content line is the change that was just received from the server (<span class="emphasis"><em>usually</em></span> the <code class="literal">HEAD</code> revision).</p><p>The second command is similar to the first, but the <span class="quote">“<span class="quote">display-conflict</span>”</span> (<strong class="userinput"><code>dc</code></strong>) command shows only the conflict regions, not all the changes made to the file. Additionally, this command uses a slightly different display format for the conflict regions which allows you to more easily compare the file's contents in those regions as they would appear in each of three states: original and unedited; with your local changes applied and the server's conflicting changes ignored; and with only the server's incoming changes applied and your local, conflicting changes reverted.</p><p>After reviewing the information provided by these commands, you're ready to move on to the next action.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.cycle.resolve.resolve"></a>Resolving conflict differences interactively</h4></div></div></div><a id="idm1433" class="indexterm"></a><p>There are several different ways to resolve conflicts interactively—two of which allow you to selectively merge and edit changes, the rest of which allow you to simply pick a version of the file and move along.</p><p>If you wish to choose some combination of your local changes, you can use the <span class="quote">“<span class="quote">edit</span>”</span> command (<strong class="userinput"><code>e</code></strong>) to manually edit the file with conflict markers in a text editor (configured per the instructions in <a class="xref" href="#svn.advanced.externaleditors" title="Using External Editors">the section called “Using External Editors”</a>). After you've edited the file, if you're satisfied with the changes you've made, you can tell Subversion that the edited file is no longer in conflict by using the <span class="quote">“<span class="quote">resolved</span>”</span> command (<code class="literal">r</code>).</p><p>Regardless of what your local Unix snob will likely tell you, editing the file by hand in your favorite text editor is a somewhat low-tech way of remedying conflicts (see <a class="xref" href="#svn.tour.cycle.resolve.byhand" title="Merging conflicts by hand">the section called “Merging conflicts by hand”</a> for a walkthrough). For this reason, Subversion provides the <span class="quote">“<span class="quote">launch</span>”</span> resolution command (<strong class="userinput"><code>l</code></strong>) to fire up a fancy graphical merge tool instead (see <a class="xref" href="#svn.advanced.externaldifftools.merge" title="External merge">the section called “External merge”</a>).</p><p>If you decide that you don't need to merge any changes, but just want to accept one version of the file or the other, you can either choose your changes (a.k.a. <span class="quote">“<span class="quote">mine</span>”</span>) by using the <span class="quote">“<span class="quote">mine-full</span>”</span> command (<strong class="userinput"><code>mf</code></strong>) or choose theirs by using the <span class="quote">“<span class="quote">theirs-full</span>”</span> command (<strong class="userinput"><code>tf</code></strong>).</p><p>Finally, there is also a pair of compromise options available. The <span class="quote">“<span class="quote">mine-conflict</span>”</span> (<strong class="userinput"><code>mc</code></strong>) and <span class="quote">“<span class="quote">theirs-conflict</span>”</span> (<strong class="userinput"><code>tc</code></strong>) commands instruct Subversion to select your local changes or the server's incoming changes, respectively, as the <span class="quote">“<span class="quote">winner</span>”</span> for all conflicts in the file. But, unlike the <span class="quote">“<span class="quote">mine-full</span>”</span> and <span class="quote">“<span class="quote">theirs-full</span>”</span> commands, these commands preserve both your local changes and changes received from the server in regions of the file where no conflict was detected.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.cycle.resolve.pending"></a>Postponing conflict resolution</h4></div></div></div><a id="idm1465" class="indexterm"></a><p>This may sound like an appropriate section for avoiding marital disagreements, but it's actually still about Subversion, so read on. If you're doing an update and encounter a conflict that you're not prepared to review or resolve, you can type <strong class="userinput"><code>p</code></strong> to postpone resolving a conflict on a file-by-file basis when you run <strong class="userinput"><code>svn update</code></strong>. If you know in advance that you don't want to resolve any conflicts interactively, you can pass the <code class="option">--non-interactive</code> option to <span class="command"><strong>svn update</strong></span>, and any file in conflict will be marked with a <code class="computeroutput">C</code> automatically.</p><p>The <code class="computeroutput">C</code> (for <span class="quote">“<span class="quote">Conflicted</span>”</span>) means that the changes from the server overlapped with your own, and now you have to manually choose between them after the update has completed. When you postpone a conflict resolution, <span class="command"><strong>svn</strong></span> typically does three things to assist you in noticing and resolving that conflict:</p><div class="itemizedlist"><a id="idm1480" class="indexterm"></a><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Subversion prints a <code class="computeroutput">C</code> during the update and remembers that the file is in a state of conflict.</p></li><li class="listitem"><p>If Subversion considers the file to be mergeable, it places <em class="firstterm">conflict markers</em>—special strings of text that delimit the <span class="quote">“<span class="quote">sides</span>”</span> of the conflict—into the file to visibly demonstrate the overlapping areas. (Subversion uses the <code class="literal">svn:mime-type</code> property to decide whether a file is capable of contextual, line-based merging. See <a class="xref" href="#svn.advanced.props.special.mime-type" title="File Content Type">the section called “File Content Type”</a> to learn more.)</p></li><li class="listitem"><p>For every conflicted file, Subversion places three extra unversioned files in your working copy:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="filename">filename.mine</code></span></dt><dd><p>This is the file as it existed in your working copy before you began the update process. It contains any local modifications you had made to the file up to that point. (If Subversion considers the file to be unmergeable, the <code class="filename">.mine</code> file isn't created, since it would be identical to the working file.)</p></dd><dt><span class="term"><code class="filename">filename.r<em class="replaceable"><code>OLDREV</code></em> </code></span></dt><dd><p>This is the file as it existed in the <code class="literal">BASE</code> revision—that is, the unmodified revision of the file in your working copy <span class="emphasis"><em>before</em></span> you began the update process—where <em class="replaceable"><code>OLDREV</code></em> is that base revision number.</p></dd><dt><span class="term"><code class="filename">filename.r<em class="replaceable"><code>NEWREV</code></em> </code></span></dt><dd><p>This is the file that your Subversion client just received from the server via the update of your working copy, where <em class="replaceable"><code>NEWREV</code></em> corresponds to the revision number to which you were updating (<code class="literal">HEAD</code>, unless otherwise requested).</p></dd></dl></div></li></ul></div><p>For example, Sally makes changes to the file <code class="filename">sandwich.txt</code>, but does not yet commit those changes. Meanwhile, Harry commits changes to that same file. Sally updates her working copy before committing and she gets a conflict, which she postpones:</p><div class="informalexample"><pre class="screen"> $ svn update Updating '.': Conflict discovered in 'sandwich.txt'. Select: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options: p C sandwich.txt Updated to revision 2. Summary of conflicts: Text conflicts: 1 $ ls -1 sandwich.txt sandwich.txt.mine sandwich.txt.r1 sandwich.txt.r2 </pre></div><p>At this point, Subversion will <span class="emphasis"><em>not</em></span> allow Sally to commit the file <code class="filename">sandwich.txt</code> until the three temporary files are removed:</p><div class="informalexample"><pre class="screen"> $ svn commit -m "Add a few more things" svn: E155015: Commit failed (details follow): svn: E155015: Aborting commit: '/home/sally/svn-work/sandwich.txt' remains in conflict </pre></div><p>If you've postponed a conflict, you need to resolve the conflict before Subversion will allow you to commit your changes. You'll do this with the <span class="command"><strong>svn resolve</strong></span> command and one of several arguments to the <code class="option">--accept</code> option.</p><p>If you want to choose the version of the file that you last checked out before making your edits, choose the <em class="replaceable"><code>base</code></em> argument.</p><p>If you want to choose the version that contains only your edits, choose the <em class="replaceable"><code>mine-full</code></em> argument.</p><p>If you want to choose the version that your most recent update pulled from the server (and thus discarding your edits entirely), choose the <em class="replaceable"><code>theirs-full</code></em> argument.</p><p>However, if you want to pick and choose from your changes and the changes that your update fetched from the server, merge the conflicted text <span class="quote">“<span class="quote">by hand</span>”</span> (by examining and editing the conflict markers within the file) and then choose the <em class="replaceable"><code>working</code></em> argument.</p><p><span class="command"><strong>svn resolve</strong></span> removes the three temporary files and accepts the version of the file that you specified with the <code class="option">--accept</code> option, and Subversion no longer considers the file to be in a state of conflict:</p><div class="informalexample"><pre class="screen"> $ svn resolve --accept working sandwich.txt Resolved conflicted state of 'sandwich.txt' </pre></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.cycle.resolve.byhand"></a>Merging conflicts by hand</h4></div></div></div><a id="idm1546" class="indexterm"></a><p>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.</p><p>Here's an example. Due to a miscommunication, you and Sally, your collaborator, both edit the file <code class="filename">sandwich.txt</code> 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 <code class="filename">sandwich.txt</code> to resolve the conflict. First, let's take a look at the file:</p><div class="informalexample"><pre class="screen"> $ cat sandwich.txt Top piece of bread Mayonnaise Lettuce Tomato Provolone &lt;&lt;&lt;&lt;&lt;&lt;&lt; .mine Salami Mortadella Prosciutto ======= Sauerkraut Grilled Chicken &gt;&gt;&gt;&gt;&gt;&gt;&gt; .r2 Creole Mustard Bottom piece of bread </pre></div><p>The strings of less-than signs, equals 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:</p><div class="informalexample"><pre class="screen"> &lt;&lt;&lt;&lt;&lt;&lt;&lt; .mine Salami Mortadella Prosciutto ======= </pre></div><p>The text between the second and third sets of conflict markers is the text from Sally's commit:</p><div class="informalexample"><pre class="screen"> ======= Sauerkraut Grilled Chicken &gt;&gt;&gt;&gt;&gt;&gt;&gt; .r2 </pre></div><p>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. 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.<a href="#ftn.idm1563" class="footnote" id="idm1563"><sup class="footnote">[7]</sup></a> Once you've agreed on the changes you will commit, edit your file and remove the conflict markers:</p><div class="informalexample"><pre class="screen"> Top piece of bread Mayonnaise Lettuce Tomato Provolone Salami Mortadella Prosciutto Creole Mustard Bottom piece of bread </pre></div><p>Now use <span class="command"><strong>svn resolve</strong></span>, and you're ready to commit your changes:</p><div class="informalexample"><pre class="screen"> $ svn resolve --accept working sandwich.txt Resolved conflicted state of 'sandwich.txt' $ svn commit -m "Go ahead and use my sandwich, discarding Sally's edits." </pre></div><p>Note that <span class="command"><strong>svn resolve</strong></span>, unlike most of the other commands we deal with in this chapter, requires that you explicitly list any filenames that you wish to resolve. In any case, you want to be careful and use <span class="command"><strong>svn resolve</strong></span> only 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.</p><p>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.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.cycle.resolve.theirsfull"></a>Discarding your changes in favor of a newly fetched revision</h4></div></div></div><a id="idm1577" class="indexterm"></a><p>If you get a conflict and decide that you want to throw out your changes, you can run <strong class="userinput"><code>svn resolve --accept theirs-full <em class="replaceable"><code>CONFLICTED-PATH</code></em></code></strong> and Subversion will discard your edits and remove the temporary files:</p><div class="informalexample"><pre class="screen"> $ svn update Updating '.': Conflict discovered in 'sandwich.txt'. Select: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options: p C sandwich.txt Updated to revision 2. Summary of conflicts: Text conflicts: 1 $ ls sandwich.* sandwich.txt sandwich.txt.mine sandwich.txt.r2 sandwich.txt.r1 $ svn resolve --accept theirs-full sandwich.txt Resolved conflicted state of 'sandwich.txt' $ </pre></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.cycle.resolve.revert"></a>Punting: using svn revert</h4></div></div></div><p>If you decide that you want to throw out your changes and start your edits again (whether this occurs after a conflict or anytime), just revert your changes:</p><div class="informalexample"><pre class="screen"> $ svn revert sandwich.txt Reverted 'sandwich.txt' $ ls sandwich.* sandwich.txt $ </pre></div><p>Note that when you revert a conflicted file, you don't have to use <span class="command"><strong>svn resolve</strong></span>.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.cycle.commit"></a>Commit Your Changes</h3></div></div></div><p>Finally! Your edits are finished, you've merged all changes from the server, and you're ready to commit your changes to the repository.</p><p>The <span class="command"><strong>svn commit</strong></span> 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. If your log message is brief, you may wish to supply it on the command line using the <code class="option">--message</code> (<code class="option">-m</code>) option:</p><div class="informalexample"><pre class="screen"> $ svn commit -m "Corrected number of cheese slices." Sending sandwich.txt Transmitting file data . Committed revision 3. </pre></div><p>However, if you've been composing your log message in some other text file as you work, you may want to tell Subversion to get the message from that file by passing its filename as the value of the <code class="option">--file</code> (<code class="option">-F</code>) option:</p><div class="informalexample"><pre class="screen"> $ svn commit -F logmsg Sending sandwich.txt Transmitting file data . Committed revision 4. </pre></div><p>If you fail to specify either the <code class="option">--message</code> (<code class="option">-m</code>) or <code class="option">--file</code> (<code class="option">-F</code>) option, Subversion will automatically launch your favorite editor (see the information on <code class="literal">editor-cmd</code> in <a class="xref" href="#svn.advanced.confarea.opts.config" title="Config">the section called “Config”</a>) for composing a log message.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>If you're in your editor writing a commit message and decide that you want to cancel your commit, you can just quit your editor without saving changes. If you've already saved your commit message, simply delete all the text, save again, and then abort:</p><div class="informalexample"><pre class="screen"> $ svn commit Waiting for Emacs...Done Log message unchanged or not specified (a)bort, (c)ontinue, (e)dit a $ </pre></div></td></tr></table></div><p>The repository doesn't know or care whether your changes make any sense as a whole; it checks only to make sure nobody else has changed any of the same files that you did when you weren't looking. If somebody <span class="emphasis"><em>has</em></span> done that, the entire commit will fail with a message informing you that one or more of your files are out of date:</p><div class="informalexample"><pre class="screen"> $ svn commit -m "Add another rule" Sending rules.txt svn: E155011: Commit failed (details follow): svn: E155011: File '/home/sally/svn-work/sandwich.txt' is out of date … </pre></div><p>(The exact wording of this error message depends on the network protocol and server you're using, but the idea is the same in all cases.)</p><p>At this point, you need to run <strong class="userinput"><code>svn update</code></strong>, deal with any merges or conflicts that result, and attempt your commit again.</p><p>That covers the basic work cycle for using Subversion. Subversion offers many other features that you can use to manage your repository and working copy, but most of your day-to-day use of Subversion will involve only the commands that we've discussed so far in this chapter. We will, however, cover a few more commands that you'll use fairly often.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.tour.history"></a>Examining History</h2></div></div></div><p>Your Subversion repository is like a time machine. It 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. However, sometimes you just want to <span class="emphasis"><em>peer into</em></span> the past instead of <span class="emphasis"><em>going into</em></span> it.</p><p>Several commands can provide you with historical data from the repository:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="command"><strong>svn diff</strong></span></span></dt><dd><p>Shows line-level details of a particular change</p></dd><dt><span class="term"><span class="command"><strong>svn log</strong></span></span></dt><dd><p>Shows you broad information: log messages with date and author information attached to revisions and which paths changed in each revision</p></dd><dt><span class="term"><span class="command"><strong>svn cat</strong></span></span></dt><dd><p>Retrieves a file as it existed in a particular revision number and displays it on your screen</p></dd><dt><span class="term"><span class="command"><strong>svn annotate</strong></span></span></dt><dd><p>Retrieves a human-readable file as it existed in a particular revision number, displaying its contents in a tabular form with last-changed information attributed to each line of the file.</p></dd><dt><span class="term"><span class="command"><strong>svn list</strong></span></span></dt><dd><p>Displays the files in a directory for any given revision</p></dd></dl></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.history.diff"></a>Examining the Details of Historical Changes</h3></div></div></div><p>We've already seen <span class="command"><strong>svn diff</strong></span> before—it displays file differences in unified diff format; we used it to show the local modifications made to our working copy before committing to the repository.</p><p>In fact, it turns out that there are <span class="emphasis"><em>three</em></span> distinct uses of <span class="command"><strong>svn diff</strong></span>:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Examining local changes</p></li><li class="listitem"><p>Comparing your working copy to the repository</p></li><li class="listitem"><p>Comparing repository revisions</p></li></ul></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.history.diff.local"></a>Examining local changes</h4></div></div></div><p>As we've seen, invoking <strong class="userinput"><code>svn diff</code></strong> with no options will compare your working files to the cached <span class="quote">“<span class="quote">pristine</span>”</span> copies in the <code class="filename">.svn</code> area:</p><div class="informalexample"><pre class="screen"> $ svn diff Index: rules.txt =================================================================== --- rules.txt (revision 3) +++ rules.txt (working copy) @@ -1,4 +1,5 @@ Be kind to others Freedom = Responsibility Everything in moderation -Chew with your mouth open +Chew with your mouth closed +Listen when others are speaking $ </pre></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.history.diff.wcrepos"></a>Comparing working copy to repository</h4></div></div></div><p>If a single <code class="option">--revision</code> (<code class="option">-r</code>) number is passed, your working copy is compared to the specified revision in the repository:</p><div class="informalexample"><pre class="screen"> $ svn diff -r 3 rules.txt Index: rules.txt =================================================================== --- rules.txt (revision 3) +++ rules.txt (working copy) @@ -1,4 +1,5 @@ Be kind to others Freedom = Responsibility Everything in moderation -Chew with your mouth open +Chew with your mouth closed +Listen when others are speaking $ </pre></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.history.diff.reposrepos"></a>Comparing repository revisions</h4></div></div></div><p>If two revision numbers, separated by a colon, are passed via <code class="option">--revision</code> (<code class="option">-r</code>), the two revisions are directly compared:</p><div class="informalexample"><pre class="screen"> $ svn diff -r 2:3 rules.txt Index: rules.txt =================================================================== --- rules.txt (revision 2) +++ rules.txt (revision 3) @@ -1,4 +1,4 @@ Be kind to others -Freedom = Chocolate Ice Cream +Freedom = Responsibility Everything in moderation Chew with your mouth open $ </pre></div><p>A more convenient way of comparing one revision to the previous revision is to use the <code class="option">--change</code> (<code class="option">-c</code>) option:</p><div class="informalexample"><pre class="screen"> $ svn diff -c 3 rules.txt Index: rules.txt =================================================================== --- rules.txt (revision 2) +++ rules.txt (revision 3) @@ -1,4 +1,4 @@ Be kind to others -Freedom = Chocolate Ice Cream +Freedom = Responsibility Everything in moderation Chew with your mouth open $ </pre></div><p>Lastly, you can compare repository revisions even when you don't have a working copy on your local machine, just by including the appropriate URL on the command line:</p><div class="informalexample"><pre class="screen"> $ svn diff -c 5 http://svn.example.com/repos/example/trunk/text/rules.txt … $ </pre></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.history.log"></a>Generating a List of Historical Changes</h3></div></div></div><p>To find information about the history of a file or directory, use the <span class="command"><strong>svn log</strong></span> command. <span class="command"><strong>svn log</strong></span> will provide you with a record of who made changes to a file or directory, at what revision it changed, the time and date of that revision, and—if it was provided—the log message that accompanied the commit:</p><div class="informalexample"><pre class="screen"> $ svn log ------------------------------------------------------------------------ r3 | sally | 2008-05-15 23:09:28 -0500 (Thu, 15 May 2008) | 1 line Added include lines and corrected # of cheese slices. ------------------------------------------------------------------------ r2 | harry | 2008-05-14 18:43:15 -0500 (Wed, 14 May 2008) | 1 line Added main() methods. ------------------------------------------------------------------------ r1 | sally | 2008-05-10 19:50:31 -0500 (Sat, 10 May 2008) | 1 line Initial import ------------------------------------------------------------------------ </pre></div><p>Note that the log messages are printed in <span class="emphasis"><em>reverse chronological order</em></span> by default. If you wish to see a different range of revisions in a particular order or just a single revision, pass the <code class="option">--revision</code> (<code class="option">-r</code>) option:</p><div class="table"><a id="svn.tour.history.log.tbl-1"></a><p class="title"><strong>Table 2.1. Common log requests</strong></p><div class="table-contents"><table class="table" summary="Common log requests" border="1"><colgroup><col></col><col></col></colgroup><thead><tr><th>Command</th><th>Description</th></tr></thead><tbody><tr><td><strong class="userinput"><code>svn log -r 5:19</code></strong></td><td>Display logs for revisions 5 through 19 in chronological order</td></tr><tr><td><strong class="userinput"><code>svn log -r 19:5</code></strong></td><td>Display logs for revisions 5 through 19 in reverse chronological order</td></tr><tr><td><strong class="userinput"><code>svn log -r 8</code></strong></td><td>Display logs for revision 8 only</td></tr></tbody></table></div></div><br class="table-break"></br><p>You can also examine the log history of a single file or directory. For example:</p><div class="informalexample"><pre class="screen"> $ svn log foo.c … $ svn log http://foo.com/svn/trunk/code/foo.c … </pre></div><p>These will display log messages <span class="emphasis"><em>only</em></span> for those revisions in which the working file (or URL) changed.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Why Does svn log Not Show Me What I Just Committed?</strong></p></div></div></div><p>If you make a commit and immediately type <strong class="userinput"><code>svn log</code></strong> with no arguments, you may notice that your most recent commit doesn't show up in the list of log messages. This is due to a combination of the behavior of <span class="command"><strong>svn commit</strong></span> and the default behavior of <span class="command"><strong>svn log</strong></span>. First, when you commit changes to the repository, <span class="command"><strong>svn</strong></span> bumps only the revision of files (and directories) that it commits, so usually the parent directory remains at the older revision (See <a class="xref" href="#svn.basic.in-action.mixedrevs.update-commit" title="Updates and commits are separate">the section called “Updates and commits are separate”</a> for an explanation of why). <span class="command"><strong>svn log</strong></span> then defaults to fetching the history of the directory at its current revision, and thus you don't see the newly committed changes. The solution here is to either update your working copy or explicitly provide a revision number to <span class="command"><strong>svn log</strong></span> by using the <code class="option">--revision</code> (<code class="option">-r</code>) option.</p></div><p>If you want even more information about a file or directory, <span class="command"><strong>svn log</strong></span> also takes a <code class="option">--verbose</code> (<code class="option">-v</code>) option. Because Subversion allows you to move and copy files and directories, it is important to be able to track path changes in the filesystem. So, in verbose mode, <span class="command"><strong>svn log</strong></span> will include a list of changed paths in a revision in its output:</p><div class="informalexample"><pre class="screen"> $ svn log -r 8 -v ------------------------------------------------------------------------ r8 | sally | 2008-05-21 13:19:25 -0500 (Wed, 21 May 2008) | 1 line Changed paths: M /trunk/code/foo.c M /trunk/code/bar.h A /trunk/code/doc/README Frozzled the sub-space winch. ------------------------------------------------------------------------ </pre></div><p><span class="command"><strong>svn log</strong></span> also takes a <code class="option">--quiet</code> (<code class="option">-q</code>) option, which suppresses the body of the log message. When combined with <code class="option">--verbose</code> (<code class="option">-v</code>), it gives just the names of the changed files.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Why Does svn log Give Me an Empty Response?</strong></p></div></div></div><p>After working with Subversion for a bit, most users will come across something like this:</p><div class="informalexample"><pre class="screen"> $ svn log -r 2 ------------------------------------------------------------------------ $ </pre></div><p>At first glance, this seems like an error. But recall that while revisions are repository-wide, <span class="command"><strong>svn log</strong></span> operates on a path in the repository. If you supply no path, Subversion uses the current working directory as the default target. As a result, if you're operating in a subdirectory of your working copy and attempt to see the log of a revision in which neither that directory nor any of its children was changed, Subversion will show you an empty log. If you want to see what changed in that revision, try pointing <span class="command"><strong>svn log</strong></span> directly at the topmost URL of your repository, as in <strong class="userinput"><code>svn log -r 2 ^/</code></strong>.</p></div><p>As of Subversion 1.7, users of the Subversion command-line can also take advantage of a special output mode for <span class="command"><strong>svn log</strong></span> which integrates a difference report such as is generated by the <span class="command"><strong>svn diff</strong></span> command we introduced earlier. When you invoke <span class="command"><strong>svn log</strong></span> with the <code class="option">--diff</code> option, Subversion will append to each revision log chunk in the log report a <span class="command"><strong>diff</strong></span>-style difference report. This is a very convenient way to see both the high-level, semantic changes and the line-based modifications of a revision all at the same time!</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.history.browsing"></a>Browsing the Repository</h3></div></div></div><p>Using <span class="command"><strong>svn cat</strong></span> and <span class="command"><strong>svn list</strong></span>, you can view various revisions of files and directories without changing the working revision of your working copy. In fact, you don't even need a working copy to use either one.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.history.browsing.cat"></a>Displaying file contents</h4></div></div></div><p>If you want to examine an earlier version of a file and not necessarily the differences between two files, you can use <span class="command"><strong>svn cat</strong></span>:</p><div class="informalexample"><pre class="screen"> $ svn cat -r 2 rules.txt Be kind to others Freedom = Chocolate Ice Cream Everything in moderation Chew with your mouth open $ </pre></div><p>You can also redirect the output directly into a file:</p><div class="informalexample"><pre class="screen"> $ svn cat -r 2 rules.txt &gt; rules.txt.v2 $ </pre></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.history.browsing.annotate"></a>Displaying line-by-line change attribution</h4></div></div></div><p>Very similar to the <span class="command"><strong>svn cat</strong></span> command we discussed in the previous section is the <span class="command"><strong>svn annotate</strong></span> command. This command also displays the contents of a versioned file, but it does so using a tabular format. Each line of output shows not only a line of the file's content but also the username, the revision number and (optionally) the datestamp of the revision in which that line was last modified.</p><p>When used with a working copy file target, <span class="command"><strong>svn annotate</strong></span> will by default show line-by-line attribution of the file as it currently appears in the working copy.</p><div class="informalexample"><pre class="screen"> $ svn annotate rules.txt 1 harry Be kind to others 3 sally Freedom = Responsibility 1 harry Everything in moderation - - Chew with your mouth closed - - Listen when others are speaking </pre></div><p>Notice that for some lines, there is no attribution provided. In this case, that's because those lines have been modified in the working copy's version of the file. In this way, <span class="command"><strong>svn annotate</strong></span> becomes another way for you to see which lines in the file you have changed. You can use the <code class="literal">BASE</code> revision keyword (see <a class="xref" href="#svn.tour.revs.keywords" title="Revision Keywords">the section called “Revision Keywords”</a>) to instead see the unmodified form of the file as it resides in your working copy.</p><div class="informalexample"><pre class="screen"> $ svn annotate rules.txt@BASE 1 harry Be kind to others 3 sally Freedom = Responsibility 1 harry Everything in moderation 1 harry Chew with your mouth open </pre></div><p>The <code class="option">--verbose (-v)</code> option causes <span class="command"><strong>svn annotate</strong></span> to also include on each line the datestamp associated with that line's reported revision number. (This adds a significant amount of width to each line of ouput, so we'll skip the demonstration here.)</p><p>As with <span class="command"><strong>svn cat</strong></span>, you can also ask <span class="command"><strong>svn annotate</strong></span> to display previous versions of the file. This can be a handy trick when, after finding out who most recently modified a particular line of interest in the file, you then wish to see who modified the same line prior to that.</p><div class="informalexample"><pre class="screen"> $ svn blame rules.txt -r 2 1 harry Be kind to others 1 harry Freedom = Chocolate Ice Cream 1 harry Everything in moderation 1 harry Chew with your mouth open </pre></div><p>Unlike the <span class="command"><strong>svn cat</strong></span> command, the functionality of <span class="command"><strong>svn annotate</strong></span> is tied heavily to the idea of <span class="quote">“<span class="quote">lines</span>”</span> of text in a human-readable file. As such, if you attempt to run the command on a file that Subversion has determined is <span class="emphasis"><em>not</em></span> human-readable (per the file's <code class="literal">svn:mime-type</code> property—see <a class="xref" href="#svn.advanced.props.special.mime-type" title="File Content Type">the section called “File Content Type”</a> for details), you'll get an error message.</p><div class="informalexample"><pre class="screen"> $ svn annotate images/logo.png Skipping binary file: 'images/logo.png' $ </pre></div><p>As revealed in the error message, you can use the <code class="option">--force</code> option to disable this check and proceed with the annotation as if the file's contents are, in fact, human-readable and line-based. Naturally, if you force Subversion to try to perform line-based annotation on a nontextual file, you'll get what you asked for: a screenful of nonsense.</p><div class="informalexample"><pre class="screen"> $ svn annotate images/logo.png --force 6 harry \211PNG 6 harry ^Z 6 harry 7 harry \274\361\MI\300\365\353^X\300… </pre></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Depending on your mood at the time you execute this command and your reasons for doing so, you may find yourself typing <strong class="userinput"><code>svn blame …</code></strong> or <strong class="userinput"><code>svn praise …</code></strong> instead of using the canonical <span class="command"><strong>svn annotate</strong></span> command form. That's okay—the Subversion developers anticipated as much, so those particular command aliases work, too!</p></td></tr></table></div><p>Finally, as with many of Subversion's informational commands, you can also reference files in your <span class="command"><strong>svn annotate</strong></span> command invocations by their repository URLs, allowing access to this information even when you don't have ready access to a working copy.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.history.browsing.list"></a>Listing versioned directories</h4></div></div></div><p>The <span class="command"><strong>svn list</strong></span> command shows you what files are in a repository directory without actually downloading the files to your local machine:</p><div class="informalexample"><pre class="screen"> $ svn list http://svn.example.com/repo/project README branches/ tags/ trunk/ </pre></div><p>If you want a more detailed listing, pass the <code class="option">--verbose</code> (<code class="option">-v</code>) flag to get output like this:</p><div class="informalexample"><pre class="screen"> $ svn list -v http://svn.example.com/repo/project 23351 sally Feb 05 13:26 ./ 20620 harry 1084 Jul 13 2006 README 23339 harry Feb 04 01:40 branches/ 23198 harry Jan 23 17:17 tags/ 23351 sally Feb 05 13:26 trunk/ </pre></div><p>The columns tell you the revision at which the file or directory was last modified, the user who modified it, the size if it is a file, the date it was last modified, and the item's name.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>The <strong class="userinput"><code>svn list</code></strong> command with no arguments defaults to the <span class="emphasis"><em>repository URL</em></span> of the current working directory, <span class="emphasis"><em>not</em></span> the local working copy directory. After all, if you want a listing of your local directory, you could use just plain <span class="command"><strong>ls</strong></span> (or any reasonable non-Unixy equivalent).</p></td></tr></table></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.history.snapshots"></a>Fetching Older Repository Snapshots</h3></div></div></div><p>In addition to all of the previous commands, you can use the <code class="option">--revision</code> (<code class="option">-r</code>) option with <span class="command"><strong>svn update</strong></span> to take an entire working copy <span class="quote">“<span class="quote">back in time</span>”</span>:<a href="#ftn.idm1859" class="footnote" id="idm1859"><sup class="footnote">[8]</sup></a></p><div class="informalexample"><pre class="screen"> # Make the current directory look like it did in r1729. $ svn update -r 1729 Updating '.': … $ </pre></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Many Subversion newcomers attempt to use the preceding <span class="command"><strong>svn update</strong></span> example to <span class="quote">“<span class="quote">undo</span>”</span> committed changes, but this won't work as you can't commit changes that you obtain from backdating a working copy if the changed files have newer revisions. See <a class="xref" href="#svn.branchmerge.basicmerging.resurrect" title="Resurrecting Deleted Items">the section called “Resurrecting Deleted Items”</a> for a description of how to <span class="quote">“<span class="quote">undo</span>”</span> a commit.</p></td></tr></table></div><p>If you'd prefer to create a whole new working copy from an older snapshot, you can do so by modifying the typical <span class="command"><strong>svn checkout</strong></span> command. As with <span class="command"><strong>svn update</strong></span>, you can provide the <code class="option">--revision</code> (<code class="option">-r</code>) option. But for reasons that we cover in <a class="xref" href="#svn.advanced.pegrevs" title="Peg and Operative Revisions">the section called “Peg and Operative Revisions”</a>, you might instead want to specify the target revision as part of Subversion's expanded URL syntax.</p><div class="informalexample"><pre class="screen"> # Checkout the trunk from r1729. $ svn checkout http://svn.example.com/svn/repo/trunk@1729 trunk-1729 … # Checkout the current trunk as it looked in r1729. $ svn checkout http://svn.example.com/svn/repo/trunk -r 1729 trunk-1729 … $ </pre></div><p>Lastly, if you're building a release and wish to bundle up your versioned files and directories, you can use <span class="command"><strong>svn export</strong></span> to create a local copy of all or part of your repository without any <code class="filename">.svn</code> administrative directories included. The basic syntax of this subcommand is identical to that of <span class="command"><strong>svn checkout</strong></span>:</p><div class="informalexample"><pre class="screen"> # Export the trunk from the latest revision. $ svn export http://svn.example.com/svn/repo/trunk trunk-export … # Export the trunk from r1729. $ svn export http://svn.example.com/svn/repo/trunk@1729 trunk-1729 … # Export the current trunk as it looked in r1729. $ svn export http://svn.example.com/svn/repo/trunk -r 1729 trunk-1729 … $ </pre></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.tour.cleanup"></a>Sometimes You Just Need to Clean Up</h2></div></div></div><p>Now that we've covered the day-to-day tasks that you'll frequently use Subversion for, we'll review a few administrative tasks relating to your working copy.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.cleanup.disposal"></a>Disposing of a Working Copy</h3></div></div></div><p>Subversion doesn't track either the state or the existence of working copies on the server, so there's no server overhead to keeping working copies around. Likewise, there's no need to let the server know that you're going to delete a working copy.</p><p>If you're likely to use a working copy again, there's nothing wrong with just leaving it on disk until you're ready to use it again, at which point all it takes is an <span class="command"><strong>svn update</strong></span> to bring it up to date and ready for use.</p><p>However, if you're definitely not going to use a working copy again, you can safely delete the entire thing using whatever directory removal capabilities your operating system offers. We recommend that before you do so you run <strong class="userinput"><code>svn status</code></strong> and review any files listed in its output that are prefixed with a <code class="literal">?</code> to make certain that they're not of importance.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.cleanup.interruption"></a>Recovering from an Interruption</h3></div></div></div><p>When Subversion modifies your working copy—either your files or its own administrative state—it tries to do so as safely as possible. Before changing the working copy, Subversion logs its intentions in a private <span class="quote">“<span class="quote">to-do list</span>”</span>, of sorts. Next, it performs those actions to effect the desired change, holding a lock on the relevant part of the working copy while it works. This prevents other Subversion clients from accessing the working copy mid-change. Finally, Subversion releases its lock and cleans up its private to-do list. Architecturally, this is similar to a journaled filesystem. If a Subversion operation is interrupted (e.g, if the process is killed or if the machine crashes), the private to-do list remains on disk. This allows Subversion to return to that list later to complete any unfinished operations and return your working copy to a consistent state.</p><p>This is exactly what <span class="command"><strong>svn cleanup</strong></span> does: it searches your working copy and runs any leftover to-do items, removing working copy locks as it completes those operations. If Subversion ever tells you that some part of your working copy is <span class="quote">“<span class="quote">locked,</span>”</span> run <span class="command"><strong>svn cleanup</strong></span> to remedy the problem. The <span class="command"><strong>svn status</strong></span> command will inform you about administrative locks in the working copy, too, by displaying an <code class="literal">L</code> next to those locked paths:</p><div class="informalexample"><pre class="screen"> $ svn status L somedir M somedir/foo.c $ svn cleanup $ svn status M somedir/foo.c </pre></div><p>Don't confuse these working copy administrative locks with the user-managed locks that Subversion users create when using the lock-modify-unlock model of concurrent version control; see the sidebar <a class="xref" href="#svn.advanced.locking.meanings" title="The Three Meanings of “Lock”">The Three Meanings of <span class="quote">“<span class="quote">Lock</span>”</span></a> for clarification.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.tour.treeconflicts"></a>Dealing with Structural Conflicts</h2></div></div></div><p>So far, we have only talked about conflicts at the level of file content. When you and your collaborators make overlapping changes within the same file, Subversion forces you to merge those changes before you can commit.<a href="#ftn.idm1911" class="footnote" id="idm1911"><sup class="footnote">[9]</sup></a></p><p>But what happens if your collaborators move or delete a file that you are still working on? Maybe there was a miscommunication, and one person thinks the file should be deleted, while another person still wants to commit changes to the file. Or maybe your collaborators did some refactoring, renaming files and moving around directories in the process. If you were still working on these files, those modifications may need to be applied to the files at their new location. Such conflicts manifest themselves at the directory tree structure level rather than at the file content level, and are known as <em class="firstterm">tree conflicts</em>.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Tree conflicts prior to Subversion 1.6</strong></p></div></div></div><p>Prior to Subversion 1.6, tree conflicts could yield rather unexpected results. For example, if a file was locally modified, but had been renamed in the repository, running <span class="command"><strong>svn update</strong></span> would make Subversion carry out the following steps:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Check the file to be renamed for local modifications.</p></li><li class="listitem"><p>Delete the file at its old location, and if it had local modifications, keep an on-disk copy of the file at the old location. This on-disk copy now appears as an unversioned file in the working copy.</p></li><li class="listitem"><p>Add the file, as it exists in the repository, at its new location.</p></li></ul></div><p>When this situation arises, there is the possibility that the user makes a commit without realizing that local modifications have been left in a now-unversioned file in the working copy, and have not reached the repository. This gets more and more likely (and tedious) if the number of files affected by this problem is large.</p><p>Since Subversion 1.6, this and other similar situations are flagged as conflicts in the working copy.</p></div><p>As with textual conflicts, tree conflicts prevent a commit from being made from the conflicted state, giving the user the opportunity to examine the state of the working copy for potential problems arising from the tree conflict, and resolving any such problems before committing.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.treeconflicts.example"></a>An Example Tree Conflict</h3></div></div></div><p>Suppose a software project you were working on currently looked like this:</p><div class="informalexample"><pre class="screen"> $ svn list -Rv svn://svn.example.com/trunk/ 13 harry Sep 06 10:34 ./ 13 harry 27 Sep 06 10:34 COPYING 13 harry 41 Sep 06 10:32 Makefile 13 harry 53 Sep 06 10:34 README 13 harry Sep 06 10:32 code/ 13 harry 54 Sep 06 10:32 code/bar.c 13 harry 130 Sep 06 10:32 code/foo.c $ </pre></div><p>Later, in revision 14, your collaborator Harry renames the file <code class="filename">bar.c</code> to <code class="filename">baz.c</code>. Unfortunately, you don't realize this yet. As it turns out, you are busy in your working copy composing a different set of changes, some of which also involve modifications to <code class="filename">bar.c</code>:</p><div class="informalexample"><pre class="screen"> $ svn diff Index: code/foo.c =================================================================== --- code/foo.c (revision 13) +++ code/foo.c (working copy) @@ -3,5 +3,5 @@ int main(int argc, char *argv[]) { printf("I don't like being moved around!\n%s", bar()); - return 0; + return 1; } Index: code/bar.c =================================================================== --- code/bar.c (revision 13) +++ code/bar.c (working copy) @@ -1,4 +1,4 @@ const char *bar(void) { - return "Me neither!\n"; + return "Well, I do like being moved around!\n"; } $ </pre></div><p>You first realize that someone else has changed <code class="filename">bar.c</code> when your own commit attempt fails:</p><div class="informalexample"><pre class="screen"> $ svn commit -m "Small fixes" Sending code/bar.c svn: E155011: Commit failed (details follow): svn: E155011: File '/home/svn/project/code/bar.c' is out of date svn: E160013: File not found: transaction '14-e', path '/code/bar.c' $ </pre></div><p>At this point, you need to run <span class="command"><strong>svn update</strong></span>. Besides bringing our working copy up to date so that you can see Harry's changes, this also flags a tree conflict so you have the opportunity to evaluate and properly resolve it.</p><div class="informalexample"><pre class="screen"> $ svn update Updating '.': C code/bar.c A code/baz.c U Makefile Updated to revision 14. Summary of conflicts: Tree conflicts: 1 $ </pre></div><p>In its output, <span class="command"><strong>svn update</strong></span> signifies tree conflicts using a capital C in the fourth output column. <span class="command"><strong>svn status</strong></span> reveals additional details of the conflict:</p><div class="informalexample"><pre class="screen"> $ svn status M code/foo.c A + C code/bar.c &gt; local edit, incoming delete upon update Summary of conflicts: Tree conflicts: 1 $ </pre></div><p>Note how <code class="filename">bar.c</code> is automatically scheduled for re-addition in your working copy, which simplifies things in case you want to keep the file.</p><p>Because a move in Subversion is implemented as a copy operation followed by a delete operation, and these two operations cannot be easily related to one another during an update, all Subversion can warn you about is an incoming delete operation on a locally modified file. This delete operation <span class="emphasis"><em>may</em></span> be part of a move, or it could be a genuine delete operation. Determining exactly what semantic change was made to the repository is important—you want to know just how your own edits fit into the overall trajectory of the project. So read log messages, talk to your collaborators, study the line-based differences—do whatever you must do—to determine your best course of action.</p><p>In this case, Harry's commit log message tells you what you need to know.</p><div class="informalexample"><pre class="screen"> $ svn log -r14 ^/trunk ------------------------------------------------------------------------ r14 | harry | 2011-09-06 10:38:17 -0400 (Tue, 06 Sep 2011) | 1 line Changed paths: M /Makefile D /code/bar.c A /code/baz.c (from /code/bar.c:13) Rename bar.c to baz.c, and adjust Makefile accordingly. ------------------------------------------------------------------------ $ </pre></div><p><span class="command"><strong>svn info</strong></span> shows the URLs of the items involved in the conflict. The <span class="emphasis"><em>left</em></span> URL shows the source of the local side of the conflict, while the <span class="emphasis"><em>right</em></span> URL shows the source of the incoming side of the conflict. These URLs indicate where you should start searching the repository's history for the change which conflicts with your local change.</p><div class="informalexample"><pre class="screen"> $ svn info code/bar.c Path: code/bar.c Name: bar.c URL: http://svn.example.com/svn/repo/trunk/code/bar.c … Tree conflict: local edit, incoming delete upon update Source left: (file) ^/trunk/code/bar.c@4 Source right: (none) ^/trunk/code/bar.c@5 $ </pre></div><p><code class="filename">bar.c</code> is now said to be the <em class="firstterm">victim</em> of a tree conflict. It cannot be committed until the conflict is resolved:</p><div class="informalexample"><pre class="screen"> $ svn commit -m "Small fixes" svn: E155015: Commit failed (details follow): svn: E155015: Aborting commit: '/home/svn/project/code/bar.c' remains in confl ict $ </pre></div><p>To resolve this conflict, you must either agree or disagree with the move that Harry made.</p><p>If you agree with the move, your <code class="filename">bar.c</code> is superfluous. You'll want to delete it and mark the tree conflict as resolved. But wait: you made changes to that file! Before deleting <code class="filename">bar.c</code>, you need to decide if the changes you made to it need to be applied elsewhere, for example to the new <code class="filename">baz.c</code> file where all of <code class="filename">bar.c</code>'s code now lives. Let's assume that your changes do need to <span class="quote">“<span class="quote">follow the move</span>”</span>. Subversion isn't smart enough to do this work for you<a href="#ftn.idm1979" class="footnote" id="idm1979"><sup class="footnote">[10]</sup></a>, so you need to migrate your changes manually.</p><p>In our example, you could manually re-make your change to <code class="filename">bar.c</code> pretty easily—it was, after all, a single-line change. That's not always the case, though, so we'll show a more scalable approach. We'll first use <span class="command"><strong>svn diff</strong></span> to create a patch file. Then we'll edit the headers of that patch file to point to the new name of our renamed file. Finally, we re-apply the modified patch to our working copy.</p><div class="informalexample"><pre class="screen"> $ svn diff code/bar.c &gt; PATCHFILE $ cat PATCHFILE Index: code/bar.c =================================================================== --- code/bar.c (working copy) +++ code/bar.c (working copy) @@ -1,4 +1,4 @@ const char *bar(void) { - return "Me neither!\n"; + return "Well, I do like being moved around!\n"; } $ ### Edit PATCHFILE to refer to code/baz.c instead of code/bar.c $ cat PATCHFILE Index: code/baz.c =================================================================== --- code/baz.c (working copy) +++ code/baz.c (working copy) @@ -1,4 +1,4 @@ const char *bar(void) { - return "Me neither!\n"; + return "Well, I do like being moved around!\n"; } $ svn patch PATCHFILE U code/baz.c $ </pre></div><p>Now that the changes you originally made to <code class="filename">bar.c</code> have been successfully reproduced in <code class="filename">baz.c</code>, you can delete <code class="filename">bar.c</code> and resolve the conflict, instructing the resolution logic to accept what is currently in the working copy as the desired result.</p><div class="informalexample"><pre class="screen"> $ svn delete --force code/bar.c D code/bar.c $ svn resolve --accept=working code/bar.c Resolved conflicted state of 'code/bar.c' $ svn status M code/foo.c M code/baz.c $ svn diff Index: code/foo.c =================================================================== --- code/foo.c (revision 14) +++ code/foo.c (working copy) @@ -3,5 +3,5 @@ int main(int argc, char *argv[]) { printf("I don't like being moved around!\n%s", bar()); - return 0; + return 1; } Index: code/baz.c =================================================================== --- code/baz.c (revision 14) +++ code/baz.c (working copy) @@ -1,4 +1,4 @@ const char *bar(void) { - return "Me neither!\n"; + return "Well, I do like being moved around!\n"; } $ </pre></div><p>But what if you do not agree with the move? Well, in that case, you can delete <code class="filename">baz.c</code> instead, after making sure any changes made to it after it was renamed are either preserved or not worth keeping. (Do not forget to also revert the changes Harry made to <code class="filename">Makefile</code>.) Since <code class="filename">bar.c</code> is already scheduled for re-addition, there is nothing else left to do, and the conflict can be marked resolved:</p><div class="informalexample"><pre class="screen"> $ svn delete --force code/baz.c D code/baz.c $ svn resolve --accept=working code/bar.c Resolved conflicted state of 'code/bar.c' $ svn status M code/foo.c A + code/bar.c D code/baz.c M Makefile $ svn diff Index: code/foo.c =================================================================== --- code/foo.c (revision 14) +++ code/foo.c (working copy) @@ -3,5 +3,5 @@ int main(int argc, char *argv[]) { printf("I don't like being moved around!\n%s", bar()); - return 0; + return 1; } Index: code/bar.c =================================================================== --- code/bar.c (revision 14) +++ code/bar.c (working copy) @@ -1,4 +1,4 @@ const char *bar(void) { - return "Me neither!\n"; + return "Well, I do like being moved around!\n"; } Index: code/baz.c =================================================================== --- code/baz.c (revision 14) +++ code/baz.c (working copy) @@ -1,4 +0,0 @@ -const char *bar(void) -{ - return "Me neither!\n"; -} Index: Makefile =================================================================== --- Makefile (revision 14) +++ Makefile (working copy) @@ -1,2 +1,2 @@ foo: - $(CC) -o $@ code/foo.c code/baz.c + $(CC) -o $@ code/foo.c code/bar.c </pre></div><p>You've now resolved your first tree conflict! You can commit your changes and tell Harry during tea break about all the extra work he caused for you.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.tour.summary"></a>Summary</h2></div></div></div><p>Now we've covered most of the Subversion client commands. Notable exceptions are those dealing with branching and merging (see <a class="xref" href="#svn.branchmerge" title="Chapter 4. Branching and Merging">Chapter 4, <em>Branching and Merging</em></a>) and properties (see <a class="xref" href="#svn.advanced.props" title="Properties">the section called “Properties”</a>). However, you may want to take a moment to skim through <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a> to get an idea of all the different commands that Subversion has—and how you can use them to make your work easier.</p></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm1098" class="footnote"><p><a href="#idm1098" class="para"><sup class="para">[6] </sup></a>Of course, nothing is ever totally deleted from the repository—just from its <code class="literal">HEAD</code> revision. You may continue to access the deleted item in previous revisions. Should you desire to resurrect the item so that it is again present in <code class="literal">HEAD</code>, see <a class="xref" href="#svn.branchmerge.basicmerging.resurrect" title="Resurrecting Deleted Items">the section called “Resurrecting Deleted Items”</a>.</p></div><div id="ftn.idm1563" class="footnote"><p><a href="#idm1563" class="para"><sup class="para">[7] </sup></a>And if you ask them for it, they may very well ride you out of town on a rail.</p></div><div id="ftn.idm1859" class="footnote"><p><a href="#idm1859" class="para"><sup class="para">[8] </sup></a>See? We told you that Subversion was a time machine.</p></div><div id="ftn.idm1911" class="footnote"><p><a href="#idm1911" class="para"><sup class="para">[9] </sup></a>Well, you <span class="emphasis"><em>could</em></span> mark files containing conflict markers as resolved and commit them, if you really wanted to. But this is rarely done in practice.</p></div><div id="ftn.idm1979" class="footnote"><p><a href="#idm1979" class="para"><sup class="para">[10] </sup></a>In some cases, Subversion 1.5 and 1.6 <span class="emphasis"><em>would</em></span> actually handle this for you, but this somewhat hit-or-miss functionality was removed in Subversion 1.7.</p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="svn.advanced"></a>Chapter 3. Advanced Topics</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.tour.revs.specifiers">Revision Specifiers</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.tour.revs.keywords">Revision Keywords</a></span></dt><dt><span class="sect2"><a href="#svn.tour.revs.dates">Revision Dates</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.advanced.pegrevs">Peg and Operative Revisions</a></span></dt><dt><span class="sect1"><a href="#svn.advanced.props">Properties</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.props.why">Why Properties?</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.props.manip">Manipulating Properties</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.props.workflow">Properties and the Subversion Workflow</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.props.auto">Automatic Property Setting</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.advanced.props.file-portability">File Portability</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.props.special.mime-type">File Content Type</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.props.special.executable">File Executability</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.props.special.eol-style">End-of-Line Character Sequences</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.advanced.props.special.ignore">Ignoring Unversioned Items</a></span></dt><dt><span class="sect1"><a href="#svn.advanced.props.special.keywords">Keyword Substitution</a></span></dt><dt><span class="sect1"><a href="#svn.advanced.sparsedirs">Sparse Directories</a></span></dt><dt><span class="sect1"><a href="#svn.advanced.locking">Locking</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.locking.creation">Creating Locks</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.locking.discovery">Discovering Locks</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.locking.break-steal">Breaking and Stealing Locks</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.locking.lock-communication">Lock Communication</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.advanced.externals">Externals Definitions</a></span></dt><dt><span class="sect1"><a href="#svn.advanced.changelists">Changelists</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.changelists.creating">Creating and Modifying Changelists</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.changelists.asfilters">Changelists As Operation Filters</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.changelists.limitations">Changelist Limitations</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.serverconfig.netmodel">Network Model</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.serverconfig.netmodel.reqresp">Requests and Responses</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.netmodel.creds">Client Credentials</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.netmodel.credcache">Caching credentials</a></span></dt><dt><span class="sect3"><a href="#svn.tour.initial.disabling-password-caching">Disabling password caching</a></span></dt><dt><span class="sect3"><a href="#svn.tour.initial.authn-cache-purge">Removing cached credentials</a></span></dt><dt><span class="sect3"><a href="#svn.tour.initial.different-user">Command-line authentication</a></span></dt><dt><span class="sect3"><a href="#svn.tour.initial.authn-wrapup">Authentication wrap-up</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.advanced.summary">Summary</a></span></dt></dl></div><p>If you've been reading this book chapter by chapter, from start to finish, you should by now have acquired enough knowledge to use the Subversion client to perform the most common version control operations. You understand how to check out a working copy from a Subversion repository. You are comfortable with submitting and receiving changes using the <span class="command"><strong>svn commit</strong></span> and <span class="command"><strong>svn update</strong></span> operations. You've probably even developed a reflex that causes you to run the <span class="command"><strong>svn status</strong></span> command almost unconsciously. For all intents and purposes, you are ready to use Subversion in a typical environment.</p><p>But the Subversion feature set doesn't stop at <span class="quote">“<span class="quote">common version control operations.</span>”</span> It has other bits of functionality besides just communicating file and directory changes to and from a central repository.</p><p>This chapter highlights some of Subversion's features that, while important, may not be part of the typical user's daily routine. It assumes that you are familiar with Subversion's basic file and directory versioning capabilities. If you aren't, you'll want to first read <a class="xref" href="#svn.basic" title="Chapter 1. Fundamental Concepts">Chapter 1, <em>Fundamental Concepts</em></a> and <a class="xref" href="#svn.tour" title="Chapter 2. Basic Usage">Chapter 2, <em>Basic Usage</em></a>. Once you've mastered those basics and consumed this chapter, you'll be a Subversion power user!</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.tour.revs.specifiers"></a>Revision Specifiers</h2></div></div></div><p>As we described in <a class="xref" href="#svn.basic.in-action.revs" title="Revisions">the section called “Revisions”</a>, revision numbers in Subversion are pretty straightforward—integers that keep getting larger as you commit more changes to your versioned data. Still, it doesn't take long before you can no longer remember exactly what happened in each and every revision. Fortunately, the typical Subversion workflow doesn't often demand that you supply arbitrary revisions to the Subversion operations you perform. For operations that <span class="emphasis"><em>do</em></span> require a revision specifier, you generally supply a revision number that you saw in a commit email, in the output of some other Subversion operation, or in some other context that would give meaning to that particular number.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Referring to revision numbers with an <span class="quote">“<span class="quote"><code class="literal">r</code></span>”</span> prefix (<code class="literal">r314</code>, for example) is an established practice in Subversion communities, and is both supported and encouraged by many Subversion-related tools. In most places where you would specify a bare revision number on the command line, you may also use the <code class="literal">r</code><em class="replaceable"><code>NNN</code></em> syntax.</p></td></tr></table></div><p>But occasionally, you need to pinpoint a moment in time for which you don't already have a revision number memorized or handy. So besides the integer revision numbers, <span class="command"><strong>svn</strong></span> allows as input some additional forms of revision specifiers: <em class="firstterm">revision keywords</em> and revision dates.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The various forms of Subversion revision specifiers can be mixed and matched when used to specify revision ranges. For example, you can use <code class="option">-r <em class="replaceable"><code>REV1</code></em>:<em class="replaceable"><code>REV2</code></em></code> where <em class="replaceable"><code>REV1</code></em> is a revision keyword and <em class="replaceable"><code>REV2</code></em> is a revision number, or where <em class="replaceable"><code>REV1</code></em> is a date and <em class="replaceable"><code>REV2</code></em> is a revision keyword, and so on. The individual revision specifiers are independently evaluated, so you can put whatever you want on the opposite sides of that colon.</p></td></tr></table></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.revs.keywords"></a>Revision Keywords</h3></div></div></div><a id="idm2043" class="indexterm"></a><p>The Subversion client understands a number of revision keywords. These keywords can be used instead of integer arguments to the <code class="option">--revision</code> (<code class="option">-r</code>) option, and are resolved into specific revision numbers by Subversion:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">HEAD</code></span></dt><dd><a id="idm2054" class="indexterm"></a><a id="idm2056" class="indexterm"></a><p>The latest (or <span class="quote">“<span class="quote">youngest</span>”</span>) revision in the repository.</p></dd><dt><span class="term"><code class="literal">BASE</code></span></dt><dd><a id="idm2066" class="indexterm"></a><a id="idm2068" class="indexterm"></a><p>The revision number of an item in a working copy. If the item has been locally modified, this refers to the way the item appears without those local modifications.</p></dd><dt><span class="term"><code class="literal">COMMITTED</code></span></dt><dd><a id="idm2077" class="indexterm"></a><a id="idm2079" class="indexterm"></a><p>The most recent revision prior to, or equal to, <code class="literal">BASE</code>, in which an item changed.</p></dd><dt><span class="term"><code class="literal">PREV</code></span></dt><dd><a id="idm2089" class="indexterm"></a><a id="idm2091" class="indexterm"></a><p>The revision immediately <span class="emphasis"><em>before</em></span> the last revision in which an item changed. Technically, this boils down to <code class="literal">COMMITTED</code>-1.</p></dd></dl></div><p>As can be derived from their descriptions, the <code class="literal">PREV</code>, <code class="literal">BASE</code>, and <code class="literal">COMMITTED</code> revision keywords are used only when referring to a working copy path—they don't apply to repository URLs. <code class="literal">HEAD</code>, on the other hand, can be used in conjunction with both of these path types.</p><p>Here are some examples of revision keywords in action:</p><div class="informalexample"><pre class="screen"> $ svn diff -r PREV:COMMITTED foo.c # shows the last change committed to foo.c $ svn log -r HEAD # shows log message for the latest repository commit $ svn diff -r HEAD # compares your working copy (with all of its local changes) to the # latest version of that tree in the repository $ svn diff -r BASE:HEAD foo.c # compares the unmodified version of foo.c with the latest version of # foo.c in the repository $ svn log -r BASE:HEAD # shows all commit logs for the current versioned directory since you # last updated $ svn update -r PREV foo.c # rewinds the last change on foo.c, decreasing foo.c's working revision $ svn diff -r BASE:14 foo.c # compares the unmodified version of foo.c with the way foo.c looked # in revision 14 </pre></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.tour.revs.dates"></a>Revision Dates</h3></div></div></div><a id="idm2108" class="indexterm"></a><p>Revision numbers reveal nothing about the world outside the version control system, but sometimes you need to correlate a moment in real time with a moment in version history. To facilitate this, the <code class="option">--revision</code> (<code class="option">-r</code>) option can also accept as input date specifiers wrapped in curly braces (<code class="literal">{</code> and <code class="literal">}</code>). Subversion accepts the standard ISO-8601 date and time formats, plus a few others. Here are some examples.</p><div class="informalexample"><pre class="screen"> $ svn update -r {2006-02-17} $ svn update -r {15:30} $ svn update -r {15:30:00.200000} $ svn update -r {"2006-02-17 15:30"} $ svn update -r {"2006-02-17 15:30 +0230"} $ svn update -r {2006-02-17T15:30} $ svn update -r {2006-02-17T15:30Z} $ svn update -r {2006-02-17T15:30-04:00} $ svn update -r {20060217T1530} $ svn update -r {20060217T1530Z} $ svn update -r {20060217T1530-0500} … </pre></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Keep in mind that most shells will require you to, at a minimum, quote or otherwise escape any spaces that are included as part of revision date specifiers. Certain shells may also take issue with the unescaped use of curly braces, too. Consult your shell's documentation for the requirements specific to your environment.</p></td></tr></table></div><p>When you specify a date, Subversion resolves that date to the most recent revision of the repository as of that date, and then continues to operate against that resolved revision number:</p><div class="informalexample"><pre class="screen"> $ svn log -r {2006-11-28} ------------------------------------------------------------------------ r12 | ira | 2006-11-27 12:31:51 -0600 (Mon, 27 Nov 2006) | 6 lines … </pre></div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Is Subversion a Day Early?</strong></p></div></div></div><p>If you specify a single date as a revision without specifying a time of day (for example <code class="literal">2006-11-27</code>), you may think that Subversion should give you the last revision that took place on the 27th of November. Instead, you'll get back a revision from the 26th, or even earlier. Remember that Subversion will find the <span class="emphasis"><em>most recent revision of the repository</em></span> as of the date you give. If you give a date without a timestamp, such as <code class="literal">2006-11-27</code>, Subversion assumes a time of 00:00:00, so looking for the most recent revision won't return anything on the 27th.</p><p>If you want to include the 27th in your search, you can either specify the 27th with the time (<code class="literal">{"2006-11-27 23:59"}</code>), or just specify the next day (<code class="literal">{2006-11-28}</code>).</p></div><p>You can also use a range of dates. Subversion will find all revisions between both dates, inclusive:</p><div class="informalexample"><pre class="screen"> $ svn log -r {2006-11-20}:{2006-11-29} … </pre></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Since the timestamp of a revision is stored as an unversioned, modifiable property of the revision (see <a class="xref" href="#svn.advanced.props" title="Properties">the section called “Properties”</a>), revision timestamps can be changed to represent complete falsifications of true chronology, or even removed altogether. Subversion's ability to correctly convert revision dates into real revision numbers depends on revision datestamps maintaining a sequential ordering—the younger the revision, the younger its timestamp. If this ordering isn't maintained, you will likely find that trying to use dates to specify revision ranges in your repository doesn't always return the data you might have expected.</p></td></tr></table></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.pegrevs"></a>Peg and Operative Revisions</h2></div></div></div><p>We copy, move, rename, and completely replace files and directories on our computers all the time. And your version control system shouldn't get in the way of your doing these things with your version-controlled files and directories, either. Subversion's file management support is quite liberating, affording almost as much flexibility for versioned files as you'd expect when manipulating your unversioned ones. But that flexibility means that across the lifetime of your repository, a given versioned object might have many paths, and a given path might represent several entirely different versioned objects. This introduces a certain level of complexity to your interactions with those paths and objects.</p><p>Subversion is pretty smart about noticing when an object's version history includes such <span class="quote">“<span class="quote">changes of address.</span>”</span> For example, if you ask for the revision history log of a particular file that was renamed last week, Subversion happily provides all those logs—the revision in which the rename itself happened, plus the logs of relevant revisions both before and after that rename. So, most of the time, you don't even have to think about such things. But occasionally, Subversion needs your help to clear up ambiguities.</p><p>The simplest example of this occurs when a directory or file is deleted from version control, and then a new directory or file is created with the same name and added to version control. The thing you deleted and the thing you later added aren't the same thing. They merely happen to have had the same path—<code class="filename">/trunk/object</code>, for example. What, then, does it mean to ask Subversion about the history of <code class="filename">/trunk/object</code>? Are you asking about the thing currently at that location, or the old thing you deleted from that location? Are you asking about the operations that have happened to <span class="emphasis"><em>all</em></span> the objects that have ever lived at that path? Subversion needs a hint about what you really want.</p><p>And thanks to moves, versioned object history can get far more twisted than even that. For example, you might have a directory named <code class="filename">concept</code>, containing some nascent software project you've been toying with. Eventually, though, that project matures to the point that the idea seems to actually have some wings, so you do the unthinkable and decide to give the project a name.<a href="#ftn.idm2149" class="footnote" id="idm2149"><sup class="footnote">[11]</sup></a> Let's say you called your software Frabnaggilywort. At this point, it makes sense to rename the directory to reflect the project's new name, so <code class="filename">concept</code> is renamed to <code class="filename">frabnaggilywort</code>. Life goes on, Frabnaggilywort releases a 1.0 version and is downloaded and used daily by hordes of people aiming to improve their lives.</p><p>It's a nice story, really, but it doesn't end there. Entrepreneur that you are, you've already got another think in the tank. So you make a new directory, <code class="filename">concept</code>, and the cycle begins again. In fact, the cycle begins again many times over the years, each time starting with that old <code class="filename">concept</code> directory, then sometimes seeing that directory renamed as the idea cures, sometimes seeing it deleted when you scrap the idea. Or, to get really sick, maybe you rename <code class="filename">concept</code> to something else for a while, but later rename the thing back to <code class="filename">concept</code> for some reason.</p><p>In scenarios like these, attempting to instruct Subversion to work with these reused paths can be a little like instructing a motorist in Chicago's West Suburbs to drive east down Roosevelt Road and turn left onto Main Street. In a mere 20 minutes, you can cross <span class="quote">“<span class="quote">Main Street</span>”</span> in Wheaton, Glen Ellyn, and Lombard. And no, they aren't the same street. Our motorist—and our Subversion—need a little more detail to do the right thing.</p><p>Fortunately, Subversion allows you to tell it exactly which Main Street you meant. The mechanism used is called a <em class="firstterm">peg revision</em>, and you provide these to Subversion for the sole purpose of identifying unique lines of history. Because at most one versioned object may occupy a path at any given time—or, more precisely, in any one revision—the combination of a path and a peg revision is all that is needed to unambiguously identify a specific line of history. Peg revisions are specified to the Subversion command-line client using <em class="firstterm">at syntax</em>, so called because the syntax involves appending an <span class="quote">“<span class="quote">at sign</span>”</span> (<code class="literal">@</code>) and the peg revision to the end of the path with which the revision is associated.</p><p>But what of the <code class="option">--revision</code> (<code class="option">-r</code>) of which we've spoken so much in this book? That revision (or set of revisions) is called the <em class="firstterm">operative revision</em> (or <em class="firstterm">operative revision range</em>). Once a particular line of history has been identified using a path and peg revision, Subversion performs the requested operation using the operative revision(s). To map this to our Chicagoland streets analogy, if we are told to go to 606 N. Main Street in Wheaton,<a href="#ftn.idm2171" class="footnote" id="idm2171"><sup class="footnote">[12]</sup></a> we can think of <span class="quote">“<span class="quote">Main Street</span>”</span> as our path and <span class="quote">“<span class="quote">Wheaton</span>”</span> as our peg revision. These two pieces of information identify a unique path that can be traveled (north or south on Main Street), and they keep us from traveling up and down the wrong Main Street in search of our destination. Now we throw in <span class="quote">“<span class="quote">606 N.</span>”</span> as our operative revision of sorts, and we know <span class="emphasis"><em>exactly</em></span> where to go.</p><div class="sidebar"><a id="svn.advanced.pegrevs.algorithm"></a><div class="titlepage"><div><div><p class="title"><strong>The Peg Revision Algorithm</strong></p></div></div></div><p>The Subversion command-line client performs the peg revision algorithm any time it needs to resolve possible ambiguities in the paths and revisions provided to it. Here's an example of such an invocation:</p><div class="informalexample"><pre class="screen"> $ svn <em class="replaceable"><code>command</code></em> -r <em class="replaceable"><code>OPERATIVE-REV</code></em> item@<em class="replaceable"><code>PEG-REV</code></em> </pre></div><p>If <em class="replaceable"><code>OPERATIVE-REV</code></em> is older than <em class="replaceable"><code>PEG-REV</code></em>, the algorithm is as follows:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Locate <em class="replaceable"><code>item</code></em> in the revision identified by <em class="replaceable"><code>PEG-REV</code></em>. There can be only one such object.</p></li><li class="listitem"><p>Trace the object's history backwards (through any possible renames) to its ancestor in the revision <em class="replaceable"><code>OPERATIVE-REV</code></em>.</p></li><li class="listitem"><p>Perform the requested action on that ancestor, wherever it is located, or whatever its name might be or might have been at that time.</p></li></ol></div><p>But what if <em class="replaceable"><code>OPERATIVE-REV</code></em> is <span class="emphasis"><em>younger</em></span> than <em class="replaceable"><code>PEG-REV</code></em>? Well, that adds some complexity to the theoretical problem of locating the path in <em class="replaceable"><code>OPERATIVE-REV</code></em>, because the path's history could have forked multiple times (thanks to copy operations) between <em class="replaceable"><code>PEG-REV</code></em> and <em class="replaceable"><code>OPERATIVE-REV</code></em>. And that's not all—Subversion doesn't store enough information to performantly trace an object's history forward, anyway. So the algorithm is a little different:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Locate <em class="replaceable"><code>item</code></em> in the revision identified by <em class="replaceable"><code>OPERATIVE-REV</code></em>. There can be only one such object.</p></li><li class="listitem"><p>Trace the object's history backward (through any possible renames) to its ancestor in the revision <em class="replaceable"><code>PEG-REV</code></em>.</p></li><li class="listitem"><p>Verify that the object's location (path-wise) in <em class="replaceable"><code>PEG-REV</code></em> is the same as it is in <em class="replaceable"><code>OPERATIVE-REV</code></em>. If that's the case, at least the two locations are known to be directly related, so perform the requested action on the location in <em class="replaceable"><code>OPERATIVE-REV</code></em>. Otherwise, relatedness was not established, so error out with a loud complaint that no viable location was found. (Someday, we expect that Subversion will be able to handle this usage scenario with more flexibility and grace.)</p></li></ol></div><p>Note that even when you don't explicitly supply a peg revision or operative revision, they are still present. For your convenience, the default peg revision is <code class="literal">BASE</code> for working copy items and <code class="literal">HEAD</code> for repository URLs. And when no operative revision is provided, it defaults to being the same revision as the peg revision.</p></div><p>Say that long ago we created our repository, and in revision 1 we added our first <code class="filename">concept</code> directory, plus an <code class="filename">IDEA</code> file in that directory talking about the concept. After several revisions in which real code was added and tweaked, we, in revision 20, renamed this directory to <code class="filename">frabnaggilywort</code>. By revision 27, we had a new concept, a new <code class="filename">concept</code> directory to hold it, and a new <code class="filename">IDEA</code> file to describe it. And then five years and thousands of revisions flew by, just like they would in any good romance story.</p><p>Now, years later, we wonder what the <code class="filename">IDEA</code> file looked like back in revision 1. But Subversion needs to know whether we are asking about how the <span class="emphasis"><em>current</em></span> file looked back in revision 1, or whether we are asking for the contents of whatever file lived at <code class="filename">concept/IDEA</code> in revision 1. Certainly those questions have different answers, and because of peg revisions, you can ask those questions. To find out how the current <code class="filename">IDEA</code> file looked in that old revision, you run:</p><div class="informalexample"><pre class="screen"> $ svn cat -r 1 concept/IDEA svn: E195012: Unable to find repository location for 'concept/IDEA' in revision 1 </pre></div><p>Of course, in this example, the current <code class="filename">IDEA</code> file didn't exist yet in revision 1, so Subversion gives an error. The previous command is shorthand for a longer notation which explicitly lists a peg revision. The expanded notation is:</p><div class="informalexample"><pre class="screen"> $ svn cat -r 1 concept/IDEA@BASE svn: E195012: Unable to find repository location for 'concept/IDEA' in revision 1 </pre></div><p>And when executed, it has the expected results.</p><p>The perceptive reader is probably wondering at this point whether the peg revision syntax causes problems for working copy paths or URLs that actually have at signs in them. After all, how does <span class="command"><strong>svn</strong></span> know whether <code class="literal">news@11</code> is the name of a directory in my tree or just a syntax for <span class="quote">“<span class="quote">revision 11 of <code class="filename">news</code></span>”</span>? Thankfully, while <span class="command"><strong>svn</strong></span> will always assume the latter, there is a trivial workaround. You need only append an at sign to the end of the path, such as <code class="literal">news@11@</code>. <span class="command"><strong>svn</strong></span> cares only about the last at sign in the argument, and it is not considered illegal to omit a literal peg revision specifier after that at sign. This workaround even applies to paths that end in an at sign—you would use <code class="literal">filename@@</code> to talk about a file named <code class="filename">filename@</code>.</p><p>Let's ask the other question, then—in revision 1, what were the contents of whatever file occupied the address <code class="filename">concepts/IDEA</code> at the time? We'll use an explicit peg revision to help us out.</p><div class="informalexample"><pre class="screen"> $ svn cat concept/IDEA@1 The idea behind this project is to come up with a piece of software that can frab a naggily wort. Frabbing naggily worts is tricky business, and doing it incorrectly can have serious ramifications, so we need to employ over-the-top input validation and data verification mechanisms. </pre></div><p>Notice that we didn't provide an operative revision this time. That's because when no operative revision is specified, Subversion assumes a default operative revision that's the same as the peg revision.</p><p>As you can see, the output from our operation appears to be correct. The text even mentions frabbing naggily worts, so this is almost certainly the file that describes the software now called Frabnaggilywort. In fact, we can verify this using the combination of an explicit peg revision and explicit operative revision. We know that in <code class="literal">HEAD</code>, the Frabnaggilywort project is located in the <code class="filename">frabnaggilywort</code> directory. So we specify that we want to see how the line of history identified in <code class="literal">HEAD</code> as the path <code class="filename">frabnaggilywort/IDEA</code> looked in revision 1.</p><div class="informalexample"><pre class="screen"> $ svn cat -r 1 frabnaggilywort/IDEA@HEAD The idea behind this project is to come up with a piece of software that can frab a naggily wort. Frabbing naggily worts is tricky business, and doing it incorrectly can have serious ramifications, so we need to employ over-the-top input validation and data verification mechanisms. </pre></div><p>And the peg and operative revisions need not be so trivial, either. For example, say <code class="filename">frabnaggilywort</code> had been deleted from <code class="literal">HEAD</code>, but we know it existed in revision 20, and we want to see the diffs for its <code class="filename">IDEA</code> file between revisions 4 and 10. We can use peg revision 20 in conjunction with the URL that would have held Frabnaggilywort's <code class="filename">IDEA</code> file in revision 20, and then use 4 and 10 as our operative revision range.</p><div class="informalexample"><pre class="screen"> $ svn diff -r 4:10 http://svn.red-bean.com/projects/frabnaggilywort/IDEA@20 Index: frabnaggilywort/IDEA =================================================================== --- frabnaggilywort/IDEA (revision 4) +++ frabnaggilywort/IDEA (revision 10) @@ -1,5 +1,5 @@ -The idea behind this project is to come up with a piece of software -that can frab a naggily wort. Frabbing naggily worts is tricky -business, and doing it incorrectly can have serious ramifications, so -we need to employ over-the-top input validation and data verification -mechanisms. +The idea behind this project is to come up with a piece of +client-server software that can remotely frab a naggily wort. +Frabbing naggily worts is tricky business, and doing it incorrectly +can have serious ramifications, so we need to employ over-the-top +input validation and data verification mechanisms. </pre></div><p>Fortunately, most folks aren't faced with such complex situations. But when you are, remember that peg revisions are that extra hint Subversion needs to clear up ambiguity.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.props"></a>Properties</h2></div></div></div><a id="idm2272" class="indexterm"></a><p>We've already covered in detail how Subversion stores and retrieves various versions of files and directories in its repository. Whole chapters have been devoted to this most fundamental piece of functionality provided by the tool. And if the versioning support stopped there, Subversion would still be complete from a version control perspective.</p><p>But it doesn't stop there.</p><p>In addition to versioning your directories and files, Subversion provides interfaces for adding, modifying, and removing versioned metadata on each of your versioned directories and files. We refer to this metadata as <em class="firstterm">properties</em>, and they can be thought of as two-column tables that map property names to arbitrary values attached to each item in your working copy. Generally speaking, the names and values of the properties can be whatever you want them to be, with the constraint that the names must contain only ASCII characters. And the best part about these properties is that they, too, are versioned, just like the textual contents of your files. You can modify, commit, and revert property changes as easily as you can file content changes. And the sending and receiving of property changes occurs as part of your typical commit and update operations—you don't have to change your basic processes to accommodate them.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Subversion has reserved the set of properties whose names begin with <code class="literal">svn:</code> as its own. While there are only a handful of such properties in use today, you should avoid creating custom properties for your own needs whose names begin with this prefix. Otherwise, you run the risk that a future release of Subversion will grow support for a feature or behavior driven by a property of the same name but with perhaps an entirely different interpretation.</p></td></tr></table></div><p>Properties show up elsewhere in Subversion, too. Just as files and directories may have arbitrary property names and values attached to them, each revision as a whole may have arbitrary properties attached to it. The same constraints apply—human-readable names and anything-you-want binary values. The main difference is that revision properties are not versioned. In other words, if you change the value of, or delete, a revision property, there's no way, within the scope of Subversion's functionality, to recover the previous value.</p><p>Subversion has no particular policy regarding the use of properties. It asks only that you do not use property names that begin with the prefix <code class="literal">svn:</code> as that's the namespace that it sets aside for its own use. And Subversion does, in fact, use properties—both the versioned and unversioned variety. Certain versioned properties have special meaning or effects when found on files and directories, or they house a particular bit of information about the revisions on which they are found. Certain revision properties are automatically attached to revisions by Subversion's commit process, and they carry information about the revision. Most of these properties are mentioned elsewhere in this or other chapters as part of the more general topics to which they are related. For an exhaustive list of Subversion's predefined properties, see <a class="xref" href="#svn.ref.properties" title="Subversion Properties">the section called “Subversion Properties”</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>While Subversion automatically attaches properties (<code class="literal">svn:date</code>, <code class="literal">svn:author</code>, <code class="literal">svn:log</code>, and so on) to revisions, it does <span class="emphasis"><em>not</em></span> presume thereafter the existence of those properties, and neither should you or the tools you use to interact with your repository. Revision properties can be deleted programmatically or via the client (if allowed by the repository hooks) without damaging Subversion's ability to function. So, when writing scripts which operate on your Subversion repository data, do not make the mistake of assuming that any particular revision property exists on a revision.</p></td></tr></table></div><p>In this section, we will examine the utility—both to users of Subversion and to Subversion itself—of property support. You'll learn about the property-related <span class="command"><strong>svn</strong></span> subcommands and how property modifications affect your normal Subversion workflow.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.props.why"></a>Why Properties?</h3></div></div></div><p>Just as Subversion uses properties to store extra information about the files, directories, and revisions that it contains, you might also find properties to be of similar use. You might find it useful to have a place close to your versioned data to hang custom metadata about that data.</p><p>Say you wish to design a web site that houses many digital photos and displays them with captions and a datestamp. Now, your set of photos is constantly changing, so you'd like to have as much of this site automated as possible. These photos can be quite large, so as is common with sites of this nature, you want to provide smaller thumbnail images to your site visitors.</p><p>Now, you can get this functionality using traditional files. That is, you can have your <code class="filename">image123.jpg</code> and an <code class="filename">image123-thumbnail.jpg</code> side by side in a directory. Or if you want to keep the filenames the same, you might have your thumbnails in a different directory, such as <code class="filename">thumbnails/image123.jpg</code>. You can also store your captions and datestamps in a similar fashion, again separated from the original image file. But the problem here is that your collection of files multiplies with each new photo added to the site.</p><p>Now consider the same web site deployed in a way that makes use of Subversion's file properties. Imagine having a single image file, <code class="filename">image123.jpg</code>, with properties set on that file that are named <code class="literal">caption</code>, <code class="literal">datestamp</code>, and even <code class="literal">thumbnail</code>. Now your working copy directory looks much more manageable—in fact, it looks to the casual browser like there are nothing but image files in it. But your automation scripts know better. They know that they can use <span class="command"><strong>svn</strong></span> (or better yet, they can use the Subversion language bindings—see <a class="xref" href="#svn.developer.usingapi" title="Using the APIs">the section called “Using the APIs”</a>) to dig out the extra information that your site needs to display without having to read an index file or play path manipulation games.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>While Subversion places few restrictions on the names and values you use for properties, it has not been designed to optimally carry large property values or large sets of properties on a given file or directory. Subversion commonly holds all the property names and values associated with a single item in memory at the same time, which can cause detrimental performance or failed operations when extremely large property sets are used.</p></td></tr></table></div><p>Custom revision properties are also frequently used. One common such use is a property whose value contains an issue tracker ID with which the revision is associated, perhaps because the change made in that revision fixes a bug filed in the tracker issue with that ID. Other uses include hanging more friendly names on the revision—it might be hard to remember that revision 1935 was a fully tested revision. But if there's, say, a <code class="literal">test-results</code> property on that revision with the value <code class="literal">all passing</code>, that's meaningful information to have. And Subversion allows you to easily do this via the <code class="option">--with-revprop</code> option of the <span class="command"><strong>svn commit</strong></span> command:</p><div class="informalexample"><pre class="screen"> $ svn commit -m "Fix up the last remaining known regression bug." \ --with-revprop "test-results=all passing" Sending lib/crit_bits.c Transmitting file data . Committed revision 912. $ </pre></div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Searchability (or, Why <span class="emphasis"><em>Not</em></span> Properties)</strong></p></div></div></div><p>For all their utility, Subversion properties—or, more accurately, the available interfaces to them—have a major shortcoming: while it is a simple matter to <span class="emphasis"><em>set</em></span> a custom property, <span class="emphasis"><em>finding</em></span> that property later is a whole different ball of wax.</p><p>Trying to locate a custom revision property generally involves performing a linear walk across all the revisions of the repository, asking of each revision, <span class="quote">“<span class="quote">Do you have the property I'm looking for?</span>”</span> Use the <code class="option">--with-all-revprops</code> option with the <span class="command"><strong>svn log</strong></span> command's XML output mode to facilitate this search. Notice the presence of the custom revision property <code class="literal">testresults</code> in the following output:</p><div class="informalexample"><pre class="screen"> $ svn log --with-all-revprops --xml lib/crit_bits.c &lt;?xml version="1.0"?&gt; &lt;log&gt; &lt;logentry revision="912"&gt; &lt;author&gt;harry&lt;/author&gt; &lt;date&gt;2011-07-29T14:47:41.169894Z&lt;/date&gt; &lt;msg&gt;Fix up the last remaining known regression bug.&lt;/msg&gt; &lt;revprops&gt; &lt;property name="testresults"&gt;all passing&lt;/property&gt; &lt;/revprops&gt; &lt;/logentry&gt; … $ </pre></div><p>Trying to find a custom versioned property is painful, too, and often involves a recursive <span class="command"><strong>svn propget</strong></span> across an entire working copy. In your situation, that might not be as bad as a linear walk across all revisions. But it certainly leaves much to be desired in terms of both performance and likelihood of success, especially if the scope of your search would require a working copy from the root of your repository.</p><p>For this reason, you might choose—especially in the revision property use case—to simply add your metadata to the revision's log message using some policy-driven (and perhaps programmatically enforced) formatting that is designed to be quickly parsed from the output of <span class="command"><strong>svn log</strong></span>. It is quite common to see the following in Subversion log messages:</p><div class="informalexample"><pre class="programlisting"> Issue(s): IZ2376, IZ1919 Reviewed by: sally This fixes a nasty segfault in the wort frabbing process … </pre></div><p>But here again lies some misfortune. Subversion doesn't yet provide a log message templating mechanism, which would go a long way toward helping users be consistent with the formatting of their log-embedded revision metadata.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.props.manip"></a>Manipulating Properties</h3></div></div></div><p>The <span class="command"><strong>svn</strong></span> program affords a few ways to add or modify file and directory properties. For properties with short, human-readable values, perhaps the simplest way to add a new property is to specify the property name and value on the command line of the <span class="command"><strong>svn propset</strong></span> subcommand:</p><div class="informalexample"><pre class="screen"> $ svn propset copyright '(c) 2006 Red-Bean Software' calc/button.c property 'copyright' set on 'calc/button.c' $ </pre></div><p>But we've been touting the flexibility that Subversion offers for your property values. And if you are planning to have a multiline textual, or even binary, property value, you probably do not want to supply that value on the command line. So the <span class="command"><strong>svn propset</strong></span> subcommand takes a <code class="option">--file</code> (<code class="option">-F</code>) option for specifying the name of a file that contains the new property value.</p><div class="informalexample"><pre class="screen"> $ svn propset license -F /path/to/LICENSE calc/button.c property 'license' set on 'calc/button.c' $ </pre></div><p>There are some restrictions on the names you can use for properties. A property name must start with a letter, a colon (<code class="literal">:</code>), or an underscore (<code class="literal">_</code>); after that, you can also use digits, hyphens (<code class="literal">-</code>), and periods (<code class="literal">.</code>).<a href="#ftn.idm2356" class="footnote" id="idm2356"><sup class="footnote">[13]</sup></a></p><p>In addition to the <span class="command"><strong>propset</strong></span> command, the <span class="command"><strong>svn</strong></span> program supplies the <span class="command"><strong>propedit</strong></span> command. This command uses the configured editor program (see <a class="xref" href="#svn.advanced.confarea.opts.config" title="Config">the section called “Config”</a>) to add or modify properties. When you run the command, <span class="command"><strong>svn</strong></span> invokes your editor program on a temporary file that contains the current value of the property (or that is empty, if you are adding a new property). Then, you just modify that value in your editor program until it represents the new value you wish to store for the property, save the temporary file, and then exit the editor program. If Subversion detects that you've actually changed the existing value of the property, it will accept that as the new property value. If you exit your editor without making any changes, no property modification will occur:</p><div class="informalexample"><pre class="screen"> $ svn propedit copyright calc/button.c ### exit the editor without changes No changes to property 'copyright' on 'calc/button.c' $ </pre></div><p>We should note that, as with other <span class="command"><strong>svn</strong></span> subcommands, those related to properties can act on multiple paths at once. This enables you to modify properties on whole sets of files with a single command. For example, we could have done the following:</p><div class="informalexample"><pre class="screen"> $ svn propset copyright '(c) 2006 Red-Bean Software' calc/* property 'copyright' set on 'calc/Makefile' property 'copyright' set on 'calc/button.c' property 'copyright' set on 'calc/integer.c' … $ </pre></div><p>All of this property adding and editing isn't really very useful if you can't easily get the stored property value. So the <span class="command"><strong>svn</strong></span> program supplies two subcommands for displaying the names and values of properties stored on files and directories. The <span class="command"><strong>svn proplist</strong></span> command will list the names of properties that exist on a path. Once you know the names of the properties on the node, you can request their values individually using <span class="command"><strong>svn propget</strong></span>. This command will, given a property name and a path (or set of paths), print the value of the property to the standard output stream.</p><div class="informalexample"><pre class="screen"> $ svn proplist calc/button.c Properties on 'calc/button.c': copyright license $ svn propget copyright calc/button.c (c) 2006 Red-Bean Software </pre></div><p>There's even a variation of the <span class="command"><strong>proplist</strong></span> command that will list both the name and the value for all of the properties. Simply supply the <code class="option">--verbose</code> (<code class="option">-v</code>) option.</p><div class="informalexample"><pre class="screen"> $ svn proplist -v calc/button.c Properties on 'calc/button.c': copyright (c) 2006 Red-Bean Software license ================================================================ Copyright (c) 2006 Red-Bean Software. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the recipe for Fitz's famous red-beans-and-rice. … </pre></div><p>The last property-related subcommand is <span class="command"><strong>propdel</strong></span>. Since Subversion allows you to store properties with empty values, you can't remove a property altogether using <span class="command"><strong>svn propedit</strong></span> or <span class="command"><strong>svn propset</strong></span>. For example, this command will <span class="emphasis"><em>not</em></span> yield the desired effect:</p><div class="informalexample"><pre class="screen"> $ svn propset license "" calc/button.c property 'license' set on 'calc/button.c' $ svn proplist -v calc/button.c Properties on 'calc/button.c': copyright (c) 2006 Red-Bean Software license $ </pre></div><p>You need to use the <span class="command"><strong>propdel</strong></span> subcommand to delete properties altogether. The syntax is similar to the other property commands:</p><div class="informalexample"><pre class="screen"> $ svn propdel license calc/button.c property 'license' deleted from 'calc/button.c'. $ svn proplist -v calc/button.c Properties on 'calc/button.c': copyright (c) 2006 Red-Bean Software $ </pre></div><p>Remember those unversioned revision properties? You can modify those, too, using the same <span class="command"><strong>svn</strong></span> subcommands that we just described. Simply add the <code class="option">--revprop</code> command-line parameter and specify the revision whose property you wish to modify. Since revisions are global, you don't need to specify a target path to these property-related commands so long as you are positioned in a working copy of the repository whose revision property you wish to modify. Otherwise, you can simply provide the URL of any path in the repository of interest (including the repository's root URL). For example, you might want to replace the commit log message of an existing revision.<a href="#ftn.idm2397" class="footnote" id="idm2397"><sup class="footnote">[14]</sup></a> If your current working directory is part of a working copy of your repository, you can simply run the <span class="command"><strong>svn propset</strong></span> command with no target path:</p><div class="informalexample"><pre class="screen"> $ svn propset svn:log "* button.c: Fix a compiler warning." -r11 --revprop property 'svn:log' set on repository revision '11' $ </pre></div><p>But even if you haven't checked out a working copy from that repository, you can still effect the property change by providing the repository's root URL:</p><div class="informalexample"><pre class="screen"> $ svn propset svn:log "* button.c: Fix a compiler warning." -r11 --revprop \ http://svn.example.com/repos/project property 'svn:log' set on repository revision '11' $ </pre></div><p>Note that the ability to modify these unversioned properties must be explicitly added by the repository administrator (see <a class="xref" href="#svn.reposadmin.maint.setlog" title="Commit Log Message Correction">the section called “Commit Log Message Correction”</a>). That's because the properties aren't versioned, so you run the risk of losing information if you aren't careful with your edits. The repository administrator can set up methods to protect against this loss, and by default, modification of unversioned properties is disabled.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Users should, where possible, use <span class="command"><strong>svn propedit</strong></span> instead of <span class="command"><strong>svn propset</strong></span>. While the end result of the commands is identical, the former will allow them to see the current value of the property that they are about to change, which helps them to verify that they are, in fact, making the change they think they are making. This is especially true when modifying unversioned revision properties. Also, it is significantly easier to modify multiline property values in a text editor than at the command line.</p></td></tr></table></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.props.workflow"></a>Properties and the Subversion Workflow</h3></div></div></div><p>Now that you are familiar with all of the property-related <span class="command"><strong>svn</strong></span> subcommands, let's see how property modifications affect the usual Subversion workflow. As we mentioned earlier, file and directory properties are versioned, just like your file contents. As a result, Subversion provides the same opportunities for merging—cleanly or with conflicts—someone else's modifications into your own.</p><p>As with file contents, your property changes are local modifications, made permanent only when you commit them to the repository with <span class="command"><strong>svn commit</strong></span>. Your property changes can be easily unmade, too—the <span class="command"><strong>svn revert</strong></span> command will restore your files and directories to their unedited states—contents, properties, and all. Also, you can receive interesting information about the state of your file and directory properties by using the <span class="command"><strong>svn status</strong></span> and <span class="command"><strong>svn diff</strong></span> commands.</p><div class="informalexample"><pre class="screen"> $ svn status calc/button.c M calc/button.c $ svn diff calc/button.c Property changes on: calc/button.c ___________________________________________________________________ Added: copyright ## -0,0 +1 ## +(c) 2006 Red-Bean Software $ </pre></div><p>Notice how the <span class="command"><strong>status</strong></span> subcommand displays <code class="literal">M</code> in the second column instead of the first. That is because we have modified the properties on <code class="filename">calc/button.c</code>, but not its textual contents. Had we changed both, we would have seen <code class="literal">M</code> in the first column, too. (We cover <span class="command"><strong>svn status</strong></span> in <a class="xref" href="#svn.tour.cycle.examine.status" title="See an overview of your changes">the section called “See an overview of your changes”</a>).</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Property Conflicts</strong></p></div></div></div><p>As with file contents, local property modifications can conflict with changes committed by someone else. If you update your working copy directory and receive property changes on a versioned object that clash with your own, Subversion will report that the object is in a conflicted state.</p><div class="informalexample"><pre class="screen"> $ svn update calc Updating 'calc': M calc/Makefile.in Conflict for property 'linecount' discovered on 'calc/button.c'. Select: (p) postpone, (df) diff-full, (e) edit, (s) show all options: p C calc/button.c Updated to revision 143. Summary of conflicts: Property conflicts: 1 $ </pre></div><p>Subversion will also create, in the same directory as the conflicted object, a file with a <code class="filename">.prej</code> extension that contains the details of the conflict. You should examine the contents of this file so you can decide how to resolve the conflict. Until the conflict is resolved, you will see a <code class="literal">C</code> in the second column of <span class="command"><strong>svn status</strong></span> output for that object, and attempts to commit your local modifications will fail.</p><div class="informalexample"><pre class="screen"> $ svn status calc C calc/button.c ? calc/button.c.prej $ cat calc/button.c.prej Trying to change property 'linecount' from '1267' to '1301', but property has been locally changed from '1267' to '1256'. $ </pre></div><p>To resolve property conflicts, simply ensure that the conflicting properties contain the values that they should, and then use the <span class="command"><strong>svn resolve --accept=working</strong></span> command to alert Subversion that you have manually resolved the problem.</p></div><p>You might also have noticed the nonstandard way that Subversion currently displays property differences. You can still use <span class="command"><strong>svn diff</strong></span> and redirect its output to create a usable patch file. The <span class="command"><strong>patch</strong></span> program will ignore property patches—as a rule, it ignores any noise it can't understand. This does, unfortunately, mean that to fully apply a patch generated by <span class="command"><strong>svn diff</strong></span> using <span class="command"><strong>patch</strong></span>, any property modifications will need to be applied by hand.</p><p>Subversion 1.7 improves this situation in two ways. First, its nonstandard display of property differences is at least machine-readable—an improvement over the display of properties in versions prior to 1.7. But Subversion 1.7 also introduces the <span class="command"><strong>svn patch</strong></span> subcommand, designed specifically to handle the additional information which <span class="command"><strong>svn diff</strong></span>'s output can carry, applying those changes to the Subversion working copy. Of specific relevance to our topic, property differences present in patch files generated by <span class="command"><strong>svn diff</strong></span> in Subversion 1.7 or better can be automatically applied to a working copy by the <span class="command"><strong>svn patch</strong></span> command. For more about <span class="command"><strong>svn patch</strong></span>, see <a class="xref" href="#svn.ref.svn.c.patch" title="svn patch">svn patch</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>There's one exception to how property changes are reported by <span class="command"><strong>svn diff</strong></span>: changes to Subversion's special <code class="literal">svn:mergeinfo</code> property—used to track information about merges which have been performed in your repository—are described in a more human-readable fashion. This is quite helpful to the humans who have to read those descriptions. But it also serves to cause patching programs (including <span class="command"><strong>svn patch</strong></span>) to skip those change descriptions as noise. This might sound like a bug, but it really isn't because this property is intended to be managed solely by the <span class="command"><strong>svn merge</strong></span> subcommand. For more about merge tracking, see <a class="xref" href="#svn.branchmerge" title="Chapter 4. Branching and Merging">Chapter 4, <em>Branching and Merging</em></a>.</p></td></tr></table></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.props.auto"></a>Automatic Property Setting</h3></div></div></div><p>Properties are a powerful feature of Subversion, acting as key components of many Subversion features discussed elsewhere in this and other chapters—textual diff and merge support, keyword substitution, newline translation, and so on. But to get the full benefit of properties, they must be set on the right files and directories. Unfortunately, that step can be easily forgotten in the routine of things, especially since failing to set a property doesn't usually result in an obvious error (at least compared to, say, failing to add a file to version control). To help your properties get applied to the places that need them, Subversion provides a couple of simple but useful features.</p><p>Whenever you introduce a file to version control using the <span class="command"><strong>svn add</strong></span> or <span class="command"><strong>svn import</strong></span> commands, Subversion tries to assist by setting some common file properties automatically. First, on operating systems whose filesystems support an execute permission bit, Subversion will automatically set the <code class="literal">svn:executable</code> property on newly added or imported files whose execute bit is enabled. (See <a class="xref" href="#svn.advanced.props.special.executable" title="File Executability">the section called “File Executability”</a> later in this chapter for more about this property.)</p><p>Second, Subversion tries to determine the file's MIME type. If you've configured a <code class="literal">mime-types-files</code> runtime configuration parameter, Subversion will try to find a MIME type mapping in that file for your file's extension. If it finds such a mapping, it will set your file's <code class="literal">svn:mime-type</code> property to the MIME type it found. If no mapping file is configured, or no mapping for your file's extension could be found, Subversion will fall back to heuristic algorithms to determine the file's MIME type. Depending on how it is built, Subversion 1.7 can make use of file scanning libraries<a href="#ftn.idm2475" class="footnote" id="idm2475"><sup class="footnote">[15]</sup></a> to detect a file's type based on its content. Failing all else, Subversion will employ its own very basic heuristic to determine whether the file contains nontextual content. If so, it automatically sets the <code class="literal">svn:mime-type</code> property on that file to <code class="literal">application/octet-stream</code> (the generic <span class="quote">“<span class="quote">this is a collection of bytes</span>”</span> MIME type). Of course, if Subversion guesses incorrectly, or if you wish to set the <code class="literal">svn:mime-type</code> property to something more precise—perhaps <code class="literal">image/png</code> or <code class="literal">application/x-shockwave-flash</code>—you can always remove or edit that property. (For more on Subversion's use of MIME types, see <a class="xref" href="#svn.advanced.props.special.mime-type" title="File Content Type">the section called “File Content Type”</a> later in this chapter.)</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>UTF-16 is commonly used to encode files whose semantic content is textual in nature, but the encoding itself makes heavy use of bytes which are outside the typical ASCII character byte range. As such, Subversion will tend to classify such files as binary files, much to the chagrin of users who desire line-based differencing and merging, keyword substitution, and other behaviors for those files.</p></td></tr></table></div><p>Subversion also provides, via its runtime configuration system (see <a class="xref" href="#svn.advanced.confarea" title="Runtime Configuration Area">the section called “Runtime Configuration Area”</a>), a more flexible automatic property setting feature that allows you to create mappings of filename patterns to property names and values. Once again, these mappings affect adds and imports, and can not only override the default MIME type decision made by Subversion during those operations, but can also set additional Subversion or custom properties, too. For example, you might create a mapping that says that anytime you add JPEG files—ones whose names match the pattern <code class="literal">*.jpg</code>—Subversion should automatically set the <code class="literal">svn:mime-type</code> property on those files to <code class="literal">image/jpeg</code>. Or perhaps any files that match <code class="literal">*.cpp</code> should have <code class="literal">svn:eol-style</code> set to <code class="literal">native</code>, and <code class="literal">svn:keywords</code> set to <code class="literal">Id</code>. Automatic property support is perhaps the handiest property-related tool in the Subversion toolbox. See <a class="xref" href="#svn.advanced.confarea.opts.config" title="Config">the section called “Config”</a> for more about configuring that support.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Subversion administrators commonly ask if it is possible to configure, on the server side, a set of property definitions which all connecting clients will automatically consider when operating on working copies checked out from that server. Unfortunately, Subversion doesn't offer this feature. Administrators can use hook scripts to validate that the properties added to and modified on files and directories match the administrator's preferred policies, rejecting commits which are non-compliant in this fashion. (See <a class="xref" href="#svn.reposadmin.create.hooks" title="Implementing Repository Hooks">the section called “Implementing Repository Hooks”</a> for more about hook scripts.) But there's no way to automatically dictate those preferences to Subversion clients beforehand.</p></td></tr></table></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.props.file-portability"></a>File Portability</h2></div></div></div><p>Fortunately for Subversion users who routinely find themselves on different computers with different operating systems, Subversion's command-line program behaves almost identically on all those systems. If you know how to wield <span class="command"><strong>svn</strong></span> on one platform, you know how to wield it everywhere.</p><p>However, the same is not always true of other general classes of software or of the actual files you keep in Subversion. For example, on a Windows machine, the definition of a <span class="quote">“<span class="quote">text file</span>”</span> would be similar to that used on a Linux box, but with a key difference—the character sequences used to mark the ends of the lines of those files. There are other differences, too. Unix platforms have (and Subversion supports) symbolic links; Windows does not. Unix platforms use filesystem permission to determine executability; Windows uses filename extensions.</p><p>Because Subversion is in no position to unite the whole world in common definitions and implementations of all of these things, the best it can do is to try to help make your life simpler when you need to work with your versioned files and directories on multiple computers and operating systems. This section describes some of the ways Subversion does this.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.props.special.mime-type"></a>File Content Type</h3></div></div></div><p>Subversion joins the ranks of the many applications that recognize and make use of Multipurpose Internet Mail Extensions (MIME) content types. Besides being a general-purpose storage location for a file's content type, the value of the <code class="literal">svn:mime-type</code> file property determines some behavioral characteristics of Subversion itself.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Identifying File Types</strong></p></div></div></div><p>Various programs on most modern operating systems make assumptions about the type and format of the contents of a file by the file's name, specifically its file extension. For example, files whose names end in <code class="filename">.txt</code> are generally assumed to be human-readable; that is, able to be understood by simple perusal rather than requiring complex processing to decipher. Files whose names end in <code class="filename">.png</code>, on the other hand, are assumed to be of the Portable Network Graphics type—not human-readable at all, and sensible only when interpreted by software that understands the PNG format and can render the information in that format as a raster image.</p><p>Unfortunately, some of those extensions have changed their meanings over time. When personal computers first appeared, a file named <code class="filename">README.DOC</code> would have almost certainly been a plain-text file, just like today's <code class="filename">.txt</code> files. But by the mid-1990s, you could almost bet that a file of that name would not be a plain-text file at all, but instead a Microsoft Word document in a proprietary, non-human-readable format. But this change didn't occur overnight—there was certainly a period of confusion for computer users over what exactly they had in hand when they saw a <code class="filename">.DOC</code> file.<a href="#ftn.idm2520" class="footnote" id="idm2520"><sup class="footnote">[16]</sup></a></p><p>The popularity of computer networking cast still more doubt on the mapping between a file's name and its content. With information being served across networks and generated dynamically by server-side scripts, there was often no real file per se, and therefore no filename. Web servers, for example, needed some other way to tell browsers what they were downloading so that the browser could do something intelligent with that information, whether that was to display the data using a program registered to handle that datatype or to prompt the user for where on the client machine to store the downloaded data.</p><p>Eventually, a standard emerged for, among other things, describing the contents of a data stream. In 1996, RFC 2045 was published. It was the first of five RFCs describing MIME. It describes the concept of media types and subtypes and recommends a syntax for the representation of those types. Today, MIME media types—or <span class="quote">“<span class="quote">MIME types</span>”</span>—are used almost universally across email applications, web servers, and other software as the de facto mechanism for clearing up the file content confusion.</p></div><p>For example, one of the benefits that Subversion typically provides is contextual, line-based merging of changes received from the server during an update into your working file. But for files containing nontextual data, there is often no concept of a <span class="quote">“<span class="quote">line.</span>”</span> So, for versioned files whose <code class="literal">svn:mime-type</code> property is set to a nontextual MIME type (generally, something that doesn't begin with <code class="literal">text/</code>, though there are exceptions), Subversion does not attempt to perform contextual merges during updates. Instead, any time you have locally modified a binary working copy file that is also being updated, your file is left untouched and Subversion creates two new files. One file has a <code class="filename">.oldrev</code> extension and contains the BASE revision of the file. The other file has a <code class="filename">.newrev</code> extension and contains the contents of the updated revision of the file. This behavior is really for the protection of the user against failed attempts at performing contextual merges on files that simply cannot be contextually merged.</p><p>Additionally, since the acts of displaying line-based differences and line-based change attribution are, rather obviously, dependent on there being a meaningful definition of <span class="quote">“<span class="quote">line</span>”</span> for a given file, files with nontextual MIME types will by default trigger errors when used as the targets of <span class="command"><strong>svn diff</strong></span> and <span class="command"><strong>svn annotate</strong></span> operations. This can be especially frustrating for users with XML files whose <code class="literal">svn:mime-type</code> property is set to something such as <code class="literal">application/xml</code> which is not unambiguously human-readable and as such is treated as nontextual by Subversion. Fortunately, those subcommands offer a <code class="option">--force</code> option for forcing Subversion to attempt the operations in spite of the apparent non-human-readability of the files.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>The <code class="literal">svn:mime-type</code> property, when set to a value that does not indicate textual file contents, can cause some unexpected behaviors with respect to other properties. For example, since the idea of line endings (and therefore, line-ending conversion) makes no sense when applied to nontextual files, Subversion will prevent you from setting the <code class="literal">svn:eol-style</code> property on such files. This is obvious when attempted on a single file target—<span class="command"><strong>svn propset</strong></span> will error out. But it might not be as clear if you perform a recursive property set, where Subversion will silently skip over files that it deems unsuitable for a given property.</p></td></tr></table></div><p>Subversion provides a number of mechanisms by which to automatically set the <code class="literal">svn:mime-type</code> property on a versioned file. See <a class="xref" href="#svn.advanced.props.auto" title="Automatic Property Setting">the section called “Automatic Property Setting”</a> for details.</p><p>Also, if the <code class="literal">svn:mime-type</code> property is set, then the Subversion Apache module will use its value to populate the <code class="literal">Content-type:</code> HTTP header when responding to GET requests. This gives your web browser a crucial clue about how to display a file when you use it to peruse your Subversion repository's contents.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.props.special.executable"></a>File Executability</h3></div></div></div><p>On many operating systems, the ability to execute a file as a command is governed by the presence of an execute permission bit. This bit usually defaults to being disabled, and must be explicitly enabled by the user for each file that needs it. But it would be a monumental hassle to have to remember exactly which files in a freshly checked-out working copy were supposed to have their executable bits toggled on, and then to have to do that toggling. So, Subversion provides the <code class="literal">svn:executable</code> property as a way to specify that the executable bit for the file on which that property is set should be enabled, and Subversion honors that request when populating working copies with such files.</p><p>This property has no effect on filesystems that have no concept of an executable permission bit, such as FAT32 and NTFS.<a href="#ftn.idm2555" class="footnote" id="idm2555"><sup class="footnote">[17]</sup></a> Also, although it has no defined values, Subversion will force its value to <code class="literal">*</code> when setting this property. Finally, this property is valid only on files, not on directories.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.props.special.eol-style"></a>End-of-Line Character Sequences</h3></div></div></div><p>Unless otherwise noted using a versioned file's <code class="literal">svn:mime-type</code> property, Subversion assumes the file contains human-readable data. Generally speaking, Subversion uses this knowledge only to determine whether contextual difference reports for that file are possible. Otherwise, to Subversion, bytes are bytes.</p><p>This means that by default, Subversion doesn't pay any attention to the type of <em class="firstterm">end-of-line (EOL) markers</em> used in your files. Unfortunately, different operating systems have different conventions about which character sequences represent the end of a line of text in a file. For example, the usual line-ending token used by software on the Windows platform is a pair of ASCII control characters—a carriage return (<code class="literal">CR</code>) followed by a line feed (<code class="literal">LF</code>). Unix software, however, just uses the <code class="literal">LF</code> character to denote the end of a line.</p><p>Not all of the various tools on these operating systems understand files that contain line endings in a format that differs from the <em class="firstterm">native line-ending style</em> of the operating system on which they are running. So, typically, Unix programs treat the <code class="literal">CR</code> character present in Windows files as a regular character (usually rendered as <code class="literal">^M</code>), and Windows programs combine all of the lines of a Unix file into one giant line because no carriage return-linefeed (or <code class="literal">CRLF</code>) character combination was found to denote the ends of the lines.</p><p>This sensitivity to foreign EOL markers can be frustrating for folks who share a file across different operating systems. For example, consider a source code file, and developers who edit this file on both Windows and Unix systems. If all the developers always use tools that preserve the line-ending style of the file, no problems occur.</p><p>But in practice, many common tools either fail to properly read a file with foreign EOL markers, or convert the file's line endings to the native style when the file is saved. If the former is true for a developer, he has to use an external conversion utility (such as <span class="command"><strong>dos2unix</strong></span> or its companion, <span class="command"><strong>unix2dos</strong></span>) to prepare the file for editing. The latter case requires no extra preparation. But both cases result in a file that differs from the original quite literally on every line! Prior to committing his changes, the user has two choices. Either he can use a conversion utility to restore the modified file to the same line-ending style that it was in before his edits were made, or he can simply commit the file—new EOL markers and all.</p><p>The result of scenarios like these include wasted time and unnecessary modifications to committed files. Wasted time is painful enough. But when commits change every line in a file, this complicates the job of determining which of those lines were changed in a nontrivial way. Where was that bug really fixed? On what line was a syntax error introduced?</p><p>The solution to this problem is the <code class="literal">svn:eol-style</code> property. When this property is set to a valid value, Subversion uses it to determine what special processing to perform on the file so that the file's line-ending style isn't flip-flopping with every commit that comes from a different operating system. The valid values are:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">native</code></span></dt><dd><p>This causes the file to contain the EOL markers that are native to the operating system on which Subversion was run. In other words, if a user on a Windows machine checks out a working copy that contains a file with an <code class="literal">svn:eol-style</code> property set to <code class="literal">native</code>, that file will contain <code class="literal">CRLF</code> EOL markers. A Unix user checking out a working copy that contains the same file will see <code class="literal">LF</code> EOL markers in his copy of the file.</p><p>Note that Subversion will actually store the file in the repository using normalized <code class="literal">LF</code> EOL markers regardless of the operating system. This is basically transparent to the user, though.</p></dd><dt><span class="term"><code class="literal">CRLF</code></span></dt><dd><p>This causes the file to contain <code class="literal">CRLF</code> sequences for EOL markers, regardless of the operating system in use.</p></dd><dt><span class="term"><code class="literal">LF</code></span></dt><dd><p>This causes the file to contain <code class="literal">LF</code> characters for EOL markers, regardless of the operating system in use.</p></dd><dt><span class="term"><code class="literal">CR</code></span></dt><dd><p>This causes the file to contain <code class="literal">CR</code> characters for EOL markers, regardless of the operating system in use. This line-ending style is not very common.</p></dd></dl></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.props.special.ignore"></a>Ignoring Unversioned Items</h2></div></div></div><p>In any given working copy, there is a good chance that alongside all those versioned files and directories are other files and directories that are neither versioned nor intended to be. Text editors litter directories with backup files. Software compilers generate intermediate—or even final—files that you typically wouldn't bother to version. And users themselves drop various other files and directories wherever they see fit, often in version control working copies.</p><p>It's ludicrous to expect Subversion working copies to be somehow impervious to this kind of clutter and impurity. In fact, Subversion counts it as a <span class="emphasis"><em>feature</em></span> that its working copies are just typical directories, just like unversioned trees. But these not-to-be-versioned files and directories can cause some annoyance for Subversion users. For example, because the <span class="command"><strong>svn add</strong></span> and <span class="command"><strong>svn import</strong></span> commands act recursively by default and don't know which files in a given tree you do and don't wish to version, it's easy to accidentally add stuff to version control that you didn't mean to. And because <span class="command"><strong>svn status</strong></span> reports, by default, every item of interest in a working copy—including unversioned files and directories—its output can get quite noisy where many of these things exist.</p><p>So Subversion provides two ways for telling it which files you would prefer that it simply disregard. One of the ways involves the use of Subversion's runtime configuration system (see <a class="xref" href="#svn.advanced.confarea" title="Runtime Configuration Area">the section called “Runtime Configuration Area”</a>), and therefore applies to all the Subversion operations that make use of that runtime configuration—generally those performed on a particular computer or by a particular user of a computer. The other way makes use of Subversion's directory property support and is more tightly bound to the versioned tree itself, and therefore affects everyone who has a working copy of that tree. Both of the mechanisms use <em class="firstterm">file patterns</em> (strings of literal and special wildcard characters used to match against filenames) to decide which files to ignore.</p><p>The Subversion runtime configuration system provides an option, <code class="literal">global-ignores</code>, whose value is a whitespace-delimited collection of file patterns. The Subversion client checks these patterns against the names of the files that are candidates for addition to version control, as well as to unversioned files that the <span class="command"><strong>svn status</strong></span> command notices. If any file's name matches one of the patterns, Subversion will basically act as if the file didn't exist at all. This is really useful for the kinds of files that you almost never want to version, such as editor backup files such as Emacs' <code class="literal">*~</code> and <code class="literal">.*~</code> files.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>File Patterns in Subversion</strong></p></div></div></div><p>File patterns (also called <em class="firstterm">globs</em> or <em class="firstterm">shell wildcard patterns</em>) are strings of characters that are intended to be matched against filenames, typically for the purpose of quickly selecting some subset of similar files from a larger grouping without having to explicitly name each file. The patterns contain two types of characters: regular characters, which are compared explicitly against potential matches, and special wildcard characters, which are interpreted differently for matching purposes.</p><p>There are different types of file pattern syntaxes, but Subversion uses the one most commonly found in Unix systems implemented as the <code class="function">fnmatch</code> system function. It supports the following wildcards, described here simply for your convenience:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">?</code></span></dt><dd><p>Matches any single character</p></dd><dt><span class="term"><code class="literal">*</code></span></dt><dd><p>Matches any string of characters, including the empty string</p></dd><dt><span class="term"><code class="literal">[</code></span></dt><dd><p>Begins a character class definition terminated by <code class="literal">]</code>, used for matching a subset of characters</p></dd></dl></div><p>You can see this same pattern matching behavior at a Unix shell prompt. The following are some examples of patterns being used for various things:</p><div class="informalexample"><pre class="screen"> $ ls ### the book sources appa-quickstart.xml ch06-server-configuration.xml appb-svn-for-cvs-users.xml ch07-customizing-svn.xml appc-webdav.xml ch08-embedding-svn.xml book.xml ch09-reference.xml ch00-preface.xml ch10-world-peace-thru-svn.xml ch01-fundamental-concepts.xml copyright.xml ch02-basic-usage.xml foreword.xml ch03-advanced-topics.xml images/ ch04-branching-and-merging.xml index.xml ch05-repository-admin.xml styles.css $ ls ch* ### the book chapters ch00-preface.xml ch06-server-configuration.xml ch01-fundamental-concepts.xml ch07-customizing-svn.xml ch02-basic-usage.xml ch08-embedding-svn.xml ch03-advanced-topics.xml ch09-reference.xml ch04-branching-and-merging.xml ch10-world-peace-thru-svn.xml ch05-repository-admin.xml $ ls ch?0-* ### the book chapters whose numbers end in zero ch00-preface.xml ch10-world-peace-thru-svn.xml $ ls ch0[3578]-* ### the book chapters that Mike is responsible for ch03-advanced-topics.xml ch07-customizing-svn.xml ch05-repository-admin.xml ch08-embedding-svn.xml $ </pre></div><p>File pattern matching is a bit more complex than what we've described here, but this basic usage level tends to suit the majority of Subversion users.</p></div><p>When found on a versioned directory, the <code class="literal">svn:ignore</code> property is expected to contain a list of newline-delimited file patterns that Subversion should use to determine ignorable objects in that same directory. These patterns do not override those found in the <code class="literal">global-ignores</code> runtime configuration option, but are instead appended to that list. And it's worth noting again that, unlike the <code class="literal">global-ignores</code> option, the patterns found in the <code class="literal">svn:ignore</code> property apply only to the directory on which that property is set, and not to any of its subdirectories. The <code class="literal">svn:ignore</code> property is a good way to tell Subversion to ignore files that are likely to be present in every user's working copy of that directory, such as compiler output or—to use an example more appropriate to this book—the HTML, PDF, or PostScript files generated as the result of a conversion of some source DocBook XML files to a more legible output format.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Subversion's support for ignorable file patterns extends only to the one-time process of adding unversioned files and directories to version control. Once an object is under Subversion's control, the ignore pattern mechanisms no longer apply to it. In other words, don't expect Subversion to avoid committing changes you've made to a versioned file simply because that file's name matches an ignore pattern—Subversion <span class="emphasis"><em>always</em></span> notices all of its versioned objects.</p></td></tr></table></div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Ignore Patterns for CVS Users</strong></p></div></div></div><p>The Subversion <code class="literal">svn:ignore</code> property is very similar in syntax and function to the CVS <code class="filename">.cvsignore</code> file. In fact, if you are migrating a CVS working copy to Subversion, you can directly migrate the ignore patterns by using the <code class="filename">.cvsignore</code> file as input file to the <span class="command"><strong>svn propset</strong></span> command:</p><div class="informalexample"><pre class="screen"> $ svn propset svn:ignore -F .cvsignore . property 'svn:ignore' set on '.' $ </pre></div><p>There are, however, some differences in the ways that CVS and Subversion handle ignore patterns. The two systems use the ignore patterns at some different times, and there are slight discrepancies in what the ignore patterns apply to. Also, Subversion does not recognize the use of the <code class="literal">!</code> pattern as a reset back to having no ignore patterns at all.</p></div><p>The global list of ignore patterns tends to be more a matter of personal taste and ties more closely to a user's particular tool chain than to the details of any particular working copy's needs. So, the rest of this section will focus on the <code class="literal">svn:ignore</code> property and its uses.</p><p>Say you have the following output from <span class="command"><strong>svn status</strong></span>:</p><div class="informalexample"><pre class="screen"> $ svn status calc M calc/button.c ? calc/calculator ? calc/data.c ? calc/debug_log ? calc/debug_log.1 ? calc/debug_log.2.gz ? calc/debug_log.3.gz </pre></div><p>In this example, you have made some property modifications to <code class="filename">button.c</code>, but in your working copy, you also have some unversioned files: the latest <code class="filename">calculator</code> program that you've compiled from your source code, a source file named <code class="filename">data.c</code>, and a set of debugging output logfiles. Now, you know that your build system always results in the <code class="filename">calculator</code> program being generated.<a href="#ftn.idm2687" class="footnote" id="idm2687"><sup class="footnote">[18]</sup></a> And you know that your test suite always leaves those debugging logfiles lying around. These facts are true for all working copies of this project, not just your own. And you know that you aren't interested in seeing those things every time you run <span class="command"><strong>svn status</strong></span>, and you are pretty sure that nobody else is interested in them either. So you use <strong class="userinput"><code>svn propedit svn:ignore calc</code></strong> to add some ignore patterns to the <code class="filename">calc</code> directory.</p><div class="informalexample"><pre class="screen"> $ svn propget svn:ignore calc calculator debug_log* $ </pre></div><p>After you've added this property, you will now have a local property modification on the <code class="filename">calc</code> directory. But notice what else is different about your <span class="command"><strong>svn status</strong></span> output:</p><div class="informalexample"><pre class="screen"> $ svn status M calc M calc/button.c ? calc/data.c </pre></div><p>Now, all that cruft is missing from the output! Your <code class="filename">calculator</code> compiled program and all those logfiles are still in your working copy; Subversion just isn't constantly reminding you that they are present and unversioned. And now with all the uninteresting noise removed from the display, you are left with more intriguing items—such as that source code file <code class="filename">data.c</code> that you probably forgot to add to version control.</p><p>Of course, this less-verbose report of your working copy status isn't the only one available. If you actually want to see the ignored files as part of the status report, you can pass the <code class="option">--no-ignore</code> option to Subversion:</p><div class="informalexample"><pre class="screen"> $ svn status --no-ignore M calc M calc/button.c I calc/calculator ? calc/data.c I calc/debug_log I calc/debug_log.1 I calc/debug_log.2.gz I calc/debug_log.3.gz </pre></div><p>As mentioned earlier, the list of file patterns to ignore is also used by <span class="command"><strong>svn add</strong></span> and <span class="command"><strong>svn import</strong></span>. Both of these operations involve asking Subversion to begin managing some set of files and directories. Rather than force the user to pick and choose which files in a tree she wishes to start versioning, Subversion uses the ignore patterns—both the global and the per-directory lists—to determine which files should not be swept into the version control system as part of a larger recursive addition or import operation. And here again, you can use the <code class="option">--no-ignore</code> option to tell Subversion to disregard its ignores list and operate on all the files and directories present.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Even if <code class="literal">svn:ignore</code> is set, you may run into problems if you use shell wildcards in a command. Shell wildcards are expanded into an explicit list of targets before Subversion operates on them, so running <strong class="userinput"><code>svn <em class="replaceable"><code>SUBCOMMAND</code></em> *</code></strong> is just like running <strong class="userinput"><code>svn <em class="replaceable"><code>SUBCOMMAND</code></em> file1 file2 file3 …</code></strong>. In the case of the <span class="command"><strong>svn add</strong></span> command, this has an effect similar to passing the <code class="option">--no-ignore</code> option. So instead of using a wildcard, use <strong class="userinput"><code>svn add --force .</code></strong> to do a bulk scheduling of unversioned things for addition. The explicit target will ensure that the current directory isn't overlooked because of being already under version control, and the <code class="option">--force</code> option will cause Subversion to crawl through that directory, adding unversioned files while still honoring the <code class="literal">svn:ignore</code> property and <code class="literal">global-ignores</code> runtime configuration variable. Be sure to also provide the <code class="option">--depth files</code> option to the <span class="command"><strong>svn add</strong></span> command if you don't want a fully recursive crawl for things to add.</p></td></tr></table></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.props.special.keywords"></a>Keyword Substitution</h2></div></div></div><p>Subversion has the ability to substitute <em class="firstterm">keywords</em>—pieces of useful, dynamic information about a versioned file—into the contents of the file itself. Keywords generally provide information about the last modification made to the file. Because this information changes each time the file changes, and more importantly, just <span class="emphasis"><em>after</em></span> the file changes, it is a hassle for any process except the version control system to keep the data completely up to date. Left to human authors, the information would inevitably grow stale.</p><p>For example, say you have a document in which you would like to display the last date on which it was modified. You could burden every author of that document to, just before committing their changes, also tweak the part of the document that describes when it was last changed. But sooner or later, someone would forget to do that. Instead, simply ask Subversion to perform keyword substitution on the <code class="literal">LastChangedDate</code> keyword. You control where the keyword is inserted into your document by placing a <em class="firstterm">keyword anchor</em> at the desired location in the file. This anchor is just a string of text formatted as <code class="literal">$</code><em class="replaceable"><code>KeywordName</code></em><code class="literal">$</code>.</p><p>All keywords are case-sensitive where they appear as anchors in files: you must use the correct capitalization for the keyword to be expanded. You should consider the value of the <code class="literal">svn:keywords</code> property to be case-sensitive, too—certain keyword names will be recognized regardless of case, but this behavior is deprecated.</p><p>Subversion defines the list of keywords available for substitution. That list contains the following keywords, some of which have aliases that you can also use:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">Date</code></span></dt><dd><p>This keyword describes the last time the file was known to have been changed in the repository, and is of the form <code class="literal">$Date: 2006-07-22 21:42:37 -0700 (Sat, 22 Jul 2006) $</code>. It may also be specified as <code class="literal">LastChangedDate</code>. Unlike the <code class="literal">Id</code> keyword, which uses UTC, the <code class="literal">Date</code> keyword displays dates using the local time zone.</p></dd><dt><span class="term"><code class="literal">Revision</code></span></dt><dd><p>This keyword describes the last known revision in which this file changed in the repository, and looks something like <code class="literal">$Revision: 144 $</code>. It may also be specified as <code class="literal">LastChangedRevision</code> or <code class="literal">Rev</code>.</p></dd><dt><span class="term"><code class="literal">Author</code></span></dt><dd><p>This keyword describes the last known user to change this file in the repository, and looks something like <code class="literal">$Author: harry $</code>. It may also be specified as <code class="literal">LastChangedBy</code>.</p></dd><dt><span class="term"><code class="literal">HeadURL</code></span></dt><dd><p>This keyword describes the full URL to the latest version of the file in the repository, and looks something like <code class="literal">$HeadURL: http://svn.example.com/repos/trunk/calc.c $</code>. It may be abbreviated as <code class="literal">URL</code>.</p></dd><dt><span class="term"><code class="literal">Id</code></span></dt><dd><p>This keyword is a compressed combination of the other keywords. Its substitution looks something like <code class="literal">$Id: calc.c 148 2006-07-28 21:30:43Z sally $</code>, and is interpreted to mean that the file <code class="filename">calc.c</code> was last changed in revision 148 on the evening of July 28, 2006 by the user <code class="literal">sally</code>. The date displayed by this keyword is in UTC, unlike that of the <code class="literal">Date</code> keyword (which uses the local time zone).</p></dd><dt><span class="term"><code class="literal">Header</code></span></dt><dd><p>This keyword is similar to the <code class="literal">Id</code> keyword but contains the full URL of the latest revision of the item, identical to <code class="literal">HeadURL</code>. Its substitution looks something like <code class="literal">$Header: http://svn.example.com/repos/trunk/calc.c 148 2006-07-28 21:30:43Z sally $</code>.</p></dd></dl></div><p>Several of the preceding descriptions use the phrase <span class="quote">“<span class="quote">last known</span>”</span> or similar wording. Keep in mind that keyword expansion is a client-side operation, and your client <span class="quote">“<span class="quote">knows</span>”</span> only about changes that have occurred in the repository when you update your working copy to include those changes. If you never update your working copy, your keywords will never expand to different values even if those versioned files are being changed regularly in the repository.</p><p>Simply adding keyword anchor text to your file does nothing special. Subversion will never attempt to perform textual substitutions on your file contents unless explicitly asked to do so. After all, you might be writing a document<a href="#ftn.idm2792" class="footnote" id="idm2792"><sup class="footnote">[19]</sup></a> about how to use keywords, and you don't want Subversion to substitute your beautiful examples of unsubstituted keyword anchors!</p><p>To tell Subversion whether to substitute keywords on a particular file, we again turn to the property-related subcommands. The <code class="literal">svn:keywords</code> property, when set on a versioned file, controls which keywords will be substituted on that file. The value is a space-delimited list of keyword names or aliases.</p><p>For example, say you have a versioned file named <code class="filename">weather.txt</code> that looks like this:</p><div class="informalexample"><pre class="programlisting"> Here is the latest report from the front lines. $LastChangedDate$ $Rev$ Cumulus clouds are appearing more frequently as summer approaches. </pre></div><p>With no <code class="literal">svn:keywords</code> property set on that file, Subversion will do nothing special. Now, let's enable substitution of the <code class="literal">LastChangedDate</code> keyword.</p><div class="informalexample"><pre class="screen"> $ svn propset svn:keywords "Date Author" weather.txt property 'svn:keywords' set on 'weather.txt' $ </pre></div><p>Now you have made a local property modification on the <code class="filename">weather.txt</code> file. You will see no changes to the file's contents (unless you made some of your own prior to setting the property). Notice that the file contained a keyword anchor for the <code class="literal">Rev</code> keyword, yet we did not include that keyword in the property value we set. Subversion will happily ignore requests to substitute keywords that are not present in the file and will not substitute keywords that are not present in the <code class="literal">svn:keywords</code> property value.</p><p>Immediately after you commit this property change, Subversion will update your working file with the new substitute text. Instead of seeing your keyword anchor <code class="literal">$LastChangedDate$</code>, you'll see its substituted result. That result also contains the name of the keyword and continues to be delimited by the dollar sign (<code class="literal">$</code>) characters. And as we predicted, the <code class="literal">Rev</code> keyword was not substituted because we didn't ask for it to be.</p><p>Note also that we set the <code class="literal">svn:keywords</code> property to <code class="literal">Date Author</code>, yet the keyword anchor used the alias <code class="literal">$LastChangedDate$</code> and still expanded correctly:</p><div class="informalexample"><pre class="programlisting"> Here is the latest report from the front lines. $LastChangedDate: 2006-07-22 21:42:37 -0700 (Sat, 22 Jul 2006) $ $Rev$ Cumulus clouds are appearing more frequently as summer approaches. </pre></div><p>If someone else now commits a change to <code class="filename">weather.txt</code>, your copy of that file will continue to display the same substituted keyword value as before—until you update your working copy. At that time, the keywords in your <code class="filename">weather.txt</code> file will be resubstituted with information that reflects the most recent known commit to that file.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Where's $GlobalRev$?</strong></p></div></div></div><p>New users are often confused by how the <code class="literal">$Rev$</code> keyword works. Since the repository has a single, globally increasing revision number, many people assume that it is this number that is reflected by the <code class="literal">$Rev$</code> keyword's value. But <code class="literal">$Rev$</code> expands to show the last revision in which the file <span class="emphasis"><em>changed</em></span>, not the last revision to which it was updated. Understanding this clears the confusion, but frustration often remains—without the support of a Subversion keyword to do so, how can you automatically get the global revision number into your files?</p><p>To do this, you need external processing. Subversion ships with a tool called <span class="command"><strong>svnversion</strong></span>, which was designed for just this purpose. It crawls your working copy and generates as output the revision(s) it finds. You can use this program, plus some additional tooling, to embed that revision information into your files. For more information on <span class="command"><strong>svnversion</strong></span>, see <a class="xref" href="#svn.ref.svnversion" title="svnversion—Subversion Working Copy Version Info">the section called “svnversion—Subversion Working Copy Version Info”</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>.</p></div><p>You can also instruct Subversion to maintain a fixed length (in terms of the number of bytes consumed) for the substituted keyword. By using a double colon (<code class="literal">::</code>) after the keyword name, followed by a number of space characters, you define that fixed width. When Subversion goes to substitute your keyword for the keyword and its value, it will essentially replace only those space characters, leaving the overall width of the keyword field unchanged. If the substituted value is shorter than the defined field width, there will be extra padding characters (spaces) at the end of the substituted field; if it is too long, it is truncated with a special hash (<code class="literal">#</code>) character just before the final dollar sign terminator.</p><p>For example, say you have a document in which you have some section of tabular data reflecting the document's Subversion keywords. Using the original Subversion keyword substitution syntax, your file might look something like:</p><div class="informalexample"><pre class="programlisting"> $Rev$: Revision of last commit $Author$: Author of last commit $Date$: Date of last commit </pre></div><p>Now, that looks nice and tabular at the start of things. But when you then commit that file (with keyword substitution enabled, of course), you see:</p><div class="informalexample"><pre class="programlisting"> $Rev: 12 $: Revision of last commit $Author: harry $: Author of last commit $Date: 2006-03-15 02:33:03 -0500 (Wed, 15 Mar 2006) $: Date of last commit </pre></div><p>The result is not so beautiful. And you might be tempted to then adjust the file after the substitution so that it again looks tabular. But that holds only as long as the keyword values are the same width. If the last committed revision rolls into a new place value (say, from 99 to 100), or if another person with a longer username commits the file, stuff gets all crooked again. However, if you are using Subversion 1.2 or later, you can use the new fixed-length keyword syntax and define some field widths that seem sane, so your file might look like this:</p><div class="informalexample"><pre class="programlisting"> $Rev:: $: Revision of last commit $Author:: $: Author of last commit $Date:: $: Date of last commit </pre></div><p>You commit this change to your file. This time, Subversion notices the new fixed-length keyword syntax and maintains the width of the fields as defined by the padding you placed between the double colon and the trailing dollar sign. After substitution, the width of the fields is completely unchanged—the short values for <code class="literal">Rev</code> and <code class="literal">Author</code> are padded with spaces, and the long <code class="literal">Date</code> field is truncated by a hash character:</p><div class="informalexample"><pre class="programlisting"> $Rev:: 13 $: Revision of last commit $Author:: harry $: Author of last commit $Date:: 2006-03-15 0#$: Date of last commit </pre></div><p>The use of fixed-length keywords is especially handy when performing substitutions into complex file formats that themselves use fixed-length fields for data, or for which the stored size of a given data field is overbearingly difficult to modify from outside the format's native application. Of course, where binary file formats are concerned, you must always take great care that any keyword substitution you introduce—fixed-length or otherwise—does not violate the integrity of that format. While it might sound easy enough, this can be an astonishingly difficult task for most of the popular binary file formats in use today, and <span class="emphasis"><em>not</em></span> something to be undertaken by the faint of heart!</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Be aware that because the width of a keyword field is measured in bytes, the potential for corruption of multibyte values exists. For example, a username that contains some multibyte UTF-8 characters might suffer truncation in the middle of the string of bytes that make up one of those characters. The result will be a mere truncation when viewed at the byte level, but will likely appear as a string with an incorrect or garbled final character when viewed as UTF-8 text. It is conceivable that certain applications, when asked to load the file, would notice the broken UTF-8 text and deem the entire file corrupt, refusing to operate on the file altogether. So, when limiting keywords to a fixed size, choose a size that allows for this type of byte-wise expansion.</p></td></tr></table></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.sparsedirs"></a>Sparse Directories</h2></div></div></div><p>By default, most Subversion operations on directories act in a recursive manner. For example, <span class="command"><strong>svn checkout</strong></span> creates a working copy with every file and directory in the specified area of the repository, descending recursively through the repository tree until the entire structure is copied to your local disk. Subversion 1.5 introduces a feature called <em class="firstterm">sparse directories</em> (or <em class="firstterm">shallow checkouts</em>) that allows you to easily check out a working copy—or a portion of a working copy—more shallowly than full recursion, with the freedom to bring in previously ignored files and subdirectories at a later time.</p><p>For example, say we have a repository with a tree of files and directories with names of the members of a human family with pets. (It's an odd example, to be sure, but bear with us.) A regular <span class="command"><strong>svn checkout</strong></span> operation will give us a working copy of the whole tree:</p><div class="informalexample"><pre class="screen"> $ svn checkout file:///var/svn/repos mom A mom/son A mom/son/grandson A mom/daughter A mom/daughter/granddaughter1 A mom/daughter/granddaughter1/bunny1.txt A mom/daughter/granddaughter1/bunny2.txt A mom/daughter/granddaughter2 A mom/daughter/fishie.txt A mom/kitty1.txt A mom/doggie1.txt Checked out revision 1. $ </pre></div><p>Now, let's check out the same tree again, but this time we'll ask Subversion to give us only the topmost directory with none of its children at all:</p><div class="informalexample"><pre class="screen"> $ svn checkout file:///var/svn/repos mom-empty --depth empty Checked out revision 1 $ </pre></div><p>Notice that we added to our original <span class="command"><strong>svn checkout</strong></span> command line a new <code class="option">--depth</code> option. This option is present on many of Subversion's subcommands and is similar to the <code class="option">--non-recursive</code> (<code class="option">-N</code>) and <code class="option">--recursive</code> (<code class="option">-R</code>) options. In fact, it combines, improves upon, supercedes, and ultimately obsoletes these two older options. For starters, it expands the supported degrees of depth specification available to users, adding some previously unsupported (or inconsistently supported) depths. Here are the depth values that you can request for a given Subversion operation:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">--depth empty</code></span></dt><dd><p>Include only the immediate target of the operation, not any of its file or directory children.</p></dd><dt><span class="term"><code class="literal">--depth files</code></span></dt><dd><p>Include the immediate target of the operation and any of its immediate file children.</p></dd><dt><span class="term"><code class="literal">--depth immediates</code></span></dt><dd><p>Include the immediate target of the operation and any of its immediate file or directory children. The directory children will themselves be empty.</p></dd><dt><span class="term"><code class="literal">--depth infinity</code></span></dt><dd><p>Include the immediate target, its file and directory children, its children's children, and so on to full recursion.</p></dd></dl></div><p>Of course, merely combining two existing options into one hardly constitutes a new feature worthy of a whole section in our book. Fortunately, there is more to this story. This idea of depth extends not just to the operations you perform with your Subversion client, but also as a description of a working copy citizen's <em class="firstterm">ambient depth</em>, which is the depth persistently recorded by the working copy for that item. Its key strength is this very persistence—the fact that it is <em class="firstterm">sticky</em>. The working copy remembers the depth you've selected for each item in it until you later change that depth selection; by default, Subversion commands operate on the working copy citizens present, regardless of their selected depth settings.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>You can check the recorded ambient depth of a working copy using the <span class="command"><strong>svn info</strong></span> command. If the ambient depth is anything other than infinite recursion, <span class="command"><strong>svn info</strong></span> will display a line describing that depth value:</p><div class="informalexample"><pre class="screen"> $ svn info mom-immediates | grep "^Depth:" Depth: immediates $ </pre></div></td></tr></table></div><p>Our previous examples demonstrated checkouts of infinite depth (the default for <span class="command"><strong>svn checkout</strong></span>) and empty depth. Let's look now at examples of the other depth values:</p><div class="informalexample"><pre class="screen"> $ svn checkout file:///var/svn/repos mom-files --depth files A mom-files/kitty1.txt A mom-files/doggie1.txt Checked out revision 1. $ svn checkout file:///var/svn/repos mom-immediates --depth immediates A mom-immediates/son A mom-immediates/daughter A mom-immediates/kitty1.txt A mom-immediates/doggie1.txt Checked out revision 1. $ </pre></div><p>As described, each of these depths is something more than only the target, but something less than full recursion.</p><p>We've used <span class="command"><strong>svn checkout</strong></span> as an example here, but you'll find the <code class="option">--depth</code> option present on many other Subversion commands, too. In those other commands, depth specification is a way to limit the scope of an operation to some depth, much like the way the older <code class="option">--non-recursive</code> (<code class="option">-N</code>) and <code class="option">--recursive</code> (<code class="option">-R</code>) options behave. This means that when operating on a working copy of some depth, while requesting an operation of a shallower depth, the operation is limited to that shallower depth. In fact, we can make an even more general statement: given a working copy of any arbitrary—even mixed—ambient depth, and a Subversion command with some requested operational depth, the command will maintain the ambient depth of the working copy members while still limiting the scope of the operation to the requested (or default) operational depth.</p><p>In addition to the <code class="option">--depth</code> option, the <span class="command"><strong>svn update</strong></span> and <span class="command"><strong>svn switch</strong></span> subcommands also accept a second depth-related option: <code class="option">--set-depth</code>. It is with this option that you can change the sticky depth of a working copy item. Watch what happens as we take our empty-depth checkout and gradually telescope it deeper using <strong class="userinput"><code>svn update --set-depth <em class="replaceable"><code>NEW-DEPTH</code></em> <em class="replaceable"><code>TARGET</code></em></code></strong>:</p><div class="informalexample"><pre class="screen"> $ svn update --set-depth files mom-empty Updating 'mom-empty': A mom-empty/kittie1.txt A mom-empty/doggie1.txt Updated to revision 1. $ svn update --set-depth immediates mom-empty Updating 'mom-empty': A mom-empty/son A mom-empty/daughter Updated to revision 1. $ svn update --set-depth infinity mom-empty Updating 'mom-empty': A mom-empty/son/grandson A mom-empty/daughter/granddaughter1 A mom-empty/daughter/granddaughter1/bunny1.txt A mom-empty/daughter/granddaughter1/bunny2.txt A mom-empty/daughter/granddaughter2 A mom-empty/daughter/fishie1.txt Updated to revision 1. $ </pre></div><p>As we gradually increased our depth selection, the repository gave us more pieces of our tree.</p><p>In our example, we operated only on the root of our working copy, changing its ambient depth value. But we can independently change the ambient depth value of <span class="emphasis"><em>any</em></span> subdirectory inside the working copy, too. Careful use of this ability allows us to flesh out only certain portions of the working copy tree, leaving other portions absent altogether (hence the <span class="quote">“<span class="quote">sparse</span>”</span> bit of the feature's name). Here's an example of how we might build out a portion of one branch of our family's tree, enable full recursion on another branch, and keep still other pieces pruned (absent from disk).</p><div class="informalexample"><pre class="screen"> $ rm -rf mom-empty $ svn checkout file:///var/svn/repos mom-empty --depth empty Checked out revision 1. $ svn update --set-depth empty mom-empty/son Updating 'mom-empty/son': A mom-empty/son Updated to revision 1. $ svn update --set-depth empty mom-empty/daughter Updating 'mom-empty/daughter': A mom-empty/daughter Updated to revision 1. $ svn update --set-depth infinity mom-empty/daughter/granddaughter1 Updating 'mom-empty/daughter/granddaughter1': A mom-empty/daughter/granddaughter1 A mom-empty/daughter/granddaughter1/bunny1.txt A mom-empty/daughter/granddaughter1/bunny2.txt Updated to revision 1. $ </pre></div><p>Fortunately, having a complex collection of ambient depths in a single working copy doesn't complicate the way you interact with that working copy. You can still make, revert, display, and commit local modifications in your working copy without providing any new options (including <code class="option">--depth</code> and <code class="option">--set-depth</code>) to the relevant subcommands. Even <span class="command"><strong>svn update</strong></span> works as it does elsewhere when no specific depth is provided—it updates the working copy targets that are present while honoring their sticky depths.</p><p>You might at this point be wondering, <span class="quote">“<span class="quote">So what? When would I use this?</span>”</span> One scenario where this feature finds utility is tied to a particular repository layout, specifically where you have many related or codependent projects or software modules living as siblings in a single repository location (<code class="filename">trunk/project1</code>, <code class="filename">trunk/project2</code>, <code class="filename">trunk/project3</code>, etc.). In such scenarios, it might be the case that you personally care about only a handful of those projects—maybe some primary project and a few other modules on which it depends. You can check out individual working copies of all of these things, but those working copies are disjoint and, as a result, it can be cumbersome to perform operations across several or all of them at the same time. The alternative is to use the sparse directories feature, building out a single working copy that contains only the modules you care about. You'd start with an empty-depth checkout of the common parent directory of the projects, and then update with infinite depth only the items you wish to have, like we demonstrated in the previous example. Think of it like an opt-in system for working copy citizens.</p><p>The original (Subversion 1.5) implementation of shallow checkouts was good, but didn't support de-telescoping of working copy items. Subversion 1.6 remedied this problem. For example, running <strong class="userinput"><code>svn update --set-depth empty</code></strong> in an infinite-depth working copy will discard everything but the topmost directory.<a href="#ftn.idm2945" class="footnote" id="idm2945"><sup class="footnote">[20]</sup></a> Subversion 1.6 also introduced another supported value for the <code class="option">--set-depth</code> option: <code class="literal">exclude</code>. Using <code class="option">--set-depth exclude</code> with <span class="command"><strong>svn update</strong></span> will cause the update target to be removed from the working copy entirely—a directory target won't even be left present-but-empty. This is especially handy when there are more things that you'd like to keep in a working copy than things you'd like to <span class="emphasis"><em>not</em></span> keep.</p><p>Consider a directory with hundreds of subdirectories, one of which you would like to omit from your working copy. Using an <span class="quote">“<span class="quote">additive</span>”</span> approach to sparse directories, you might check out the directory with an empty depth, then explicitly telescope (using <strong class="userinput"><code>svn update --set-depth infinity</code></strong>) each and every subdirectory of the directory except the one you don't care about.</p><div class="informalexample"><pre class="screen"> $ svn checkout http://svn.example.com/repos/many-dirs --depth empty … $ svn update --set-depth infinity many-dirs/wanted-dir-1 … $ svn update --set-depth infinity many-dirs/wanted-dir-2 … $ svn update --set-depth infinity many-dirs/wanted-dir-3 … ### and so on, and so on, ... </pre></div><p>This could be quite tedious, especially since you don't even have stubs of these directories in your working copy to deal with. Such a working copy would also have another characteristic that you might not expect or desire: if someone else creates any new subdirectories in this top-level directory, you won't receive those when you update your working copy.</p><p>Beginning with Subversion 1.6, you can take a different approach. First, check out the directory in full. Then run <strong class="userinput"><code>svn update --set-depth exclude</code></strong> on the one subdirectory you don't care about.</p><div class="informalexample"><pre class="screen"> $ svn checkout http://svn.example.com/repos/many-dirs … $ svn update --set-depth exclude many-dirs/unwanted-dir D many-dirs/unwanted-dir $ </pre></div><p>This approach leaves your working copy with the same stuff as in the first approach, but any new subdirectories which appear in the top-level directory would also show up when you update your working copy. The downside of this approach is that you have to actually check out that whole subdirectory that you don't even want just so you can tell Subversion that you don't want it. This might not even be possible if that subdirectory is too large to fit on your disk (which might, after all, be the very reason you don't want it in your working copy).</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>While the functionality for excluding an existing item from a working copy was hung off of the <span class="command"><strong>svn update</strong></span> command, you might have noticed that the output from <strong class="userinput"><code>svn update --set-depth exclude</code></strong> differs from that of a normal update operation. This output betrays the fact that, under the hood, exclusion is a completely client-side operation, very much unlike a typical update.</p></td></tr></table></div><p>In such a situation, you might consider a compromise approach. First, check out the top-level directory with <code class="option">--depth immediates</code>. Then, exclude the directory you don't want using <strong class="userinput"><code>svn update --set-depth exclude</code></strong>. Finally, telescope all the items that remain to infinite depth, which should be fairly easy to do because they are all addressable in your shell.</p><div class="informalexample"><pre class="screen"> $ svn checkout http://svn.example.com/repos/many-dirs --depth immediates … $ svn update --set-depth exclude many-dirs/unwanted-dir D many-dirs/unwanted-dir $ svn update --set-depth infinity many-dirs/* … $ </pre></div><p>Once again, your working copy will have the same stuff as in the previous two scenarios. But now, any time a new file or subdirectory is committed to the top-level directory, you'll receive it—at an empty depth—when you update your working copy. You can now decide what to do with such newly appearing working copy items: expand them into infinite depth, or exclude them altogether.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.locking"></a>Locking</h2></div></div></div><p>Subversion's copy-modify-merge version control model lives and dies on its data merging algorithms—specifically on how well those algorithms perform when trying to resolve conflicts caused by multiple users modifying the same file concurrently. Subversion itself provides only one such algorithm: a three-way differencing algorithm that is smart enough to handle data at a granularity of a single line of text. Subversion also allows you to supplement its content merge processing with external differencing utilities (as described in <a class="xref" href="#svn.advanced.externaldifftools.diff3" title="External diff3">the section called “External diff3”</a> and <a class="xref" href="#svn.advanced.externaldifftools.merge" title="External merge">the section called “External merge”</a>), some of which may do an even better job, perhaps providing granularity of a word or a single character of text. But common among those algorithms is that they generally work only on text files. The landscape starts to look pretty grim when you start talking about content merges of nontextual file formats. And when you can't find a tool that can handle that type of merging, you begin to run into problems with the copy-modify-merge model.</p><p>Let's look at a real-life example of where this model runs aground. Harry and Sally are both graphic designers working on the same project, a bit of marketing collateral for an automobile mechanic. Central to the design of a particular poster is an image of a car in need of some bodywork, stored in a file using the PNG image format. The poster's layout is almost finished, and both Harry and Sally are pleased with the particular photo they chose for their damaged car—a baby blue 1967 Ford Mustang with an unfortunate bit of crumpling on the left front fender.</p><p>Now, as is common in graphic design work, there's a change in plans, which causes the car's color to be a concern. So Sally updates her working copy to <code class="literal">HEAD</code>, fires up her photo-editing software, and sets about tweaking the image so that the car is now cherry red. Meanwhile, Harry, feeling particularly inspired that day, decides that the image would have greater impact if the car also appears to have suffered greater impact. He, too, updates to <code class="literal">HEAD</code>, and then draws some cracks on the vehicle's windshield. He manages to finish his work before Sally finishes hers, and after admiring the fruits of his undeniable talent, he commits the modified image. Shortly thereafter, Sally is finished with the car's new finish and tries to commit her changes. But, as expected, Subversion fails the commit, informing Sally that her version of the image is now out of date.</p><p>Here's where the difficulty sets in. If Harry and Sally were making changes to a text file, Sally would simply update her working copy, receiving Harry's changes in the process. In the worst possible case, they would have modified the same region of the file, and Sally would have to work out by hand the proper resolution to the conflict. But these aren't text files—they are binary images. And while it's a simple matter to describe what one would expect the results of this content merge to be, there is precious little chance that any software exists that is smart enough to examine the common baseline image that each of these graphic artists worked against, the changes that Harry made, and the changes that Sally made, and then spit out an image of a busted-up red Mustang with a cracked windshield!</p><p>Of course, things would have gone more smoothly if Harry and Sally had serialized their modifications to the image—if, say, Harry had waited to draw his windshield cracks on Sally's now-red car, or if Sally had tweaked the color of a car whose windshield was already cracked. As is discussed in <a class="xref" href="#svn.basic.vsn-models.copy-merge" title="The copy-modify-merge solution">the section called “The copy-modify-merge solution”</a>, most of these types of problems go away entirely where perfect communication between Harry and Sally exists.<a href="#ftn.idm2985" class="footnote" id="idm2985"><sup class="footnote">[21]</sup></a> But as one's version control system is, in fact, one form of communication, it follows that having that software facilitate the serialization of nonparallelizable editing efforts is no bad thing. This is where Subversion's implementation of the lock-modify-unlock model steps into the spotlight. This is where we talk about Subversion's <em class="firstterm">locking</em> feature, which is similar to the <span class="quote">“<span class="quote">reserved checkouts</span>”</span> mechanisms of other version control systems.</p><p>Subversion's locking feature exists ultimately to minimize wasted time and effort. By allowing a user to programmatically claim the exclusive right to change a file in the repository, that user can be reasonably confident that any energy he invests on unmergeable changes won't be wasted—his commit of those changes will succeed. Also, because Subversion communicates to other users that serialization is in effect for a particular versioned object, those users can reasonably expect that the object is about to be changed by someone else. They, too, can then avoid wasting their time and energy on unmergeable changes that won't be committable due to eventual out-of-dateness.</p><p>When referring to Subversion's locking feature, one is actually talking about a fairly diverse collection of behaviors, which include the ability to lock a versioned file<a href="#ftn.idm2991" class="footnote" id="idm2991"><sup class="footnote">[22]</sup></a> (claiming the exclusive right to modify the file), to unlock that file (yielding that exclusive right to modify), to see reports about which files are locked and by whom, to annotate files for which locking before editing is strongly advised, and so on. In this section, we'll cover all of these facets of the larger locking feature.</p><div class="sidebar"><a id="svn.advanced.locking.meanings"></a><div class="titlepage"><div><div><p class="title"><strong>The Three Meanings of <span class="quote">“<span class="quote">Lock</span>”</span></strong></p></div></div></div><p>In this section, and almost everywhere in this book, the words <span class="quote">“<span class="quote">lock</span>”</span> and <span class="quote">“<span class="quote">locking</span>”</span> describe a mechanism for mutual exclusion between users to avoid clashing commits. Unfortunately, there are two other sorts of <span class="quote">“<span class="quote">lock</span>”</span> with which Subversion, and therefore this book, sometimes needs to be concerned.</p><p>The second is <em class="firstterm">working copy locks</em>, used internally by Subversion to prevent clashes between multiple Subversion clients operating on the same working copy. This is the sort of lock indicated by an <code class="computeroutput">L</code> in the third column of <span class="command"><strong>svn status</strong></span> output, and removed by the <span class="command"><strong>svn cleanup</strong></span> command, as described in <a class="xref" href="#svn.tour.cleanup" title="Sometimes You Just Need to Clean Up">the section called “Sometimes You Just Need to Clean Up”</a>.</p><p>Third, there are <em class="firstterm">database locks</em>, used internally by the Berkeley DB backend to prevent clashes between multiple programs trying to access the database. This is the sort of lock whose unwanted persistence after an error can cause a repository to be <span class="quote">“<span class="quote">wedged,</span>”</span> as described in <a class="xref" href="#svn.reposadmin.maint.recovery" title="Berkeley DB Recovery">the section called “Berkeley DB Recovery”</a>.</p><p>You can generally forget about these other kinds of locks until something goes wrong that requires you to care about them. In this book, <span class="quote">“<span class="quote">lock</span>”</span> means the first sort unless the contrary is either clear from context or explicitly stated.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.locking.creation"></a>Creating Locks</h3></div></div></div><p>In the Subversion repository, a <em class="firstterm">lock</em> is a piece of metadata that grants exclusive access to one user to change a file. This user is said to be the <em class="firstterm">lock owner</em>. Each lock also has a unique identifier, typically a long string of characters, known as the <em class="firstterm">lock token</em>. The repository manages locks, ultimately handling their creation, enforcement, and removal. If any commit transaction attempts to modify or delete a locked file (or delete one of the parent directories of the file), the repository will demand two pieces of information—that the client performing the commit be authenticated as the lock owner, and that the lock token has been provided as part of the commit process as a form of proof that the client knows which lock it is using.</p><p>To demonstrate lock creation, let's refer back to our example of multiple graphic designers working on the same binary image files. Harry has decided to change a JPEG image. To prevent other people from committing changes to the file while he is modifying it (as well as alerting them that he is about to change it), he locks the file in the repository using the <span class="command"><strong>svn lock</strong></span> command.</p><div class="informalexample"><pre class="screen"> $ svn lock banana.jpg -m "Editing file for tomorrow's release." 'banana.jpg' locked by user 'harry'. $ </pre></div><p>The preceding example demonstrates a number of new things. First, notice that Harry passed the <code class="option">--message</code> (<code class="option">-m</code>) option to <span class="command"><strong>svn lock</strong></span>. Similar to <span class="command"><strong>svn commit</strong></span>, the <span class="command"><strong>svn lock</strong></span> command can take comments—via either <code class="option">--message</code> (<code class="option">-m</code>) or <code class="option">--file</code> (<code class="option">-F</code>)—to describe the reason for locking the file. Unlike <span class="command"><strong>svn commit</strong></span>, however, <span class="command"><strong>svn lock</strong></span> will not demand a message by launching your preferred text editor. Lock comments are optional, but still recommended to aid communication.</p><p>Second, the lock attempt succeeded. This means that the file wasn't already locked, and that Harry had the latest version of the file. If Harry's working copy of the file had been out of date, the repository would have rejected the request, forcing Harry to <span class="command"><strong>svn update</strong></span> and reattempt the locking command. The locking command would also have failed if the file had already been locked by someone else.</p><p>As you can see, the <span class="command"><strong>svn lock</strong></span> command prints confirmation of the successful lock. At this point, the fact that the file is locked becomes apparent in the output of the <span class="command"><strong>svn status</strong></span> and <span class="command"><strong>svn info</strong></span> reporting subcommands.</p><div class="informalexample"><pre class="screen"> $ svn status K banana.jpg $ svn info banana.jpg Path: banana.jpg Name: banana.jpg Working Copy Root Path: /home/harry/project URL: http://svn.example.com/repos/project/banana.jpg Repository Root: http://svn.example.com/repos/project Repository UUID: edb2f264-5ef2-0310-a47a-87b0ce17a8ec Revision: 2198 Node Kind: file Schedule: normal Last Changed Author: frank Last Changed Rev: 1950 Last Changed Date: 2006-03-15 12:43:04 -0600 (Wed, 15 Mar 2006) Text Last Updated: 2006-06-08 19:23:07 -0500 (Thu, 08 Jun 2006) Properties Last Updated: 2006-06-08 19:23:07 -0500 (Thu, 08 Jun 2006) Checksum: 3b110d3b10638f5d1f4fe0f436a5a2a5 Lock Token: opaquelocktoken:0c0f600b-88f9-0310-9e48-355b44d4a58e Lock Owner: harry Lock Created: 2006-06-14 17:20:31 -0500 (Wed, 14 Jun 2006) Lock Comment (1 line): Editing file for tomorrow's release. $ </pre></div><p>The fact that the <span class="command"><strong>svn info</strong></span> command, which does not contact the repository when run against working copy paths, can display the lock token reveals an important piece of information about those tokens: they are cached in the working copy. The presence of the lock token is critical. It gives the working copy authorization to make use of the lock later on. Also, the <span class="command"><strong>svn status</strong></span> command shows a <code class="literal">K</code> next to the file (short for locKed), indicating that the lock token is present.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Regarding Lock Tokens</strong></p></div></div></div><p>A lock token isn't an authentication token, so much as an <span class="emphasis"><em>authorization</em></span> token. The token isn't a protected secret. In fact, a lock's unique token is discoverable by anyone who runs <strong class="userinput"><code>svn info <em class="replaceable"><code>URL</code></em></code></strong>. A lock token is special only when it lives inside a working copy. It's proof that the lock was created in that particular working copy, and not somewhere else by some other client. Merely authenticating as the lock owner isn't enough to prevent accidents.</p><p>For example, suppose you lock a file using a computer at your office, but leave work for the day before you finish your changes to that file. It should not be possible to accidentally commit changes to that same file from your home computer later that evening simply because you've authenticated as the lock's owner. In other words, the lock token prevents one piece of Subversion-related software from undermining the work of another. (In our example, if you really need to change the file from an alternative working copy, you would need to <em class="firstterm">break</em> the lock and relock the file.)</p></div><p>Now that Harry has locked <code class="filename">banana.jpg</code>, Sally is unable to change or delete that file:</p><div class="informalexample"><pre class="screen"> $ svn delete banana.jpg D banana.jpg $ svn commit -m "Delete useless file." Deleting banana.jpg svn: E175002: Commit failed (details follow): svn: E175002: Server sent unexpected return value (423 Locked) in response to DELETE request for '/repos/project/!svn/wrk/64bad3a9-96f9-0310-818a-df4224ddc 35d/banana.jpg' $ </pre></div><p>But Harry, after touching up the banana's shade of yellow, is able to commit his changes to the file. That's because he authenticates as the lock owner and also because his working copy holds the correct lock token:</p><div class="informalexample"><pre class="screen"> $ svn status M K banana.jpg $ svn commit -m "Make banana more yellow" Sending banana.jpg Transmitting file data . Committed revision 2201. $ svn status $ </pre></div><p>Notice that after the commit is finished, <span class="command"><strong>svn status</strong></span> shows that the lock token is no longer present in the working copy. This is the standard behavior of <span class="command"><strong>svn commit</strong></span>—it searches the working copy (or list of targets, if you provide such a list) for local modifications and sends all the lock tokens it encounters during this walk to the server as part of the commit transaction. After the commit completes successfully, all of the repository locks that were mentioned are released—<span class="emphasis"><em>even on files that weren't committed</em></span>. This is meant to discourage users from being sloppy about locking or from holding locks for too long. If Harry haphazardly locks 30 files in a directory named <code class="filename">images</code> because he's unsure of which files he needs to change, yet changes only four of those files, when he runs <strong class="userinput"><code>svn commit images</code></strong>, the process will still release all 30 locks.</p><p>This behavior of automatically releasing locks can be overridden with the <code class="option">--no-unlock</code> option to <span class="command"><strong>svn commit</strong></span>. This is best used for those times when you want to commit changes, but still plan to make more changes and thus need to retain existing locks. You can also make this your default behavior by setting the <code class="literal">no-unlock</code> runtime configuration option (see <a class="xref" href="#svn.advanced.confarea" title="Runtime Configuration Area">the section called “Runtime Configuration Area”</a>).</p><p>Of course, locking a file doesn't oblige one to commit a change to it. The lock can be released at any time with a simple <span class="command"><strong>svn unlock</strong></span> command:</p><div class="informalexample"><pre class="screen"> $ svn unlock banana.c 'banana.c' unlocked. </pre></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.locking.discovery"></a>Discovering Locks</h3></div></div></div><p>When a commit fails due to someone else's locks, it's fairly easy to learn about them. The easiest way is to run <strong class="userinput"><code>svn status -u</code></strong>:</p><div class="informalexample"><pre class="screen"> $ svn status -u M 23 bar.c M O 32 raisin.jpg * 72 foo.h Status against revision: 105 $ </pre></div><p>In this example, Sally can see not only that her copy of <code class="filename">foo.h</code> is out of date, but also that one of the two modified files she plans to commit is locked in the repository. The <code class="literal">O</code> symbol stands for <span class="quote">“<span class="quote">Other,</span>”</span> meaning that a lock exists on the file and was created by somebody else. If she were to attempt a commit, the lock on <code class="filename">raisin.jpg</code> would prevent it. Sally is left wondering who made the lock, when, and why. Once again, <span class="command"><strong>svn info</strong></span> has the answers:</p><div class="informalexample"><pre class="screen"> $ svn info ^/raisin.jpg Path: raisin.jpg Name: raisin.jpg URL: http://svn.example.com/repos/project/raisin.jpg Repository Root: http://svn.example.com/repos/project Repository UUID: edb2f264-5ef2-0310-a47a-87b0ce17a8ec Revision: 105 Node Kind: file Last Changed Author: sally Last Changed Rev: 32 Last Changed Date: 2006-01-25 12:43:04 -0600 (Sun, 25 Jan 2006) Lock Token: opaquelocktoken:fc2b4dee-98f9-0310-abf3-653ff3226e6b Lock Owner: harry Lock Created: 2006-02-16 13:29:18 -0500 (Thu, 16 Feb 2006) Lock Comment (1 line): Need to make a quick tweak to this image. $ </pre></div><p>Just as you can use <span class="command"><strong>svn info</strong></span> to examine objects in the working copy, you can also use it to examine objects in the repository. If the main argument to <span class="command"><strong>svn info</strong></span> is a working copy path, then all of the working copy's cached information is displayed; any mention of a lock means that the working copy is holding a lock token (if a file is locked by another user or in another working copy, <span class="command"><strong>svn info</strong></span> on a working copy path will show no lock information at all). If the main argument to <span class="command"><strong>svn info</strong></span> is a URL, the information reflects the latest version of an object in the repository, and any mention of a lock describes the current lock on the object.</p><p>So in this particular example, Sally can see that Harry locked the file on February 16 to <span class="quote">“<span class="quote">make a quick tweak.</span>”</span> It being June, she suspects that he probably forgot all about the lock. She might phone Harry to complain and ask him to release the lock. If he's unavailable, she might try to forcibly break the lock herself or ask an administrator to do so.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.locking.break-steal"></a>Breaking and Stealing Locks</h3></div></div></div><p>A repository lock isn't sacred—in Subversion's default configuration state, locks can be released not only by the person who created them, but by anyone. When somebody other than the original lock creator destroys a lock, we refer to this as <em class="firstterm">breaking the lock</em>.</p><p>From the administrator's chair, it's simple to break locks. The <span class="command"><strong>svnlook</strong></span> and <span class="command"><strong>svnadmin</strong></span> programs have the ability to display and remove locks directly from the repository. (For more information about these tools, see <a class="xref" href="#svn.reposadmin.maint.tk" title="An Administrator's Toolkit">the section called “An Administrator's Toolkit”</a>.)</p><div class="informalexample"><pre class="screen"> $ svnadmin lslocks /var/svn/repos Path: /project2/images/banana.jpg UUID Token: opaquelocktoken:c32b4d88-e8fb-2310-abb3-153ff1236923 Owner: frank Created: 2006-06-15 13:29:18 -0500 (Thu, 15 Jun 2006) Expires: Comment (1 line): Still improving the yellow color. Path: /project/raisin.jpg UUID Token: opaquelocktoken:fc2b4dee-98f9-0310-abf3-653ff3226e6b Owner: harry Created: 2006-02-16 13:29:18 -0500 (Thu, 16 Feb 2006) Expires: Comment (1 line): Need to make a quick tweak to this image. $ svnadmin rmlocks /var/svn/repos /project/raisin.jpg Removed lock on '/project/raisin.jpg'. $ </pre></div><p>The more interesting option is to allow users to break each other's locks over the network. To do this, Sally simply needs to pass the <code class="option">--force</code> to the <span class="command"><strong>svn unlock</strong></span> command:</p><div class="informalexample"><pre class="screen"> $ svn status -u M 23 bar.c M O 32 raisin.jpg * 72 foo.h Status against revision: 105 $ svn unlock raisin.jpg svn: E195013: 'raisin.jpg' is not locked in this working copy $ svn info raisin.jpg | grep URL URL: http://svn.example.com/repos/project/raisin.jpg $ svn unlock http://svn.example.com/repos/project/raisin.jpg svn: warning: W160039: Unlock failed on 'raisin.jpg' (403 Forbidden) $ svn unlock --force http://svn.example.com/repos/project/raisin.jpg 'raisin.jpg' unlocked. $ </pre></div><p>Now, Sally's initial attempt to unlock failed because she ran <span class="command"><strong>svn unlock</strong></span> directly on her working copy of the file, and no lock token was present. To remove the lock directly from the repository, she needs to pass a URL to <span class="command"><strong>svn unlock</strong></span>. Her first attempt to unlock the URL fails, because she can't authenticate as the lock owner (nor does she have the lock token). But when she passes <code class="option">--force</code>, the authentication and authorization requirements are ignored, and the remote lock is broken.</p><p>Simply breaking a lock may not be enough. In the running example, Sally may not only want to break Harry's long-forgotten lock, but relock the file for her own use. She can accomplish this by using <span class="command"><strong>svn unlock</strong></span> with <code class="option">--force</code> and then <span class="command"><strong>svn lock</strong></span> back-to-back, but there's a small chance that somebody else might lock the file between the two commands. The simpler thing to do is to <em class="firstterm">steal</em> the lock, which involves breaking and relocking the file all in one atomic step. To do this, Sally passes the <code class="option">--force</code> option to <span class="command"><strong>svn lock</strong></span>:</p><div class="informalexample"><pre class="screen"> $ svn lock raisin.jpg svn: warning: W160035: Path '/project/raisin.jpg' is already locked by user 'h arry' in filesystem '/var/svn/repos/db' $ svn lock --force raisin.jpg 'raisin.jpg' locked by user 'sally'. $ </pre></div><p>In any case, whether the lock is broken or stolen, Harry may be in for a surprise. Harry's working copy still contains the original lock token, but that lock no longer exists. The lock token is said to be <em class="firstterm">defunct</em>. The lock represented by the lock token has either been broken (no longer in the repository) or stolen (replaced with a different lock). Either way, Harry can see this by asking <span class="command"><strong>svn status</strong></span> to contact the repository:</p><div class="informalexample"><pre class="screen"> $ svn status K raisin.jpg $ svn status -u B 32 raisin.jpg Status against revision: 105 $ svn update Updating '.': B raisin.jpg Updated to revision 105. $ svn status $ </pre></div><p>If the repository lock was broken, then <strong class="userinput"><code>svn status --show-updates</code></strong> (<code class="option">-u</code>) displays a <code class="literal">B</code> (Broken) symbol next to the file. If a new lock exists in place of the old one, then a <code class="literal">T</code> (sTolen) symbol is shown. Finally, <span class="command"><strong>svn update</strong></span> notices any defunct lock tokens and removes them from the working copy.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Locking Policies</strong></p></div></div></div><p>Different systems have different notions of how strict a lock should be. Some folks argue that locks must be strictly enforced at all costs, releasable only by the original creator or administrator. They argue that if anyone can break a lock, chaos runs rampant and the whole point of locking is defeated. The other side argues that locks are first and foremost a communication tool. If users are constantly breaking each other's locks, it represents a cultural failure within the team and the problem falls outside the scope of software enforcement.</p><p>Subversion defaults to the <span class="quote">“<span class="quote">softer</span>”</span> approach, but still allows administrators to create stricter enforcement policies through the use of hook scripts. In particular, the pre-lock and pre-unlock hooks allow administrators to decide when lock creation and lock releases are allowed to happen. Depending on whether a lock already exists, these two hooks can decide whether to allow a certain user to break or steal a lock. The post-lock and post-unlock hooks are also available, and can be used to send email after locking actions. To learn more about repository hooks, see <a class="xref" href="#svn.reposadmin.create.hooks" title="Implementing Repository Hooks">the section called “Implementing Repository Hooks”</a>.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.locking.lock-communication"></a>Lock Communication</h3></div></div></div><p>We've seen how <span class="command"><strong>svn lock</strong></span> and <span class="command"><strong>svn unlock</strong></span> can be used to create, release, break, and steal locks. This satisfies the goal of serializing commit access to a file. But what about the larger problem of preventing wasted time?</p><p>For example, suppose Harry locks an image file and then begins editing it. Meanwhile, miles away, Sally wants to do the same thing. She doesn't think to run <strong class="userinput"><code>svn status -u</code></strong>, so she has no idea that Harry has already locked the file. She spends hours editing the file, and when she tries to commit her change, she discovers that either the file is locked or that she's out of date. Regardless, her changes aren't mergeable with Harry's. One of these two people has to throw away his or her work, and a lot of time has been wasted.</p><p>Subversion's solution to this problem is to provide a mechanism to remind users that a file ought to be locked <span class="emphasis"><em>before</em></span> the editing begins. The mechanism is a special property: <code class="literal">svn:needs-lock</code>. If that property is attached to a file (regardless of its value, which is irrelevant), Subversion will try to use filesystem-level permissions to make the file read-only—unless, of course, the user has explicitly locked the file. When a lock token is present (as a result of using <span class="command"><strong>svn lock</strong></span>), the file becomes read/write. When the lock is released, the file becomes read-only again.</p><p>The theory, then, is that if the image file has this property attached, Sally would immediately notice something is strange when she opens the file for editing: many applications alert users immediately when a read-only file is opened for editing, and nearly all would prevent her from saving changes to the file. This reminds her to lock the file before editing, whereby she discovers the preexisting lock:</p><div class="informalexample"><pre class="screen"> $ /usr/local/bin/gimp raisin.jpg gimp: error: file is read-only! $ ls -l raisin.jpg -r--r--r-- 1 sally sally 215589 Jun 8 19:23 raisin.jpg $ svn lock raisin.jpg svn: warning: W160035: Path '/project/raisin.jpg' is already locked by user 'h arry' in filesystem '/var/svn/repos/db' $ svn info http://svn.example.com/repos/project/raisin.jpg | grep Lock Lock Token: opaquelocktoken:fc2b4dee-98f9-0310-abf3-653ff3226e6b Lock Owner: harry Lock Created: 2006-06-08 07:29:18 -0500 (Thu, 08 June 2006) Lock Comment (1 line): Making some tweaks. Locking for the next two hours. $ </pre></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Users and administrators alike are encouraged to attach the <code class="literal">svn:needs-lock</code> property to any file that cannot be contextually merged. This is the primary technique for encouraging good locking habits and preventing wasted effort.</p></td></tr></table></div><p>Note that this property is a communication tool that works independently from the locking system. In other words, any file can be locked, whether or not this property is present. And conversely, the presence of this property doesn't make the repository require a lock when committing.</p><p>Unfortunately, the system isn't flawless. It's possible that even when a file has the property, the read-only reminder won't always work. Sometimes applications misbehave and <span class="quote">“<span class="quote">hijack</span>”</span> the read-only file, silently allowing users to edit and save the file anyway. There's not much that Subversion can do in this situation—at the end of the day, there's simply no substitution for good interpersonal communication.<a href="#ftn.idm3162" class="footnote" id="idm3162"><sup class="footnote">[23]</sup></a></p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.externals"></a>Externals Definitions</h2></div></div></div><p>Sometimes it is useful to construct a working copy that is made out of a number of different checkouts. For example, you may want different subdirectories to come from different locations in a repository or perhaps from different repositories altogether. You could certainly set up such a scenario by hand—using <span class="command"><strong>svn checkout</strong></span> to create the sort of nested working copy structure you are trying to achieve. But if this layout is important for everyone who uses your repository, every other user will need to perform the same checkout operations that you did.</p><p>Fortunately, Subversion provides support for <em class="firstterm">externals definitions</em>. An externals definition is a mapping of a local directory to the URL—and ideally a particular revision—of a versioned directory. In Subversion, you declare externals definitions in groups using the <code class="literal">svn:externals</code> property. You can create or modify this property using <span class="command"><strong>svn propset</strong></span> or <span class="command"><strong>svn propedit</strong></span> (see <a class="xref" href="#svn.advanced.props.manip" title="Manipulating Properties">the section called “Manipulating Properties”</a>). It can be set on any versioned directory, and its value describes both the external repository location and the client-side directory to which that location should be checked out.</p><p>The convenience of the <code class="literal">svn:externals</code> property is that once it is set on a versioned directory, everyone who checks out a working copy with that directory also gets the benefit of the externals definition. In other words, once one person has made the effort to define the nested working copy structure, no one else has to bother—Subversion will, after checking out the original working copy, automatically also check out the external working copies.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>The relative target subdirectories of externals definitions <span class="emphasis"><em>must not</em></span> already exist on your or other users' systems—Subversion will create them when it checks out the external working copy.</p></td></tr></table></div><p>You also get in the externals definition design all the regular benefits of Subversion properties. The definitions are versioned. If you need to change an externals definition, you can do so using the regular property modification subcommands. When you commit a change to the <code class="literal">svn:externals</code> property, Subversion will synchronize the checked-out items against the changed externals definition when you next run <strong class="userinput"><code>svn update</code></strong>. The same thing will happen when others update their working copies and receive your changes to the externals definition.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Because the <code class="literal">svn:externals</code> property has a multiline value, we strongly recommend that you use <span class="command"><strong>svn propedit</strong></span> instead of <span class="command"><strong>svn propset</strong></span>.</p></td></tr></table></div><p>Subversion releases prior to 1.5 honor an externals definition format that is a multiline table of subdirectories (relative to the versioned directory on which the property is set), optional revision flags, and fully qualified, absolute Subversion repository URLs. An example of this might look as follows:</p><div class="informalexample"><pre class="screen"> $ svn propget svn:externals calc # Resources versioned elsewhere. third-party/sounds http://svn.example.com/repos/sounds third-party/skins -r148 http://svn.example.com/skinproj third-party/skins/toolkit -r21 http://svn.example.com/skin-maker $ </pre></div><p>In the previous example, three externals have been defined. The first is <span class="quote">“<span class="quote">unpinned</span>”</span>—it effectively refers to the HEAD revision of its target. The other two have specific revisions declared. Also demonstrated is the fact that lines that begin with a hash (<code class="literal">#</code>) are treated as comments and ignored by the externals definitions parsing logic.</p><p>When someone checks out a working copy of the <code class="filename">calc</code> directory referred to in the previous example, Subversion also continues to check out the items found in its externals definition.</p><div class="informalexample"><pre class="screen"> $ svn checkout http://svn.example.com/repos/calc A calc A calc/Makefile A calc/integer.c A calc/button.c Checked out revision 148. Fetching external item into calc/third-party/sounds A calc/third-party/sounds/ding.ogg A calc/third-party/sounds/dong.ogg A calc/third-party/sounds/clang.ogg … A calc/third-party/sounds/bang.ogg A calc/third-party/sounds/twang.ogg Checked out revision 14. Fetching external item into calc/third-party/skins … </pre></div><p>As of Subversion 1.5, though, a new format of the <code class="literal">svn:externals</code> property is supported. Externals definitions are still multiline, but the order and format of the various pieces of information have changed. The new syntax more closely mimics the order of arguments you might pass to <span class="command"><strong>svn checkout</strong></span>: the optional revision flags come first, then the external Subversion repository URL, and finally the relative local subdirectory. Notice, though, that this time we didn't say <span class="quote">“<span class="quote">fully qualified, absolute Subversion repository URLs.</span>”</span> That's because the new format supports relative URLs and URLs that carry peg revisions. The previous example of an externals definition might, in Subversion 1.5, look like the following:</p><div class="informalexample"><pre class="screen"> $ svn propget svn:externals calc # Resources versioned elsewhere. http://svn.example.com/repos/sounds third-party/sounds -r148 http://svn.example.com/skinproj third-party/skins -r21 http://svn.example.com/skin-maker third-party/skins/toolkit $ </pre></div><p>Or, making use of the peg revision syntax (which we describe in detail in <a class="xref" href="#svn.advanced.pegrevs" title="Peg and Operative Revisions">the section called “Peg and Operative Revisions”</a>), it might appear as:</p><div class="informalexample"><pre class="screen"> $ svn propget svn:externals calc # Resources versioned elsewhere. http://svn.example.com/repos/sounds third-party/sounds http://svn.example.com/skinproj@148 third-party/skins http://svn.example.com/skin-maker@21 third-party/skins/toolkit $ </pre></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>You should seriously consider using explicit revision numbers in all of your externals definitions. Doing so means that you get to decide when to pull down a different snapshot of external information, and exactly which snapshot to pull. Besides avoiding the surprise of getting changes to third-party repositories that you might not have any control over, using explicit revision numbers also means that as you backdate your working copy to a previous revision, your externals definitions will also revert to the way they looked in that previous revision, which in turn means that the external working copies will be updated to match the way <span class="emphasis"><em>they</em></span> looked back when your repository was at that previous revision. For software projects, this could be the difference between a successful and a failed build of an older snapshot of your complex codebase.</p></td></tr></table></div><p>For most repositories, these three ways of formatting the externals definitions have the same ultimate effect. They all bring the same benefits. Unfortunately, they all bring the same annoyances, too. Since the definitions shown use absolute URLs, moving or copying a directory to which they are attached will not affect what gets checked out as an external (though the relative local target subdirectory will, of course, move with the renamed directory). This can be confusing—even frustrating—in certain situations. For example, say you have a top-level directory named <code class="filename">my-project</code>, and you've created an externals definition on one of its subdirectories (<code class="filename">my-project/some-dir</code>) that tracks the latest revision of another of its subdirectories (<code class="filename">my-project/external-dir</code>).</p><div class="informalexample"><pre class="screen"> $ svn checkout http://svn.example.com/projects . A my-project A my-project/some-dir A my-project/external-dir … Fetching external item into 'my-project/some-dir/subdir' Checked out external at revision 11. Checked out revision 11. $ svn propget svn:externals my-project/some-dir subdir http://svn.example.com/projects/my-project/external-dir $ </pre></div><p>Now you use <span class="command"><strong>svn move</strong></span> to rename the <code class="filename">my-project</code> directory. At this point, your externals definition will still refer to a path under the <code class="filename">my-project</code> directory, even though that directory no longer exists.</p><div class="informalexample"><pre class="screen"> $ svn move -q my-project renamed-project $ svn commit -m "Rename my-project to renamed-project." Deleting my-project Adding renamed-project Committed revision 12. $ svn update Updating '.': svn: warning: W200000: Error handling externals definition for 'renamed-projec t/some-dir/subdir': svn: warning: W170000: URL 'http://svn.example.com/projects/my-project/externa l-dir' at revision 12 doesn't exist At revision 12. svn: E205011: Failure occurred processing one or more externals definitions $ </pre></div><p>Also, absolute URLs can cause problems with repositories that are available via multiple URL schemes. For example, if your Subversion server is configured to allow everyone to check out the repository over <code class="literal">http://</code> or <code class="literal">https://</code>, but only allow commits to come in via <code class="literal">https://</code>, you have an interesting problem on your hands. If your externals definitions use the <code class="literal">http://</code> form of the repository URLs, you won't be able to commit anything from the working copies created by those externals. On the other hand, if they use the <code class="literal">https://</code> form of the URLs, anyone who might be checking out via <code class="literal">http://</code> because his client doesn't support <code class="literal">https://</code> will be unable to fetch the external items. Be aware, too, that if you need to reparent your working copy (using <span class="command"><strong>svn relocate</strong></span>), externals definitions will <span class="emphasis"><em>not</em></span> also be reparented.</p><p>Subversion 1.5 takes a huge step in relieving these frustrations. As mentioned earlier, the URLs used in the new externals definition format can be relative, and Subversion provides syntax magic for specifying multiple flavors of URL relativity.</p><div class="variablelist"><a id="svn.advanced.externals.urlmagic"></a><dl class="variablelist"><dt><span class="term"><code class="literal">../</code></span></dt><dd><p>Relative to the URL of the directory on which the <code class="literal">svn:externals</code> property is set</p></dd><dt><span class="term"><code class="literal">^/</code></span></dt><dd><p>Relative to the root of the repository in which the <code class="literal">svn:externals</code> property is versioned</p></dd><dt><span class="term"><code class="literal">//</code></span></dt><dd><p>Relative to the scheme of the URL of the directory on which the <code class="literal">svn:externals</code> property is set</p></dd><dt><span class="term"><code class="literal">/</code></span></dt><dd><p>Relative to the root URL of the server on which the <code class="literal">svn:externals</code> property is versioned</p></dd><dt><span class="term"><code class="literal">^/../<em class="replaceable"><code>REPO-NAME</code></em></code></span></dt><dd><p>Relative to a sibling repository beneath the same <code class="literal">SVNParentPath</code> location as the repository in which the <code class="literal">svn:externals</code> is defined.</p></dd></dl></div><p>So, looking a fourth time at our previous externals definition example, and making use of the new absolute URL syntax in various ways, we might now see:</p><div class="informalexample"><pre class="screen"> $ svn propget svn:externals calc # Resources versioned elsewhere. ^/sounds third-party/sounds /skinproj@148 third-party/skins //svn.example.com/skin-maker@21 third-party/skins/toolkit $ </pre></div><p>Subversion 1.6 brought two more improvements to externals definitions. First, it added a quoting and escape mechanism to the syntax so that the path of the external working copy may contain whitespace. This was previously problematic, of course, because whitespace is used to delimit the fields in an externals definition. Now you need only wrap such a path specification in double-quote (<code class="literal">"</code>) characters or escape the problematic characters in the path with a backslash (<code class="literal">\</code>) character. Of course, if you have spaces in the <span class="emphasis"><em>URL</em></span> portion of the external definition, you should use the standard URI-encoding mechanism to represent those.</p><div class="informalexample"><pre class="screen"> $ svn propget svn:externals paint http://svn.thirdparty.com/repos/My%20Project "My Project" http://svn.thirdparty.com/repos/%22Quotes%20Too%22 \"Quotes\ Too\" $ </pre></div><p>Subversion 1.6 also introduced support for external definitions for files. <em class="firstterm">File externals</em> are configured just like externals for directories and appear as a versioned file in the working copy.</p><p>For example, let's say you had the file <code class="filename">/trunk/bikeshed/blue.html</code> in your repository, and you wanted this file, as it appeared in revision 40, to appear in your working copy of <code class="filename">/trunk/www/</code> as <code class="filename">green.html</code>.</p><p>The externals definition required to achieve this should look familiar by now:</p><div class="informalexample"><pre class="screen"> $ svn propget svn:externals www/ ^/trunk/bikeshed/blue.html@40 green.html $ svn update Updating '.': Fetching external item into 'www' E www/green.html Updated external to revision 40. Update to revision 103. $ svn status X www/green.html $ </pre></div><p>As you can see in the previous output, Subversion denotes file externals with the letter <code class="literal">E</code> when they are fetched into the working copy, and with the letter <code class="literal">X</code> when showing the working copy status.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>While directory externals can place the external directory at any depth, and any missing intermediate directories will be created, file externals must be placed into a working copy that is already checked out.</p></td></tr></table></div><p>When examining the file external with <span class="command"><strong>svn info</strong></span>, you can see the URL and revision the external is coming from:</p><div class="informalexample"><pre class="screen"> $ svn info www/green.html Path: www/green.html Name: green.html Working Copy Root Path: /home/harry/projects/my-project URL: http://svn.example.com/projects/my-project/trunk/bikeshed/blue.html Repository Root: http://svn.example.com/projects/my-project Repository UUID: b2a368dc-7564-11de-bb2b-113435390e17 Revision: 40 Node kind: file Schedule: normal Last Changed Author: harry Last Changed Rev: 40 Last Changed Date: 2009-07-20 20:38:20 +0100 (Mon, 20 Jul 2009) Text Last Updated: 2009-07-20 23:22:36 +0100 (Mon, 20 Jul 2009) Checksum: 01a58b04617b92492d99662c3837b33b $ </pre></div><p>Because file externals appear in the working copy as versioned files, they can be modified and even committed if they reference a file at the HEAD revision. The committed changes will then appear in the external as well as the file referenced by the external. However, in our example, we pinned the external to an older revision, so attempting to commit the external fails:</p><div class="informalexample"><pre class="screen"> $ svn status M X www/green.html $ svn commit -m "change the color" www/green.html Sending www/green.html svn: E155011: Commit failed (details follow): svn: E155011: File '/trunk/bikeshed/blue.html' is out of date $ </pre></div><p>Keep this in mind when defining file externals. If you need the external to refer to a certain revision of a file you will not be able to modify the external. If you want to be able to modify the external, you cannot specify a revision other than the <code class="literal">HEAD</code> revision, which is implied if no revision is specified.</p><p>Unfortunately, the support which exists for externals definitions in Subversion remains less than ideal. Both file and directory externals have shortcomings. For either type of external, the local subdirectory part of the definition cannot contain <code class="literal">..</code> parent directory indicators (such as <code class="filename">../../skins/myskin</code>). File externals cannot refer to files from other repositories. A file external's URL must always be in the same repository as the URL that the file external will be inserted into. Also, file externals cannot be moved or deleted. The <code class="literal">svn:externals</code> property must be modified instead. However, file externals can be copied.</p><p>Perhaps most disappointingly, the working copies created via the externals definition support are still disconnected from the primary working copy (on whose versioned directories the <code class="literal">svn:externals</code> property was actually set). And Subversion still truly operates only on nondisjoint working copies. So, for example, if you want to commit changes that you've made in one or more of those external working copies, you must run <span class="command"><strong>svn commit</strong></span> explicitly on those working copies—committing on the primary working copy will not recurse into any external ones.</p><p>We've already mentioned some of the additional shortcomings of the old <code class="literal">svn:externals</code> format and how the newer Subversion 1.5 format improves upon it. But be careful when making use of the new format that you don't inadvertently introduce new problems. For example, while the latest clients will continue to recognize and support the original externals definition format, pre-1.5 clients will <span class="emphasis"><em>not</em></span> be able to correctly parse the new format. If you change all your externals definitions to the newer format, you effectively force everyone who uses those externals to upgrade their Subversion clients to a version that can parse them. Also, be careful to avoid naively relocating the <code class="literal">-r<em class="replaceable"><code>NNN</code></em></code> portion of the definition—the older format uses that revision as a peg revision, but the newer format uses it as an operative revision (with a peg revision of <code class="literal">HEAD</code> unless otherwise specified; see <a class="xref" href="#svn.advanced.pegrevs" title="Peg and Operative Revisions">the section called “Peg and Operative Revisions”</a> for a full explanation of the distinction here).</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>External working copies are still completely self-sufficient working copies. You can operate directly on them as you would any other working copy. This can be a handy feature, allowing you to examine an external working copy independently of any primary working copy whose <code class="literal">svn:externals</code> property caused its instantiation. Be careful, though, that you don't inadvertently modify your external working copy in subtle ways that cause problems. For example, while an externals definition might specify that the external working copy should be held at a particular revision number, if you run <span class="command"><strong>svn update</strong></span> directly on the external working copy, Subversion will oblige, and now your external working copy is out of sync with its declaration in the primary working copy. Using <span class="command"><strong>svn switch</strong></span> to directly switch the external working copy (or some portion thereof) to another URL could cause similar problems if the contents of the primary working copy are expecting particular contents in the external content.</p></td></tr></table></div><p>Besides the <span class="command"><strong>svn checkout</strong></span>, <span class="command"><strong>svn update</strong></span>, <span class="command"><strong>svn switch</strong></span>, and <span class="command"><strong>svn export</strong></span> commands which actually manage the <em class="firstterm">disjoint</em> (or disconnected) subdirectories into which externals are checked out, the <span class="command"><strong>svn status</strong></span> command also recognizes externals definitions. It displays a status code of <code class="literal">X</code> for the disjoint external subdirectories, and then recurses into those subdirectories to display the status of the external items themselves. You can pass the <code class="option">--ignore-externals</code> option to any of these subcommands to disable externals definition processing.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.changelists"></a>Changelists</h2></div></div></div><p>It is commonplace for a developer to find himself working at any given time on multiple different, distinct changes to a particular bit of source code. This isn't necessarily due to poor planning or some form of digital masochism. A software engineer often spots bugs in his peripheral vision while working on some nearby chunk of source code. Or perhaps he's halfway through some large change when he realizes the solution he's working on is best committed as several smaller logical units. Often, these logical units aren't nicely contained in some module, safely separated from other changes. The units might overlap, modifying different files in the same module, or even modifying different lines in the same file.</p><p>Developers can employ various work methodologies to keep these logical changes organized. Some use separate working copies of the same repository to hold each individual change in progress. Others might choose to create short-lived feature branches in the repository and use a single working copy that is constantly switched to point to one such branch or another. Still others use <span class="command"><strong>diff</strong></span> and <span class="command"><strong>patch</strong></span> tools to back up and restore uncommitted changes to and from patch files associated with each change. Each of these methods has its pros and cons, and to a large degree, the details of the changes being made heavily influence the methodology used to distinguish them.</p><p>Subversion provides a <em class="firstterm">changelists</em> feature that adds yet another method to the mix. Changelists are basically arbitrary labels (currently at most one per file) applied to working copy files for the express purpose of associating multiple files together. Users of many of Google's software offerings are familiar with this concept already. For example, <a class="ulink" href="http://mail.google.com/" target="_top">Gmail</a> doesn't provide the traditional folders-based email organization mechanism. In Gmail, you apply arbitrary labels to emails, and multiple emails can be said to be part of the same group if they happen to share a particular label. Viewing only a group of similarly labeled emails then becomes a simple user interface trick. Many other Web 2.0 sites have similar mechanisms—consider the <span class="quote">“<span class="quote">tags</span>”</span> used by sites such as <a class="ulink" href="http://www.youtube.com/" target="_top">YouTube</a> and <a class="ulink" href="http://www.flickr.com/" target="_top">Flickr</a>, <span class="quote">“<span class="quote">categories</span>”</span> applied to blog posts, and so on. Folks understand today that organization of data is critical, but that how that data is organized needs to be a flexible concept. The old files-and-folders paradigm is too rigid for some applications.</p><p>Subversion's changelist support allows you to create changelists by applying labels to files you want to be associated with that changelist, remove those labels, and limit the scope of the files on which its subcommands operate to only those bearing a particular label. In this section, we'll look in detail at how to do these things.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.changelists.creating"></a>Creating and Modifying Changelists</h3></div></div></div><p>You can create, modify, and delete changelists using the <span class="command"><strong>svn changelist</strong></span> command. More accurately, you use this command to set or unset the changelist association of a particular working copy file. A changelist is effectively created the first time you label a file with that changelist; it is deleted when you remove that label from the last file that had it. Let's examine a usage scenario that demonstrates these concepts.</p><p>Harry is fixing some bugs in the calculator application's mathematics logic. His work leads him to change a couple of files:</p><div class="informalexample"><pre class="screen"> $ svn status M integer.c M mathops.c $ </pre></div><p>While testing his bug fix, Harry notices that his changes bring to light a tangentially related bug in the user interface logic found in <code class="filename">button.c</code>. Harry decides that he'll go ahead and fix that bug, too, as a separate commit from his math fixes. Now, in a small working copy with only a handful of files and few logical changes, Harry can probably keep his two logical change groupings mentally organized without any problem. But today he's going to use Subversion's changelists feature as a special favor to the authors of this book.</p><p>Harry first creates a changelist and associates with it the two files he's already changed. He does this by using the <span class="command"><strong>svn changelist</strong></span> command to assign the same arbitrary changelist name to those files:</p><div class="informalexample"><pre class="screen"> $ svn changelist math-fixes integer.c mathops.c A [math-fixes] integer.c A [math-fixes] mathops.c $ svn status --- Changelist 'math-fixes': M integer.c M mathops.c $ </pre></div><p>As you can see, the output of <span class="command"><strong>svn status</strong></span> reflects this new grouping.</p><p>Harry now sets off to fix the secondary UI problem. Since he knows which file he'll be changing, he assigns that path to a changelist, too. Unfortunately, Harry carelessly assigns this third file to the same changelist as the previous two files:</p><div class="informalexample"><pre class="screen"> $ svn changelist math-fixes button.c A [math-fixes] button.c $ svn status --- Changelist 'math-fixes': button.c M integer.c M mathops.c $ </pre></div><p>Fortunately, Harry catches his mistake. At this point, he has two options. He can remove the changelist association from <code class="filename">button.c</code>, and then assign a different changelist name:</p><div class="informalexample"><pre class="screen"> $ svn changelist --remove button.c D [math-fixes] button.c $ svn changelist ui-fix button.c A [ui-fix] button.c $ </pre></div><p>Or, he can skip the removal and just assign a new changelist name. In this case, Subversion will first warn Harry that <code class="filename">button.c</code> is being removed from the first changelist:</p><div class="informalexample"><pre class="screen"> $ svn changelist ui-fix button.c D [math-fixes] button.c A [ui-fix] button.c $ svn status --- Changelist 'ui-fix': button.c --- Changelist 'math-fixes': M integer.c M mathops.c $ </pre></div><p>Harry now has two distinct changelists present in his working copy, and <span class="command"><strong>svn status</strong></span> will group its output according to these changelist determinations. Notice that even though Harry hasn't yet modified <code class="filename">button.c</code>, it still shows up in the output of <span class="command"><strong>svn status</strong></span> as interesting because it has a changelist assignment. Changelists can be added to and removed from files at any time, regardless of whether they contain local modifications.</p><p>Harry now fixes the user interface problem in <code class="filename">button.c</code>.</p><div class="informalexample"><pre class="screen"> $ svn status --- Changelist 'ui-fix': M button.c --- Changelist 'math-fixes': M integer.c M mathops.c $ </pre></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.changelists.asfilters"></a>Changelists As Operation Filters</h3></div></div></div><p>The visual grouping that Harry sees in the output of <span class="command"><strong>svn status</strong></span> as shown in our previous section is nice, but not entirely useful. The <span class="command"><strong>status</strong></span> command is but one of many operations that he might wish to perform on his working copy. Fortunately, many of Subversion's other operations understand how to operate on changelists via the use of the <code class="option">--changelist</code> option.</p><p>When provided with a <code class="option">--changelist</code> option, Subversion commands will limit the scope of their operation to only those files to which a particular changelist name is assigned. If Harry now wants to see the actual changes he's made to the files in his <code class="literal">math-fixes</code> changelist, he <span class="emphasis"><em>could</em></span> explicitly list only the files that make up that changelist on the <span class="command"><strong>svn diff</strong></span> command line.</p><div class="informalexample"><pre class="screen"> $ svn diff integer.c mathops.c Index: integer.c =================================================================== --- integer.c (revision 1157) +++ integer.c (working copy) … Index: mathops.c =================================================================== --- mathops.c (revision 1157) +++ mathops.c (working copy) … $ </pre></div><p>That works okay for a few files, but what if Harry's change touched 20 or 30 files? That would be an annoyingly long list of explicitly named files. Now that he's using changelists, though, Harry can avoid explicitly listing the set of files in his changelist from now on, and instead provide just the changelist name:</p><div class="informalexample"><pre class="screen"> $ svn diff --changelist math-fixes Index: integer.c =================================================================== --- integer.c (revision 1157) +++ integer.c (working copy) … Index: mathops.c =================================================================== --- mathops.c (revision 1157) +++ mathops.c (working copy) … $ </pre></div><p>And when it's time to commit, Harry can again use the <code class="option">--changelist</code> option to limit the scope of the commit to files in a certain changelist. He might commit his user interface fix by doing the following:</p><div class="informalexample"><pre class="screen"> $ svn commit -m "Fix a UI bug found while working on math logic." \ --changelist ui-fix Sending button.c Transmitting file data . Committed revision 1158. $ </pre></div><p>In fact, the <span class="command"><strong>svn commit</strong></span> command provides a second changelists-related option: <code class="option">--keep-changelists</code>. Normally, changelist assignments are removed from files after they are committed. But if <code class="option">--keep-changelists</code> is provided, Subversion will leave the changelist assignment on the committed (and now unmodified) files. In any case, committing files assigned to one changelist leaves other changelists undisturbed.</p><div class="informalexample"><pre class="screen"> $ svn status --- Changelist 'math-fixes': M integer.c M mathops.c $ </pre></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The <code class="option">--changelist</code> option acts only as a filter for Subversion command targets, and will not add targets to an operation. For example, on a commit operation specified as <strong class="userinput"><code>svn commit /path/to/dir</code></strong>, the target is the directory <code class="filename">/path/to/dir</code> and its children (to infinite depth). If you then add a changelist specifier to that command, only those files in and under <code class="filename">/path/to/dir</code> that are assigned that changelist name will be considered as targets of the commit—the commit will not include files located elsewhere (such as in <code class="filename">/path/to/another-dir</code>), regardless of their changelist assignment, even if they are part of the same working copy as the operation's target(s).</p></td></tr></table></div><p>Even the <span class="command"><strong>svn changelist</strong></span> command accepts the <code class="option">--changelist</code> option. This allows you to quickly and easily rename or remove a changelist:</p><div class="informalexample"><pre class="screen"> $ svn changelist math-bugs --changelist math-fixes --depth infinity . D [math-fixes] integer.c A [math-bugs] integer.c D [math-fixes] mathops.c A [math-bugs] mathops.c $ svn changelist --remove --changelist math-bugs --depth infinity . D [math-bugs] integer.c D [math-bugs] mathops.c $ </pre></div><p>Finally, you can specify multiple instances of the <code class="option">--changelist</code> option on a single command line. Doing so limits the operation you are performing to files found in any of the specified changesets.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.changelists.limitations"></a>Changelist Limitations</h3></div></div></div><p>Subversion's changelist feature is a handy tool for grouping working copy files, but it does have a few limitations. Changelists are artifacts of a particular working copy, which means that changelist assignments cannot be propagated to the repository or otherwise shared with other users. Changelists can be assigned only to files—Subversion doesn't currently support the use of changelists with directories. Finally, you can have at most one changelist assignment on a given working copy file. Here is where the blog post category and photo service tag analogies break down—if you find yourself needing to assign a file to multiple changelists, you're out of luck.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.serverconfig.netmodel"></a>Network Model</h2></div></div></div><p>At some point, you're going to need to understand how your Subversion client communicates with its server. Subversion's networking layer is abstracted, meaning that Subversion clients exhibit the same general behaviors no matter what sort of server they are operating against. Whether speaking the HTTP protocol (<code class="literal">http://</code>) with the Apache HTTP Server or speaking the custom Subversion protocol (<code class="literal">svn://</code>) with <span class="command"><strong>svnserve</strong></span>, the basic network model is the same. In this section, we'll explain the basics of that network model, including how Subversion manages authentication and authorization matters.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.netmodel.reqresp"></a>Requests and Responses</h3></div></div></div><p>The Subversion client spends most of its time managing working copies. When it needs information from a remote repository, however, it makes a network request, and the server responds with an appropriate answer. The details of the network protocol are hidden from the user—the client attempts to access a URL, and depending on the URL scheme, a particular protocol is used to contact the server (see <a class="xref" href="#svn.advanced.reposurls" title="Addressing the Repository">the section called “Addressing the Repository”</a>).</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Run <strong class="userinput"><code>svn --version</code></strong> to see which URL schemes and protocols the client knows how to use.</p></td></tr></table></div><p>When the server process receives a client request, it often demands that the client identify itself. It issues an authentication challenge to the client, and the client responds by providing <em class="firstterm">credentials</em> back to the server. Once authentication is complete, the server responds with the original information that the client asked for. Notice that this system is different from systems such as CVS, where the client preemptively offers credentials (<span class="quote">“<span class="quote">logs in</span>”</span>) to the server before ever making a request. In Subversion, the server <span class="quote">“<span class="quote">pulls</span>”</span> credentials by challenging the client at the appropriate moment, rather than the client <span class="quote">“<span class="quote">pushing</span>”</span> them. This makes certain operations more elegant. For example, if a server is configured to allow anyone in the world to read a repository, the server will never issue an authentication challenge when a client attempts to <span class="command"><strong>svn checkout</strong></span>.</p><p>If the particular network requests issued by the client result in a new revision being created in the repository (e.g., <span class="command"><strong>svn commit</strong></span>), Subversion uses the authenticated username associated with those requests as the author of the revision. That is, the authenticated user's name is stored as the value of the <code class="literal">svn:author</code> property on the new revision (see <a class="xref" href="#svn.ref.properties" title="Subversion Properties">the section called “Subversion Properties”</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>). If the client was not authenticated (i.e., if the server never issued an authentication challenge), the revision's <code class="literal">svn:author</code> property is empty.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.netmodel.creds"></a>Client Credentials</h3></div></div></div><p>Many Subversion servers are configured to require authentication. Sometimes anonymous read operations are allowed, while write operations must be authenticated. In other cases, reads and writes alike require authentication. Subversion's different server options understand different authentication protocols, but from the user's point of view, authentication typically boils down to usernames and passwords. Subversion clients offer several different ways to retrieve and store a user's authentication credentials, from interactive prompting for usernames and passwords to encrypted and non-encrypted on-disk data caches.</p><p>The security-conscious reader will suspect immediately that there is reason for concern here. <span class="quote">“<span class="quote">Caching passwords on disk? That's terrible! You should never do that!</span>”</span> Don't worry—it's not as bad as it sounds. The following sections discuss the various types of credential caches that Subversion uses, when it uses them, and how to disable that functionality in whole or in part.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.netmodel.credcache"></a>Caching credentials</h4></div></div></div><p>Subversion offers a remedy for the annoyance caused when users are forced to type their usernames and passwords over and over again. By default, whenever the command-line client successfully responds to a server's authentication challenge, credentials are cached on disk and keyed on a combination of the server's hostname, port, and authentication realm. This cache will then be automatically consulted in the future, avoiding the need for the user to re-type his or her authentication credentials. If seemingly suitable credentials are not present in the cache, or if the cached credentials ultimately fail to authenticate, the client will, by default, fall back to prompting the user for the necessary information.</p><p>The Subversion developers recognize that on-disk caches of authentication credentials can be a security risk. To offset this, Subversion works with available mechanisms provided by the operating system and environment to try to minimize the risk of leaking this information.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>On Windows, the Subversion client stores passwords in the <code class="filename">%APPDATA%/Subversion/auth/</code> directory. On Windows 2000 and later, the standard Windows cryptography services are used to encrypt the password on disk. Because the encryption key is managed by Windows and is tied to the user's own login credentials, only the user can decrypt the cached password. (Note that if the user's Windows account password is reset by an administrator, all of the cached passwords become undecipherable. The Subversion client will behave as though they don't exist, prompting for passwords when required.)</p></li><li class="listitem"><p>Similarly, on Mac OS X, the Subversion client stores all repository passwords in the login keyring (managed by the Keychain service), which is protected by the user's account password. User preference settings can impose additional policies, such as requiring that the user's account password be entered each time the Subversion password is used.</p></li><li class="listitem"><p>For other Unix-like operating systems, no single standard <span class="quote">“<span class="quote">keychain</span>”</span> service exists. However, the Subversion client knows how to store passwords securely using the <span class="quote">“<span class="quote">GNOME Keyring</span>”</span> and <span class="quote">“<span class="quote">KDE Wallet</span>”</span> services. Also, before storing unencrypted passwords in the <code class="filename">~/.subversion/auth/</code> caching area, the Subversion client will ask the user for permission to do so. Note that the <code class="filename">auth/</code> caching area is still permission-protected so that only the user (owner) can read data from it, not the world at large. The operating system's own file permissions protect the passwords from other non-administrative users on the same system, provided they have no direct physical access to the storage media of the home directory, or backups thereof.</p></li></ul></div><p>Of course, for the truly paranoid, none of these mechanisms meets the test of perfection. So for those folks willing to sacrifice convenience for the ultimate in security, Subversion provides various ways of disabling its credentials caching system altogether.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.initial.disabling-password-caching"></a>Disabling password caching</h4></div></div></div><p>When you perform a Subversion operation that requires you to authenticate, by default Subversion tries to cache your authentication credentials on disk in encrypted form. On some systems, Subversion may be unable to encrypt your authentication data. In those situations, Subversion will ask whether you want to cache your credentials to disk in plaintext:</p><div class="informalexample"><pre class="screen"> $ svn checkout https://host.example.com:443/svn/private-repo ----------------------------------------------------------------------- ATTENTION! Your password for authentication realm: &lt;https://host.example.com:443&gt; Subversion Repository can only be stored to disk unencrypted! You are advised to configure your system so that Subversion can store passwords encrypted, if possible. See the documentation for details. You can avoid future appearances of this warning by setting the value of the 'store-plaintext-passwords' option to either 'yes' or 'no' in '/tmp/servers'. ----------------------------------------------------------------------- Store password unencrypted (yes/no)? </pre></div><p>If you want the convenience of not having to continually reenter your password for future operations, you can answer <code class="literal">yes</code> to this prompt. If you're concerned about caching your Subversion passwords in plaintext and do not want to be asked about it again and again, you can disable caching of plaintext passwords either permanently, or on a server-per-server basis.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>When considering how to use Subversion's password caching system, you'll want to consult any governing policies that are in place for your client computer—many companies have strict rules about the ways that their employees' authentication credentials should be stored.</p></td></tr></table></div><p>To permanently disable caching of passwords in plaintext, add the line <code class="literal">store-plaintext-passwords = no</code> to the <code class="literal">[global]</code> section in the <code class="filename">servers</code> configuration file on the local machine. To disable plaintext password caching for a particular server, use the same setting in the appropriate group section in the <code class="filename">servers</code> configuration file. (See <a class="xref" href="#svn.advanced.confarea.opts" title="Configuration Options">the section called “Configuration Options”</a> in <a class="xref" href="#svn.customization" title="Chapter 7. Customizing Your Subversion Experience">Chapter 7, <em>Customizing Your Subversion Experience</em></a> for details.)</p><p>To disable password caching entirely for any single Subversion command-line operation, pass the <code class="option">--no-auth-cache</code> option to that command line. To permanently disable caching entirely, add the line <code class="literal">store-passwords = no</code> to your local machine's Subversion configuration file.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.initial.authn-cache-purge"></a>Removing cached credentials</h4></div></div></div><p>Sometimes users will want to remove specific credentials from the disk cache. To do this, you need to navigate into the <code class="filename">auth/</code> area and manually delete the appropriate cache file. Credentials are cached in individual files; if you look inside each file, you will see keys and values. The <code class="literal">svn:realmstring</code> key describes the particular server realm that the file is associated with:</p><div class="informalexample"><pre class="screen"> $ ls ~/.subversion/auth/svn.simple/ 5671adf2865e267db74f09ba6f872c28 3893ed123b39500bca8a0b382839198e 5c3c22968347b390f349ff340196ed39 $ cat ~/.subversion/auth/svn.simple/5671adf2865e267db74f09ba6f872c28 K 8 username V 3 joe K 8 password V 4 blah K 15 svn:realmstring V 45 &lt;https://svn.domain.com:443&gt; Joe's repository END </pre></div><p>Once you have located the proper cache file, just delete it.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.initial.different-user"></a>Command-line authentication</h4></div></div></div><p>All Subversion command-line operations accept the <code class="option">--username</code> and <code class="option">--password</code> options, which allow you to specify your username and password, respectively, so that Subversion isn't forced to prompt you for that information. This is especially handy if you need to invoke Subversion from a script and cannot rely on Subversion being able to locate valid cached credentials for you. These options are also helpful when Subversion has already cached authentication credentials for you, but you know they aren't the ones you want it to use. Perhaps several system users share a login to the system, but each have distinct Subversion identities. You can omit the <code class="option">--password</code> option from this pair if you wish Subversion to use only the provided username, but still prompt you for that username's password.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.tour.initial.authn-wrapup"></a>Authentication wrap-up</h4></div></div></div><p>One last word about <span class="command"><strong>svn</strong></span>'s authentication behavior, specifically regarding the <code class="option">--username</code> and <code class="option">--password</code> options. Many client subcommands accept these options, but it is important to understand that using these options does <span class="emphasis"><em>not</em></span> automatically send credentials to the server. As discussed earlier, the server <span class="quote">“<span class="quote">pulls</span>”</span> credentials from the client when it deems necessary; the client cannot <span class="quote">“<span class="quote">push</span>”</span> them at will. If a username and/or password are passed as options, they will be presented to the server only if the server requests them. These options are typically used to authenticate as a different user than Subversion would have chosen by default (such as your system login name) or when trying to avoid interactive prompting (such as when calling <span class="command"><strong>svn</strong></span> from a script).</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>A common mistake is to misconfigure a server so that it never issues an authentication challenge. When users pass <code class="option">--username</code> and <code class="option">--password</code> options to the client, they're surprised to see that they're never used; that is, new revisions still appear to have been committed anonymously!</p></td></tr></table></div><p>Here is a final summary that describes how a Subversion client behaves when it receives an authentication challenge.</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>First, the client checks whether the user specified any credentials as command-line options (<code class="option">--username</code> and/or <code class="option">--password</code>). If so, the client will try to use those credentials to authenticate against the server.</p></li><li class="listitem"><p>If no command-line credentials were provided, or the provided ones were invalid, the client looks up the server's hostname, port, and realm in the runtime configuration's <code class="filename">auth/</code> area, to see whether appropriate credentials are cached there. If so, it attempts to use those credentials to authenticate.</p></li><li class="listitem"><p>Finally, if the previous mechanisms failed to successfully authenticate the user against the server, the client resorts to interactively prompting the user for valid credentials (unless instructed not to do so via the <code class="option">--non-interactive</code> option or its client-specific equivalents).</p></li></ol></div><p>If the client successfully authenticates by any of these methods, it will attempt to cache the credentials on disk (unless the user has disabled this behavior, as mentioned earlier).</p></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.summary"></a>Summary</h2></div></div></div><p>After reading this chapter, you should have a firm grasp on some of Subversion's features that, while perhaps not used <span class="emphasis"><em>every</em></span> time you interact with your version control system, are certainly handy to know about. But don't stop here! Read on to the following chapter, where you'll learn about branches, tags, and merging. Then you'll have nearly full mastery of the Subversion client. Though our lawyers won't allow us to promise you anything, this additional knowledge could make you measurably more cool.<a href="#ftn.idm3529" class="footnote" id="idm3529"><sup class="footnote">[24]</sup></a></p></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm2149" class="footnote"><p><a href="#idm2149" class="para"><sup class="para">[11] </sup></a><span class="quote">“<span class="quote">You're not supposed to name it. Once you name it, you start getting attached to it.</span>”</span>—Mike Wazowski</p></div><div id="ftn.idm2171" class="footnote"><p><a href="#idm2171" class="para"><sup class="para">[12] </sup></a>606 N. Main Street, Wheaton, Illinois, is the home of the Wheaton <span class="emphasis"><em>History</em></span> Center. It seemed appropriate….</p></div><div id="ftn.idm2356" class="footnote"><p><a href="#idm2356" class="para"><sup class="para">[13] </sup></a>If you're familiar with XML, this is pretty much the ASCII subset of the syntax for XML <span class="quote">“<span class="quote">Name</span>”</span>.</p></div><div id="ftn.idm2397" class="footnote"><p><a href="#idm2397" class="para"><sup class="para">[14] </sup></a>Fixing spelling errors, grammatical gotchas, and <span class="quote">“<span class="quote">just-plain-wrongness</span>”</span> in commit log messages is perhaps the most common use case for the <code class="option">--revprop</code> option.</p></div><div id="ftn.idm2475" class="footnote"><p><a href="#idm2475" class="para"><sup class="para">[15] </sup></a>Currently, libmagic is the support library used to accomplish this.</p></div><div id="ftn.idm2520" class="footnote"><p><a href="#idm2520" class="para"><sup class="para">[16] </sup></a>You think that was rough? During that same era, WordPerfect also used <code class="filename">.DOC</code> for their proprietary file format's preferred extension!</p></div><div id="ftn.idm2555" class="footnote"><p><a href="#idm2555" class="para"><sup class="para">[17] </sup></a>The Windows filesystems use file extensions (such as <code class="filename">.EXE</code>, <code class="filename">.BAT</code>, and <code class="filename">.COM</code>) to denote executable files.</p></div><div id="ftn.idm2687" class="footnote"><p><a href="#idm2687" class="para"><sup class="para">[18] </sup></a>Isn't that the whole point of a build system?</p></div><div id="ftn.idm2792" class="footnote"><p><a href="#idm2792" class="para"><sup class="para">[19] </sup></a>… or maybe even a section of a book …</p></div><div id="ftn.idm2945" class="footnote"><p><a href="#idm2945" class="para"><sup class="para">[20] </sup></a>Safely, of course. As in other situations, Subversion will leave on disk any files you've modified or which aren't versioned.</p></div><div id="ftn.idm2985" class="footnote"><p><a href="#idm2985" class="para"><sup class="para">[21] </sup></a>Communication wouldn't have been such bad medicine for Harry and Sally's Hollywood namesakes, either, for that matter.</p></div><div id="ftn.idm2991" class="footnote"><p><a href="#idm2991" class="para"><sup class="para">[22] </sup></a>Subversion does not currently allow locks on directories.</p></div><div id="ftn.idm3162" class="footnote"><p><a href="#idm3162" class="para"><sup class="para">[23] </sup></a>Except, perhaps, a classic Vulcan mind-meld.</p></div><div id="ftn.idm3529" class="footnote"><p><a href="#idm3529" class="para"><sup class="para">[24] </sup></a>No purchase necessary. Certains terms and conditions apply. No guarantee of coolness—implicit or otherwise—exists. Mileage may vary.</p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="svn.branchmerge"></a>Chapter 4. Branching and Merging</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.branchmerge.whatis">What's a Branch?</a></span></dt><dt><span class="sect1"><a href="#svn.branchmerge.using">Using Branches</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.branchmerge.using.create">Creating a Branch</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.using.work">Working with Your Branch</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.using.concepts">The Key Concepts Behind Branching</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.branchmerge.basicmerging">Basic Merging</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.branchmerge.changesets">Changesets</a></span></dt><dt><span class="sect2"><a href="#svn.branchemerge.basicmerging.stayinsync">Keeping a Branch in Sync</a></span></dt><dt><span class="sect2"><a href="#svn.branchemerge.basicmerging.stayinsync.subtree">Subtree Merges and Subtree Mergeinfo</a></span></dt><dt><span class="sect2"><a href="#svn.branchemerge.basicmerging.reintegrate">Reintegrating a Branch</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.basicmerging.mergeinfo">Mergeinfo and Previews</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.basicmerging.undo">Undoing Changes</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.basicmerging.resurrect">Resurrecting Deleted Items</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.branchmerge.advanced">Advanced Merging</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.branchmerge.cherrypicking">Cherrypicking</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.advancedsyntax">Merge Syntax: Full Disclosure</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.nomergedata">Merges Without Mergeinfo</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.mergeconflicts">More on Merge Conflicts</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.blockchanges">Blocking Changes</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.reintegratetwice">Keeping a Reintegrated Branch Alive</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.logblame">Merge-Sensitive Logs and Annotations</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.ancestry">Noticing or Ignoring Ancestry</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.moves">Merges and Moves</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.pre1.5clients">Preventing Naïve Clients from Committing Merges</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.advanced.finalword">The Final Word on Merge Tracking</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.branchmerge.switchwc">Traversing Branches</a></span></dt><dt><span class="sect1"><a href="#svn.branchmerge.tags">Tags</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.branchmerge.tags.mksimple">Creating a Simple Tag</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.tags.mkcomplex">Creating a Complex Tag</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.branchmerge.maint">Branch Maintenance</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.branchmerge.maint.layout">Repository Layout</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.maint.lifetime">Data Lifetimes</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.branchmerge.commonpatterns">Common Branching Patterns</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.branchmerge.commonpatterns.release">Release Branches</a></span></dt><dt><span class="sect2"><a href="#svn.branchmerge.commonpatterns.feature">Feature Branches</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.advanced.vendorbr">Vendor Branches</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.vendorbr.general">General Vendor Branch Management Procedure</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.vendorbr.svn_load_dirs">svn_load_dirs.pl</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.branchmerge.when">To Branch or Not to Branch?</a></span></dt><dt><span class="sect1"><a href="#svn.branchmerge.summary">Summary</a></span></dt></dl></div><div class="blockquote"><table border="0" class="blockquote" style="width: 100%; cellspacing: 0; cellpadding: 0;" summary="Block quote"><tr><td width="10%" valign="top"> </td><td width="80%" valign="top"><p><span class="quote">“<span class="quote">君子务本 (It is upon the Trunk that a gentleman works.)</span>”</span></p></td><td width="10%" valign="top"> </td></tr><tr><td width="10%" valign="top"> </td><td colspan="2" align="right" valign="top">--<span class="attribution">Confucius</span></td></tr></table></div><p>Branching and merging are fundamental aspects of version control, simple enough to explain conceptually but offering just enough complexity and nuance to merit their own chapter in this book. Herein, we'll introduce you to the general ideas behind these operations as well as Subversion's somewhat unique approach to them. If you've not familiarized yourself with Subversion's basic concepts (found in <a class="xref" href="#svn.basic" title="Chapter 1. Fundamental Concepts">Chapter 1, <em>Fundamental Concepts</em></a>), we recommmend that you do so before reading this chapter.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.branchmerge.whatis"></a>What's a Branch?</h2></div></div></div><p>Suppose it's your job to maintain a document for a division in your company—a handbook of some sort. One day a different division asks you for the same handbook, but with a few parts <span class="quote">“<span class="quote">tweaked</span>”</span> for them, since they do things slightly differently.</p><p>What do you do in this situation? You do the obvious: make a second copy of your document and begin maintaining the two copies separately. As each department asks you to make small changes, you incorporate them into one copy or the other.</p><p>You often want to make the same change to both copies. For example, if you discover a typo in the first copy, it's very likely that the same typo exists in the second copy. The two documents are almost the same, after all; they differ only in small, specific ways.</p><p> <a id="idm3546" class="indexterm"></a> This is the basic concept of a branch—namely, a line of development that exists independently of another line, yet still shares a common history if you look far enough back in time. A branch always begins life as a copy of something, and moves on from there, generating its own history (see <a class="xref" href="#svn.branchmerge.whatis.dia-1" title="Figure 4.1. Branches of development">Figure 4.1, “Branches of development”</a>).</p><div class="figure"><a id="svn.branchmerge.whatis.dia-1"></a><p class="title"><strong>Figure 4.1. Branches of development</strong></p><div class="figure-contents"><div><img src="images/ch04dia1.png" alt="Branches of development"></img></div></div></div><br class="figure-break"></br><p>Subversion has commands to help you maintain parallel branches of your files and directories. It allows you to create branches by copying your data, and remembers that the copies are related to one another. It also helps you duplicate changes from one branch to another. Finally, it can make portions of your working copy reflect different branches so that you can <span class="quote">“<span class="quote">mix and match</span>”</span> different lines of development in your daily work.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.branchmerge.using"></a>Using Branches</h2></div></div></div><p>At this point, you should understand how each commit creates a new state of the filesystem tree (called a <span class="quote">“<span class="quote">revision</span>”</span>) in the repository. If you don't, go back and read about revisions in <a class="xref" href="#svn.basic.in-action.revs" title="Revisions">the section called “Revisions”</a>.</p><p>Let's revisit the example from <a class="xref" href="#svn.basic" title="Chapter 1. Fundamental Concepts">Chapter 1, <em>Fundamental Concepts</em></a>. Remember that you and your collaborator, Sally, are sharing a repository that contains two projects, <code class="filename">paint</code> and <code class="filename">calc</code>. Notice that in <a class="xref" href="#svn.branchmerge.using.dia-1" title="Figure 4.2. Starting repository layout">Figure 4.2, “Starting repository layout”</a>, however, each project directory now contains subdirectories named <code class="filename">trunk</code> and <code class="filename">branches</code>. The reason for this will soon become clear.</p><div class="figure"><a id="svn.branchmerge.using.dia-1"></a><p class="title"><strong>Figure 4.2. Starting repository layout</strong></p><div class="figure-contents"><div><img src="images/ch04dia2.png" alt="Starting repository layout"></img></div></div></div><br class="figure-break"></br><p>As before, assume that Sally and you both have working copies of the <span class="quote">“<span class="quote">calc</span>”</span> project. Specifically, you each have a working copy of <code class="filename">/calc/trunk</code>. All the files for the project are in this subdirectory rather than in <code class="filename">/calc</code> itself, because your team has decided that <code class="filename">/calc/trunk</code> is where the <span class="quote">“<span class="quote">main line</span>”</span> of development is going to take place.</p><p>Let's say that you've been given the task of implementing a large software feature. It will take a long time to write, and will affect all the files in the project. The immediate problem is that you don't want to interfere with Sally, who is in the process of fixing small bugs here and there. She's depending on the fact that the latest version of the project (in <code class="filename">/calc/trunk</code>) is always usable. If you start committing your changes bit by bit, you'll surely break things for Sally (and other team members as well).</p><p>One strategy is to crawl into a hole: you can stop sharing information for a week or two, gutting and reorganizing all the files in your private working copy but not committing or updating until you're completely finished with your task. There are a number of problems with this, though. First, it's not very safe. Should something bad happen to your working copy or computer, you risk losing all your changes. Second, it's not very flexible. Unless you manually replicate your changes across different working copies or computers, you're stuck trying to make your changes in a single working copy. Similarly, it's difficult to share your work-in-progress with anyone else. A common software development <span class="quote">“<span class="quote">best practice</span>”</span> is to allow your peers to review your work as you go. If nobody sees your intermediate commits, you lose potential feedback and may end up going down the wrong path for weeks before another person on your team notices. Finally, when you're finished with all your changes, you might find it very difficult to merge your completed work with the rest of the company's main body of code. Sally (or others) may have made many other changes in the repository that are difficult to incorporate into your working copy when you eventually run <span class="command"><strong>svn update</strong></span> after weeks of isolation.</p><p>The better solution is to create your own branch, or line of development, in the repository. This allows you to save your not-yet-completed work frequently without interfering with others' changes and while still selectively sharing information with your collaborators. You'll see exactly how this works as we continue.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.using.create"></a>Creating a Branch</h3></div></div></div><p>Creating a branch is very simple—you make a copy of your project tree in the repository using the <span class="command"><strong>svn copy</strong></span> command. Since your project's source code is rooted in the <code class="filename">/calc/trunk</code> directory, it's that directory that you'll copy. Where should the new copy live? Wherever you wish. The repository location in which branches are stashed is left by Subversion as a matter of project policy. Finally, your branch will need a name to distinguish it from other branches. Once again, the name you choose is unimportant to Subversion—you can use whatever name works best for you and your team.</p><p>Let's assume that your team (like most) has a policy of creating branches in the <code class="filename">branches</code> directory that is a sibling of the project's trunk (the <code class="filename">/calc/branches</code> directory in our scenario). Lacking inspiration, you settle on <code class="literal">my-calc-branch</code> as the name you wish to give your branch. This means that you'll create a new directory, <code class="filename">/calc/branches/my-calc-branch</code>, which begins its life as a copy of <code class="filename">/calc/trunk</code>.</p><p>You may already have seen <span class="command"><strong>svn copy</strong></span> used to copy one file to another within a working copy. But it can also be used to do a <em class="firstterm">remote copy</em>—a copy that immediately results in a newly committed repository revision and for which no working copy is required at all. Just copy one URL to another:</p><div class="informalexample"><pre class="screen"> $ svn copy http://svn.example.com/repos/calc/trunk \ http://svn.example.com/repos/calc/branches/my-calc-branch \ -m "Creating a private branch of /calc/trunk." Committed revision 341. $ </pre></div><p>This command causes a near-instantaneous commit in the repository, creating a new directory in revision 341. The new directory is a copy of <code class="filename">/calc/trunk</code>. This is shown in <a class="xref" href="#svn.branchmerge.using.create.dia-1" title="Figure 4.3. Repository with new copy">Figure 4.3, “Repository with new copy”</a>.<a href="#ftn.idm3600" class="footnote" id="idm3600"><sup class="footnote">[25]</sup></a> While it's also possible to create a branch by using <span class="command"><strong>svn copy</strong></span> to duplicate a directory within the working copy, this technique isn't recommended. It can be quite slow, in fact! Copying a directory on the client side is a linear-time operation, in that it actually has to duplicate every file and subdirectory within that working copy directory on the local disk. Copying a directory on the server, however, is a constant-time operation, and it's the way most people create branches.</p><div class="figure"><a id="svn.branchmerge.using.create.dia-1"></a><p class="title"><strong>Figure 4.3. Repository with new copy</strong></p><div class="figure-contents"><div><img src="images/ch04dia3.png" alt="Repository with new copy"></img></div></div></div><br class="figure-break"></br><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Cheap Copies</strong></p></div></div></div><p>Subversion's repository has a special design. When you copy a directory, you don't need to worry about the repository growing huge—Subversion doesn't actually duplicate any data. Instead, it creates a new directory entry that points to an <span class="emphasis"><em>existing</em></span> tree. If you're an experienced Unix user, you'll recognize this as the same concept behind a hard link. As further changes are made to files and directories beneath the copied directory, Subversion continues to employ this hard link concept where it can. It duplicates data only when it is necessary to disambiguate different versions of objects.</p><p>This is why you'll often hear Subversion users talk about <span class="quote">“<span class="quote">cheap copies.</span>”</span> It doesn't matter how large the directory is—it takes a very tiny, constant amount of time and space to make a copy of it. In fact, this feature is the basis of how commits work in Subversion: each revision is a <span class="quote">“<span class="quote">cheap copy</span>”</span> of the previous revision, with a few items lazily changed within. (To read more about this, visit Subversion's web site and read about the <span class="quote">“<span class="quote">bubble up</span>”</span> method in Subversion's design documents.)</p><p>Of course, these internal mechanics of copying and sharing data are hidden from the user, who simply sees copies of trees. The main point here is that copies are cheap, both in time and in space. If you create a branch entirely within the repository (by running <strong class="userinput"><code>svn copy <em class="replaceable"><code>URL1</code></em> <em class="replaceable"><code>URL2</code></em></code></strong>), it's a quick, constant-time operation. Make branches as often as you want.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.using.work"></a>Working with Your Branch</h3></div></div></div><p>Now that you've created a branch of the project, you can check out a new working copy to start using it:</p><div class="informalexample"><pre class="screen"> $ svn checkout http://svn.example.com/repos/calc/branches/my-calc-branch A my-calc-branch/Makefile A my-calc-branch/integer.c A my-calc-branch/button.c Checked out revision 341. $ </pre></div><p>There's nothing special about this working copy; it simply mirrors a different directory in the repository. When you commit changes, however, Sally won't see them when she updates, because her working copy is of <code class="filename">/calc/trunk</code>. (Be sure to read <a class="xref" href="#svn.branchmerge.switchwc" title="Traversing Branches">the section called “Traversing Branches”</a> later in this chapter: the <span class="command"><strong>svn switch</strong></span> command is an alternative way of creating a working copy of a branch.)</p><p>Let's pretend that a week goes by, and the following commits happen:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>You make a change to <code class="filename">/calc/branches/my-calc-branch/button.c</code>, which creates revision 342.</p></li><li class="listitem"><p>You make a change to <code class="filename">/calc/branches/my-calc-branch/integer.c</code>, which creates revision 343.</p></li><li class="listitem"><p>Sally makes a change to <code class="filename">/calc/trunk/integer.c</code>, which creates revision 344.</p></li></ul></div><p>Now two independent lines of development (shown in <a class="xref" href="#svn.branchmerge.using.work.dia-1" title="Figure 4.4. The branching of one file's history">Figure 4.4, “The branching of one file's history”</a>) are happening on <code class="filename">integer.c</code>.</p><div class="figure"><a id="svn.branchmerge.using.work.dia-1"></a><p class="title"><strong>Figure 4.4. The branching of one file's history</strong></p><div class="figure-contents"><div><img src="images/ch04dia4.png" alt="The branching of one file's history"></img></div></div></div><br class="figure-break"></br><p>Things get interesting when you look at the history of changes made to your copy of <code class="filename">integer.c</code>:</p><div class="informalexample"><pre class="screen"> $ pwd /home/user/my-calc-branch $ svn log -v integer.c ------------------------------------------------------------------------ r343 | user | 2002-11-07 15:27:56 -0600 (Thu, 07 Nov 2002) | 2 lines Changed paths: M /calc/branches/my-calc-branch/integer.c * integer.c: frozzled the wazjub. ------------------------------------------------------------------------ r341 | user | 2002-11-03 15:27:56 -0600 (Thu, 07 Nov 2002) | 2 lines Changed paths: A /calc/branches/my-calc-branch (from /calc/trunk:340) Creating a private branch of /calc/trunk. ------------------------------------------------------------------------ r303 | sally | 2002-10-29 21:14:35 -0600 (Tue, 29 Oct 2002) | 2 lines Changed paths: M /calc/trunk/integer.c * integer.c: changed a docstring. ------------------------------------------------------------------------ r98 | sally | 2002-02-22 15:35:29 -0600 (Fri, 22 Feb 2002) | 2 lines Changed paths: A /calc/trunk/integer.c * integer.c: adding this file to the project. ------------------------------------------------------------------------ </pre></div><p>Notice that Subversion is tracing the history of your branch's <code class="filename">integer.c</code> all the way back through time, even traversing the point where it was copied. It shows the creation of the branch as an event in the history, because <code class="filename">integer.c</code> was implicitly copied when all of <code class="filename">/calc/trunk/</code> was copied. Now look at what happens when Sally runs the same command on her copy of the file:</p><div class="informalexample"><pre class="screen"> $ pwd /home/sally/calc $ svn log -v integer.c ------------------------------------------------------------------------ r344 | sally | 2002-11-07 15:27:56 -0600 (Thu, 07 Nov 2002) | 2 lines Changed paths: M /calc/trunk/integer.c * integer.c: fix a bunch of spelling errors. ------------------------------------------------------------------------ r303 | sally | 2002-10-29 21:14:35 -0600 (Tue, 29 Oct 2002) | 2 lines Changed paths: M /calc/trunk/integer.c * integer.c: changed a docstring. ------------------------------------------------------------------------ r98 | sally | 2002-02-22 15:35:29 -0600 (Fri, 22 Feb 2002) | 2 lines Changed paths: A /calc/trunk/integer.c * integer.c: adding this file to the project. ------------------------------------------------------------------------ </pre></div><p>Sally sees her own revision 344 change, but not the change you made in revision 343. As far as Subversion is concerned, these two commits affected different files in different repository locations. However, Subversion <span class="emphasis"><em>does</em></span> show that the two files share a common history. Before the branch copy was made in revision 341, the files used to be the same file. That's why you and Sally both see the changes made in revisions 303 and 98.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.using.concepts"></a>The Key Concepts Behind Branching</h3></div></div></div><p>You should remember two important lessons from this section. First, Subversion has no internal concept of a branch—it knows only how to make copies. When you copy a directory, the resultant directory is only a <span class="quote">“<span class="quote">branch</span>”</span> because <span class="emphasis"><em>you</em></span> attach that meaning to it. You may think of the directory differently, or treat it differently, but to Subversion it's just an ordinary directory that happens to carry some extra historical information.</p><p>Second, because of this copy mechanism, Subversion's branches exist as <span class="emphasis"><em>normal filesystem directories</em></span> in the repository. This is different from other version control systems, where branches are typically defined by adding extra-dimensional <span class="quote">“<span class="quote">labels</span>”</span> to collections of files. The location of your branch directory doesn't matter to Subversion. Most teams follow a convention of putting all branches into a <code class="filename">/branches</code> directory, but you're free to invent any policy you wish.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.branchmerge.basicmerging"></a>Basic Merging</h2></div></div></div><p>Now you and Sally are working on parallel branches of the project: you're working on a private branch, and Sally is working on the trunk, or main line of development.</p><p>For projects that have a large number of contributors, it's common for most people to have working copies of the trunk. Whenever someone needs to make a long-running change that is likely to disrupt the trunk, a standard procedure is to create a private branch and commit changes there until all the work is complete.</p><p>So, the good news is that you and Sally aren't interfering with each other. The bad news is that it's very easy to drift <span class="emphasis"><em>too</em></span> far apart. Remember that one of the problems with the <span class="quote">“<span class="quote">crawl in a hole</span>”</span> strategy is that by the time you're finished with your branch, it may be near-impossible to merge your changes back into the trunk without a huge number of conflicts.</p><p>Instead, you and Sally might continue to share changes as you work. It's up to you to decide which changes are worth sharing; Subversion gives you the ability to selectively <span class="quote">“<span class="quote">copy</span>”</span> changes between branches. And when you're completely finished with your branch, your entire set of branch changes can be copied back into the trunk. In Subversion terminology, the general act of replicating changes from one branch to another is called <em class="firstterm">merging</em>, and it is performed using various invocations of the <span class="command"><strong>svn merge</strong></span> subcommand.</p><p>In the examples that follow, we're assuming that both your Subversion client and server are running Subversion 1.7 (or later). If either client or server is older than version 1.5, things are more complicated: the system won't track changes automatically, forcing you to use painful manual methods to achieve similar results. That is, you'll always need to use the detailed merge syntax to specify specific ranges of revisions to replicate (see <a class="xref" href="#svn.branchmerge.advanced.advancedsyntax" title="Merge Syntax: Full Disclosure">the section called “Merge Syntax: Full Disclosure”</a> later in this chapter), and take special care to keep track of what's already been merged and what hasn't. For this reason, we <span class="emphasis"><em>strongly</em></span> recommend that you make sure your client and server are at least at version 1.5.</p><div class="sidebar"><a id="svn.branchmerge.basicmerging.mergetracking"></a><div class="titlepage"><div><div><p class="title"><strong>Merge Tracking</strong></p></div></div></div><p> <a id="idm3684" class="indexterm"></a> Subversion 1.5 introduced the <em class="firstterm">merge tracking</em> feature to Subversion. Prior to this feature keeping track of merges required cumbersome manual procedures or the use of external tools. Subsequent releases of Subversion introduced many enhancements and bug fixes to merge tracking, which is why we recommend using the most recent versions on both your server and client. Keep in mind that even if your server is running 1.5 or 1.6, you can still use a 1.7 client. This is particularly important as regards merge tracking, because the overwhelming majority of fixes to it are on the client side.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.changesets"></a>Changesets</h3></div></div></div><p>Before we proceed further, we should warn you that there's a lot of discussion of <span class="quote">“<span class="quote">changes</span>”</span> in the pages ahead. A lot of people experienced with version control systems use the terms <span class="quote">“<span class="quote">change</span>”</span> and <span class="quote">“<span class="quote">changeset</span>”</span> interchangeably, and we should clarify what Subversion understands as a <em class="firstterm">changeset</em>.</p><p>Everyone seems to have a slightly different definition of changeset, or at least a different expectation of what it means for a version control system to have one. For our purposes, let's say that a changeset is just a collection of changes with a unique name. The changes might include textual edits to file contents, modifications to tree structure, or tweaks to metadata. In more common speak, a changeset is just a patch with a name you can refer to.</p><p>In Subversion, a global revision number <em class="replaceable"><code>N</code></em> names a tree in the repository: it's the way the repository looked after the <em class="replaceable"><code>N</code></em>th commit. It's also the name of an implicit changeset: if you compare tree <em class="replaceable"><code>N</code></em> with tree <em class="replaceable"><code>N</code></em>-1, you can derive the exact patch that was committed. For this reason, it's easy to think of revision <em class="replaceable"><code>N</code></em> as not just a tree, but a changeset as well. If you use an issue tracker to manage bugs, you can use the revision numbers to refer to particular patches that fix bugs—for example, <span class="quote">“<span class="quote">this issue was fixed by r9238.</span>”</span> Somebody can then run <strong class="userinput"><code>svn log -r 9238</code></strong> to read about the exact changeset that fixed the bug, and run <strong class="userinput"><code>svn diff -c 9238</code></strong> to see the patch itself. And (as you'll see shortly) Subversion's <span class="command"><strong>svn merge</strong></span> command is able to use revision numbers. You can merge specific changesets from one branch to another by naming them in the merge arguments: passing <strong class="userinput"><code>-c 9238</code></strong> to <span class="command"><strong>svn merge</strong></span> would merge changeset r9238 into your working copy.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchemerge.basicmerging.stayinsync"></a>Keeping a Branch in Sync</h3></div></div></div><p>Continuing with our running example, let's suppose that a week has passed since you started working on your private branch. Your new feature isn't finished yet, but at the same time you know that other people on your team continue to make important changes in the project's <code class="filename">/trunk</code>. It's in your best interest to replicate those changes to your own branch, just to make sure they mesh well with your changes. This is done by performing a <em class="firstterm">sync merge</em>—a merge operation designed to bring your branch up to date with any changes made to its ancestral parent branch since your branch was created.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Frequently keeping your branch in sync with the main development line helps prevent <span class="quote">“<span class="quote">surprise</span>”</span> conflicts when the time comes for you to fold your changes back into the trunk.</p></td></tr></table></div><p>Subversion is aware of the history of your branch and knows when it split away from the trunk. To perform a sync merge, first make sure your working copy of the branch is <span class="quote">“<span class="quote">clean</span>”</span>—that it has no local modifications reported by <span class="command"><strong>svn status</strong></span>. Then simply run:</p><div class="informalexample"><pre class="screen"> $ pwd /home/user/my-calc-branch $ svn merge ^/calc/trunk --- Merging r345 through r356 into '.': U button.c U integer.c --- Recording mergeinfo for merge of r345 through r356 into '.': U . $ </pre></div><p>This basic syntax—<strong class="userinput"><code>svn merge <em class="replaceable"><code>URL</code></em></code></strong>—tells Subversion to merge all changes which have not been previously merged from the URL to the current working directory (which is typically the root of your working copy). Notice that we're using the caret (<code class="literal">^</code>) syntax<a href="#ftn.idm3724" class="footnote" id="idm3724"><sup class="footnote">[26]</sup></a> to avoid having to type out the entire <code class="filename">/trunk</code> URL. Also note the <span class="quote">“<span class="quote">Recording mergeinfo for merge…</span>”</span> notification. This tells you that the merge is updating the <code class="literal">svn:mergeinfo</code> property. We'll discuss both this property and these notifications later in this chapter, in <a class="xref" href="#svn.branchmerge.basicmerging.mergeinfo" title="Mergeinfo and Previews">the section called “Mergeinfo and Previews”</a>.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p> <a id="idm3732" class="indexterm"></a> In this book and elsewhere (Subversion mailing lists, articles on merge tracking, etc.) you will frequently come across the term <em class="firstterm">mergeinfo</em>. This is simply shorthand for the <code class="literal">svn:mergeinfo</code> property.</p></td></tr></table></div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Keeping a Branch in Sync Without Merge Tracking</strong></p></div></div></div><p>You may not always be able to use Subversion's merge tracking feature, perhaps because your server is running Subversion 1.4 or earlier. In such a scenario, you can of course still perform merges, but Subversion will need you to manually do many of the historical calculations that it automatically does on your behalf when the merge tracking feature is available.</p><p>To replicate the most recent trunk changes you need to perform sync merges the <span class="quote">“<span class="quote">old-fashioned</span>”</span> way—by specifying ranges of revisions you wish to merge.</p><p>Let's say you branched <code class="filename">/trunk</code> to <code class="filename">/branches/foo-feature</code> in revision 400:</p><div class="informalexample"><pre class="screen"> $ svn log -v -r 400 ^/branches/foo-feature ------------------------------------------------------------------------ r400 | carol | 2011-11-09 10:51:27 -0500 (Wed, 09 Nov 2011) | 1 line Changed paths: A /branch/b2 (from /trunk:399) Create branch for the foo feature ------------------------------------------------------------------------ </pre></div><p>When you are ready to syncronize your branch with the ongoing changes from trunk, you specify the starting revision as the revision of <code class="filename">/trunk</code> which the branch was copied from and the ending revision as <code class="literal">HEAD</code>:</p><div class="informalexample"><pre class="screen"> $ svn merge ^/trunk -r399:HEAD --- Merging r400 through r556 into '.': A include/foo.h U src/main.c A src/foo.c … </pre></div><p>After any conflicts have been resolved, you can commit the merged changed to your branch. Now, to avoid accidentally trying to merge these same changes into your branch again in the future, you'll need to record the fact that you've already merged them. But where should that record be kept? One of the simplest places to record this information is in the log message for the commit of the merge:</p><div class="informalexample"><pre class="screen"> $ svn ci -m "Sync the foo-feature branch with ^/trunk through r556." Sending include/foo.h … Transmitting file data . Committed revision 557. </pre></div><p>The next time you sync <code class="filename">/branches/foo-branch</code> with <code class="filename">/trunk</code> you repeat this process, except that the starting revision is the <span class="emphasis"><em>youngest</em></span> revision that's already been merged in from the trunk. If you've been keeping good records of your merges in the commit log messages, you should be able to determine what that youngest revision was by reading the revision logs associated with your branch. Once you know your starting revision, you can perform another sync merge:</p><div class="informalexample"><pre class="screen"> $ svn merge ^/trunk -r556:HEAD … </pre></div></div><p>After running the prior example, your branch working copy now contains new local modifications, and these edits are duplications of all of the changes that have happened on the trunk since you first created your branch:</p><div class="informalexample"><pre class="screen"> $ svn status M . M button.c M integer.c $ </pre></div><p>At this point, the wise thing to do is look at the changes carefully with <span class="command"><strong>svn diff</strong></span>, and then build and test your branch. Notice that the current working directory (<span class="quote">“<span class="quote"><code class="filename">.</code></span>”</span>) has also been modified; <span class="command"><strong>svn diff</strong></span> will show that its <code class="literal">svn:mergeinfo</code> property has been either created or modified. This is important merge-related metadata that you should <span class="emphasis"><em>not</em></span> touch, since it is needed by future <span class="command"><strong>svn merge</strong></span> commands. (We'll learn more about this metadata later in the chapter.)</p><p>After performing the merge, you might also need to resolve some conflicts—just as you do with <span class="command"><strong>svn update</strong></span>—or possibly make some small edits to get things working properly. (Remember, just because there are no <span class="emphasis"><em>syntactic</em></span> conflicts doesn't mean there aren't any <span class="emphasis"><em>semantic</em></span> conflicts!) If you encounter serious problems, you can always abort the local changes by running <strong class="userinput"><code>svn revert . -R</code></strong> (which will undo all local modifications) and starting a long <span class="quote">“<span class="quote">what's going on?</span>”</span> discussion with your collaborators. If things look good, however, you can submit these changes into the repository:</p><div class="informalexample"><pre class="screen"> $ svn commit -m "Merged latest trunk changes to my-calc-branch." Sending . Sending button.c Sending integer.c Transmitting file data .. Committed revision 357. $ </pre></div><p>At this point, your private branch is now <span class="quote">“<span class="quote">in sync</span>”</span> with the trunk, so you can rest easier knowing that as you continue to work in isolation, you're not drifting too far away from what everyone else is doing.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Why Not Use Patches Instead?</strong></p></div></div></div><p>A question may be on your mind, especially if you're a Unix user: why bother to use <span class="command"><strong>svn merge</strong></span> at all? Why not simply use <span class="command"><strong>svn patch</strong></span> or the operating system's <span class="command"><strong>patch</strong></span> command to accomplish the same job? For example:</p><div class="informalexample"><pre class="screen"> $ cd my-calc-branch $ svn diff -r 341:HEAD ^/calc/trunk &gt; my-patch-file $ svn patch my-patch-file U integer.c $ </pre></div><p>In this particular example, there really isn't much difference. But <span class="command"><strong>svn merge</strong></span> has special abilities that surpass the <span class="command"><strong>patch</strong></span> program. The file format used by <span class="command"><strong>patch</strong></span> is quite limited; it's able to tweak file contents only. There's no way to represent changes to <span class="emphasis"><em>trees</em></span>, such as the addition, removal, or renaming of files and directories. Nor can the <span class="command"><strong>patch</strong></span> program notice changes to properties. If Sally's change had, say, added a new directory, the output of <span class="command"><strong>svn diff</strong></span> wouldn't have mentioned it at all. <span class="command"><strong>svn diff</strong></span> outputs only the limited patch format, so there are some ideas it simply can't express. Even Subversion's own <span class="command"><strong>svn patch</strong></span> subcommand, while more flexible than patch program, still has similar limitations.</p><p>The <span class="command"><strong>svn merge</strong></span> command, however, can express changes in tree structure and properties by directly applying them to your working copy. Even more important, this command records the changes that have been duplicated to your branch so that Subversion is aware of exactly which changes exist in each location (see <a class="xref" href="#svn.branchmerge.basicmerging.mergeinfo" title="Mergeinfo and Previews">the section called “Mergeinfo and Previews”</a>). This is a critical feature that makes branch management usable; without it, users would have to manually keep notes on which sets of changes have or haven't been merged yet.</p></div><p>Suppose that another week has passed. You've committed more changes to your branch, and your comrades have continued to improve the trunk as well. Once again, you want to replicate the latest trunk changes to your branch and bring yourself in sync. Just run the same merge command again!</p><div class="informalexample"><pre class="screen"> $ svn merge ^/calc/trunk svn: E195020: Cannot merge into mixed-revision working copy [357:378]; try up\ dating first $ </pre></div><p>Well that was unexpected! After making changes to your branch over the past week you now find yourself with a working copy that contains a mixture of revisions (see <a class="xref" href="#svn.basic.in-action.mixedrevs" title="Mixed-revision working copies">the section called “Mixed-revision working copies”</a>). With the release of Subversion 1.7 the <span class="command"><strong>svn merge</strong></span> subcommand disables merges into mixed-revision working copies by default. Without going into too much detail, this is because of limitations in the way merges are tracked by the <code class="literal">svn:mergeinfo</code> property (see <a class="xref" href="#svn.branchmerge.basicmerging.mergeinfo" title="Mergeinfo and Previews">the section called “Mergeinfo and Previews”</a> for details). These limitations mean that merges into mixed-revision working copies can result in unexpected text and tree conflicts.<a href="#ftn.idm3809" class="footnote" id="idm3809"><sup class="footnote">[27]</sup></a> We don't want any needless conflicts, so we update the working copy and then reattempt the merge.</p><div class="informalexample"><pre class="screen"> $ svn up Updating '.': At revision 380. $ svn merge ^/calc/trunk --- Merging r357 through r380 into '.': U integer.c U Makefile A README --- Recording mergeinfo for merge of r357 through r380 into '.': U . $ </pre></div><p>Subversion knows which trunk changes you previously replicated to your branch, so it carefully replicates only those changes you don't yet have. And once again, you build, test, and <span class="command"><strong>svn commit</strong></span> the local modifications to your branch.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchemerge.basicmerging.stayinsync.subtree"></a>Subtree Merges and Subtree Mergeinfo</h3></div></div></div><p> <a id="idm3820" class="indexterm"></a> <a id="idm3822" class="indexterm"></a> In most of the examples in this chapter the merge target is the root directory of a branch (see <a class="xref" href="#svn.branchmerge.whatis" title="What's a Branch?">the section called “What's a Branch?”</a>). While this is a best practice, you may occasionally need to merge directly to some child of the branch root. This type of merge is called a <em class="firstterm">subtree merge</em> and the mergeinfo recorded to describe it is called <em class="firstterm">subtree mergeinfo</em>. There is nothing special about subtree merges or subtree mergeinfo. In fact there is really only one important point to keep in mind about these concepts: the complete record of merges to a branch may not be contained solely in the mergeinfo on the branch root. You may have to look to any subtree mergeinfo to get a full accounting. Fortunately Subversion does this for you and rarely will you need to concern yourself with it. A brief example will help explain:</p><div class="informalexample"><pre class="screen"> # We need to merge r958 from trunk to branches/proj-X/doc/INSTALL, # but that revision also affects main.c, which we don't want to merge: $ svn log --verbose --quiet -r 958 ^/ ------------------------------------------------------------------------ r958 | bruce | 2011-10-20 13:28:11 -0400 (Thu, 20 Oct 2011) Changed paths: M /trunk/doc/INSTALL M /trunk/src/main.c ------------------------------------------------------------------------ # No problem, we'll do a subtree merge targeting the INSTALL file # directly, but first take a note of what mergeinfo exists on the # root of the branch: $ cd branches/proj-X $ svn propget svn:mergeinfo --recursive Properties on '.': svn:mergeinfo /trunk:651-652 # Now we perform the subtree merge, note that merge source # and target both point to INSTALL: $ svn merge ^/trunk/doc/INSTALL doc/INSTALL -c 958 --- Merging r958 into 'doc/INSTALL': U doc/INSTALL --- Recording mergeinfo for merge of r958 into 'doc/INSTALL': G doc/INSTALL # Once the merge is complete there is now subtree mergeinfo on INSTALL: $ svn propget svn:mergeinfo --recursive Properties on '.': svn:mergeinfo /trunk:651-652 Properties on 'doc/INSTALL': svn:mergeinfo /trunk/doc/INSTALL:651-652,958 # What if we then decide we do want all of r958? Easy, all we need do is # repeat the merge of that revision, but this time to the root of the # branch, Subversion notices the subtree mergeinfo on INSTALL and doesn't # try to merge any changes to it, only the changes to main.c are merged: $ svn merge ^/subversion/trunk . -c 958 --- Merging r958 into '.': U src/main.c --- Recording mergeinfo for merge of r958 into '.': U . --- Eliding mergeinfo from 'doc/INSTALL': U doc/INSTALL </pre></div><a id="idm3829" class="indexterm"></a><p>You might be wondering why <code class="filename">INSTALL</code> in the above example has mergeinfo for r651-652, when we only merged r958. This is due to mergeinfo inheritance, which we'll cover in the sidebar <a class="xref" href="#svn.branchmerge.basicmerging.mergeinfo.inheritance" title="Mergeinfo Inheritance">Mergeinfo Inheritance</a>. Also note that the subtree mergeinfo on <code class="filename">doc/INSTALL</code> was removed, or <span class="quote">“<span class="quote">elided</span>”</span>. This is called <em class="firstterm">mergeinfo elision</em> and it occurs whenever Subversion detects redundant subtree mergeinfo.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Prior to Subversion 1.7, merges unconditionally updated <span class="emphasis"><em>all</em></span> of the subtree mergeinfo under the target to describe the merge. For users with a lot of subtree mergeinfo this meant that relatively <span class="quote">“<span class="quote">simple</span>”</span> merges (e.g. one which applied a diff to only a single file) resulted in changes to every subtree with mergeinfo, even those that were not parents of the effected path(s). This caused some level of confusion and frustration. Subversion 1.7 addresses this problem by only updating the mergeinfo on subtrees which are parents of the paths modified by the merge (i.e. paths changed, added, or deleted by application of the difference, see <a class="xref" href="#svn.branchmerge.advanced.advancedsyntax" title="Merge Syntax: Full Disclosure">the section called “Merge Syntax: Full Disclosure”</a>). The one exception to this behavior regards the actual merge target; the merge target's mergeinfo is always updated to describe the merge, even if the applied difference made no changes.</p></td></tr></table></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchemerge.basicmerging.reintegrate"></a>Reintegrating a Branch</h3></div></div></div><p>What happens when you finally finish your work, though? Your new feature is done, and you're ready to merge your branch changes back to the trunk (so your team can enjoy the bounty of your labor). The process is simple. First, bring your branch into sync with the trunk again, just as you've been doing all along<a href="#ftn.idm3845" class="footnote" id="idm3845"><sup class="footnote">[28]</sup></a>:</p><div class="informalexample"><pre class="screen"> $ svn merge ^/calc/trunk --- Merging r381 through r385 into '.': U button.c U README --- Recording mergeinfo for merge of r381 through r385 into '.': U . $ # build, test, ... $ svn commit -m "Final merge of trunk changes to my-calc-branch." Sending . Sending button.c Sending README Transmitting file data .. Committed revision 390. </pre></div><p>Now, use <span class="command"><strong>svn merge</strong></span> with the <code class="option">--reintegrate</code> option to replicate your branch changes back into the trunk. You'll need a working copy of <code class="filename">/trunk</code>. You can get one by doing an <span class="command"><strong>svn checkout</strong></span>, dredging up an old trunk working copy from somewhere on your disk, or using <span class="command"><strong>svn switch</strong></span> (see <a class="xref" href="#svn.branchmerge.switchwc" title="Traversing Branches">the section called “Traversing Branches”</a>). Your trunk working copy cannot have any local edits or contain a mixture of revisions (see <a class="xref" href="#svn.basic.in-action.mixedrevs" title="Mixed-revision working copies">the section called “Mixed-revision working copies”</a>). While these are typically best practices for merging anyway, they are <span class="emphasis"><em>required</em></span> when using the <code class="option">--reintegrate</code> option.</p><p>Once you have a clean working copy of the trunk, you're ready to merge your branch back into it:</p><div class="informalexample"><pre class="screen"> $ pwd /home/user/calc-trunk $ svn update # (make sure the working copy is up to date) Updating '.': At revision 390. $ svn merge --reintegrate ^/calc/branches/my-calc-branch --- Merging differences between repository URLs into '.': U button.c U integer.c U Makefile --- Recording mergeinfo for merge between repository URLs into '.': U . $ # build, test, verify, ... $ svn commit -m "Merge my-calc-branch back into trunk!" Sending . Sending button.c Sending integer.c Sending Makefile Transmitting file data .. Committed revision 391. </pre></div><p>Congratulations, your branch-specific changes have now been merged back into the main line of development. Notice our use of the <code class="option">--reintegrate</code> option this time around. The option is critical for reintegrating changes from a branch back into its original line of development—don't forget it! It's needed because this sort of <span class="quote">“<span class="quote">merge back</span>”</span> is a different sort of work than what you've done up until now. Previously, we were asking <span class="command"><strong>svn merge</strong></span> to grab the <span class="quote">“<span class="quote">next set</span>”</span> of changes from one line of development (the trunk) and duplicate them to another (your branch). This is fairly straightforward, and each time Subversion knows how to pick up where it left off. In our prior examples, you can see that first it merges the ranges 345:356 from trunk to branch; later on, it continues by merging the next contiguously available range, 356:380. When doing the final sync, it merges the range 380:385.</p><p>When merging your branch back to the trunk, however, the underlying mathematics are quite different. Your feature branch is now a mishmash of both duplicated trunk changes and private branch changes, so there's no simple contiguous range of revisions to copy over. By specifying the <code class="option">--reintegrate</code> option, you're asking Subversion to carefully replicate <span class="emphasis"><em>only</em></span> those changes unique to your branch. (And in fact, it does this by comparing the latest trunk tree with the latest branch tree: the resulting difference is exactly your branch changes!)</p><p>Keep in mind that the <code class="option">--reintegrate</code> option is quite specialized in contrast to the more general nature of most Subversion subcommand options. It supports the use case described above, but has little applicability outside of that. Because of this narrow focus, in addition to requiring an up-to-date working copy<a href="#ftn.idm3873" class="footnote" id="idm3873"><sup class="footnote">[29]</sup></a> with no mixed-revisions, it will not function in combination with most of the other <span class="command"><strong>svn merge</strong></span> options. You'll get an error if you use any non-global options but these: <code class="option">--accept</code>, <code class="option">--dry-run</code>, <code class="option">--diff3-cmd</code>, <code class="option">--extensions</code>, or <code class="option">--quiet</code>.</p><p>Now that your private branch is merged to trunk, you may wish to remove it from the repository:</p><div class="informalexample"><pre class="screen"> $ svn delete ^/calc/branches/my-calc-branch \ -m "Remove my-calc-branch, reintegrated with trunk in r391." Committed revision 392. </pre></div><p>But wait! Isn't the history of that branch valuable? What if somebody wants to audit the evolution of your feature someday and look at all of your branch changes? No need to worry. Remember that even though your branch is no longer visible in the <code class="filename">/branches</code> directory, its existence is still an immutable part of the repository's history. A simple <span class="command"><strong>svn log</strong></span> command on the <code class="filename">/branches</code> URL will show the entire history of your branch. Your branch can even be resurrected at some point, should you desire (see <a class="xref" href="#svn.branchmerge.basicmerging.resurrect" title="Resurrecting Deleted Items">the section called “Resurrecting Deleted Items”</a>).</p><p>Once a <code class="option">--reintegrate</code> merge is done from branch to trunk, the branch is no longer usable for further work. It's not able to correctly absorb new trunk changes, nor can it be properly reintegrated to trunk again. For this reason, if you want to keep working on your feature branch, we recommend destroying it and then re-creating it from the trunk:</p><div class="informalexample"><pre class="screen"> $ svn delete http://svn.example.com/repos/calc/branches/my-calc-branch \ -m "Remove my-calc-branch, reintegrated with trunk in r391." Committed revision 392. $ svn copy http://svn.example.com/repos/calc/trunk \ http://svn.example.com/repos/calc/branches/my-calc-branch \ -m "Recreate my-calc-branch from trunk@HEAD." Committed revision 393. </pre></div><p>There is another way of making the branch usable again after reintegration, without deleting the branch. See <a class="xref" href="#svn.branchmerge.advanced.reintegratetwice" title="Keeping a Reintegrated Branch Alive">the section called “Keeping a Reintegrated Branch Alive”</a>.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.basicmerging.mergeinfo"></a>Mergeinfo and Previews</h3></div></div></div><p> <a id="idm3901" class="indexterm"></a>The basic mechanism Subversion uses to track changesets—that is, which changes have been merged to which branches—is by recording data in versioned properties. Specifically, merge data is tracked in the <code class="literal">svn:mergeinfo</code> property attached to files and directories. (If you're not familiar with Subversion properties, see <a class="xref" href="#svn.advanced.props" title="Properties">the section called “Properties”</a>.)</p><p>You can examine the property, just like any other:</p><div class="informalexample"><pre class="screen"> $ cd my-calc-branch $ svn propget svn:mergeinfo . /trunk:341-390 $ </pre></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>While it is possible to modify <code class="literal">svn:mergeinfo</code> just as you might any other versioned property, we strongly discourage doing so unless you <span class="emphasis"><em>really</em></span> know what you're doing.</p></td></tr></table></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>The amount of <code class="literal">svn:mergeinfo</code> on a single path can get quite large, as can the output of a <span class="command"><strong>svn propget --recursive</strong></span> or <span class="command"><strong>svn proplist --recursive</strong></span> when dealing with large amounts of subtree mergeinfo, see <a class="xref" href="#svn.branchemerge.basicmerging.stayinsync.subtree" title="Subtree Merges and Subtree Mergeinfo">the section called “Subtree Merges and Subtree Mergeinfo”</a> . The formatted output produced by the <code class="option">--verbose</code> option with either of these subcommands is often very helpful in these cases.</p></td></tr></table></div><p>The <code class="literal">svn:mergeinfo</code> property is automatically maintained by Subversion whenever you run <span class="command"><strong>svn merge</strong></span>. Its value indicates which changes made to a given path have been replicated into the directory in question. In our previous example, the path which is the source of the merged changes is <code class="filename">/trunk</code> and the directory which has received the changes is <code class="filename">/branches/my-calc-branch</code>. Earlier versions of Subversion maintained the <code class="literal">svn:mergeinfo</code> property silently. You could still detect the changes, after a merge completed, with the <span class="command"><strong>svn diff</strong></span> or <span class="command"><strong>svn status</strong></span> subcommands, but the merge itself gave no indication when it changed the <code class="literal">svn:mergeinfo</code> property. This is no longer true in Subversion 1.7, which has several new notifications to alert you when a merge updates the <code class="literal">svn:mergeinfo</code> property. These notifications all begin with <span class="quote">“<span class="quote">--- Recording mergeinfo for</span>”</span> and appear at the end of the merge. Unlike other merge notifications, these don't describe the application of a difference to a working copy (see <a class="xref" href="#svn.branchmerge.advanced.advancedsyntax" title="Merge Syntax: Full Disclosure">the section called “Merge Syntax: Full Disclosure”</a>), but instead describe "housekeeping" changes made to keep track of what was merged.</p><p>Subversion also provides a subcommand, <span class="command"><strong>svn mergeinfo</strong></span>, which is helpful in seeing not only which changesets a directory has absorbed, but also which changesets it's still eligible to receive. This gives a sort of preview of which changes a subsequent <span class="command"><strong>svn merge</strong></span> operation would replicate to your branch.</p><div class="informalexample"><pre class="screen"> $ cd my-calc-branch # Which changes have already been merged from trunk to branch? $ svn mergeinfo ^/calc/trunk r341 r342 r343 … r388 r389 r390 # Which changes are still eligible to merge from trunk to branch? $ svn mergeinfo ^/calc/trunk --show-revs eligible r391 r392 r393 r394 r395 $ </pre></div><p>The <span class="command"><strong>svn mergeinfo</strong></span> command requires a <span class="quote">“<span class="quote">source</span>”</span> URL (where the changes come from), and takes an optional <span class="quote">“<span class="quote">target</span>”</span> URL (where the changes merge to). If no target URL is given, it assumes that the current working directory is the target. In the prior example, because we're querying our branch working copy, the command assumes we're interested in receiving changes to <code class="filename">/branches/mybranch</code> from the specified trunk URL.</p><div class="sidebar"><a id="svn.branchmerge.basicmerging.mergeinfo.inheritance"></a><div class="titlepage"><div><div><p class="title"><strong>Mergeinfo Inheritance</strong></p></div></div></div><a id="idm3944" class="indexterm"></a><p>When a path has the <code class="literal">svn:mergeinfo</code> property set on it we say it has <em class="firstterm">explicit mergeinfo</em>. This explicit mergeinfo describes not only what changes were merged into that particular directory, but also all the children of that directory (because those children inherit the mergeinfo of their parent path). For example:</p><div class="informalexample"><pre class="screen"> # What explicit mergeinfo exists on a branch? $ svn propget svn:mergeinfo ^/branches/proj-X --recursive /trunk:651-652 # What children does proj-X have? $ svn list --recursive ^/branches/proj-X doc/ doc/INSTALL README src/main.c # Ask what revs were merged to a file with no explicit mergeinfo $ svn mergeinfo ^/trunk/src/main.c ^/branches/proj-X/src/main.c 651 652 </pre></div><p>Notice from our first subcommand that only the root of <code class="filename">/branches/proj-X</code> has any explicit mergeinfo. However, when we use <span class="command"><strong>svn mergeinfo</strong></span> to ask what was merged to <code class="filename">/branches/proj-X/src/main.c</code> it reports that the two revisions described in the explicit mergeinfo on <code class="filename">/branches/proj-X</code> were merged. This is because <code class="filename">/branches/proj-X/src/main.c</code>, having no explicit mergeinfo of its own, inherits the mergeinfo from its nearest parent with explicit mergeinfo, <code class="filename">/branches/proj-X</code>.</p><p>There are two cases in which mergeinfo is not inherited. First, if a path has explicit mergeinfo, then it never inherits mergeinfo. Another way to think of this is that explicit mergeinfo is always a complete record of the merges to a given path, once it exists it overrides any mergeinfo that path might otherwise inherit. The second way is when dealing with non-inheritable mergeinfo, a special type of explicit mergeinfo that applies <span class="emphasis"><em>only</em></span> to the directory on which the <code class="literal">svn:mergeinfo</code> property is set (and it's only directories, non-inheritable mergeinfo is never set on files). For example:</p><div class="informalexample"><pre class="screen"> # The '*' decorator indicates non-inheritable mergeinfo $ svn propget svn:mergeinfo ^/branches/proj-X /trunk:651-652,758* # Revision 758 is non-inheritable, but still applies to the path it is # set on. Here the '*' decorator signals that r758 is only partially # merged from trunk. $ svn mergeinfo ^/trunk ^/branches/proj-X 651 652 758* # Revision 758 is not reported as merged because it is non-inheritable # and applies only to ^/trunk $ svn mergeinfo ^/trunk/src/main.c ^/branches/proj-X/src/main.c 651 652 </pre></div><p>You might never have to think about mergeinfo inheritance or encounter non-inheritable mergeinfo in your own repository. A discussion of the full ramifications of mergeinfo inheritance are beyond the scope of this book. If you have more questions check out some of the references mentioned in <a class="xref" href="#svn.branchmerge.advanced.finalword" title="The Final Word on Merge Tracking">the section called “The Final Word on Merge Tracking”</a></p></div><p>With the release of Subversion 1.7, the <span class="command"><strong>svn mergeinfo</strong></span> subcommand can also account for subtree mergeinfo and non-inheritable mergeinfo. It accounts for subtree mergeinfo by use of the <code class="option">--recursive</code> or <code class="option">--depth</code> options, while non-inheritable mergeinfo is considered by default.</p><p>Let's say we have a branch with both subtree and non-inheritable mergeinfo:</p><div class="informalexample"><pre class="screen"> $ svn propget svn:mergeinfo --recursive -v # Non-inheritable mergeinfo Properties on '.': svn:mergeinfo /trunk:651-652,758* # Subtree mergeinfo Properties on 'doc/INSTALL': svn:mergeinfo /trunk/doc/INSTALL:651-652,958,1060 </pre></div><p>From the above mergeinfo we see that r758 has only been merged into the root of the branch, but not any of the root's children. We also see that both r958 and r1060 have been merged only to the <code class="filename">doc/INSTALL</code> file. When we use <span class="command"><strong>svn mergeinfo</strong></span> with the <code class="option">--recursive</code> option to see what has been merged from <code class="filename">^/trunk</code> to this branch, we see two revisions are flagged with the <code class="literal">*</code> marker:</p><div class="informalexample"><pre class="screen"> $ svn mergeinfo --show-revs=merged ^/trunk . --recursive 651 652 758* 958* 1060 </pre></div><p>The <code class="literal">*</code> indicates revisions that are only <span class="emphasis"><em>partially</em></span> merged to the target in question (the meaning is the same if we are checking for eligible revisions). What this means in this example is that if we tried to merge r758 or r958 from <code class="filename">^/trunk</code> then more changes would result. Likewise, because r1060 is <span class="emphasis"><em>not</em></span> flagged with a <code class="literal">*</code>, we know that it only affects <code class="filename">doc/INSTALL</code> and that trying to merge it would have no result.<a href="#ftn.idm3987" class="footnote" id="idm3987"><sup class="footnote">[30]</sup></a></p><p>Another way to get a more precise preview of a merge operation is to use the <code class="option">--dry-run</code> option:</p><div class="informalexample"><pre class="screen"> $ svn merge ^/calc/trunk --dry-run --- Merging r391 through r395 into 'branch': U integer.c $ svn status # nothing printed, working copy is still unchanged. </pre></div><p>The <code class="option">--dry-run</code> option doesn't actually apply any local changes to the working copy. It shows only status codes that <span class="emphasis"><em>would</em></span> be printed in a real merge. It's useful for getting a <span class="quote">“<span class="quote">high-level</span>”</span> preview of the potential merge, for those times when running <span class="command"><strong>svn diff</strong></span> gives too much detail.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>After performing a merge operation, but before committing the results of the merge, you can use <strong class="userinput"><code>svn diff --depth=empty <em class="replaceable"><code>/path/to/merge/target</code></em></code></strong> to see only the changes to the immediate target of your merge. If your merge target was a directory, only property differences are displayed. This is a handy way to see the changes to the <code class="literal">svn:mergeinfo</code> property recorded by the merge operation, which will remind you about what you've just merged.</p></td></tr></table></div><p>Of course, the best way to preview a merge operation is to just do it! Remember, running <span class="command"><strong>svn merge</strong></span> isn't an inherently risky thing (unless you've made local modifications to your working copy—but we already stressed that you shouldn't merge into such an environment). If you don't like the results of the merge, simply run <strong class="userinput"><code>svn revert . -R</code></strong> to revert the changes from your working copy and retry the command with different options. The merge isn't final until you actually <span class="command"><strong>svn commit</strong></span> the results.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.basicmerging.undo"></a>Undoing Changes</h3></div></div></div><p>An extremely common use for <span class="command"><strong>svn merge</strong></span> is to roll back a change that has already been committed. Suppose you're working away happily on a working copy of <code class="filename">/calc/trunk</code>, and you discover that the change made way back in revision 303, which changed <code class="filename">integer.c</code>, is completely wrong. It never should have been committed. You can use <span class="command"><strong>svn merge</strong></span> to <span class="quote">“<span class="quote">undo</span>”</span> the change in your working copy, and then commit the local modification to the repository. All you need to do is to specify a <span class="emphasis"><em>reverse</em></span> difference. (You can do this by specifying <code class="option">--revision 303:302</code>, or by an equivalent <code class="option">--change -303</code>.)</p><div class="informalexample"><pre class="screen"> $ svn merge -c -303 ^/calc/trunk --- Reverse-merging r303 into 'integer.c': U integer.c --- Recording mergeinfo for reverse merge of r303 into 'integer.c': U A-branch $ svn status M . M integer.c $ svn diff … # verify that the change is removed … $ svn commit -m "Undoing change committed in r303." Sending integer.c Transmitting file data . Committed revision 350. </pre></div><p>As we mentioned earlier, one way to think about a repository revision is as a specific changeset. By using the <code class="option">-r</code> option, you can ask <span class="command"><strong>svn merge</strong></span> to apply a changeset, or a whole range of changesets, to your working copy. In our case of undoing a change, we're asking <span class="command"><strong>svn merge</strong></span> to apply changeset r303 to our working copy <span class="emphasis"><em>backward</em></span>.</p><p>Keep in mind that rolling back a change like this is just like any other <span class="command"><strong>svn merge</strong></span> operation, so you should use <span class="command"><strong>svn status</strong></span> and <span class="command"><strong>svn diff</strong></span> to confirm that your work is in the state you want it to be in, and then use <span class="command"><strong>svn commit</strong></span> to send the final version to the repository. After committing, this particular changeset is no longer reflected in the <code class="literal">HEAD</code> revision.</p><p>Again, you may be thinking: well, that really didn't undo the commit, did it? The change still exists in revision 303. If somebody checks out a version of the <code class="filename">calc</code> project between revisions 303 and 349, she'll still see the bad change, right?</p><p>Yes, that's true. When we talk about <span class="quote">“<span class="quote">removing</span>”</span> a change, we're really talking about removing it from the <code class="literal">HEAD</code> revision. The original change still exists in the repository's history. For most situations, this is good enough. Most people are only interested in tracking the <code class="literal">HEAD</code> of a project anyway. There are special cases, however, where you really might want to destroy all evidence of the commit. (Perhaps somebody accidentally committed a confidential document.) This isn't so easy, it turns out, because Subversion was deliberately designed to never lose information. Revisions are immutable trees that build upon one another. Removing a revision from history would cause a domino effect, creating chaos in all subsequent revisions and possibly invalidating all working copies.<a href="#ftn.idm4038" class="footnote" id="idm4038"><sup class="footnote">[31]</sup></a></p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.basicmerging.resurrect"></a>Resurrecting Deleted Items</h3></div></div></div><p>The great thing about version control systems is that information is never lost. Even when you delete a file or directory, it may be gone from the <code class="literal">HEAD</code> revision, but the object still exists in earlier revisions. One of the most common questions new users ask is, <span class="quote">“<span class="quote">How do I get my old file or directory back?</span>”</span></p><p>The first step is to define exactly <span class="emphasis"><em>which</em></span> item you're trying to resurrect. Here's a useful metaphor: you can think of every object in the repository as existing in a sort of two-dimensional coordinate system. The first coordinate is a particular revision tree, and the second coordinate is a path within that tree. So every version of your file or directory is defined by a specific coordinate pair. (Remember the <span class="quote">“<span class="quote">peg revision</span>”</span> syntax—foo.c@224—mentioned back in <a class="xref" href="#svn.advanced.pegrevs" title="Peg and Operative Revisions">the section called “Peg and Operative Revisions”</a>.)</p><p>First, you might need to use <span class="command"><strong>svn log</strong></span> to discover the exact coordinate pair you wish to resurrect. A good strategy is to run <strong class="userinput"><code>svn log --verbose</code></strong> in a directory that used to contain your deleted item. The <code class="option">--verbose</code> (<code class="option">-v</code>) option shows a list of all changed items in each revision; all you need to do is find the revision in which you deleted the file or directory. You can do this visually, or by using another tool to examine the log output (via <span class="command"><strong>grep</strong></span>, or perhaps via an incremental search in an editor).</p><div class="informalexample"><pre class="screen"> $ cd parent-dir $ svn log -v … ------------------------------------------------------------------------ r808 | joe | 2003-12-26 14:29:40 -0600 (Fri, 26 Dec 2003) | 3 lines Changed paths: D /calc/trunk/real.c M /calc/trunk/integer.c Added fast fourier transform functions to integer.c. Removed real.c because code now in double.c. … </pre></div><p>In the example, we're assuming that you're looking for a deleted file <code class="filename">real.c</code>. By looking through the logs of a parent directory, you've spotted that this file was deleted in revision 808. Therefore, the last version of the file to exist was in the revision right before that. Conclusion: you want to resurrect the path <code class="filename">/calc/trunk/real.c</code> from revision 807.</p><p>That was the hard part—the research. Now that you know what you want to restore, you have two different choices.</p><p>One option is to use <span class="command"><strong>svn merge</strong></span> to apply revision 808 <span class="quote">“<span class="quote">in reverse.</span>”</span> (We already discussed how to undo changes in <a class="xref" href="#svn.branchmerge.basicmerging.undo" title="Undoing Changes">the section called “Undoing Changes”</a>.) This would have the effect of re-adding <code class="filename">real.c</code> as a local modification. The file would be scheduled for addition, and after a commit, the file would again exist in <code class="literal">HEAD</code>.</p><p>In this particular example, however, this is probably not the best strategy. Reverse-applying revision 808 would not only schedule <code class="filename">real.c</code> for addition, but the log message indicates that it would also undo certain changes to <code class="filename">integer.c</code>, which you don't want. Certainly, you could reverse-merge revision 808 and then <span class="command"><strong>svn revert</strong></span> the local modifications to <code class="filename">integer.c</code>, but this technique doesn't scale well. What if 90 files were changed in revision 808?</p><p>A second, more targeted strategy is not to use <span class="command"><strong>svn merge</strong></span> at all, but rather to use the <span class="command"><strong>svn copy</strong></span> command. Simply copy the exact revision and path <span class="quote">“<span class="quote">coordinate pair</span>”</span> from the repository to your working copy:</p><div class="informalexample"><pre class="screen"> $ svn copy ^/calc/trunk/real.c@807 ./real.c $ svn status A + real.c $ svn commit -m "Resurrected real.c from revision 807, /calc/trunk/real.c." Adding real.c Transmitting file data . Committed revision 1390. </pre></div><p>The plus sign in the status output indicates that the item isn't merely scheduled for addition, but scheduled for addition <span class="quote">“<span class="quote">with history.</span>”</span> Subversion remembers where it was copied from. In the future, running <span class="command"><strong>svn log</strong></span> on this file will traverse back through the file's resurrection and through all the history it had prior to revision 807. In other words, this new <code class="filename">real.c</code> isn't really new; it's a direct descendant of the original, deleted file. This is usually considered a good and useful thing. If, however, you wanted to resurrect the file <span class="emphasis"><em>without</em></span> maintaining a historical link to the old file, this technique works just as well:</p><div class="informalexample"><pre class="screen"> $ svn cat ^/calc/trunk/real.c@807 &gt; ./real.c $ svn add real.c A real.c $ svn commit -m "Re-created real.c from revision 807." Adding real.c Transmitting file data . Committed revision 1390. </pre></div><p>Although our example shows us resurrecting a file, note that these same techniques work just as well for resurrecting deleted directories. Also note that a resurrection doesn't have to happen in your working copy—it can happen entirely in the repository:</p><div class="informalexample"><pre class="screen"> $ svn copy ^/calc/trunk/real.c@807 ^/calc/trunk/ \ -m "Resurrect real.c from revision 807." Committed revision 1390. $ svn update Updating '.': A real.c Updated to revision 1390. </pre></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.branchmerge.advanced"></a>Advanced Merging</h2></div></div></div><p>Here ends the automated magic. Sooner or later, once you get the hang of branching and merging, you're going to have to ask Subversion to merge <span class="emphasis"><em>specific</em></span> changes from one place to another. To do this, you're going to have to start passing more complicated arguments to <span class="command"><strong>svn merge</strong></span>. The next section describes the fully expanded syntax of the command and discusses a number of common scenarios that require it.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.cherrypicking"></a>Cherrypicking</h3></div></div></div><p>Just as the term <span class="quote">“<span class="quote">changeset</span>”</span> is often used in version control systems, so is the term <em class="firstterm">cherrypicking</em>. This word refers to the act of choosing <span class="emphasis"><em>one</em></span> specific changeset from a branch and replicating it to another. Cherrypicking may also refer to the act of duplicating a particular set of (not necessarily contiguous!) changesets from one branch to another. This is in contrast to more typical merging scenarios, where the <span class="quote">“<span class="quote">next</span>”</span> contiguous range of revisions is duplicated automatically.</p><p>Why would people want to replicate just a single change? It comes up more often than you'd think. For example, let's go back in time and imagine that you haven't yet merged your private feature branch back to the trunk. At the water cooler, you get word that Sally made an interesting change to <code class="filename">integer.c</code> on the trunk. Looking over the history of commits to the trunk, you see that in revision 355 she fixed a critical bug that directly impacts the feature you're working on. You might not be ready to merge all the trunk changes to your branch just yet, but you certainly need that particular bug fix in order to continue your work.</p><div class="informalexample"><pre class="screen"> $ svn diff -c 355 ^/calc/trunk Index: integer.c =================================================================== --- integer.c (revision 354) +++ integer.c (revision 355) @@ -147,7 +147,7 @@ case 6: sprintf(info-&gt;operating_system, "HPFS (OS/2 or NT)"); break; case 7: sprintf(info-&gt;operating_system, "Macintosh"); break; case 8: sprintf(info-&gt;operating_system, "Z-System"); break; - case 9: sprintf(info-&gt;operating_system, "CP/MM"); + case 9: sprintf(info-&gt;operating_system, "CP/M"); break; case 10: sprintf(info-&gt;operating_system, "TOPS-20"); break; case 11: sprintf(info-&gt;operating_system, "NTFS (Windows NT)"); break; case 12: sprintf(info-&gt;operating_system, "QDOS"); break; </pre></div><p>Just as you used <span class="command"><strong>svn diff</strong></span> in the prior example to examine revision 355, you can pass the same option to <span class="command"><strong>svn merge</strong></span>:</p><div class="informalexample"><pre class="screen"> $ svn merge -c 355 ^/calc/trunk --- Merging r355 into '.': U integer.c --- Recording mergeinfo for merge of r355 into '.': U . $ svn status M integer.c </pre></div><p>You can now go through the usual testing procedures before committing this change to your branch. After the commit, Subversion marks r355 as having been merged to the branch so that future <span class="quote">“<span class="quote">magic</span>”</span> merges that synchronize your branch with the trunk know to skip over r355. (Merging the same change to the same branch almost always results in a conflict!)</p><div class="informalexample"><pre class="screen"> $ cd my-calc-branch $ svn propget svn:mergeinfo . /trunk:341-349,355 # Notice that r355 isn't listed as "eligible" to merge, because # it's already been merged. $ svn mergeinfo ^/calc/trunk --show-revs eligible r350 r351 r352 r353 r354 r356 r357 r358 r359 r360 $ svn merge ^/calc/trunk --- Merging r350 through r354 into '.': U . U integer.c U Makefile --- Merging r356 through r360 into '.': U . U integer.c U button.c --- Recording mergeinfo for merge of r350 through r360 into '.': U . </pre></div><p>This use case of replicating (or <em class="firstterm">backporting</em>) bug fixes from one branch to another is perhaps the most popular reason for cherrypicking changes; it comes up all the time, for example, when a team is maintaining a <span class="quote">“<span class="quote">release branch</span>”</span> of software. (We discuss this pattern in <a class="xref" href="#svn.branchmerge.commonpatterns.release" title="Release Branches">the section called “Release Branches”</a>.)</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Did you notice how, in the last example, the merge invocation merged two distinct ranges? The <span class="command"><strong>svn merge</strong></span> command applied two independent patches to your working copy to skip over changeset 355, which your branch already contained. There's nothing inherently wrong with this, except that it has the potential to make conflict resolution trickier. If the first range of changes creates conflicts, you <span class="emphasis"><em>must</em></span> resolve them interactively for the merge process to continue and apply the second range of changes. If you postpone a conflict from the first wave of changes, the whole merge command will bail out with an error message.<a href="#ftn.idm4122" class="footnote" id="idm4122"><sup class="footnote">[32]</sup></a></p></td></tr></table></div><p>A word of warning: while <span class="command"><strong>svn diff</strong></span> and <span class="command"><strong>svn merge</strong></span> are very similar in concept, they do have different syntax in many cases. Be sure to read about them in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a> for details, or ask <span class="command"><strong>svn help</strong></span>. For example, <span class="command"><strong>svn merge</strong></span> requires a working copy path as a target, that is, a place where it should apply the generated patch. If the target isn't specified, it assumes you are trying to perform one of the following common operations:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>You want to merge directory changes into your current working directory.</p></li><li class="listitem"><p>You want to merge the changes in a specific file into a file by the same name that exists in your current working directory.</p></li></ul></div><p>If you are merging a directory and haven't specified a target path, <span class="command"><strong>svn merge</strong></span> assumes the first case and tries to apply the changes into your current directory. If you are merging a file, and that file (or a file by the same name) exists in your current working directory, <span class="command"><strong>svn merge</strong></span> assumes the second case and tries to apply the changes to a local file with the same name.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.advanced.advancedsyntax"></a>Merge Syntax: Full Disclosure</h3></div></div></div><p>You've now seen some examples of the <span class="command"><strong>svn merge</strong></span> command, and you're about to see several more. If you're feeling confused about exactly how merging works, you're not alone. Many users (especially those new to version control) are initially perplexed about the proper syntax of the command and about how and when the feature should be used. But fear not, this command is actually much simpler than you think! There's a very easy technique for understanding exactly how <span class="command"><strong>svn merge</strong></span> behaves.</p><p>The main source of confusion is the <span class="emphasis"><em>name</em></span> of the command. The term <span class="quote">“<span class="quote">merge</span>”</span> somehow denotes that branches are combined together, or that some sort of mysterious blending of data is going on. That's not the case. A better name for the command might have been <span class="command"><strong>svn diff-and-apply</strong></span>, because that's all that happens: two repository trees are compared, and the differences are applied to a working copy.</p><p>If you're using <span class="command"><strong>svn merge</strong></span> to do basic copying of changes between branches, it will generally do the right thing automatically. For example, a command such as the following:</p><div class="informalexample"><pre class="screen"> $ svn merge ^/calc/branches/some-branch </pre></div><p>will attempt to duplicate any changes made on <code class="filename">some-branch</code> into your current working directory, which is presumably a working copy that shares some historical connection to the branch. The command is smart enough to only duplicate changes that your working copy doesn't yet have. If you repeat this command once a week, it will only duplicate the <span class="quote">“<span class="quote">newest</span>”</span> branch changes that happened since you last merged.</p><p>If you choose to use the <span class="command"><strong>svn merge</strong></span> command in all its full glory by giving it specific revision ranges to duplicate, the command takes three main arguments:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>An initial repository tree (often called the <em class="firstterm">left side</em> of the comparison)</p></li><li class="listitem"><p>A final repository tree (often called the <em class="firstterm">right side</em> of the comparison)</p></li><li class="listitem"><p>A working copy to accept the differences as local changes (often called the <em class="firstterm">target</em> of the merge)</p></li></ol></div><p>Once these three arguments are specified, then the two trees are compared and the differences applied to the target working copy as local modifications. When the command is done, the results are no different than if you had hand-edited the files or run various <span class="command"><strong>svn add</strong></span> or <span class="command"><strong>svn delete</strong></span> commands yourself. If you like the results, you can commit them. If you don't like the results, you can simply <span class="command"><strong>svn revert</strong></span> all of the changes.</p><p>The syntax of <span class="command"><strong>svn merge</strong></span> allows you to specify the three necessary arguments rather flexibly. Here are some examples:</p><div class="informalexample"><pre class="screen"> $ svn merge http://svn.example.com/repos/branch1@150 \ http://svn.example.com/repos/branch2@212 \ my-working-copy $ svn merge -r 100:200 http://svn.example.com/repos/trunk my-working-copy $ svn merge -r 100:200 http://svn.example.com/repos/trunk </pre></div><p>The first syntax lays out all three arguments explicitly, naming each tree in the form <span class="emphasis"><em>URL@REV</em></span> and naming the working copy target. The second syntax is used as a shorthand for situations when you're comparing two different revisions of the same URL. The last syntax shows how the working copy argument is optional; if omitted, it defaults to the current directory.</p><p>While the first example shows the <span class="quote">“<span class="quote">full</span>”</span> syntax of <span class="command"><strong>svn merge</strong></span>, use it very carefully; it can result in merges which do not record any <code class="literal">svn:mergeinfo</code> metadata at all. The next section talks a bit more about this.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.nomergedata"></a>Merges Without Mergeinfo</h3></div></div></div><p>Subversion tries to generate merge metadata whenever it can, to make future invocations of <span class="command"><strong>svn merge</strong></span> smarter. There are still situations, however, where <code class="literal">svn:mergeinfo</code> data is not created or changed. Remember to be a bit wary of these scenarios:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">Merging unrelated sources</span></dt><dd><p>If you ask <span class="command"><strong>svn merge</strong></span> to compare two URLs that aren't related to each other, a patch is still generated and applied to your working copy, but no merging metadata is created. There's no common history between the two sources, and future <span class="quote">“<span class="quote">smart</span>”</span> merges depend on that common history.</p></dd><dt><span class="term">Merging from foreign repositories</span></dt><dd><p>While it's possible to run a command such as <strong class="userinput"><code>svn merge -r 100:200 <em class="replaceable"><code>http://svn.foreignproject.com/repos/trunk</code></em></code></strong>, the resultant patch also lacks any historical merge metadata. At the time of this writing, Subversion has no way of representing different repository URLs within the <code class="literal">svn:mergeinfo</code> property.</p></dd><dt><span class="term">Using <code class="option">--ignore-ancestry</code></span></dt><dd><p>If this option is passed to <span class="command"><strong>svn merge</strong></span>, it causes the merging logic to mindlessly generate differences the same way that <span class="command"><strong>svn diff</strong></span> does, ignoring any historical relationships. We discuss this later in this chapter in <a class="xref" href="#svn.branchmerge.advanced.ancestry" title="Noticing or Ignoring Ancestry">the section called “Noticing or Ignoring Ancestry”</a>.</p></dd><dt><span class="term">Applying reverse merges from a target's natural history</span></dt><dd><p>Earlier in this chapter (<a class="xref" href="#svn.branchmerge.basicmerging.undo" title="Undoing Changes">the section called “Undoing Changes”</a>) we discussed how to use <span class="command"><strong>svn merge</strong></span> to apply a <span class="quote">“<span class="quote">reverse patch</span>”</span> as a way of rolling back changes. If this technique is used to undo a change to an object's personal history (e.g., commit r5 to the trunk, then immediately roll back r5 using <strong class="userinput"><code>svn merge . -c -5</code></strong>), this sort of merge doesn't affect the recorded mergeinfo.<a href="#ftn.idm4215" class="footnote" id="idm4215"><sup class="footnote">[33]</sup></a></p></dd></dl></div><div class="sidebar"><a id="svn.branchmerge.nomergedata.impicit.mergeinfo"></a><div class="titlepage"><div><div><p class="title"><strong>Natural History and Implicit Mergeinfo</strong></p></div></div></div><p>As we mentioned earlier when discussing <a class="xref" href="#svn.branchmerge.basicmerging.mergeinfo.inheritance" title="Mergeinfo Inheritance">Mergeinfo Inheritance</a>, a path that has the <code class="literal">svn:mergeinfo</code> property set on it is said to have <span class="quote">“<span class="quote">explicit</span>”</span> mergeinfo. Yes, this implies a path can have <span class="quote">“<span class="quote">implicit</span>”</span> mergeinfo, too! Implicit mergeinfo, or <em class="firstterm">natural history</em>, is simply a path's own history (see <a class="xref" href="#svn.tour.history" title="Examining History">the section called “Examining History”</a>) interpreted as mergeinfo. While implicit mergeinfo is largely an implementation detail, it can be a useful abstraction for understanding merge tracking behavior.</p><p>Let's say you created <code class="filename">^/trunk</code> in revision 100 and then later, in revision 201, created <code class="filename">^/branches/feature-branch</code> as a copy of <code class="filename">^/trunk@200</code>. The natural history of <code class="filename">^/branches/feature-branch</code> contains all the repository paths and revision ranges through which the history of the new branch has ever passed:</p><div class="informalexample"><div class="literallayout"><p><br></br> /trunk:100-200<br></br> /branches/feature-branch:201<br></br> </p></div></div><p>With each new revision added to the repository, the natural history—and thus, implicit mergeinfo—of the branch continues to expand to include those revisions until the day the branch is deleted. Here's what the implicit mergeinfo of our branch would look like when the <code class="literal">HEAD</code> revision of the repository had grown to 234:</p><div class="informalexample"><div class="literallayout"><p><br></br> /trunk:100-200<br></br> /branches/feature-branch:201-234<br></br> </p></div></div><p>Implicit mergeinfo does not actually show up in the <code class="literal">svn:mergeinfo</code> property, but Subversion acts as if it does. This is why if you check out <code class="filename">^/branches/feature-branch</code> and then run <strong class="userinput"><code>svn merge ^/trunk -c 58</code></strong> in the resulting working copy, nothing happens. Subversion knows that the changes committed to <code class="filename">^/trunk</code> in revision 58 are already present in the target's natural history, so there's no need to try to merge them again. After all, avoiding repeated merges of changes <span class="emphasis"><em>is</em></span> the primary goal of Subversion's merge tracking feature!</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.advanced.mergeconflicts"></a>More on Merge Conflicts</h3></div></div></div><p>Just like the <span class="command"><strong>svn update</strong></span> command, <span class="command"><strong>svn merge</strong></span> applies changes to your working copy. And therefore it's also capable of creating conflicts. The conflicts produced by <span class="command"><strong>svn merge</strong></span>, however, are sometimes different, and this section explains those differences.</p><p>To begin with, assume that your working copy has no local edits. When you <span class="command"><strong>svn update</strong></span> to a particular revision, the changes sent by the server always apply <span class="quote">“<span class="quote">cleanly</span>”</span> to your working copy. The server produces the delta by comparing two trees: a virtual snapshot of your working copy, and the revision tree you're interested in. Because the left hand side of the comparison is exactly equal to what you already have, the delta is guaranteed to correctly convert your working copy into the right hand tree.</p><p>But <span class="command"><strong>svn merge</strong></span> has no such guarantees and can be much more chaotic: the advanced user can ask the server to compare <span class="emphasis"><em>any</em></span> two trees at all, even ones that are unrelated to the working copy! This means there's large potential for human error. Users will sometimes compare the wrong two trees, creating a delta that doesn't apply cleanly. The <span class="command"><strong>svn merge</strong></span> subcommand does its best to apply as much of the delta as possible, but some parts may be impossible. A common sign that you merged the wrong delta is unexpected tree conflicts:</p><div class="informalexample"><pre class="screen"> $ svn merge -r 1288:1351 http://svn.example.com/myrepos/branch --- Merging r1289 through r1351 into '.': C bar.c C foo.c C docs --- Recording mergeinfo for merge of r1289 through r1351 into '.': U . Summary of conflicts: Tree conflicts: 3 $ svn st ! C bar.c &gt; local missing, incoming edit upon merge ! C foo.c &gt; local missing, incoming edit upon merge ! C docs &gt; local delete, incoming edit upon merge </pre></div><p>In the previous example, it might be the case that <code class="filename">bar.c</code>, <code class="filename">foo.c</code>, and <code class="filename">docs</code> all exist in both snapshots of the branch being compared. The resultant delta wants to change the contents of the corresponding paths in your working copy, but those paths don't exist in the working copy. Whatever the case, the preponderance of tree conflicts most likely means that the user compared the wrong two trees; it's a classic sign of user error. When this happens, it's easy to recursively revert all the changes created by the merge (<strong class="userinput"><code>svn revert . --recursive</code></strong>), delete any unversioned files or directories left behind after the revert, and rerun <span class="command"><strong>svn merge</strong></span> with the correct arguments.</p><p>Also keep in mind that a merge into a working copy with no local edits can still produce text conflicts.</p><div class="informalexample"><pre class="screen"> $ svn merge -c 1701 http://svn.example.com/myrepos/branchX --accept postpone --- Merging r1701 into '.': C glub.c C sputter.c --- Recording mergeinfo for merge of r1701 into '.': U . Summary of conflicts: Text conflicts: 2 C:\SVN\src-branch-1.7.x&gt;svn st M . ? glub.c.merge-left.r1700 ? glub.c.merge-right.r1701 C glub.c ? glub.c.working ? sputter.c.merge-left.r1700 ? sputter.c.merge-right.r1701 C sputter.c ? sputter.c.working Summary of conflicts: Text conflicts: 2 </pre></div><p>How can a conflict possibly happen? Again, because the user can request <span class="command"><strong>svn merge</strong></span> to define and apply any old delta to the working copy, that delta may contain textual changes that don't cleanly apply to a working file, even if the file has no local modifications.</p><p>Another small difference between <span class="command"><strong>svn update</strong></span> and <span class="command"><strong>svn merge</strong></span> is the names of the full-text files created when a conflict happens. In <a class="xref" href="#svn.tour.cycle.resolve" title="Resolve Any Conflicts">the section called “Resolve Any Conflicts”</a>, we saw that an update produces files named <code class="filename">filename.mine</code>, <code class="filename">filename.rOLDREV</code>, and <code class="filename">filename.rNEWREV</code>. When <span class="command"><strong>svn merge</strong></span> produces a conflict, though, it creates three files named <code class="filename">filename.working</code>, <code class="filename">filename.merge-left.rOLDREV</code>, and <code class="filename">filename.merge-right.rNEWREV</code>. In this case, the terms <span class="quote">“<span class="quote">merge-left</span>”</span> and <span class="quote">“<span class="quote">merge-right</span>”</span> are describing which side of the double-tree comparison the file came from, <span class="quote">“<span class="quote">rOLDREV</span>”</span> describes the revision of the left side, and <span class="quote">“<span class="quote">rNEWREV</span>”</span> the revision of the right side. In any case, these differing names help you distinguish between conflicts that happened as a result of an update and ones that happened as a result of a merge.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.advanced.blockchanges"></a>Blocking Changes</h3></div></div></div><p>Sometimes there's a particular changeset that you don't want automatically merged. For example, perhaps your team's policy is to do new development work on <code class="filename">/trunk</code>, but is more conservative about backporting changes to a stable branch you use for releasing to the public. On one extreme, you can manually cherrypick single changesets from the trunk to the branch—just the changes that are stable enough to pass muster. Maybe things aren't quite that strict, though; perhaps most of the time you just let <span class="command"><strong>svn merge</strong></span> automatically merge most changes from trunk to branch. In this case, you want a way to mask a few specific changes out, that is, prevent them from ever being automatically merged.</p><p>Through Subversion 1.7, the only way to block a changeset is to make the system believe that the change has <span class="emphasis"><em>already</em></span> been merged. To do this, invoke the merge subcommand with the <code class="option">--record-only</code> option:</p><div class="informalexample"><pre class="screen"> $ cd my-calc-branch $ svn propget svn:mergeinfo . /trunk:1680-3305 # Let's make the metadata list r3328 as already merged. $ svn merge -c 3328 --record-only ^/calc/trunk --- Recording mergeinfo for merge of r3328 into '.': U . $ svn status M . $ svn propget svn:mergeinfo . /trunk:1680-3305,3328 $ svn commit -m "Block r3328 from being merged to the branch." … </pre></div><p>Beginning with Subversion 1.7, <code class="option">--record-only</code> merges are transitive. This means that, in addition to recording mergeinfo describing the blocked revision(s), any <code class="literal">svn:mergeinfo</code> property differences in the merge source are also applied. For example, let's say we want to block the 'frazzle' feature from ever being merged from <code class="filename">^/trunk</code> to our <code class="filename">^/branches/proj-X</code> branch. We know that all the frazzle work was done on its own branch, which was reintegrated to <code class="filename">trunk</code> in revision 1055:</p><div class="informalexample"><pre class="screen"> $ svn log -v ^/trunk -r 1055 ------------------------------------------------------------------------ r1055 | francesca | 2011-09-22 07:40:06 -0400 (Thu, 22 Sep 2011) | 3 lines Changed paths: M /trunk M /trunk/src/frazzle.c Reintegrate the frazzle-feature-branch to trunk. </pre></div><p>Because revision 1055 was a reintegrate merge we know that mergeinfo was recorded describing the merge:</p><div class="informalexample"><pre class="screen"> $ svn diff ^/trunk -c 1055 --depth empty Index: . =================================================================== --- . (revision 1054) +++ . (revision 1055) Property changes on: . ___________________________________________________________________ Modified: svn:mergeinfo Merged /branches/frazzle-feature-branch:r997-1003 </pre></div><p>Now simply blocking merges of revision 1055 from <code class="filename">^/trunk</code> isn't foolproof since someone could merge r996:1003 directly from <code class="filename">^/branches/frazzle-feature-branch</code>. Fortunately the transitive nature of <code class="option">--record-only</code> merges in Subversion 1.7 prevents this; the <code class="option">--record-only</code> merge applies the <code class="literal">svn:mergeinfo</code> diff from revision 1055, thus blocking merges directly from the frazzle branch <span class="emphasis"><em>and</em></span> as it has always done prior to Subversion 1.7, it blocks merges of revision 1055 directly from <code class="filename">^/trunk</code>:</p><div class="informalexample"><pre class="screen"> $ cd branches/proj-X $ svn merge ^/trunk . -c 1055 --record-only --- Merging r1055 into '.': G . --- Recording mergeinfo for merge of r1055 into '.': G . $ svn diff --depth empty . Index: . =================================================================== --- . (revision 1070) +++ . (working copy) Property changes on: . ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r1055 Merged /branches/frazzle-feature-branch:r997-1003 </pre></div><p>Blocking changes with <code class="option">--record-only</code> works, but it's also a little bit dangerous. The main problem is that we're not clearly differentiating between the ideas of <span class="quote">“<span class="quote">I already have this change</span>”</span> and <span class="quote">“<span class="quote">I don't have this change, but don't currently want it.</span>”</span> We're effectively lying to the system, making it think that the change was previously merged. This puts the responsibility on you—the user—to remember that the change wasn't actually merged, it just wasn't wanted. There's no way to ask Subversion for a list of <span class="quote">“<span class="quote">blocked changelists.</span>”</span> If you want to track them (so that you can unblock them someday) you'll need to record them in a text file somewhere, or perhaps in an invented property.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.advanced.reintegratetwice"></a>Keeping a Reintegrated Branch Alive</h3></div></div></div><p>There is an alternative to destroying and re-creating a branch after reintegration. To understand why it works you need to understand why the branch is initially unfit for further use after it has been reintegrated.</p><p>Let's assume you created your branch in revision <span class="emphasis"><em>A</em></span>. While working on your branch, you created one or more revisions which made changes to the branch. Before reintegrating your branch back to trunk, you made a final merge from trunk to your branch, and committed the result of this merge as revision <span class="emphasis"><em>B</em></span>.</p><p>When reintegrating your branch into the trunk, you create a new revision <span class="emphasis"><em>X</em></span> which changes the trunk. The changes made to trunk in this revision <span class="emphasis"><em>X</em></span> are semantically equivalent to the changes you made to your branch between revisions <span class="emphasis"><em>A</em></span> and <span class="emphasis"><em>B</em></span>.</p><p>If you now try to merge outstanding changes from trunk to your branch, Subversion will consider changes made in revision <span class="emphasis"><em>X</em></span> as eligible for merging into the branch. However, since your branch already contains all the changes made in revision <span class="emphasis"><em>X</em></span>, merging these changes can result in spurious conflicts! These conflicts are often tree conflicts, especially if renames were made on the branch or the trunk while the branch was in development.</p><p>So what can be done about this? We need to make sure that Subversion does not try to merge revision <span class="emphasis"><em>X</em></span> into the branch. This is done using the <code class="option">--record-only</code> merge option, which was introduced in <a class="xref" href="#svn.branchmerge.advanced.blockchanges" title="Blocking Changes">the section called “Blocking Changes”</a>.</p><p>To carry out the record-only merge, get a working copy of the branch which was just reintegrated in revision <span class="emphasis"><em>X</em></span>, and merge just revision <span class="emphasis"><em>X</em></span> from trunk into your branch, making sure to use the <code class="option">--record-only</code> option.</p><p>This merge uses the cherry-picking merge syntax, which was introduced in <a class="xref" href="#svn.branchmerge.cherrypicking" title="Cherrypicking">the section called “Cherrypicking”</a>. Continuing with the running example from <a class="xref" href="#svn.branchemerge.basicmerging.reintegrate" title="Reintegrating a Branch">the section called “Reintegrating a Branch”</a>, where revision <span class="emphasis"><em>X</em></span> was revision 391:</p><div class="informalexample"><pre class="screen"> $ cd my-calc-branch $ svn update Updating '.': Updated to revision 393. $ svn merge --record-only -c 391 ^/calc/trunk --- Recording mergeinfo for merge of r391 into '.': U . $ svn commit -m "Block revision 391 from being merged into my-calc-branch." Sending . Committed revision 394. </pre></div><p>Now your branch is ready to soak up changes from the trunk again. After another sync of your branch to the trunk, you can even reintegrate the branch a second time. If necessary, you can do another record-only merge to keep the branch alive. Rinse and repeat.</p><p>It should now also be apparent why deleting the branch and re-creating it has the same effect as doing the above record-only merge. Because revision <span class="emphasis"><em>X</em></span> is part of the natural history (see the sidebar <a class="xref" href="#svn.branchmerge.nomergedata.impicit.mergeinfo" title="Natural History and Implicit Mergeinfo">Natural History and Implicit Mergeinfo</a>) of the newly created branch, Subversion will never attempt to merge revision <span class="emphasis"><em>X</em></span> into the branch, avoiding spurious conflicts.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.advanced.logblame"></a>Merge-Sensitive Logs and Annotations</h3></div></div></div><p>One of the main features of any version control system is to keep track of who changed what, and when they did it. The <span class="command"><strong>svn log</strong></span> and <span class="command"><strong>svn blame</strong></span> subcommands are just the tools for this: when invoked on individual files, they show not only the history of changesets that affected the file, but also exactly which user wrote which line of code, and when she did it.</p><p>When changes start getting replicated between branches, however, things start to get complicated. For example, if you were to ask <span class="command"><strong>svn log</strong></span> about the history of your feature branch, it would show exactly every revision that ever affected the branch:</p><div class="informalexample"><pre class="screen"> $ cd my-calc-branch $ svn log -q ------------------------------------------------------------------------ r390 | user | 2002-11-22 11:01:57 -0600 (Fri, 22 Nov 2002) ------------------------------------------------------------------------ r388 | user | 2002-11-21 05:20:00 -0600 (Thu, 21 Nov 2002) ------------------------------------------------------------------------ r381 | user | 2002-11-20 15:07:06 -0600 (Wed, 20 Nov 2002) ------------------------------------------------------------------------ r359 | user | 2002-11-19 19:19:20 -0600 (Tue, 19 Nov 2002) ------------------------------------------------------------------------ r357 | user | 2002-11-15 14:29:52 -0600 (Fri, 15 Nov 2002) ------------------------------------------------------------------------ r343 | user | 2002-11-07 13:50:10 -0600 (Thu, 07 Nov 2002) ------------------------------------------------------------------------ r341 | user | 2002-11-03 07:17:16 -0600 (Sun, 03 Nov 2002) ------------------------------------------------------------------------ r303 | sally | 2002-10-29 21:14:35 -0600 (Tue, 29 Oct 2002) ------------------------------------------------------------------------ r98 | sally | 2002-02-22 15:35:29 -0600 (Fri, 22 Feb 2002) ------------------------------------------------------------------------ </pre></div><p>But is this really an accurate picture of all the changes that happened on the branch? What's left out here is the fact that revisions 390, 381, and 357 were actually the results of merging changes from the trunk. If you look at one of these logs in detail, the multiple trunk changesets that comprised the branch change are nowhere to be seen:</p><div class="informalexample"><pre class="screen"> $ svn log -v -r 390 ------------------------------------------------------------------------ r390 | user | 2002-11-22 11:01:57 -0600 (Fri, 22 Nov 2002) | 1 line Changed paths: M /branches/my-calc-branch/button.c M /branches/my-calc-branch/README Final merge of trunk changes to my-calc-branch. </pre></div><p>We happen to know that this merge to the branch was nothing but a merge of trunk changes. How can we see those trunk changes as well? The answer is to use the <code class="option">--use-merge-history</code> (<code class="option">-g</code>) option. This option expands those <span class="quote">“<span class="quote">child</span>”</span> changes that were part of the merge.</p><div class="informalexample"><pre class="screen"> $ svn log -v -r 390 -g ------------------------------------------------------------------------ r390 | user | 2002-11-22 11:01:57 -0600 (Fri, 22 Nov 2002) | 1 line Changed paths: M /branches/my-calc-branch/button.c M /branches/my-calc-branch/README Final merge of trunk changes to my-calc-branch. ------------------------------------------------------------------------ r383 | sally | 2002-11-21 03:19:00 -0600 (Thu, 21 Nov 2002) | 2 lines Changed paths: M /branches/my-calc-branch/button.c Merged via: r390 Fix inverse graphic error on button. ------------------------------------------------------------------------ r382 | sally | 2002-11-20 16:57:06 -0600 (Wed, 20 Nov 2002) | 2 lines Changed paths: M /branches/my-calc-branch/README Merged via: r390 Document my last fix in README. </pre></div><p>By making the log operation use merge history, we see not just the revision we queried (r390), but also the two revisions that came along on the ride with it—a couple of changes made by Sally to the trunk. This is a much more complete picture of history!</p><p>The <span class="command"><strong>svn blame</strong></span> command also takes the <code class="option">--use-merge-history</code> (<code class="option">-g</code>) option. If this option is neglected, somebody looking at a line-by-line annotation of <code class="filename">button.c</code> may get the mistaken impression that you were responsible for the lines that fixed a certain error:</p><div class="informalexample"><pre class="screen"> $ svn blame button.c … 390 user retval = inverse_func(button, path); 390 user return retval; 390 user } … </pre></div><p>And while it's true that you did actually commit those three lines in revision 390, two of them were actually written by Sally back in revision 383:</p><div class="informalexample"><pre class="screen"> $ svn blame button.c -g … G 383 sally retval = inverse_func(button, path); G 383 sally return retval; 390 user } … </pre></div><p>Now we know who to <span class="emphasis"><em>really</em></span> blame for those two lines of code!</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.advanced.ancestry"></a>Noticing or Ignoring Ancestry</h3></div></div></div><p> <a id="idm4389" class="indexterm"></a> When conversing with a Subversion developer, you might very likely hear reference to the term <em class="firstterm">ancestry</em>. This word is used to describe the relationship between two objects in a repository: if they're related to each other, one object is said to be an ancestor of the other.</p><p>For example, suppose you commit revision 100, which includes a change to a file <code class="filename">foo.c</code>. Then <code class="filename">foo.c@99</code> is an <span class="quote">“<span class="quote">ancestor</span>”</span> of <code class="filename">foo.c@100</code>. On the other hand, suppose you commit the deletion of <code class="filename">foo.c</code> in revision 101, and then add a new file by the same name in revision 102. In this case, <code class="filename">foo.c@99</code> and <code class="filename">foo.c@102</code> may appear to be related (they have the same path), but in fact are completely different objects in the repository. They share no history or <span class="quote">“<span class="quote">ancestry.</span>”</span></p><p>The reason for bringing this up is to point out an important difference between <span class="command"><strong>svn diff</strong></span> and <span class="command"><strong>svn merge</strong></span>. The former command ignores ancestry, while the latter command is quite sensitive to it. For example, if you asked <span class="command"><strong>svn diff</strong></span> to compare revisions 99 and 102 of <code class="filename">foo.c</code>, you would see line-based diffs; the <span class="command"><strong>diff</strong></span> command is blindly comparing two paths. But if you asked <span class="command"><strong>svn merge</strong></span> to compare the same two objects, it would notice that they're unrelated and first attempt to delete the old file, then add the new file; the output would indicate a deletion followed by an add:</p><div class="informalexample"><pre class="screen"> D foo.c A foo.c </pre></div><p>Most merges involve comparing trees that are ancestrally related to one another; therefore, <span class="command"><strong>svn merge</strong></span> defaults to this behavior. Occasionally, however, you may want the <span class="command"><strong>merge</strong></span> command to compare two unrelated trees. For example, you may have imported two source-code trees representing different vendor releases of a software project (see <a class="xref" href="#svn.advanced.vendorbr" title="Vendor Branches">the section called “Vendor Branches”</a>). If you ask <span class="command"><strong>svn merge</strong></span> to compare the two trees, you'd see the entire first tree being deleted, followed by an add of the entire second tree! In these situations, you'll want <span class="command"><strong>svn merge</strong></span> to do a path-based comparison only, ignoring any relations between files and directories. Add the <code class="option">--ignore-ancestry</code> option to your <span class="command"><strong>merge</strong></span> command, and it will behave just like <span class="command"><strong>svn diff</strong></span>. (And conversely, the <code class="option">--notice-ancestry</code> option will cause <span class="command"><strong>svn diff</strong></span> to behave like the <span class="command"><strong>svn merge</strong></span> command.)</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>The <code class="option">--ignore-ancestry</code> option also disables <a class="xref" href="#svn.branchmerge.basicmerging.mergetracking" title="Merge Tracking">Merge Tracking</a>. This means that <code class="literal">svn:mergeinfo</code> is not considered when <span class="command"><strong>svn merge</strong></span> is determining what revisions to merge, nor is <code class="literal">svn:mergeinfo</code> recorded to describe the merge.</p></td></tr></table></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.advanced.moves"></a>Merges and Moves</h3></div></div></div><p>A common desire is to refactor source code, especially in Java-based software projects. Files and directories are shuffled around and renamed, often causing great disruption to everyone working on the project. Sounds like a perfect case to use a branch, doesn't it? Just create a branch, shuffle things around, and then merge the branch back to the trunk, right?</p><p>Alas, this scenario doesn't work so well right now and is considered one of Subversion's current weak spots. The problem is that Subversion's <span class="command"><strong>svn update</strong></span> command isn't as robust as it should be, particularly when dealing with copy and move operations.</p><p>When you use <span class="command"><strong>svn copy</strong></span> to duplicate a file, the repository remembers where the new file came from, but it fails to transmit that information to the client which is running <span class="command"><strong>svn update</strong></span> or <span class="command"><strong>svn merge</strong></span>. Instead of telling the client, <span class="quote">“<span class="quote">Copy that file you already have to this new location,</span>”</span> it sends down an entirely new file. This can lead to problems, especially because the same thing happens with renamed files. A lesser-known fact about Subversion is that it lacks <span class="quote">“<span class="quote">true renames</span>”</span>—the <span class="command"><strong>svn move</strong></span> command is nothing more than an aggregation of <span class="command"><strong>svn copy</strong></span> and <span class="command"><strong>svn delete</strong></span>.</p><p>For example, suppose that while working on your private branch, you rename <code class="filename">integer.c</code> to <code class="filename">whole.c</code>. Effectively you've created a new file in your branch that is a copy of the original file, and deleted the original file. Meanwhile, back on <code class="filename">trunk</code>, Sally has committed some improvements to <code class="filename">integer.c</code>. Now you decide to merge your branch to the trunk:</p><div class="informalexample"><pre class="screen"> $ cd calc/trunk $ svn merge --reintegrate ^/calc/branches/my-calc-branch --- Merging differences between repository URLs into '.': D integer.c A whole.c U . --- Recording mergeinfo for merge between repository URLs into '.': U . </pre></div><p>This doesn't look so bad at first glance, but it's also probably not what you or Sally expected. The merge operation has deleted the latest version of the <code class="filename">integer.c</code> file (the one containing Sally's latest changes), and blindly added your new <code class="filename">whole.c</code> file—which is a duplicate of the <span class="emphasis"><em>older</em></span> version of <code class="filename">integer.c</code>. The net effect is that merging your <span class="quote">“<span class="quote">rename</span>”</span> to the trunk has removed Sally's recent changes from the latest revision!</p><p>This isn't true data loss. Sally's changes are still in the repository's history, but it may not be immediately obvious that this has happened. The moral of this story is that until Subversion improves, be very careful about merging copies and renames from one branch to another.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.advanced.pre1.5clients"></a>Preventing Naïve Clients from Committing Merges</h3></div></div></div><p>If you've just upgraded your server to Subversion 1.5 or later, there's a risk that pre-1.5 Subversion clients can cause problems with <a class="xref" href="#svn.branchmerge.basicmerging.mergetracking" title="Merge Tracking">Merge Tracking</a>. This is because pre-1.5 clients don't support this feature; when one of these older clients performs <span class="command"><strong>svn merge</strong></span>, it doesn't modify the value of the <code class="literal">svn:mergeinfo</code> property at all. So the subsequent commit, despite being the result of a merge, doesn't tell the repository about the duplicated changes—that information is lost. Later on, when <span class="quote">“<span class="quote">merge-aware</span>”</span> clients attempt automatic merging, they're likely to run into all sorts of conflicts resulting from repeated merges.</p><p>If you and your team are relying on the merge-tracking features of Subversion, you may want to configure your repository to prevent older clients from committing changes. The easy way to do this is by inspecting the <span class="quote">“<span class="quote">capabilities</span>”</span> parameter in the start-commit hook script. If the client reports itself as having <code class="literal">mergeinfo</code> capabilities, the hook script can allow the commit to start. If the client doesn't report that capability, have the hook deny the commit. <a class="xref" href="#svn.branchmerge.advanced.hook-ex1" title="Example 4.1. Merge-tracking gatekeeper start-commit hook script">Example 4.1, “Merge-tracking gatekeeper start-commit hook script”</a> gives an example of such a hook script:</p><div class="example"><a id="svn.branchmerge.advanced.hook-ex1"></a><p class="title"><strong>Example 4.1. Merge-tracking gatekeeper start-commit hook script</strong></p><div class="example-contents"><pre class="programlisting"> #!/usr/bin/env python import sys # The start-commit hook is invoked before a Subversion txn is created # in the process of doing a commit. Subversion runs this hook # by invoking a program (script, executable, binary, etc.) named # 'start-commit' (for which this file is a template) # with the following ordered arguments: # # [1] REPOS-PATH (the path to this repository) # [2] USER (the authenticated user attempting to commit) # [3] CAPABILITIES (a colon-separated list of capabilities reported # by the client; see note below) capabilities = sys.argv[3].split(':') if "mergeinfo" not in capabilities: sys.stderr.write("Commits from merge-tracking-unaware clients are " "not permitted. Please upgrade to Subversion 1.5 " "or newer.\n") sys.exit(1) sys.exit(0) </pre></div></div><br class="example-break"></br><p>For more information about hook scripts, see <a class="xref" href="#svn.reposadmin.create.hooks" title="Implementing Repository Hooks">the section called “Implementing Repository Hooks”</a>.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.advanced.finalword"></a>The Final Word on Merge Tracking</h3></div></div></div><p>The bottom line is that Subversion's merge-tracking feature has an extremely complex internal implementation, and the <code class="literal">svn:mergeinfo</code> property is the only window the user has into the machinery.</p><p>Sometimes mergeinfo will appear on paths that you didn't expect to be touched by an operation. Sometimes mergeinfo won't be generated at all, when you expect it to. Furthermore, the management of mergeinfo metadata has a whole set of taxonomies and behaviors around it, such as <span class="quote">“<span class="quote">explicit</span>”</span> versus <span class="quote">“<span class="quote">implicit</span>”</span> mergeinfo, <span class="quote">“<span class="quote">operative</span>”</span> versus <span class="quote">“<span class="quote">inoperative</span>”</span> revisions, specific mechanisms of mergeinfo <span class="quote">“<span class="quote">elision,</span>”</span> and even <span class="quote">“<span class="quote">inheritance</span>”</span> from parent to child directories.</p><p>We've chosen to only briefly cover, if at all, these detailed topics for a couple of reasons. First, the level of detail is absolutely overwhelming for a typical user. Second, and more importantly, the typical user <span class="emphasis"><em>shouldn't</em></span> have to understand these concepts; they should typically remain in the background as pesky implementation details. All that said, if you enjoy this sort of thing, you can get a fantastic overview in a paper posted at CollabNet's website (now mirrored on the Subversion website): <a class="ulink" href="https://subversion.apache.org/blog/2008-05-06-merge-info.html" target="_top">https://subversion.apache.org/blog/2008-05-06-merge-info.html</a>.</p><p>For now, if you want to steer clear of the complexities of merge tracking, we recommend that you follow these simple best practices:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>For short-term feature branches, follow the simple procedure described throughout <a class="xref" href="#svn.branchmerge.basicmerging" title="Basic Merging">the section called “Basic Merging”</a>.</p></li><li class="listitem"><p>Avoid subtree merges and subtree mergeinfo, perform merges only on the root of your branches, not on subdirectories or files (see <a class="xref" href="#svn.branchemerge.basicmerging.stayinsync.subtree" title="Subtree Merges and Subtree Mergeinfo">the section called “Subtree Merges and Subtree Mergeinfo”</a>) .</p></li><li class="listitem"><p>Don't ever edit the <code class="literal">svn:mergeinfo</code> property directly; use <span class="command"><strong>svn merge</strong></span> with the <code class="option">--record-only</code> option to effect a desired change to the metadata (as demonstrated in <a class="xref" href="#svn.branchmerge.advanced.blockchanges" title="Blocking Changes">the section called “Blocking Changes”</a>).</p></li><li class="listitem"><p>Your merge target should be a working copy which represents the root of a <span class="emphasis"><em>complete</em></span> tree representing a <span class="emphasis"><em>single</em></span> location in the repository at a single point in time: </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>Don't use the <code class="option">--allow-mixed-revisions</code> option to merge into mixed-revision working copies.</p></li><li class="listitem"><p>Don't merge to targets with <span class="quote">“<span class="quote">switched</span>”</span> subdirectories (as described next in <a class="xref" href="#svn.branchmerge.switchwc" title="Traversing Branches">the section called “Traversing Branches”</a>).</p></li><li class="listitem"><p>Avoid merges to targets with sparse directories. Likewise, don't merge to depths other than <code class="option">--depth=infinity</code></p></li><li class="listitem"><p>Be sure you have read access to all of the merge source and read/write access to all of the merge target.</p></li></ul></div><p> </p></li></ul></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.branchmerge.switchwc"></a>Traversing Branches</h2></div></div></div><p>The <span class="command"><strong>svn switch</strong></span> command transforms an existing working copy to reflect a different branch. While this command isn't strictly necessary for working with branches, it provides a nice shortcut. In one of our earlier examples, after creating your private branch, you checked out a fresh working copy of the new repository directory. Instead, you can simply ask Subversion to change your working copy of <code class="filename">/calc/trunk</code> to mirror the new branch location:</p><div class="informalexample"><pre class="screen"> $ cd calc $ svn info | grep URL URL: http://svn.example.com/repos/calc/trunk $ svn switch ^/calc/branches/my-calc-branch U integer.c U button.c U Makefile Updated to revision 341. $ svn info | grep URL URL: http://svn.example.com/repos/calc/branches/my-calc-branch </pre></div><p><span class="quote">“<span class="quote">Switching</span>”</span> a working copy that has no local modifications to a different branch results in the working copy looking just as it would if you'd done a fresh checkout of the directory. It's usually more efficient to use this command, because often branches differ by only a small degree. The server sends only the minimal set of changes necessary to make your working copy reflect the branch directory.</p><p>The <span class="command"><strong>svn switch</strong></span> command also takes a <code class="option">--revision</code> (<code class="option">-r</code>) option, so you need not always move your working copy to the <code class="literal">HEAD</code> of the branch.</p><p>Of course, most projects are more complicated than our <code class="filename">calc</code> example, and contain multiple subdirectories. Subversion users often follow a specific algorithm when using branches:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Copy the project's entire <span class="quote">“<span class="quote">trunk</span>”</span> to a new branch directory.</p></li><li class="listitem"><p>Switch only <span class="emphasis"><em>part</em></span> of the trunk working copy to mirror the branch.</p></li></ol></div><p>In other words, if a user knows that the branch work needs to happen on only a specific subdirectory, she uses <span class="command"><strong>svn switch</strong></span> to move only that subdirectory to the branch. (Or sometimes users will switch just a single working file to the branch!) That way, the user can continue to receive normal <span class="quote">“<span class="quote">trunk</span>”</span> updates to most of her working copy, but the switched portions will remain immune (unless someone commits a change to her branch). This feature adds a whole new dimension to the concept of a <span class="quote">“<span class="quote">mixed working copy</span>”</span>—not only can working copies contain a mixture of working revisions, but they can also contain a mixture of repository locations as well.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Typically switched subdirectories share common ancestry with the location which is switched <span class="quote">“<span class="quote">away</span>”</span> from. However <span class="command"><strong>svn switch</strong></span> can switch a subdirectory to mirror a repository location which it shares no common ancestry with. To do this you need to use the <code class="option">--ignore-ancestry</code> option. </p></td></tr></table></div><p>If your working copy contains a number of switched subtrees from different repository locations, it continues to function as normal. When you update, you'll receive patches to each subtree as appropriate. When you commit, your local changes are still applied as a single, atomic change to the repository.</p><p>Note that while it's okay for your working copy to reflect a mixture of repository locations, these locations must all be within the <span class="emphasis"><em>same</em></span> repository. Subversion repositories aren't yet able to communicate with one another; that feature is planned for the future.<a href="#ftn.idm4553" class="footnote" id="idm4553"><sup class="footnote">[34]</sup></a></p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Administrators who need to change the URL of a repository which is accessed via HTTP are encouraged to add to their <code class="filename">httpd.conf</code> configuration file a permanent redirect from the old URL location to the new one (via the <code class="literal">RedirectPermanent</code> directive). Subversion clients will generally display the new repository URL in error messages generated when the user attempts to use working copies which still reflect the old URL location. In fact, Subversion 1.7 clients will go a step further, automatically relocating the working copy to the new URL.</p></td></tr></table></div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Switches and Updates</strong></p></div></div></div><p>Have you noticed that the output of <span class="command"><strong>svn switch</strong></span> and <span class="command"><strong>svn update</strong></span> looks the same? The switch command is actually a superset of the update command.</p><p>When you run <span class="command"><strong>svn update</strong></span>, you're asking the repository to compare two trees. The repository does so, and then sends a description of the differences back to the client. The only difference between <span class="command"><strong>svn switch</strong></span> and <span class="command"><strong>svn update</strong></span> is that the latter command always compares two identical repository paths.</p><p>That is, if your working copy is a mirror of <code class="filename">/calc/trunk</code>, <span class="command"><strong>svn update</strong></span> will automatically compare your working copy of <code class="filename">/calc/trunk</code> to <code class="filename">/calc/trunk</code> in the <code class="literal">HEAD</code> revision. If you're switching your working copy to a branch, <span class="command"><strong>svn switch</strong></span> will compare your working copy of <code class="filename">/calc/trunk</code> to some <span class="emphasis"><em>other</em></span> branch directory in the <code class="literal">HEAD</code> revision.</p><p>In other words, an update moves your working copy through time. A switch moves your working copy through time <span class="emphasis"><em>and</em></span> space.</p></div><p>Because <span class="command"><strong>svn switch</strong></span> is essentially a variant of <span class="command"><strong>svn update</strong></span>, it shares the same behaviors; any local modifications in your working copy are preserved when new data arrives from the repository.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Have you ever found yourself making some complex edits (in your <code class="filename">/trunk</code> working copy) and suddenly realized, <span class="quote">“<span class="quote">Hey, these changes ought to be in their own branch?</span>”</span> There is a great two step technique to do this:</p><div class="informalexample"><pre class="screen"> $ svn copy http://svn.example.com/repos/calc/trunk \ http://svn.example.com/repos/calc/branches/newbranch \ -m "Create branch 'newbranch'." Committed revision 353. $ svn switch ^/calc/branches/newbranch At revision 353. </pre></div><p>The <span class="command"><strong>svn switch</strong></span> command, like <span class="command"><strong>svn update</strong></span>, preserves your local edits. At this point, your working copy is now a reflection of the newly created branch, and your next <span class="command"><strong>svn commit</strong></span> invocation will send your changes there.</p></td></tr></table></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.branchmerge.tags"></a>Tags</h2></div></div></div><p> <a id="idm4600" class="indexterm"></a> Another common version control concept is a tag. A tag is just a <span class="quote">“<span class="quote">snapshot</span>”</span> 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.</p><p>However, people often want to give more human-friendly names to tags, such as <code class="literal">release-1.0</code>. And they want to make snapshots of smaller subdirectories of the filesystem. After all, it's not so easy to remember that release 1.0 of a piece of software is a particular subdirectory of revision 4822.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.tags.mksimple"></a>Creating a Simple Tag</h3></div></div></div><p>Once again, <span class="command"><strong>svn copy</strong></span> comes to the rescue. If you want to create a snapshot of <code class="filename">/calc/trunk</code> exactly as it looks in the <code class="literal">HEAD</code> revision, make a copy of it:</p><div class="informalexample"><pre class="screen"> $ svn copy http://svn.example.com/repos/calc/trunk \ http://svn.example.com/repos/calc/tags/release-1.0 \ -m "Tagging the 1.0 release of the 'calc' project." Committed revision 902. </pre></div><p>This example assumes that a <code class="filename">/calc/tags</code> directory already exists. (If it doesn't, you can create it using <span class="command"><strong>svn mkdir</strong></span>.) After the copy completes, the new <code class="filename">release-1.0</code> directory is forever a snapshot of how the <code class="filename">/trunk</code> directory looked in the <code class="literal">HEAD</code> revision at the time you made the copy. Of course, you might want to be more precise about exactly which revision you copy, in case somebody else may have committed changes to the project when you weren't looking. So if you know that revision 901 of <code class="filename">/calc/trunk</code> is exactly the snapshot you want, you can specify it by passing <code class="option">-r 901</code> to the <span class="command"><strong>svn copy</strong></span> command.</p><p>But wait a moment: isn't this tag creation procedure the same procedure we used to create a branch? Yes, in fact, it is. In Subversion, there's no difference between a tag and a branch. Both are just ordinary directories that are created by copying. Just as with branches, the only reason a copied directory is a <span class="quote">“<span class="quote">tag</span>”</span> is because <span class="emphasis"><em>humans</em></span> have decided to treat it that way: as long as nobody ever commits to the directory, it forever remains a snapshot. If people start committing to it, it becomes a branch.</p><p>If you are administering a repository, there are two approaches you can take to managing tags. The first approach is <span class="quote">“<span class="quote">hands off</span>”</span>: as a matter of project policy, decide where your tags will live, and make sure all users know how to treat the directories they copy. (That is, make sure they know not to commit to them.) The second approach is more paranoid: you can use one of the access control scripts provided with Subversion to prevent anyone from doing anything but creating new copies in the tags area (see <a class="xref" href="#svn.serverconfig" title="Chapter 6. Server Configuration">Chapter 6, <em>Server Configuration</em></a>). The paranoid approach, however, isn't usually necessary. If a user accidentally commits a change to a tag directory, you can simply undo the change as discussed in the previous section. This is version control, after all!</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.tags.mkcomplex"></a>Creating a Complex Tag</h3></div></div></div><p>Sometimes you may want a <span class="quote">“<span class="quote">snapshot</span>”</span> that is more complicated than a single directory at a single revision.</p><p>For example, pretend your project is much larger than our <code class="filename">calc</code> example: suppose it contains a number of subdirectories and many more files. In the course of your work, you may decide that you need to create a working copy that is designed to have specific features and bug fixes. You can accomplish this by selectively backdating files or directories to particular revisions (using <span class="command"><strong>svn update</strong></span> with the <code class="option">-r</code> option liberally), by switching files and directories to particular branches (making use of <span class="command"><strong>svn switch</strong></span>), or even just by making a bunch of local changes. When you're done, your working copy is a hodgepodge of repository locations from different revisions. But after testing, you know it's the precise combination of data you need to tag.</p><p>Time to make a snapshot. Copying one URL to another won't work here. In this case, you want to make a snapshot of your exact working copy arrangement and store it in the repository. Luckily, <span class="command"><strong>svn copy</strong></span> actually has four different uses (which you can read about in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>), including the ability to copy a working copy tree to the repository:</p><div class="informalexample"><pre class="screen"> $ ls my-working-copy/ $ svn copy my-working-copy \ http://svn.example.com/repos/calc/tags/mytag \ -m "Tag my existing working copy state." Committed revision 940. </pre></div><p>Now there is a new directory in the repository, <code class="filename">/calc/tags/mytag</code>, which is an exact snapshot of your working copy—mixed revisions, URLs, local changes, and all.</p><p>Other users have found interesting uses for this feature. Sometimes there are situations where you have a bunch of local changes made to your working copy, and you'd like a collaborator to see them. Instead of running <span class="command"><strong>svn diff</strong></span> and sending a patch file (which won't capture directory or symlink changes), you can use <span class="command"><strong>svn copy</strong></span> to <span class="quote">“<span class="quote">upload</span>”</span> your working copy to a private area of the repository. Your collaborator can then either check out a verbatim copy of your working copy or use <span class="command"><strong>svn merge</strong></span> to receive your exact changes.</p><p>While this is a nice method for uploading a quick snapshot of your working copy, note that this is <span class="emphasis"><em>not</em></span> a good way to initially create a branch. Branch creation should be an event unto itself, and this method conflates the creation of a branch with extra changes to files, all within a single revision. This makes it very difficult (later on) to identify a single revision number as a branch point.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.branchmerge.maint"></a>Branch Maintenance</h2></div></div></div><p>You may have noticed by now that Subversion is extremely flexible. Because it implements branches and tags with the same underlying mechanism (directory copies), and because branches and tags appear in normal filesystem space, many people find Subversion intimidating. It's almost <span class="emphasis"><em>too</em></span> flexible. In this section, we'll offer some suggestions for arranging and managing your data over time.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.maint.layout"></a>Repository Layout</h3></div></div></div><p>There are some standard, recommended ways to organize the contents of a repository. Most people create a <code class="filename">trunk</code> directory to hold the <span class="quote">“<span class="quote">main line</span>”</span> of development, a <code class="filename">branches</code> directory to contain branch copies, and a <code class="filename">tags</code> directory to contain tag copies. If a repository holds only one project, often people create these top-level directories:</p><div class="informalexample"><div class="literallayout"><p><br></br> /<br></br>    trunk/<br></br>    branches/<br></br>    tags/<br></br> </p></div></div><p>If a repository contains multiple projects, admins typically index their layout by project. See <a class="xref" href="#svn.reposadmin.projects.chooselayout" title="Planning Your Repository Organization">the section called “Planning Your Repository Organization”</a> to read more about <span class="quote">“<span class="quote">project roots</span>”</span>, but here's an example of such a layout:</p><div class="informalexample"><div class="literallayout"><p><br></br> /<br></br>    paint/<br></br>       trunk/<br></br>       branches/<br></br>       tags/<br></br>    calc/<br></br>       trunk/<br></br>       branches/<br></br>       tags/<br></br> </p></div></div><p>Of course, you're free to ignore these common layouts. You can create any sort of variation, whatever works best for you or your team. Remember that whatever you choose, it's not a permanent commitment. You can reorganize your repository at any time. Because branches and tags are ordinary directories, the <span class="command"><strong>svn move</strong></span> command can move or rename them however you wish. Switching from one layout to another is just a matter of issuing a series of server-side moves; if you don't like the way things are organized in the repository, just juggle the directories around.</p><p>Remember, though, that while moving directories is easy to do, you need to be considerate of other users as well. Your juggling can disorient users with existing working copies. If a user has a working copy of a particular repository directory and your <span class="command"><strong>svn move</strong></span> subcommand removes the path from the latest revision, then when the user next runs <span class="command"><strong>svn update</strong></span>, she is told that her working copy represents a path that no longer exists. She is then forced to <span class="command"><strong>svn switch</strong></span> to the new location.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.maint.lifetime"></a>Data Lifetimes</h3></div></div></div><p>Another nice feature of Subversion's model is that branches and tags can have finite lifetimes, just like any other versioned item. For example, suppose you eventually finish all your work on your personal branch of the <code class="filename">calc</code> project. After merging all of your changes back into <code class="filename">/calc/trunk</code>, there's no need for your private branch directory to stick around anymore:</p><div class="informalexample"><pre class="screen"> $ svn delete http://svn.example.com/repos/calc/branches/my-calc-branch \ -m "Removing obsolete branch of calc project." Committed revision 375. </pre></div><p>And now your branch is gone. Of course, it's not really gone: the directory is simply missing from the <code class="literal">HEAD</code> revision, no longer distracting anyone. If you use <span class="command"><strong>svn checkout</strong></span>, <span class="command"><strong>svn switch</strong></span>, or <span class="command"><strong>svn list</strong></span> to examine an earlier revision, you can still see your old branch.</p><p>If browsing your deleted directory isn't enough, you can always bring it back. Resurrecting data is very easy in Subversion. If there's a deleted directory (or file) that you'd like to bring back into <code class="literal">HEAD</code>, simply use <span class="command"><strong>svn copy</strong></span> to copy it from the old revision:</p><div class="informalexample"><pre class="screen"> $ svn copy http://svn.example.com/repos/calc/branches/my-calc-branch@374 \ http://svn.example.com/repos/calc/branches/my-calc-branch \ -m "Restore my-calc-branch." Committed revision 376. </pre></div><p>In our example, your personal branch had a relatively short lifetime: you may have created it to fix a bug or implement a new feature. When your task is done, so is the branch. In software development, though, it's also common to have two <span class="quote">“<span class="quote">main</span>”</span> branches running side by side for very long periods. For example, suppose it's time to release a stable version of the <code class="filename">calc</code> project to the public, and you know it's going to take a couple of months to shake bugs out of the software. You don't want people to add new features to the project, but you don't want to tell all developers to stop programming either. So instead, you create a <span class="quote">“<span class="quote">stable</span>”</span> branch of the software that won't change much:</p><div class="informalexample"><pre class="screen"> $ svn copy http://svn.example.com/repos/calc/trunk \ http://svn.example.com/repos/calc/branches/stable-1.0 \ -m "Creating stable branch of calc project." Committed revision 377. </pre></div><p>And now developers are free to continue adding cutting-edge (or experimental) features to <code class="filename">/calc/trunk</code>, and you can declare a project policy that only bug fixes are to be committed to <code class="filename">/calc/branches/stable-1.0</code>. That is, as people continue to work on the trunk, a human selectively ports bug fixes over to the stable branch. Even after the stable branch has shipped, you'll probably continue to maintain the branch for a long time—that is, as long as you continue to support that release for customers. We'll discuss this more in the next section.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.branchmerge.commonpatterns"></a>Common Branching Patterns</h2></div></div></div><p>There are many different uses for branching and <span class="command"><strong>svn merge</strong></span>, and this section describes the most common.</p><p>Version control is most often used for software development, so here's a quick peek at two of the most common branching/merging patterns used by teams of programmers. If you're not using Subversion for software development, feel free to skip this section. If you're a software developer using version control for the first time, pay close attention, as these patterns are often considered best practices by experienced folk. These processes aren't specific to Subversion; they're applicable to any version control system. Still, it may help to see them described in Subversion terms.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.commonpatterns.release"></a>Release Branches</h3></div></div></div><p>Most software has a typical life cycle: code, test, release, repeat. There are two problems with this process. First, developers need to keep writing new features while quality assurance teams take time to test supposedly stable versions of the software. New work cannot halt while the software is tested. Second, the team almost always needs to support older, released versions of software; if a bug is discovered in the latest code, it most likely exists in released versions as well, and customers will want to get that bug fix without having to wait for a major new release.</p><p>Here's where version control can help. The typical procedure looks like this:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p><span class="emphasis"><em>Developers commit all new work to the trunk.</em></span> Day-to-day changes are committed to <code class="filename">/trunk</code>: new features, bug fixes, and so on.</p></li><li class="listitem"><p><span class="emphasis"><em>The trunk is copied to a <span class="quote">“<span class="quote">release</span>”</span> branch.</em></span> When the team thinks the software is ready for release (say, a 1.0 release), <code class="filename">/trunk</code> might be copied to <code class="filename">/branches/1.0</code>.</p></li><li class="listitem"><p><span class="emphasis"><em>Teams continue to work in parallel.</em></span> One team begins rigorous testing of the release branch, while another team continues new work (say, for version 2.0) on <code class="filename">/trunk</code>. If bugs are discovered in either location, fixes are ported back and forth as necessary. At some point, however, even that process stops. The branch is <span class="quote">“<span class="quote">frozen</span>”</span> for final testing right before a release.</p></li><li class="listitem"><p><span class="emphasis"><em>The branch is tagged and released.</em></span> When testing is complete, <code class="filename">/branches/1.0</code> is copied to <code class="filename">/tags/1.0.0</code> as a reference snapshot. The tag is packaged and released to customers.</p></li><li class="listitem"><p><span class="emphasis"><em>The branch is maintained over time.</em></span> While work continues on <code class="filename">/trunk</code> for version 2.0, bug fixes continue to be ported from <code class="filename">/trunk</code> to <code class="filename">/branches/1.0</code>. When enough bug fixes have accumulated, management may decide to do a 1.0.1 release: <code class="filename">/branches/1.0</code> is copied to <code class="filename">/tags/1.0.1</code>, and the tag is packaged and released.</p></li></ol></div><p>This entire process repeats as the software matures: when the 2.0 work is complete, a new 2.0 release branch is created, tested, tagged, and eventually released. After some years, the repository ends up with a number of release branches in <span class="quote">“<span class="quote">maintenance</span>”</span> mode, and a number of tags representing final shipped versions.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.commonpatterns.feature"></a>Feature Branches</h3></div></div></div><p>A <em class="firstterm">feature branch</em> is the sort of branch that's been the dominant example in this chapter (the one you've been working on while Sally continues to work on <code class="filename">/trunk</code>). It's a temporary branch created to work on a complex change without interfering with the stability of <code class="filename">/trunk</code>. Unlike release branches (which may need to be supported forever), feature branches are born, used for a while, merged back to the trunk, and then ultimately deleted. They have a finite span of usefulness.</p><p>Again, project policies vary widely concerning exactly when it's appropriate to create a feature branch. Some projects never use feature branches at all: commits to <code class="filename">/trunk</code> are a free-for-all. The advantage to this system is that it's simple—nobody needs to learn about branching or merging. The disadvantage is that the trunk code is often unstable or unusable. Other projects use branches to an extreme: no change is <span class="emphasis"><em>ever</em></span> committed to the trunk directly. Even the most trivial changes are created on a short-lived branch, carefully reviewed, and merged to the trunk. Then the branch is deleted. This system guarantees an exceptionally stable and usable trunk at all times, but at the cost of tremendous process overhead.</p><p>Most projects take a middle-of-the-road approach. They commonly insist that <code class="filename">/trunk</code> compile and pass regression tests at all times. A feature branch is required only when a change requires a large number of destabilizing commits. A good rule of thumb is to ask this question: if the developer worked for days in isolation and then committed the large change all at once (so that <code class="filename">/trunk</code> were never destabilized), would it be too large a change to review? If the answer to that question is <span class="quote">“<span class="quote">yes,</span>”</span> the change should be developed on a feature branch. As the developer commits incremental changes to the branch, they can be easily reviewed by peers.</p><p>Finally, there's the issue of how to best keep a feature branch in <span class="quote">“<span class="quote">sync</span>”</span> with the trunk as work progresses. As we mentioned earlier, there's a great risk to working on a branch for weeks or months; trunk changes may continue to pour in, to the point where the two lines of development differ so greatly that it may become a nightmare trying to merge the branch back to the trunk.</p><p>This situation is best avoided by regularly merging trunk changes to the branch. Make up a policy: once a week, merge the last week's worth of trunk changes to the branch.</p><p>When you are eventually ready to merge the <span class="quote">“<span class="quote">synchronized</span>”</span> feature branch back to the trunk, begin by doing a final merge of the latest trunk changes to the branch. When that's done, the latest versions of branch and trunk are absolutely identical except for your branch changes. You then merge back with the <code class="option">--reintegrate</code> option:</p><div class="informalexample"><pre class="screen"> $ cd trunk-working-copy $ svn update Updating '.': At revision 1910. $ svn merge --reintegrate ^/calc/branches/mybranch --- Merging differences between repository URLs into '.': U real.c U integer.c A newdirectory A newdirectory/newfile U . … </pre></div><p>Another way of thinking about this pattern is that your weekly sync of trunk to branch is analogous to running <span class="command"><strong>svn update</strong></span> in a working copy, while the final merge step is analogous to running <span class="command"><strong>svn commit</strong></span> from a working copy. After all, what else <span class="emphasis"><em>is</em></span> a working copy but a very shallow private branch? It's a branch that's capable of storing only one change at a time.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.vendorbr"></a>Vendor Branches</h2></div></div></div><p>As is especially the case when developing software, the data that you maintain under version control is often closely related to, or perhaps dependent upon, someone else's data. Generally, the needs of your project will dictate that you stay as up to date as possible with the data provided by that external entity without sacrificing the stability of your own project. This scenario plays itself out all the time—anywhere that the information generated by one group of people has a direct effect on that which is generated by another group.</p><p>For example, software developers might be working on an application that makes use of a third-party library. Subversion has just such a relationship with the Apache Portable Runtime (APR) library (see <a class="xref" href="#svn.developer.usingapi.apr" title="The Apache Portable Runtime Library">the section called “The Apache Portable Runtime Library”</a>). The Subversion source code depends on the APR library for all its portability needs. In earlier stages of Subversion's development, the project closely tracked APR's changing API, always sticking to the <span class="quote">“<span class="quote">bleeding edge</span>”</span> of the library's code churn. Now that both APR and Subversion have matured, Subversion attempts to synchronize with APR's library API only at well-tested, stable release points.</p><p>Now, if your project depends on someone else's information, you could attempt to synchronize that information with your own in several ways. Most painfully, you could issue oral or written instructions to all the contributors of your project, telling them to make sure they have the specific versions of that third-party information that your project needs. If the third-party information is maintained in a Subversion repository, you could also use Subversion's externals definitions to effectively <span class="quote">“<span class="quote">pin down</span>”</span> specific versions of that information to some location in your own working copy (see <a class="xref" href="#svn.advanced.externals" title="Externals Definitions">the section called “Externals Definitions”</a>).</p><p>But sometimes you want to maintain custom modifications to third-party code in your own version control system. Returning to the software development example, programmers might need to make modifications to that third-party library for their own purposes. These modifications might include new functionality or bug fixes, maintained internally only until they become part of an official release of the third-party library. Or the changes might never be relayed back to the library maintainers, existing solely as custom tweaks to make the library further suit the needs of the software developers.</p><p>Now you face an interesting situation. Your project could house its custom modifications to the third-party data in some disjointed fashion, such as using patch files or full-fledged alternative versions of files and directories. But these quickly become maintenance headaches, requiring some mechanism by which to apply your custom changes to the third-party code and necessitating regeneration of those changes with each successive version of the third-party code that you track.</p><p>The solution to this problem is to use <em class="firstterm">vendor branches</em>. A vendor branch is a directory tree in your own version control system that contains information provided by a third-party entity, or vendor. Each version of the vendor's data that you decide to absorb into your project is called a <em class="firstterm">vendor drop</em>.</p><p>Vendor branches provide two benefits. First, by storing the currently supported vendor drop in your own version control system, you ensure that the members of your project never need to question whether they have the right version of the vendor's data. They simply receive that correct version as part of their regular working copy updates. Second, because the data lives in your own Subversion repository, you can store your custom changes to it in-place—you have no more need of an automated (or worse, manual) method for swapping in your customizations.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.vendorbr.general"></a>General Vendor Branch Management Procedure</h3></div></div></div><p>Managing vendor branches generally works like this: first, you create a top-level directory (such as <code class="filename">/vendor</code>) to hold the vendor branches. Then you import the third-party code into a subdirectory of that top-level directory. You then copy that subdirectory into your main development branch (e.g., <code class="filename">/trunk</code>) at the appropriate location. You always make your local changes in the main development branch. With each new release of the code you are tracking, you bring it into the vendor branch and merge the changes into <code class="filename">/trunk</code>, resolving whatever conflicts occur between your local changes and the upstream changes.</p><p>An example will help to clarify this algorithm. We'll use a scenario where your development team is creating a calculator program that links against a third-party complex number arithmetic library, libcomplex. We'll begin with the initial creation of the vendor branch and the import of the first vendor drop. We'll call our vendor branch directory <code class="filename">libcomplex</code>, and our code drops will go into a subdirectory of our vendor branch called <code class="filename">current</code>. And since <span class="command"><strong>svn import</strong></span> creates all the intermediate parent directories it needs, we can actually accomplish both of these steps with a single command:</p><div class="informalexample"><pre class="screen"> $ svn import /path/to/libcomplex-1.0 \ http://svn.example.com/repos/vendor/libcomplex/current \ -m "importing initial 1.0 vendor drop" … </pre></div><p>We now have the current version of the libcomplex source code in <code class="filename">/vendor/libcomplex/current</code>. Now, we tag that version (see <a class="xref" href="#svn.branchmerge.tags" title="Tags">the section called “Tags”</a>) and then copy it into the main development branch. Our copy will create a new directory called <code class="filename">libcomplex</code> in our existing <code class="filename">calc</code> project directory. It is in this copied version of the vendor data that we will make our customizations:</p><div class="informalexample"><pre class="screen"> $ svn copy http://svn.example.com/repos/vendor/libcomplex/current \ http://svn.example.com/repos/vendor/libcomplex/1.0 \ -m "tagging libcomplex-1.0" … $ svn copy http://svn.example.com/repos/vendor/libcomplex/1.0 \ http://svn.example.com/repos/calc/libcomplex \ -m "bringing libcomplex-1.0 into the main branch" … </pre></div><p>We check out our project's main branch—which now includes a copy of the first vendor drop—and we get to work customizing the libcomplex code. Before we know it, our modified version of libcomplex is now completely integrated into our calculator program.<a href="#ftn.idm4801" class="footnote" id="idm4801"><sup class="footnote">[35]</sup></a></p><p>A few weeks later, the developers of libcomplex release a new version of their library—version 1.1—which contains some features and functionality that we really want. We'd like to upgrade to this new version, but without losing the customizations we made to the existing version. What we essentially would like to do is to replace our current baseline version of libcomplex 1.0 with a copy of libcomplex 1.1, and then re-apply the custom modifications we previously made to that library to the new version. But we actually approach the problem from the other direction, applying the changes made to libcomplex between versions 1.0 and 1.1 to our modified copy of it.</p><p>To perform this upgrade, we check out a copy of our vendor branch and replace the code in the <code class="filename">current</code> directory with the new libcomplex 1.1 source code. We quite literally copy new files on top of existing files, perhaps exploding the libcomplex 1.1 release tarball atop our existing files and directories. The goal here is to make our <code class="filename">current</code> directory contain only the libcomplex 1.1 code and to ensure that all that code is under version control. Oh, and we want to do this with as little version control history disturbance as possible.</p><p>After replacing the 1.0 code with 1.1 code, <span class="command"><strong>svn status</strong></span> will show files with local modifications as well as, perhaps, some unversioned files. If we did what we were supposed to do, the unversioned files are only those new files introduced in the 1.1 release of libcomplex—we run <span class="command"><strong>svn add</strong></span> on those to get them under version control. If the 1.1 code no longer has certain files that were in the 1.0 tree, it may be hard to notice them; you'd have to compare the two trees with some external tool and then <span class="command"><strong>svn delete</strong></span> any files present in 1.0 but not in 1.1. (Although it might also be just fine to let these same files live on in unused obscurity!) Finally, once our <code class="filename">current</code> working copy contains only the libcomplex 1.1 code, we commit the changes we made to get it looking that way.</p><p>Our <code class="filename">current</code> branch now contains the new vendor drop. We tag the new version as 1.1 (in the same way we previously tagged the version 1.0 vendor drop), and then merge the differences between the tag of the previous version and the new current version into our main development branch:</p><div class="informalexample"><pre class="screen"> $ cd working-copies/calc $ svn merge ^/vendor/libcomplex/1.0 \ ^/vendor/libcomplex/current \ libcomplex … # resolve all the conflicts between their changes and our changes $ svn commit -m "merging libcomplex-1.1 into the main branch" … </pre></div><p>In the trivial use case, the new version of our third-party tool would look, from a files-and-directories point of view, just like the previous version. None of the libcomplex source files would have been deleted, renamed, or moved to different locations—the new version would contain only textual modifications against the previous one. In a perfect world, our modifications would apply cleanly to the new version of the library, with absolutely no complications or conflicts.</p><p>But things aren't always that simple, and in fact it is quite common for source files to get moved around between releases of software. This complicates the process of ensuring that our modifications are still valid for the new version of code, and things can quickly degrade into a situation where we have to manually re-create our customizations in the new version. Once Subversion knows about the history of a given source file—including all its previous locations—the process of merging in the new version of the library is pretty simple. But we are responsible for telling Subversion how the source file layout changed from vendor drop to vendor drop.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.vendorbr.svn_load_dirs"></a>svn_load_dirs.pl</h3></div></div></div><p>Vendor drops that contain more than a few deletes, additions, and moves complicate the process of upgrading to each successive version of the third-party data. So Subversion supplies the <span class="command"><strong>svn_load_dirs.pl</strong></span> script to assist with this process. This script automates the importing steps we mentioned in the general vendor branch management procedure to make sure mistakes are minimized. You will still be responsible for using the merge commands to merge the new versions of the third-party data into your main development branch, but <span class="command"><strong>svn_load_dirs.pl</strong></span> can help you more quickly and easily arrive at that stage.</p><p>In short, <span class="command"><strong>svn_load_dirs.pl</strong></span> is an enhancement to <span class="command"><strong>svn import</strong></span> that has several important characteristics:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>It can be run at any point in time to bring an existing directory in the repository to exactly match an external directory, performing all the necessary adds and deletes, and optionally performing moves, too.</p></li><li class="listitem"><p>It takes care of complicated series of operations between which Subversion requires an intermediate commit—such as before renaming a file or directory twice.</p></li><li class="listitem"><p>It will optionally tag the newly imported directory.</p></li><li class="listitem"><p>It will optionally add arbitrary properties to files and directories that match a regular expression.</p></li></ul></div><p><span class="command"><strong>svn_load_dirs.pl</strong></span> takes three mandatory arguments. The first argument is the URL to the base Subversion directory to work in. This argument is followed by the URL—relative to the first argument—into which the current vendor drop will be imported. Finally, the third argument is the local directory to import. Using our previous example, a typical run of <span class="command"><strong>svn_load_dirs.pl</strong></span> might look like this:</p><div class="informalexample"><pre class="screen"> $ svn_load_dirs.pl http://svn.example.com/repos/vendor/libcomplex \ current \ /path/to/libcomplex-1.1 … </pre></div><p>You can indicate that you'd like <span class="command"><strong>svn_load_dirs.pl</strong></span> to tag the new vendor drop by passing the <code class="option">-t</code> command-line option and specifying a tag name. This tag is another URL relative to the first program argument.</p><div class="informalexample"><pre class="screen"> $ svn_load_dirs.pl -t libcomplex-1.1 \ http://svn.example.com/repos/vendor/libcomplex \ current \ /path/to/libcomplex-1.1 … </pre></div><p>When you run <span class="command"><strong>svn_load_dirs.pl</strong></span>, it examines the contents of your existing <span class="quote">“<span class="quote">current</span>”</span> vendor drop and compares them with the proposed new vendor drop. In the trivial case, no files will be in one version and not the other, and the script will perform the new import without incident. If, however, there are discrepancies in the file layouts between versions, <span class="command"><strong>svn_load_dirs.pl</strong></span> will ask you how to resolve those differences. For example, you will have the opportunity to tell the script that you know that the file <code class="filename">math.c</code> in version 1.0 of libcomplex was renamed to <code class="filename">arithmetic.c</code> in libcomplex 1.1. Any discrepancies not explained by moves are treated as regular additions and deletions.</p><p>The script also accepts a separate configuration file for setting properties on <span class="emphasis"><em>added</em></span> files and directories which match a regular expression. This configuration file is specified to <span class="command"><strong>svn_load_dirs.pl</strong></span> using the <code class="option">-p</code> command-line option. Each line of the configuration file is a whitespace-delimited set of two or four values: a Perl-style regular expression against which to match the added path, a control keyword (either <code class="literal">break</code> or <code class="literal">cont</code>), and then optionally a property name and value.</p><div class="informalexample"><pre class="screen"> \.png$ break svn:mime-type image/png \.jpe?g$ break svn:mime-type image/jpeg \.m3u$ cont svn:mime-type audio/x-mpegurl \.m3u$ break svn:eol-style LF .* break svn:eol-style native </pre></div><p>For each added path, the configured property changes whose regular expression matches the path are applied in order, unless the control specification is <code class="literal">break</code> (which means that no more property changes should be applied to that path). If the control specification is <code class="literal">cont</code>—an abbreviation for <code class="literal">continue</code>—matching will continue with the next line of the configuration file.</p><p>Any whitespace in the regular expression, property name, or property value must be surrounded by either single or double quotes. You can escape quotes that are not used for wrapping whitespace by preceding them with a backslash (<code class="literal">\</code>) character. The backslash escapes only quotes when parsing the configuration file, so do not protect any other characters beyond what is necessary for the regular expression.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.branchmerge.when"></a>To Branch or Not to Branch?</h2></div></div></div><p>To branch or not to branch—that is an interesting question. This chapter has provided thus far a pretty deep dive into the waters of branching and merging, topics which have historically been the premier source of Subversion user confusion. As if the rote actions involved in branching and branch management aren't sometimes tricky enough, some users get hung up on deciding whether they need to branch at all. As you've learned, Subversion can handle common branching and branch management scenarios. So, the decision of whether or not to branch a project's history is rarely a technical one. Rather, the social impact of the decision often carries more weight. Let's examine some of the benefits and costs of using branches in a software project.</p><p>The most obvious benefit of working on a branch is isolation. Changes made to the branch don't affect the other lines of development in the project; changes made to those other lines don't affect the branch. In this way, a branch can serve as a great place to experiment with new features, complex bug fixes, major code rewrites, and so on. No matter how much stuff Sally breaks on her branch, Harry and the rest of the team can continue with their work unhindered outside the branch.</p><p>Branches also provide a great way to organize related changes into readily identifiable collections. For example, the changes which comprise the complete solution to a particular bug might be a list of non-sequential revision numbers. You might describe them in human language as <span class="quote">“<span class="quote">revisions 1534, 1543, 1587 and 1588</span>”</span>. You'd probably reproduce those numbers manually (or otherwise) in the issue tracker artifact which tracks the bug. When porting the bug fix to other product versions, you'd need to make sure to port all those revisions. But had those changes been made on a unique branch, you'd find yourself referring only to that branch by its name in conversation, in issue tracker comments, and when porting changes.</p><p>The unfortunate downside of branches, though, is that the very isolation that makes them so useful <span class="emphasis"><em>can</em></span> be at odds with the collaborative needs of the project team. Depending on the work habits of your project peers, changes made to branches might not get the kind of constructive review, criticism, and testing that changes made to the main line of development do. The isolation of a branch can encourage users to forsake certain version control <span class="quote">“<span class="quote">best practices</span>”</span>, leading to version history which is difficult to review <span class="foreignphrase"><em class="foreignphrase">post facto</em></span>. Developers on long-lived branches sometimes need to work extra hard to ensure that the evolutionary direction of their isolated copy of the codebase is in harmony with the direction their peers are steering the main code lines. Now, these drawbacks might be less of an issue for true exploratory branches aimed at experimenting with the future of a codebase with no expectation of reintegrating the results back into the main development lines—mere policy needn't be a vision-killer! But the simple fact remains that projects generally benefit from an orderly approach to version control where code and code changes enjoy the review and comprehension of more than one team member.</p><p>That's not to say that there are no technical penalties to branching. Pardon us while we <span class="quote">“<span class="quote">go meta</span>”</span> for a bit here. If you think about it, every time you checkout a Subversion working copy, you're creating a branch of sorts of your project. It's a special sort of branch. It lives only on your client machine; not in the repository. You synchronize this branch with changes made in the repository using <span class="command"><strong>svn update</strong></span>—which acts almost like a special-cased, simplified form of an <span class="command"><strong>svn merge</strong></span> command.<a href="#ftn.idm4879" class="footnote" id="idm4879"><sup class="footnote">[36]</sup></a> You effectively reintegrate your branch each time you run <span class="command"><strong>svn commit</strong></span>. So, in that special sense, Subversion users deal with branches and merges all the time. Given the similarities between updating and merging, it's no surprise, then, that the areas in which Subversion seems to have the most shortcomings—namely, handling file and directory renames and dealing with tree conflicts in general—are problematic for both the <span class="command"><strong>svn update</strong></span> and <span class="command"><strong>svn merge</strong></span> operations. Unfortunately, <span class="command"><strong>svn merge</strong></span> has a harder time of it precisely because of the fact that, for every way in which <span class="command"><strong>svn update</strong></span> is a special-cased, simplified kind of generic merge operation, a true Subversion merge is neither special-cased nor simplified. For this reason, merges perform much more slowly than updates, require explicit tracking (via the <code class="literal">svn:mergeinfo</code> property we've discussed in this chapter) and history-crunching arithmetic, and generally offer more opportunities for something to go awry.</p><p>To branch or not to branch? Ultimately, that depends on what your team needs in order to find that sweet balance of collaboration and isolation.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.branchmerge.summary"></a>Summary</h2></div></div></div><p>We covered a lot of ground in this chapter. We discussed the concepts of tags and branches and demonstrated how Subversion implements these concepts by copying directories with the <span class="command"><strong>svn copy</strong></span> command. We showed how to use <span class="command"><strong>svn merge</strong></span> to copy changes from one branch to another or roll back bad changes. We went over the use of <span class="command"><strong>svn switch</strong></span> to create mixed-location working copies. And we talked about how one might manage the organization and lifetimes of branches in a repository.</p><p>Remember the Subversion mantra: branches and tags are cheap. So don't be afraid to use them when needed!</p><p>As a helpful reminder of all the operations we discussed, here is handy reference table you can consult as you begin to make use of branches.</p><div class="table"><a id="svn.branchemerge.summary.tbl-1"></a><p class="title"><strong>Table 4.1. Branching and merging commands</strong></p><div class="table-contents"><table class="table" summary="Branching and merging commands" border="1"><colgroup><col></col><col></col></colgroup><thead><tr><th>Action</th><th>Command</th></tr></thead><tbody><tr><td>Create a branch or tag</td><td><strong class="userinput"><code>svn copy <em class="replaceable"><code>URL1</code></em> <em class="replaceable"><code>URL2</code></em></code></strong></td></tr><tr><td>Switch a working copy to a branch or tag</td><td><strong class="userinput"><code>svn switch <em class="replaceable"><code>URL</code></em></code></strong></td></tr><tr><td>Synchronize a branch with trunk</td><td><strong class="userinput"><code>svn merge <em class="replaceable"><code>trunkURL</code></em>; svn commit</code></strong></td></tr><tr><td>See merge history or eligible changesets</td><td><strong class="userinput"><code>svn mergeinfo <em class="replaceable"><code>SOURCE</code></em> <em class="replaceable"><code>TARGET</code></em></code></strong></td></tr><tr><td>Merge a branch back into trunk</td><td><strong class="userinput"><code>svn merge --reintegrate <em class="replaceable"><code>branchURL</code></em>; svn commit</code></strong></td></tr><tr><td>Merge one specific change</td><td><strong class="userinput"><code>svn merge -c <em class="replaceable"><code>REV</code></em> <em class="replaceable"><code>URL</code></em>; svn commit</code></strong></td></tr><tr><td>Merge a range of changes</td><td><strong class="userinput"><code>svn merge -r <em class="replaceable"><code>REV1</code></em>:<em class="replaceable"><code>REV2</code></em> <em class="replaceable"><code>URL</code></em>; svn commit</code></strong></td></tr><tr><td>Block a change from automatic merging</td><td><strong class="userinput"><code>svn merge -c <em class="replaceable"><code>REV</code></em> --record-only <em class="replaceable"><code>URL</code></em>; svn commit</code></strong></td></tr><tr><td>Preview a merge</td><td><strong class="userinput"><code>svn merge <em class="replaceable"><code>URL</code></em> --dry-run</code></strong></td></tr><tr><td>Abandon merge results</td><td><strong class="userinput"><code>svn revert -R .</code></strong></td></tr><tr><td>Resurrect something from history</td><td><strong class="userinput"><code>svn copy <em class="replaceable"><code>URL</code></em>@<em class="replaceable"><code>REV</code></em> <em class="replaceable"><code>localPATH</code></em></code></strong></td></tr><tr><td>Undo a committed change</td><td><strong class="userinput"><code>svn merge -c -<em class="replaceable"><code>REV</code></em> <em class="replaceable"><code>URL</code></em>; svn commit</code></strong></td></tr><tr><td>Examine merge-sensitive history</td><td><strong class="userinput"><code>svn log -g; svn blame -g</code></strong></td></tr><tr><td>Create a tag from a working copy</td><td><strong class="userinput"><code>svn copy . <em class="replaceable"><code>tagURL</code></em></code></strong></td></tr><tr><td>Rearrange a branch or tag</td><td><strong class="userinput"><code>svn move <em class="replaceable"><code>URL1</code></em> <em class="replaceable"><code>URL2</code></em></code></strong></td></tr><tr><td>Remove a branch or tag</td><td><strong class="userinput"><code>svn delete <em class="replaceable"><code>URL</code></em></code></strong></td></tr></tbody></table></div></div><br class="table-break"></br></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm3600" class="footnote"><p><a href="#idm3600" class="para"><sup class="para">[25] </sup></a>Subversion does not support copying between different repositories. When using URLs with <span class="command"><strong>svn copy</strong></span> or <span class="command"><strong>svn move</strong></span>, you can only copy items within the same repository.</p></div><div id="ftn.idm3724" class="footnote"><p><a href="#idm3724" class="para"><sup class="para">[26] </sup></a>This was introduced in svn 1.6.</p></div><div id="ftn.idm3809" class="footnote"><p><a href="#idm3809" class="para"><sup class="para">[27] </sup></a>The <span class="command"><strong>svn merge</strong></span> subcommand option <code class="option">--allow-mixed-revisions</code> allows you to override this prohibition, but you should only do so if you understand the ramifications and have a good reason for it.</p></div><div id="ftn.idm3845" class="footnote"><p><a href="#idm3845" class="para"><sup class="para">[28] </sup></a>With Subversion 1.7 you don't absolutely have to do all your sync merges to the root of your branch as we do in this example. <span class="emphasis"><em>If</em></span> your branch is effectively synced via a series of subtree merges then the reintegrate will work, but ask yourself, if the branch is effectively synced, then why are you doing subtree merges? Doing so is almost always needlessly complex.</p></div><div id="ftn.idm3873" class="footnote"><p><a href="#idm3873" class="para"><sup class="para">[29] </sup></a>Reintegrate merges are allowed if the target is a shallow checkout (see <a class="xref" href="#svn.advanced.sparsedirs" title="Sparse Directories">the section called “Sparse Directories”</a>) but any paths affected by the diff which are <span class="quote">“<span class="quote">missing</span>”</span> due to the sparse working copy will be skipped, probably <span class="emphasis"><em>not</em></span> what you intended!</p></div><div id="ftn.idm3987" class="footnote"><p><a href="#idm3987" class="para"><sup class="para">[30] </sup></a> This is often termed an <span class="quote">“<span class="quote">inoperative</span>”</span> merge. Though in this example the merge of r1060 would do something: It would update the mergeinfo on the root of the branch, but it would be inoperative in the sense that no diff would be applied.</p></div><div id="ftn.idm4038" class="footnote"><p><a href="#idm4038" class="para"><sup class="para">[31] </sup></a>The Subversion project has plans, however, to someday implement a command that would accomplish the task of permanently deleting information. In the meantime, see <a class="xref" href="#svn.reposadmin.maint.tk.svndumpfilter" title="svndumpfilter">the section called “svndumpfilter”</a> for a possible workaround.</p></div><div id="ftn.idm4122" class="footnote"><p><a href="#idm4122" class="para"><sup class="para">[32] </sup></a>At least, this is true in Subversion 1.7 at the time of this writing. This behavior may improve in future versions of Subversion.</p></div><div id="ftn.idm4215" class="footnote"><p><a href="#idm4215" class="para"><sup class="para">[33] </sup></a>Interestingly, after rolling back a revision like this, we wouldn't be able to reapply the revision using <strong class="userinput"><code>svn merge . -c 5</code></strong>, since the mergeinfo would already list r5 as being applied. We would have to use the <code class="option">--ignore-ancestry</code> option to make the merge command ignore the existing mergeinfo!</p></div><div id="ftn.idm4553" class="footnote"><p><a href="#idm4553" class="para"><sup class="para">[34] </sup></a>You <span class="emphasis"><em>can</em></span>, however, use <span class="command"><strong>svn relocate</strong></span> if the URL of your server changes and you don't want to abandon an existing working copy. See <a class="xref" href="#svn.ref.svn.c.relocate" title="svn relocate">svn relocate</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a> for more information and an example.</p></div><div id="ftn.idm4801" class="footnote"><p><a href="#idm4801" class="para"><sup class="para">[35] </sup></a>And is entirely bug-free, of course!</p></div><div id="ftn.idm4879" class="footnote"><p><a href="#idm4879" class="para"><sup class="para">[36] </sup></a>Actually, you <span class="emphasis"><em>could</em></span> use <strong class="userinput"><code>svn merge -r<em class="replaceable"><code>LAST_UPDATED_REV</code></em>:HEAD .</code></strong> in your working copy to quite literally merge in all the repository changes since your last update if really wanted to!</p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="svn.reposadmin"></a>Chapter 5. Repository Administration</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.reposadmin.basics">The Subversion Repository, Defined</a></span></dt><dt><span class="sect1"><a href="#svn.reposadmin.planning">Strategies for Repository Deployment</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.reposadmin.projects.chooselayout">Planning Your Repository Organization</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.basics.hosting">Deciding Where and How to Host Your Repository</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.basics.backends">Choosing a Data Store</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.reposadmin.basics.backends.bdb">Berkeley DB</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.basics.backends.fsfs">FSFS</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.reposadmin.create">Creating and Configuring Your Repository</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.reposadmin.basics.creating">Creating the Repository</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.create.hooks">Implementing Repository Hooks</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.create.bdb">Berkeley DB Configuration</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.create.fsfs">FSFS Configuration</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.reposadmin.maint">Repository Maintenance</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.reposadmin.maint.tk">An Administrator's Toolkit</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.svnadmin">svnadmin</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.svnlook">svnlook</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.svndumpfilter">svndumpfilter</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.svnrdump">svnrdump</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.svnsync">svnsync</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.fsfsreshard">fsfs-reshard.py</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.tk.bdbutil">Berkeley DB utilities</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.reposadmin.maint.setlog">Commit Log Message Correction</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.maint.diskspace">Managing Disk Space</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.reposadmin.maint.diskspace.deltas">How Subversion saves disk space</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.diskspace.deadtxns">Removing dead transactions</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.diskspace.bdblogs">Purging unused Berkeley DB logfiles</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.diskspace.fsfspacking">Packing FSFS filesystems</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.reposadmin.maint.recovery">Berkeley DB Recovery</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.maint.migrate">Migrating Repository Data Elsewhere</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.reposadmin.maint.migrate.svnadmin">Repository data migration using svnadmin</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.migrate.svnrdump">Repository data migration using svnrdump</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.reposadmin.maint.filtering">Filtering Repository History</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.maint.replication">Repository Replication</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.reposadmin.maint.replication.svnsync">Replication with svnsync</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.replication.svnsync-partial">Partial replication with svnsync</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.replication.svnsync-init-nonempty">A quick trick for mirror creation</a></span></dt><dt><span class="sect3"><a href="#svn.reposadmin.maint.replication.wrapup">Replication wrap-up</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.reposadmin.maint.backup">Repository Backup</a></span></dt><dt><span class="sect2"><a href="#svn.reposadmin.maint.uuids">Managing Repository UUIDs</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.reposadmin.maint.moving-and-removing">Moving and Removing Repositories</a></span></dt><dt><span class="sect1"><a href="#svn.reposadmin.summary">Summary</a></span></dt></dl></div><p>The Subversion repository is the central storehouse of all your versioned data. As such, it becomes an obvious candidate for all the love and attention an administrator can offer. While the repository is generally a low-maintenance item, it is important to understand how to properly configure and care for it so that potential problems are avoided, and so actual problems are safely resolved.</p><p>In this chapter, we'll discuss how to create and configure a Subversion repository. We'll also talk about repository maintenance, providing examples of how and when to use various related tools provided with Subversion. We'll address some common questions and mistakes and give some suggestions on how to arrange the data in the repository.</p><p>If you plan to access a Subversion repository only in the role of a user whose data is under version control (i.e., via a Subversion client), you can skip this chapter altogether. However, if you are, or wish to become, a Subversion repository administrator,<a href="#ftn.idm5000" class="footnote" id="idm5000"><sup class="footnote">[37]</sup></a> this chapter is for you.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.reposadmin.basics"></a>The Subversion Repository, Defined</h2></div></div></div><p>Before jumping into the broader topic of repository administration, let's further define what a repository is. How does it look? How does it feel? Does it take its tea hot or iced, sweetened, and with lemon? As an administrator, you'll be expected to understand the composition of a repository both from a literal, OS-level perspective—how a repository looks and acts with respect to non-Subversion tools—and from a logical perspective—dealing with how data is represented <span class="emphasis"><em>inside</em></span> the repository.</p><p>Seen through the eyes of a typical file browser application (such as Windows Explorer) or command-line based filesystem navigation tools, the Subversion repository is just another directory full of stuff. There are some subdirectories with human-readable configuration files in them, some subdirectories with some not-so-human-readable data files, and so on. As in other areas of the Subversion design, modularity is given high regard, and hierarchical organization is preferred to cluttered chaos. So a shallow glance into a typical repository from a nuts-and-bolts perspective is sufficient to reveal the basic components of the repository:</p><div class="informalexample"><pre class="screen"> $ ls repos conf/ db/ format hooks/ locks/ README.txt </pre></div><p>Here's a quick fly-by overview of what exactly you're seeing in this directory listing. (Don't get bogged down in the terminology—detailed coverage of these components exists elsewhere in this and other chapters.)</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">conf/</span></dt><dd><p>This directory is a container for configuration files.</p></dd><dt><span class="term">db/</span></dt><dd><p>This directory contains the data store for all of your versioned data.<a href="#ftn.idm5019" class="footnote" id="idm5019"><sup class="footnote">[38]</sup></a></p></dd><dt><span class="term">format</span></dt><dd><p>This file describes the repository's internal organizational scheme. (As it turns out, the <code class="filename">db/</code> subdirectory sometimes also contains a <code class="filename">format</code> file which describes only the contents of that subdirectory and which is not to be confused with this file.)</p></dd><dt><span class="term">hooks/</span></dt><dd><p>This directory contains hook script templates and hook scripts, if any have been installed.</p></dd><dt><span class="term">locks/</span></dt><dd><p>Subversion uses this directory to house repository lock files, used for managing concurrent access to the repository.</p></dd><dt><span class="term">README.txt</span></dt><dd><p>This is a brief text file containing merely a notice to readers that the directory they are looking in is a Subversion repository.</p></dd></dl></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Prior to Subversion 1.5, the on-disk repository structure also always contained a <code class="filename">dav</code> subdirectory. <code class="filename">mod_dav_svn</code> used this directory to store information about WebDAV <em class="firstterm">activities</em>—mappings of high-level WebDAV protocol concepts to Subversion commit transactions. Subversion 1.5 changed that behavior, moving ownership of the activities directory, and the ability to configure its location, into <code class="filename">mod_dav_svn</code> itself. Now, new repositories will not necessarily have a <code class="filename">dav</code> subdirectory unless <code class="filename">mod_dav_svn</code> is in use and hasn't been configured to store its activities database elsewhere. See <a class="xref" href="#svn.ref.mod_dav_svn.conf.directives" title="Directives">the section called “Directives”</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a> for more information.</p></td></tr></table></div><p>Of course, when accessed via the Subversion libraries, this otherwise unremarkable collection of files and directories suddenly becomes an implementation of a virtual, versioned filesystem, complete with customizable event triggers. This filesystem has its own notions of directories and files, very similar to the notions of such things held by real filesystems (such as NTFS, FAT32, ext3, etc.). But this is a special filesystem—it hangs these directories and files from revisions, keeping all the changes you've ever made to them safely stored and forever accessible. This is where the entirety of your versioned data lives.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.reposadmin.planning"></a>Strategies for Repository Deployment</h2></div></div></div><p>Due largely to the simplicity of the overall design of the Subversion repository and the technologies on which it relies, creating and configuring a repository are fairly straightforward tasks. There are a few preliminary decisions you'll want to make, but the actual work involved in any given setup of a Subversion repository is pretty basic, tending toward mindless repetition if you find yourself setting up multiples of these things.</p><p>Some things you'll want to consider beforehand, though, are:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>What data do you expect to live in your repository (or repositories), and how will that data be organized?</p></li><li class="listitem"><p>Where will your repository live, and how will it be accessed?</p></li><li class="listitem"><p>What types of access control and repository event reporting do you need?</p></li><li class="listitem"><p>Which of the available types of data store do you want to use?</p></li></ul></div><p>In this section, we'll try to help you answer those questions.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.projects.chooselayout"></a>Planning Your Repository Organization</h3></div></div></div><p>While Subversion allows you to move around versioned files and directories without any loss of information, and even provides ways of moving whole sets of versioned history from one repository to another, doing so can greatly disrupt the workflow of those who access the repository often and come to expect things to be at certain locations. So before creating a new repository, try to peer into the future a bit; plan ahead before placing your data under version control. By conscientiously <span class="quote">“<span class="quote">laying out</span>”</span> your repository or repositories and their versioned contents ahead of time, you can prevent many future headaches.</p><p>Let's assume that as repository administrator, you will be responsible for supporting the version control system for several projects. Your first decision is whether to use a single repository for multiple projects, or to give each project its own repository, or some compromise of these two.</p><p>There are benefits to using a single repository for multiple projects, most obviously the lack of duplicated maintenance. A single repository means that there is one set of hook programs, one thing to routinely back up, one thing to dump and load if Subversion releases an incompatible new version, and so on. Also, you can move data between projects easily, without losing any historical versioning information.</p><p>The downside of using a single repository is that different projects may have different requirements in terms of the repository event triggers, such as needing to send commit notification emails to different mailing lists, or having different definitions about what does and does not constitute a legitimate commit. These aren't insurmountable problems, of course—it just means that all of your hook scripts have to be sensitive to the layout of your repository rather than assuming that the whole repository is associated with a single group of people. Also, remember that Subversion uses repository-global revision numbers. While those numbers don't have any particular magical powers, some folks still don't like the fact that even though no changes have been made to their project lately, the youngest revision number for the repository keeps climbing because other projects are actively adding new revisions.<a href="#ftn.idm5071" class="footnote" id="idm5071"><sup class="footnote">[39]</sup></a></p><p>A middle-ground approach can be taken, too. For example, projects can be grouped by how well they relate to each other. You might have a few repositories with a handful of projects in each repository. That way, projects that are likely to want to share data can do so easily, and as new revisions are added to the repository, at least the developers know that those new revisions are at least remotely related to everyone who uses that repository.</p><p> <a id="idm5076" class="indexterm"></a> After deciding how to organize your projects with respect to repositories, you'll probably want to think about directory hierarchies within the repositories themselves. Because Subversion uses regular directory copies for branching and tagging (see <a class="xref" href="#svn.branchmerge" title="Chapter 4. Branching and Merging">Chapter 4, <em>Branching and Merging</em></a>), the Subversion community recommends that you choose a repository location for each project root—the <span class="quote">“<span class="quote">topmost</span>”</span> directory that contains data related to that project—and then create three subdirectories beneath that root: <code class="filename">trunk</code>, meaning the directory under which the main project development occurs; <code class="filename">branches</code>, which is a directory in which to create various named branches of the main development line; and <code class="filename">tags</code>, which is a collection of tree snapshots that are created, and perhaps destroyed, but never changed.<a href="#ftn.idm5083" class="footnote" id="idm5083"><sup class="footnote">[40]</sup></a></p><p>For example, your repository might look like this:</p><div class="informalexample"><div class="literallayout"><p><br></br> /<br></br>    calc/<br></br>       trunk/<br></br>       tags/<br></br>       branches/<br></br>    calendar/<br></br>       trunk/<br></br>       tags/<br></br>       branches/<br></br>    spreadsheet/<br></br>       trunk/<br></br>       tags/<br></br>       branches/<br></br>    …<br></br> </p></div></div><p>Note that it doesn't matter where in your repository each project root is. If you have only one project per repository, the logical place to put each project root is at the root of that project's respective repository. If you have multiple projects, you might want to arrange them in groups inside the repository, perhaps putting projects with similar goals or shared code in the same subdirectory, or maybe just grouping them alphabetically. Such an arrangement might look like this:</p><div class="informalexample"><div class="literallayout"><p><br></br> /<br></br>    utils/<br></br>       calc/<br></br>          trunk/<br></br>          tags/<br></br>          branches/<br></br>       calendar/<br></br>          trunk/<br></br>          tags/<br></br>          branches/<br></br>       …<br></br>    office/<br></br>       spreadsheet/<br></br>          trunk/<br></br>          tags/<br></br>          branches/<br></br>       …<br></br> </p></div></div><p>Lay out your repository in whatever way you see fit. Subversion does not expect or enforce a particular layout—in its eyes, a directory is a directory is a directory. Ultimately, you should choose the repository arrangement that meets the needs of the people who work on the projects that live there.</p><p>In the name of full disclosure, though, we'll mention another very common layout. In this layout, the <code class="filename">trunk</code>, <code class="filename">tags</code>, and <code class="filename">branches</code> directories live in the root directory of your repository, and your projects are in subdirectories beneath those, like so:</p><div class="informalexample"><div class="literallayout"><p><br></br> /<br></br>    trunk/<br></br>       calc/<br></br>       calendar/<br></br>       spreadsheet/<br></br>       …<br></br>    tags/<br></br>       calc/<br></br>       calendar/<br></br>       spreadsheet/<br></br>       …<br></br>    branches/<br></br>       calc/<br></br>       calendar/<br></br>       spreadsheet/<br></br>       …<br></br> </p></div></div><p>There's nothing particularly incorrect about such a layout, but it may or may not seem as intuitive for your users. Especially in large, multiproject situations with many users, those users may tend to be familiar with only one or two of the projects in the repository. But the projects-as-branch-siblings approach tends to deemphasize project individuality and focus on the entire set of projects as a single entity. That's a social issue, though. We like our originally suggested arrangement for purely practical reasons—it's easier to ask about (or modify, or migrate elsewhere) the entire history of a single project when there's a single repository path that holds the entire history—past, present, tagged, and branched—for that project and that project alone.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.basics.hosting"></a>Deciding Where and How to Host Your Repository</h3></div></div></div><p>Before creating your Subversion repository, an obvious question you'll need to answer is where the thing is going to live. This is strongly connected to myriad other questions involving how the repository will be accessed (via a Subversion server or directly), by whom (users behind your corporate firewall or the whole world out on the open Internet), what other services you'll be providing around Subversion (repository browsing interfaces, email-based commit notification, etc.), your data backup strategy, and so on.</p><p>We cover server choice and configuration in <a class="xref" href="#svn.serverconfig" title="Chapter 6. Server Configuration">Chapter 6, <em>Server Configuration</em></a>, but the point we'd like to briefly make here is simply that the answers to some of these other questions might have implications that force your hand when deciding where your repository will live. For example, certain deployment scenarios might require accessing the repository via a remote filesystem from multiple computers, in which case (as you'll read in the next section) your choice of a repository backend data store turns out not to be a choice at all because only one of the available backends will work in this scenario.</p><p>Addressing each possible way to deploy Subversion is both impossible and outside the scope of this book. We simply encourage you to evaluate your options using these pages and other sources as your reference material and to plan ahead.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.basics.backends"></a>Choosing a Data Store</h3></div></div></div><p>Subversion provides two options for the type of underlying data store—often referred to as <span class="quote">“<span class="quote">the backend</span>”</span> or, somewhat confusingly, <span class="quote">“<span class="quote">the (versioned) filesystem</span>”</span>—that each repository uses. One type of data store keeps everything in a Berkeley DB (or BDB) database environment; repositories that use this type are often referred to as being <span class="quote">“<span class="quote">BDB-backed.</span>”</span> The other type stores data in ordinary flat files, using a custom format. Subversion developers have adopted the habit of referring to this latter data storage mechanism as <em class="firstterm">FSFS</em><a href="#ftn.idm5116" class="footnote" id="idm5116"><sup class="footnote">[41]</sup></a>—a versioned filesystem implementation that uses the native OS filesystem directly—rather than via a database library or some other abstraction layer—to store data.</p><p><a class="xref" href="#svn.reposadmin.basics.backends.tbl-1" title="Table 5.1. Repository data store comparison">Table 5.1, “Repository data store comparison”</a> gives a comparative overview of Berkeley DB and FSFS repositories.</p><div class="table"><a id="svn.reposadmin.basics.backends.tbl-1"></a><p class="title"><strong>Table 5.1. Repository data store comparison</strong></p><div class="table-contents"><table class="table" summary="Repository data store comparison" border="1"><colgroup><col></col><col></col><col></col><col></col></colgroup><thead><tr><th>Category</th><th>Feature</th><th>Berkeley DB</th><th>FSFS</th></tr></thead><tbody><tr><td rowspan="2">Reliability</td><td>Data integrity</td><td>When properly deployed, extremely reliable; Berkeley DB 4.4 brings auto-recovery</td><td>Older versions had some rarely demonstrated, but data-destroying bugs</td></tr><tr><td>Sensitivity to interruptions</td><td>Very; crashes and permission problems can leave the database <span class="quote">“<span class="quote">wedged,</span>”</span> requiring journaled recovery procedures</td><td>Quite insensitive</td></tr><tr><td rowspan="4">Accessibility</td><td>Usable from a read-only mount</td><td>No</td><td>Yes</td></tr><tr><td>Platform-independent storage</td><td>No</td><td>Yes</td></tr><tr><td>Usable over network filesystems</td><td>Generally, no</td><td>Yes</td></tr><tr><td>Group permissions handling</td><td>Sensitive to user umask problems; best if accessed by only one user</td><td>Works around umask problems</td></tr><tr><td rowspan="3">Scalability</td><td>Repository disk usage</td><td>Larger (especially if logfiles aren't purged)</td><td>Smaller</td></tr><tr><td>Number of revision trees</td><td>Database; no problems</td><td>Some older native filesystems don't scale well with thousands of entries in a single directory</td></tr><tr><td>Directories with many files</td><td>Slower</td><td>Faster</td></tr><tr><td rowspan="2">Performance</td><td>Checking out latest revision</td><td>No meaningful difference</td><td>No meaningful difference</td></tr><tr><td>Large commits</td><td>Slower overall, but cost is amortized across the lifetime of the commit</td><td>Faster overall, but finalization delay may cause client timeouts</td></tr></tbody></table></div></div><br class="table-break"></br><p>There are advantages and disadvantages to each of these two backend types. Neither of them is more <span class="quote">“<span class="quote">official</span>”</span> than the other, though the newer FSFS is the default data store as of Subversion 1.2. Both are reliable enough to trust with your versioned data. But as you can see in <a class="xref" href="#svn.reposadmin.basics.backends.tbl-1" title="Table 5.1. Repository data store comparison">Table 5.1, “Repository data store comparison”</a>, the FSFS backend provides quite a bit more flexibility in terms of its supported deployment scenarios. More flexibility means you have to work a little harder to find ways to deploy it incorrectly. Those reasons—plus the fact that not using Berkeley DB means there's one fewer component in the system—largely explain why today almost everyone uses the FSFS backend when creating new repositories.</p><p>Fortunately, most programs that access Subversion repositories are blissfully ignorant of which backend data store is in use. And you aren't even necessarily stuck with your first choice of a data store—in the event that you change your mind later, Subversion provides ways of migrating your repository's data into another repository that uses a different backend data store. We talk more about that later in this chapter.</p><p>The following subsections provide a more detailed look at the available backend data store types.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.basics.backends.bdb"></a>Berkeley DB</h4></div></div></div><p>When the initial design phase of Subversion was in progress, the developers decided to use Berkeley DB for a variety of reasons, including its open source license, transaction support, reliability, performance, API simplicity, thread safety, support for cursors, and so on.</p><p>Berkeley DB provides real transaction support—perhaps its most powerful feature. Multiple processes accessing your Subversion repositories don't have to worry about accidentally clobbering each other's data. The isolation provided by the transaction system is such that for any given operation, the Subversion repository code sees a static view of the database—not a database that is constantly changing at the hand of some other process—and can make decisions based on that view. If the decision made happens to conflict with what another process is doing, the entire operation is rolled back as though it never happened, and Subversion gracefully retries the operation against a new, updated (and yet still static) view of the database.</p><p>Another great feature of Berkeley DB is <em class="firstterm">hot backups</em>—the ability to back up the database environment without taking it <span class="quote">“<span class="quote">offline.</span>”</span> We'll discuss how to back up your repository later in this chapter (in <a class="xref" href="#svn.reposadmin.maint.backup" title="Repository Backup">the section called “Repository Backup”</a>), but the benefits of being able to make fully functional copies of your repositories without any downtime should be obvious.</p><p>Berkeley DB is also a very reliable database system when properly used. Subversion uses Berkeley DB's logging facilities, which means that the database first writes to on-disk logfiles a description of any modifications it is about to make, and then makes the modification itself. This is to ensure that if anything goes wrong, the database system can back up to a previous <em class="firstterm">checkpoint</em>—a location in the logfiles known not to be corrupt—and replay transactions until the data is restored to a usable state. See <a class="xref" href="#svn.reposadmin.maint.diskspace" title="Managing Disk Space">the section called “Managing Disk Space”</a> later in this chapter for more about Berkeley DB logfiles.</p><p>But every rose has its thorn, and so we must note some known limitations of Berkeley DB. First, Berkeley DB environments are not portable. You cannot simply copy a Subversion repository that was created on a Unix system onto a Windows system and expect it to work. While much of the Berkeley DB database format is architecture-independent, other aspects of the environment are not. Second, Subversion uses Berkeley DB in a way that will not operate on Windows 95/98 systems—if you need to house a BDB-backed repository on a Windows machine, stick with Windows 2000 or later.</p><p>While Berkeley DB promises to behave correctly on network shares that meet a particular set of specifications,<a href="#ftn.idm5199" class="footnote" id="idm5199"><sup class="footnote">[42]</sup></a> most networked filesystem types and appliances do <span class="emphasis"><em>not</em></span> actually meet those requirements. And in no case can you allow a BDB-backed repository that resides on a network share to be accessed by multiple clients of that share at once (which quite often is the whole point of having the repository live on a network share in the first place).</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>If you attempt to use Berkeley DB on a noncompliant remote filesystem, the results are unpredictable—you may see mysterious errors right away, or it may be months before you discover that your repository database is subtly corrupted. You should strongly consider using the FSFS data store for repositories that need to live on a network share.</p></td></tr></table></div><p>Finally, because Berkeley DB is a library linked directly into Subversion, it's more sensitive to interruptions than a typical relational database system. Most SQL systems, for example, have a dedicated server process that mediates all access to tables. If a program accessing the database crashes for some reason, the database daemon notices the lost connection and cleans up any mess left behind. And because the database daemon is the only process accessing the tables, applications don't need to worry about permission conflicts. These things are not the case with Berkeley DB, however. Subversion (and programs using Subversion libraries) access the database tables directly, which means that a program crash can leave the database in a temporarily inconsistent, inaccessible state. When this happens, an administrator needs to ask Berkeley DB to restore to a checkpoint, which is a bit of an annoyance. Other things can cause a repository to <span class="quote">“<span class="quote">wedge</span>”</span> besides crashed processes, such as programs conflicting over ownership and permissions on the database files.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Berkeley DB 4.4 brings (to Subversion 1.4 and later) the ability for Subversion to automatically and transparently recover Berkeley DB environments in need of such recovery. When a Subversion process attaches to a repository's Berkeley DB environment, it uses some process accounting mechanisms to detect any unclean disconnections by previous processes, performs any necessary recovery, and then continues on as though nothing happened. This doesn't completely eliminate instances of repository wedging, but it does drastically reduce the amount of human interaction required to recover from them.</p></td></tr></table></div><p>So while a Berkeley DB repository is quite fast and scalable, it's best used by a single server process running as one user—such as Apache's <span class="command"><strong>httpd</strong></span> or <span class="command"><strong>svnserve</strong></span> (see <a class="xref" href="#svn.serverconfig" title="Chapter 6. Server Configuration">Chapter 6, <em>Server Configuration</em></a>)—rather than accessing it as many different users via <code class="literal">file://</code> or <code class="literal">svn+ssh://</code> URLs. If you're accessing a Berkeley DB repository directly as multiple users, be sure to read <a class="xref" href="#svn.serverconfig.multimethod" title="Supporting Multiple Repository Access Methods">the section called “Supporting Multiple Repository Access Methods”</a> later in this chapter.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.basics.backends.fsfs"></a>FSFS</h4></div></div></div><p>In mid-2004, a second type of repository storage system—one that doesn't use a database at all—came into being. An FSFS repository stores the changes associated with a revision in a single file, and so all of a repository's revisions can be found in a single subdirectory full of numbered files. Transactions are created in separate subdirectories as individual files. When complete, the transaction file is renamed and moved into the revisions directory, thus guaranteeing that commits are atomic. And because a revision file is permanent and unchanging, the repository also can be backed up while <span class="quote">“<span class="quote">hot,</span>”</span> just like a BDB-backed repository.</p><div class="sidebar"><a id="svn.reposadmin.basics.backends.fsfs.revfiles"></a><div class="titlepage"><div><div><p class="title"><strong>Revision files and shards</strong></p></div></div></div><p>FSFS repositories contain files that describe the changes made in a single revision, and files that contain the revision properties associated with a single revision. Repositories created in versions of Subversion prior to 1.5 keep these files in two directories—one for each type of file. As new revisions are committed to the repository, Subversion drops more files into these two directories—over time, the number of these files in each directory can grow to be quite large. This has been observed to cause performance problems on certain network-based filesystems.</p><p>Subversion 1.5 creates FSFS-backed repositories using a slightly modified layout in which the contents of these two directories are <em class="firstterm">sharded</em>, or scattered across several subdirectories. This can greatly reduce the time it takes the system to locate any one of these files, and therefore increases the overall performance of Subversion when reading from the repository.</p><p>Subversion 1.6 and later takes the sharded layout one step further, allowing administrators to optionally <em class="firstterm">pack</em> each of their repository shards up into a single multi-revision file. This can have both performance and disk usage benefits. See <a class="xref" href="#svn.reposadmin.maint.diskspace.fsfspacking" title="Packing FSFS filesystems">the section called “Packing FSFS filesystems”</a> for more information.</p></div><p>The FSFS revision files describe a revision's directory structure, file contents, and deltas against files in other revision trees. Unlike a Berkeley DB database, this storage format is portable across different operating systems and isn't sensitive to CPU architecture. Because no journaling or shared-memory files are being used, the repository can be safely accessed over a network filesystem and examined in a read-only environment. The lack of database overhead also means the overall repository size is a bit smaller.</p><p>FSFS has different performance characteristics, too. When committing a directory with a huge number of files, FSFS is able to more quickly append directory entries. On the other hand, FSFS has a longer delay when finalizing a commit while it performs tasks that the BDB backend amortizes across the lifetime of the commit, which could in extreme cases cause clients to time out while waiting for a response.</p><p>The most important distinction, however, is FSFS's imperviousness to wedging when something goes wrong. If a process using a Berkeley DB database runs into a permissions problem or suddenly crashes, the database can be left in an unusable state until an administrator recovers it. If the same scenarios happen to a process using an FSFS repository, the repository isn't affected at all. At worst, some transaction data is left behind.</p></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.reposadmin.create"></a>Creating and Configuring Your Repository</h2></div></div></div><p>Earlier in this chapter (in <a class="xref" href="#svn.reposadmin.planning" title="Strategies for Repository Deployment">the section called “Strategies for Repository Deployment”</a>), we looked at some of the important decisions that should be made before creating and configuring your Subversion repository. Now, we finally get to get our hands dirty! In this section, we'll see how to actually create a Subversion repository and configure it to perform custom actions when special repository events occur.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.basics.creating"></a>Creating the Repository</h3></div></div></div><p>Subversion repository creation is an incredibly simple task. The <span class="command"><strong>svnadmin</strong></span> utility that comes with Subversion provides a subcommand (<span class="command"><strong>svnadmin create</strong></span>) for doing just that.</p><div class="informalexample"><pre class="screen"> $ # Create a repository $ svnadmin create /var/svn/repos $ </pre></div><p>Assuming that the parent directory <code class="filename">/var/svn</code> exists and that you have sufficient permissions to modify that directory, the previous command creates a new repository in the directory <code class="filename">/var/svn/repos</code>, and with the default filesystem data store (FSFS). You can explicitly choose the filesystem type using the <code class="option">--fs-type</code> argument, which accepts as a parameter either <code class="literal">fsfs</code> or <code class="literal">bdb</code>.</p><div class="informalexample"><pre class="screen"> $ # Create an FSFS-backed repository $ svnadmin create --fs-type fsfs /var/svn/repos $ </pre></div><div class="informalexample"><pre class="screen"> # Create a Berkeley-DB-backed repository $ svnadmin create --fs-type bdb /var/svn/repos $ </pre></div><p>After running this simple command, you have a Subversion repository. Depending on how users will access this new repository, you might need to fiddle with its filesystem permissions. But since basic system administration is rather outside the scope of this text, we'll leave further exploration of that topic as an exercise to the reader.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>The path argument to <span class="command"><strong>svnadmin</strong></span> is just a regular filesystem path and not a URL like the <span class="command"><strong>svn</strong></span> client program uses when referring to repositories. Both <span class="command"><strong>svnadmin</strong></span> and <span class="command"><strong>svnlook</strong></span> are considered server-side utilities—they are used on the machine where the repository resides to examine or modify aspects of the repository, and are in fact unable to perform tasks across a network. A common mistake made by Subversion newcomers is trying to pass URLs (even <span class="quote">“<span class="quote">local</span>”</span> <code class="literal">file://</code> ones) to these two programs.</p></td></tr></table></div><p>Present in the <code class="filename">db/</code> subdirectory of your repository is the implementation of the versioned filesystem. Your new repository's versioned filesystem begins life at revision 0, which is defined to consist of nothing but the top-level root (<code class="filename">/</code>) directory. Initially, revision 0 also has a single revision property, <code class="literal">svn:date</code>, set to the time at which the repository was created.</p><p>Now that you have a repository, it's time to customize it.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>While some parts of a Subversion repository—such as the configuration files and hook scripts—are meant to be examined and modified manually, you shouldn't (and shouldn't need to) tamper with the other parts of the repository <span class="quote">“<span class="quote">by hand.</span>”</span> The <span class="command"><strong>svnadmin</strong></span> tool should be sufficient for any changes necessary to your repository, or you can look to third-party tools (such as Berkeley DB's tool suite) for tweaking relevant subsections of the repository. Do <span class="emphasis"><em>not</em></span> attempt manual manipulation of your version control history by poking and prodding around in your repository's data store files!</p></td></tr></table></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.create.hooks"></a>Implementing Repository Hooks</h3></div></div></div><p>A <em class="firstterm">hook</em> is a program triggered by some repository event, such as the creation of a new revision or the modification of an unversioned property. Some hooks (the so-called <span class="quote">“<span class="quote">pre hooks</span>”</span>) run in advance of a repository operation and provide a means by which to both report what is about to happen and prevent it from happening at all. Other hooks (the <span class="quote">“<span class="quote">post hooks</span>”</span>) run after the completion of a repository event and are useful for performing tasks that examine—but don't modify—the repository. Each hook is handed enough information to tell what that event is (or was), the specific repository changes proposed (or completed), and the username of the person who triggered the event.</p><p>The <code class="filename">hooks</code> subdirectory is, by default, filled with templates for various repository hooks:</p><div class="informalexample"><pre class="screen"> $ ls repos/hooks/ post-commit.tmpl post-unlock.tmpl pre-revprop-change.tmpl post-lock.tmpl pre-commit.tmpl pre-unlock.tmpl post-revprop-change.tmpl pre-lock.tmpl start-commit.tmpl $ </pre></div><p>There is one template for each hook that the Subversion repository supports; by examining the contents of those template scripts, you can see what triggers each script to run and what data is passed to that script. Also present in many of these templates are examples of how one might use that script, in conjunction with other Subversion-supplied programs, to perform common useful tasks. To actually install a working hook, you need only place some executable program or script into the <code class="filename">repos/hooks</code> directory, which can be executed as the name (such as <span class="command"><strong>start-commit</strong></span> or <span class="command"><strong>post-commit</strong></span>) of the hook.</p><p>On Unix platforms, this means supplying a script or program (which could be a shell script, a Python program, a compiled C binary, or any number of other things) named exactly like the name of the hook. Of course, the template files are present for more than just informational purposes—the easiest way to install a hook on Unix platforms is to simply copy the appropriate template file to a new file that lacks the <code class="filename">.tmpl</code> extension, customize the hook's contents, and ensure that the script is executable. Windows, however, uses file extensions to determine whether a program is executable, so you would need to supply a program whose basename is the name of the hook and whose extension is one of the special extensions recognized by Windows for executable programs, such as <code class="filename">.exe</code> for programs and <code class="filename">.bat</code> for batch files.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>For security reasons, the Subversion repository executes hook programs with an empty environment—that is, no environment variables are set at all, not even <code class="literal">$PATH</code> (or <code class="literal">%PATH%</code>, under Windows). Because of this, many administrators are baffled when their hook program runs fine by hand, but doesn't work when run by Subversion. Be sure to explicitly set any necessary environment variables in your hook program and/or use absolute paths to programs.</p></td></tr></table></div><p>Subversion executes hooks as the same user who owns the process that is accessing the Subversion repository. In most cases, the repository is being accessed via a Subversion server, so this user is the same user as whom the server runs on the system. The hooks themselves will need to be configured with OS-level permissions that allow that user to execute them. Also, this means that any programs or files (including the Subversion repository) accessed directly or indirectly by the hook will be accessed as the same user. In other words, be alert to potential permission-related problems that could prevent the hook from performing the tasks it is designed to perform.</p><p>There are several hooks implemented by the Subversion repository, and you can get details about each of them in <a class="xref" href="#svn.ref.reposhooks" title="Repository Hooks">the section called “Repository Hooks”</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>. As a repository administrator, you'll need to decide which hooks you wish to implement (by way of providing an appropriately named and permissioned hook program), and how. When you make this decision, keep in mind the big picture of how your repository is deployed. For example, if you are using server configuration to determine which users are permitted to commit changes to your repository, you don't need to do this sort of access control via the hook system.</p><p>There is no shortage of Subversion hook programs and scripts that are freely available either from the Subversion community itself or elsewhere. These scripts cover a wide range of utility—basic access control, policy adherence checking, issue tracker integration, email- or syndication-based commit notification, and beyond. Or, if you wish to write your own, see <a class="xref" href="#svn.developer" title="Chapter 8. Embedding Subversion">Chapter 8, <em>Embedding Subversion</em></a>.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>While hook scripts can do almost anything, there is one dimension in which hook script authors should show restraint: do <span class="emphasis"><em>not</em></span> modify a commit transaction using hook scripts. While it might be tempting to use hook scripts to automatically correct errors, shortcomings, or policy violations present in the files being committed, doing so can cause problems. Subversion keeps client-side caches of certain bits of repository data, and if you change a commit transaction in this way, those caches become indetectably stale. This inconsistency can lead to surprising and unexpected behavior. Instead of modifying the transaction, you should simply <span class="emphasis"><em>validate</em></span> the transaction in the pre-commit hook and reject the commit if it does not meet the desired requirements. As a bonus, your users will learn the value of careful, compliance-minded work habits.</p></td></tr></table></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.create.bdb"></a>Berkeley DB Configuration</h3></div></div></div><p>A Berkeley DB environment is an encapsulation of one or more databases, logfiles, region files, and configuration files. The Berkeley DB environment has its own set of default configuration values for things such as the number of database locks allowed to be taken out at any given time, the maximum size of the journaling logfiles, and so on. Subversion's filesystem logic additionally chooses default values for some of the Berkeley DB configuration options. However, sometimes your particular repository, with its unique collection of data and access patterns, might require a different set of configuration option values.</p><p>The producers of Berkeley DB understand that different applications and database environments have different requirements, so they have provided a mechanism for overriding at runtime many of the configuration values for the Berkeley DB environment. BDB checks for the presence of a file named <code class="filename">DB_CONFIG</code> in the environment directory (namely, the repository's <code class="filename">db</code> subdirectory), and parses the options found in that file. Subversion itself creates this file when it creates the rest of the repository. The file initially contains some default options, as well as pointers to the Berkeley DB online documentation so that you can read about what those options do. Of course, you are free to add any of the supported Berkeley DB options to your <code class="filename">DB_CONFIG</code> file. Just be aware that while Subversion never attempts to read or interpret the contents of the file and makes no direct use of the option settings in it, you'll want to avoid any configuration changes that may cause Berkeley DB to behave in a fashion that is at odds with what Subversion might expect. Also, changes made to <code class="filename">DB_CONFIG</code> won't take effect until you recover the database environment (using <span class="command"><strong>svnadmin recover</strong></span>).</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.create.fsfs"></a>FSFS Configuration</h3></div></div></div><p>As of Subversion 1.6, FSFS filesystems have several configurable parameters which an administrator can use to fine-tune the performance or disk usage of their repositories. You can find these options—and the documentation for them—in the <code class="filename">db/fsfs.conf</code> file in the repository.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.reposadmin.maint"></a>Repository Maintenance</h2></div></div></div><p>Maintaining a Subversion repository can be daunting, mostly due to the complexities inherent in systems that have a database backend. Doing the task well is all about knowing the tools—what they are, when to use them, and how. This section will introduce you to the repository administration tools provided by Subversion and discuss how to wield them to accomplish tasks such as repository data migration, upgrades, backups, and cleanups.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.maint.tk"></a>An Administrator's Toolkit</h3></div></div></div><p>Subversion provides a handful of utilities useful for creating, inspecting, modifying, and repairing your repository. Let's look more closely at each of those tools. Afterward, we'll briefly examine some of the utilities included in the Berkeley DB distribution that provide functionality specific to your repository's database backend not otherwise provided by Subversion's own tools.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.tk.svnadmin"></a>svnadmin</h4></div></div></div><p>The <span class="command"><strong>svnadmin</strong></span> program is the repository administrator's best friend. Besides providing the ability to create Subversion repositories, this program allows you to perform several maintenance operations on those repositories. The syntax of <span class="command"><strong>svnadmin</strong></span> is similar to that of other Subversion command-line programs:</p><div class="informalexample"><pre class="screen"> $ svnadmin help general usage: svnadmin SUBCOMMAND REPOS_PATH [ARGS &amp; OPTIONS ...] Type 'svnadmin help &lt;subcommand&gt;' for help on a specific subcommand. Type 'svnadmin --version' to see the program version and FS modules. Available subcommands: crashtest create deltify … </pre></div><p>Previously in this chapter (in <a class="xref" href="#svn.reposadmin.basics.creating" title="Creating the Repository">the section called “Creating the Repository”</a>), we were introduced to the <span class="command"><strong>svnadmin create</strong></span> subcommand. Most of the other <span class="command"><strong>svnadmin</strong></span> subcommands we will cover later in this chapter. And you can consult <a class="xref" href="#svn.ref.svnadmin" title="svnadmin—Subversion Repository Administration">the section called “svnadmin—Subversion Repository Administration”</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a> for a full rundown of subcommands and what each of them offers.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.tk.svnlook"></a>svnlook</h4></div></div></div><p><span class="command"><strong>svnlook</strong></span> is a tool provided by Subversion for examining the various revisions and <em class="firstterm">transactions</em> (which are revisions in the making) in a repository. No part of this program attempts to change the repository. <span class="command"><strong>svnlook</strong></span> is typically used by the repository hooks for reporting the changes that are about to be committed (in the case of the pre-commit hook) or that were just committed (in the case of the post-commit hook) to the repository. A repository administrator may use this tool for diagnostic purposes.</p><p><span class="command"><strong>svnlook</strong></span> has a straightforward syntax:</p><div class="informalexample"><pre class="screen"> $ svnlook help general usage: svnlook SUBCOMMAND REPOS_PATH [ARGS &amp; OPTIONS ...] Note: any subcommand which takes the '--revision' and '--transaction' options will, if invoked without one of those options, act on the repository's youngest revision. Type 'svnlook help &lt;subcommand&gt;' for help on a specific subcommand. Type 'svnlook --version' to see the program version and FS modules. … </pre></div><p>Most of <span class="command"><strong>svnlook</strong></span>'s subcommands can operate on either a revision or a transaction tree, printing information about the tree itself, or how it differs from the previous revision of the repository. You use the <code class="option">--revision</code> (<code class="option">-r</code>) and <code class="option">--transaction</code> (<code class="option">-t</code>) options to specify which revision or transaction, respectively, to examine. In the absence of both the <code class="option">--revision</code> (<code class="option">-r</code>) and <code class="option">--transaction</code> (<code class="option">-t</code>) options, <span class="command"><strong>svnlook</strong></span> will examine the youngest (or <code class="literal">HEAD</code>) revision in the repository. So the following two commands do exactly the same thing when 19 is the youngest revision in the repository located at <code class="filename">/var/svn/repos</code>:</p><div class="informalexample"><pre class="screen"> $ svnlook info /var/svn/repos $ svnlook info /var/svn/repos -r 19 </pre></div><p>One exception to these rules about subcommands is the <span class="command"><strong>svnlook youngest</strong></span> subcommand, which takes no options and simply prints out the repository's youngest revision number:</p><div class="informalexample"><pre class="screen"> $ svnlook youngest /var/svn/repos 19 $ </pre></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Keep in mind that the only transactions you can browse are uncommitted ones. Most repositories will have no such transactions because transactions are usually either committed (in which case, you should access them as revision with the <code class="option">--revision</code> (<code class="option">-r</code>) option) or aborted and removed.</p></td></tr></table></div><p>Output from <span class="command"><strong>svnlook</strong></span> is designed to be both human- and machine-parsable. Take, as an example, the output of the <span class="command"><strong>svnlook info</strong></span> subcommand:</p><div class="informalexample"><pre class="screen"> $ svnlook info /var/svn/repos sally 2002-11-04 09:29:13 -0600 (Mon, 04 Nov 2002) 27 Added the usual Greek tree. $ </pre></div><p>The output of <span class="command"><strong>svnlook info</strong></span> consists of the following, in the order given:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>The author, followed by a newline</p></li><li class="listitem"><p>The date, followed by a newline</p></li><li class="listitem"><p>The number of characters in the log message, followed by a newline</p></li><li class="listitem"><p>The log message itself, followed by a newline</p></li></ol></div><p>This output is human-readable, meaning items such as the datestamp are displayed using a textual representation instead of something more obscure (such as the number of nanoseconds since the Tastee Freez guy drove by). But the output is also machine-parsable—because the log message can contain multiple lines and be unbounded in length, <span class="command"><strong>svnlook</strong></span> provides the length of that message before the message itself. This allows scripts and other wrappers around this command to make intelligent decisions about the log message, such as how much memory to allocate for the message, or at least how many bytes to skip in the event that this output is not the last bit of data in the stream.</p><p><span class="command"><strong>svnlook</strong></span> can perform a variety of other queries: displaying subsets of bits of information we've mentioned previously, recursively listing versioned directory trees, reporting which paths were modified in a given revision or transaction, showing textual and property differences made to files and directories, and so on. See <a class="xref" href="#svn.ref.svnlook" title="svnlook—Subversion Repository Examination">the section called “svnlook—Subversion Repository Examination”</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a> for a full reference of <span class="command"><strong>svnlook</strong></span>'s features.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.tk.svndumpfilter"></a>svndumpfilter</h4></div></div></div><p>While it won't be the most commonly used tool at the administrator's disposal, <span class="command"><strong>svndumpfilter</strong></span> provides a very particular brand of useful functionality—the ability to quickly and easily modify streams of Subversion repository history data by acting as a path-based filter.</p><p>The syntax of <span class="command"><strong>svndumpfilter</strong></span> is as follows:</p><div class="informalexample"><pre class="screen"> $ svndumpfilter help general usage: svndumpfilter SUBCOMMAND [ARGS &amp; OPTIONS ...] Type 'svndumpfilter help &lt;subcommand&gt;' for help on a specific subcommand. Type 'svndumpfilter --version' to see the program version. Available subcommands: exclude include help (?, h) </pre></div><p>There are only two interesting subcommands: <span class="command"><strong>svndumpfilter exclude</strong></span> and <span class="command"><strong>svndumpfilter include</strong></span>. They allow you to make the choice between implicit or explicit inclusion of paths in the stream. You can learn more about these subcommands and <span class="command"><strong>svndumpfilter</strong></span>'s unique purpose later in this chapter, in <a class="xref" href="#svn.reposadmin.maint.filtering" title="Filtering Repository History">the section called “Filtering Repository History”</a>.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.tk.svnrdump"></a>svnrdump</h4></div></div></div><p>The <span class="command"><strong>svnrdump</strong></span> program is, to put it simply, essentially just network-aware flavors of the <span class="command"><strong>svnadmin dump</strong></span> and <span class="command"><strong>svnadmin load</strong></span> subcommands, rolled up into a separate program.</p><div class="informalexample"><pre class="screen"> $ svnrdump help general usage: svnrdump SUBCOMMAND URL [-r LOWER[:UPPER]] Type 'svnrdump help &lt;subcommand&gt;' for help on a specific subcommand. Type 'svnrdump --version' to see the program version and RA modules. Available subcommands: dump load help (?, h) $ </pre></div><p>We discuss the use of <span class="command"><strong>svnrdump</strong></span> and the aforementioned <span class="command"><strong>svnadmin</strong></span> commands later in this chapter (see <a class="xref" href="#svn.reposadmin.maint.migrate" title="Migrating Repository Data Elsewhere">the section called “Migrating Repository Data Elsewhere”</a>).</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.tk.svnsync"></a>svnsync</h4></div></div></div><p>The <span class="command"><strong>svnsync</strong></span> program provides all the functionality required for maintaining a read-only mirror of a Subversion repository. The program really has one job—to transfer one repository's versioned history into another repository. And while there are few ways to do that, its primary strength is that it can operate remotely—the <span class="quote">“<span class="quote">source</span>”</span> and <span class="quote">“<span class="quote">sink</span>”</span><a href="#ftn.idm5421" class="footnote" id="idm5421"><sup class="footnote">[43]</sup></a> repositories may be on different computers from each other and from <span class="command"><strong>svnsync</strong></span> itself.</p><p>As you might expect, <span class="command"><strong>svnsync</strong></span> has a syntax that looks very much like every other program we've mentioned in this chapter:</p><div class="informalexample"><pre class="screen"> $ svnsync help general usage: svnsync SUBCOMMAND DEST_URL [ARGS &amp; OPTIONS ...] Type 'svnsync help &lt;subcommand&gt;' for help on a specific subcommand. Type 'svnsync --version' to see the program version and RA modules. Available subcommands: initialize (init) synchronize (sync) copy-revprops info help (?, h) $ </pre></div><p>We talk more about replicating repositories with <span class="command"><strong>svnsync</strong></span> later in this chapter (see <a class="xref" href="#svn.reposadmin.maint.replication" title="Repository Replication">the section called “Repository Replication”</a>).</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.tk.fsfsreshard"></a>fsfs-reshard.py</h4></div></div></div><p>While not an official member of the Subversion toolchain, the <span class="command"><strong>fsfs-reshard.py</strong></span> script (found in the <code class="filename">tools/server-side</code> directory of the Subversion source distribution) is a useful performance tuning tool for administrators of FSFS-backed Subversion repositories. As described in the sidebar <a class="xref" href="#svn.reposadmin.basics.backends.fsfs.revfiles" title="Revision files and shards">Revision files and shards</a>, FSFS repositories use individual files to house information about each revision. Sometimes these files all live in a single directory; sometimes they are sharded across many directories. But the neat thing is that the number of directories used to house these files is configurable. That's where <span class="command"><strong>fsfs-reshard.py</strong></span> comes in.</p><p><span class="command"><strong>fsfs-reshard.py</strong></span> reshuffles the repository's file structure into a new arrangement that reflects the requested number of sharding subdirectories and updates the repository configuration to preserve this change. When used in conjunction with the <span class="command"><strong>svnadmin upgrade</strong></span> command, this is especially useful for upgrading a pre-1.5 Subversion (unsharded) repository to the latest filesystem format and sharding its data files (which Subversion will not automatically do for you). This script can also be used for fine-tuning an already sharded repository.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.tk.bdbutil"></a>Berkeley DB utilities</h4></div></div></div><p>If you're using a Berkeley DB repository, all of your versioned filesystem's structure and data live in a set of database tables within the <code class="filename">db/</code> subdirectory of your repository. This subdirectory is a regular Berkeley DB environment directory and can therefore be used in conjunction with any of the Berkeley database tools, typically provided as part of the Berkeley DB distribution.</p><p>For day-to-day Subversion use, these tools are unnecessary. Most of the functionality typically needed for Subversion repositories has been duplicated in the <span class="command"><strong>svnadmin</strong></span> tool. For example, <span class="command"><strong>svnadmin list-unused-dblogs</strong></span> and <span class="command"><strong>svnadmin list-dblogs</strong></span> perform a subset of what is provided by the Berkeley <span class="command"><strong>db_archive</strong></span> utility, and <span class="command"><strong>svnadmin recover</strong></span> reflects the common use cases of the <span class="command"><strong>db_recover</strong></span> utility.</p><p>However, there are still a few Berkeley DB utilities that you might find useful. The <span class="command"><strong>db_dump</strong></span> and <span class="command"><strong>db_load</strong></span> programs write and read, respectively, a custom file format that describes the keys and values in a Berkeley DB database. Since Berkeley databases are not portable across machine architectures, this format is a useful way to transfer those databases from machine to machine, irrespective of architecture or operating system. As we describe later in this chapter, you can also use <span class="command"><strong>svnadmin dump</strong></span> and <span class="command"><strong>svnadmin load</strong></span> for similar purposes, but <span class="command"><strong>db_dump</strong></span> and <span class="command"><strong>db_load</strong></span> can do certain jobs just as well and much faster. They can also be useful if the experienced Berkeley DB hacker needs to do in-place tweaking of the data in a BDB-backed repository for some reason, which is something Subversion's utilities won't allow. Also, the <span class="command"><strong>db_stat</strong></span> utility can provide useful information about the status of your Berkeley DB environment, including detailed statistics about the locking and storage subsystems.</p><p>For more information on the Berkeley DB tool chain, visit the documentation section of the Berkeley DB section of Oracle's web site, located at <a class="ulink" href="http://www.oracle.com/technology/documentation/berkeley-db/db/" target="_top">http://www.oracle.com/technology/documentation/berkeley-db/db/</a>.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.maint.setlog"></a>Commit Log Message Correction</h3></div></div></div><p>Sometimes a user will have an error in her log message (a misspelling or some misinformation, perhaps). If the repository is configured (using the pre-revprop-change hook; see <a class="xref" href="#svn.reposadmin.create.hooks" title="Implementing Repository Hooks">the section called “Implementing Repository Hooks”</a>) to accept changes to this log message after the commit is finished, the user can <span class="quote">“<span class="quote">fix</span>”</span> her log message remotely using <span class="command"><strong>svn propset</strong></span> (see <a class="xref" href="#svn.ref.svn.c.propset" title="svn propset (pset, ps)">svn propset (pset, ps)</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>). However, because of the potential to lose information forever, Subversion repositories are not, by default, configured to allow changes to unversioned properties—except by an administrator.</p><p>If a log message needs to be changed by an administrator, this can be done using <span class="command"><strong>svnadmin setlog</strong></span>. This command changes the log message (the <code class="literal">svn:log</code> property) on a given revision of a repository, reading the new value from a provided file.</p><div class="informalexample"><pre class="screen"> $ echo "Here is the new, correct log message" &gt; newlog.txt $ svnadmin setlog myrepos newlog.txt -r 388 </pre></div><p>The <span class="command"><strong>svnadmin setlog</strong></span> command, by default, is still bound by the same protections against modifying unversioned properties as a remote client is—the pre-revprop-change and post-revprop-change hooks are still triggered, and therefore must be set up to accept changes of this nature. But an administrator can get around these protections by passing the <code class="option">--bypass-hooks</code> option to the <span class="command"><strong>svnadmin setlog</strong></span> command.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Remember, though, that by bypassing the hooks, you are likely avoiding such things as email notifications of property changes, backup systems that track unversioned property changes, and so on. In other words, be very careful about what you are changing, and how you change it.</p></td></tr></table></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.maint.diskspace"></a>Managing Disk Space</h3></div></div></div><p>While the cost of storage has dropped incredibly in the past few years, disk usage is still a valid concern for administrators seeking to version large amounts of data. Every bit of version history information stored in the live repository needs to be backed up elsewhere, perhaps multiple times as part of rotating backup schedules. It is useful to know what pieces of Subversion's repository data need to remain on the live site, which need to be backed up, and which can be safely removed.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.diskspace.deltas"></a>How Subversion saves disk space</h4></div></div></div><p>To keep the repository small, Subversion uses <em class="firstterm">deltification</em> (or delta-based storage) within the repository itself. Deltification involves encoding the representation of a chunk of data as a collection of differences against some other chunk of data. If the two pieces of data are very similar, this deltification results in storage savings for the deltified chunk—rather than taking up space equal to the size of the original data, it takes up only enough space to say, <span class="quote">“<span class="quote">I look just like this other piece of data over here, except for the following couple of changes.</span>”</span> The result is that most of the repository data that tends to be bulky—namely, the contents of versioned files—is stored at a much smaller size than the original full-text representation of that data.</p><p>While deltified storage has been a part of Subversion's design since the very beginning, there have been additional improvements made over the years. Subversion repositories created with Subversion 1.4 or later benefit from compression of the full-text representations of file contents. Repositories created with Subversion 1.6 or later further enjoy the disk space savings afforded by <em class="firstterm">representation sharing</em>, a feature which allows multiple files or file revisions with identical file content to refer to a single shared instance of that data rather than each having their own distinct copy thereof.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Because all of the data that is subject to deltification in a BDB-backed repository is stored in a single Berkeley DB database file, reducing the size of the stored values will not immediately reduce the size of the database file itself. Berkeley DB will, however, keep internal records of unused areas of the database file and consume those areas first before growing the size of the database file. So while deltification doesn't produce immediate space savings, it can drastically slow future growth of the database.</p></td></tr></table></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.diskspace.deadtxns"></a>Removing dead transactions</h4></div></div></div><p>Though they are uncommon, there are circumstances in which a Subversion commit process might fail, leaving behind in the repository the remnants of the revision-to-be that wasn't—an uncommitted transaction and all the file and directory changes associated with it. This could happen for several reasons: perhaps the client operation was inelegantly terminated by the user, or a network failure occurred in the middle of an operation. Regardless of the reason, dead transactions can happen. They don't do any real harm, other than consuming disk space. A fastidious administrator may nonetheless wish to remove them.</p><p>You can use the <span class="command"><strong>svnadmin lstxns</strong></span> command to list the names of the currently outstanding transactions:</p><div class="informalexample"><pre class="screen"> $ svnadmin lstxns myrepos 19 3a1 a45 $ </pre></div><p>Each item in the resultant output can then be used with <span class="command"><strong>svnlook</strong></span> (and its <code class="option">--transaction</code> (<code class="option">-t</code>) option) to determine who created the transaction, when it was created, what types of changes were made in the transaction—information that is helpful in determining whether the transaction is a safe candidate for removal! If you do indeed want to remove a transaction, its name can be passed to <span class="command"><strong>svnadmin rmtxns</strong></span>, which will perform the cleanup of the transaction. In fact, <span class="command"><strong>svnadmin rmtxns</strong></span> can take its input directly from the output of <span class="command"><strong>svnadmin lstxns</strong></span>!</p><div class="informalexample"><pre class="screen"> $ svnadmin rmtxns myrepos `svnadmin lstxns myrepos` $ </pre></div><p>If you use these two subcommands like this, you should consider making your repository temporarily inaccessible to clients. That way, no one can begin a legitimate transaction before you start your cleanup. <a class="xref" href="#svn.reposadmin.maint.diskspace.deadtxns.ex-1" title="Example 5.1. txn-info.sh (reporting outstanding transactions)">Example 5.1, “txn-info.sh (reporting outstanding transactions)”</a> contains a bit of shell-scripting that can quickly generate information about each outstanding transaction in your repository.</p><div class="example"><a id="svn.reposadmin.maint.diskspace.deadtxns.ex-1"></a><p class="title"><strong>Example 5.1. txn-info.sh (reporting outstanding transactions)</strong></p><div class="example-contents"><pre class="programlisting"> #!/bin/sh ### Generate informational output for all outstanding transactions in ### a Subversion repository. REPOS="${1}" if [ "x$REPOS" = x ] ; then echo "usage: $0 REPOS_PATH" exit fi for TXN in `svnadmin lstxns ${REPOS}`; do echo "---[ Transaction ${TXN} ]-------------------------------------------" svnlook info "${REPOS}" -t "${TXN}" done </pre></div></div><br class="example-break"></br><p>The output of the script is basically a concatenation of several chunks of <span class="command"><strong>svnlook info</strong></span> output (see <a class="xref" href="#svn.reposadmin.maint.tk.svnlook" title="svnlook">the section called “svnlook”</a>) and will look something like this:</p><div class="informalexample"><pre class="screen"> $ txn-info.sh myrepos ---[ Transaction 19 ]------------------------------------------- sally 2001-09-04 11:57:19 -0500 (Tue, 04 Sep 2001) 0 ---[ Transaction 3a1 ]------------------------------------------- harry 2001-09-10 16:50:30 -0500 (Mon, 10 Sep 2001) 39 Trying to commit over a faulty network. ---[ Transaction a45 ]------------------------------------------- sally 2001-09-12 11:09:28 -0500 (Wed, 12 Sep 2001) 0 $ </pre></div><p>A long-abandoned transaction usually represents some sort of failed or interrupted commit. A transaction's datestamp can provide interesting information—for example, how likely is it that an operation begun nine months ago is still active?</p><p>In short, transaction cleanup decisions need not be made unwisely. Various sources of information—including Apache's error and access logs, Subversion's operational logs, Subversion revision history, and so on—can be employed in the decision-making process. And of course, an administrator can often simply communicate with a seemingly dead transaction's owner (via email, e.g.) to verify that the transaction is, in fact, in a zombie state.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.diskspace.bdblogs"></a>Purging unused Berkeley DB logfiles</h4></div></div></div><p>Until recently, the largest offender of disk space usage with respect to BDB-backed Subversion repositories were the logfiles in which Berkeley DB performs its prewrites before modifying the actual database files. These files capture all the actions taken along the route of changing the database from one state to another—while the database files, at any given time, reflect a particular state, the logfiles contain all of the many changes along the way <span class="emphasis"><em>between</em></span> states. Thus, they can grow and accumulate quite rapidly.</p><p>Fortunately, beginning with the 4.2 release of Berkeley DB, the database environment has the ability to remove its own unused logfiles automatically. Any repositories created using <span class="command"><strong>svnadmin</strong></span> when compiled against Berkeley DB version 4.2 or later will be configured for this automatic logfile removal. If you don't want this feature enabled, simply pass the <code class="option">--bdb-log-keep</code> option to the <span class="command"><strong>svnadmin create</strong></span> command. If you forget to do this or change your mind at a later time, simply edit the <code class="filename">DB_CONFIG</code> file found in your repository's <code class="filename">db</code> directory, comment out the line that contains the <code class="literal">set_flags DB_LOG_AUTOREMOVE</code> directive, and then run <span class="command"><strong>svnadmin recover</strong></span> on your repository to force the configuration changes to take effect. See <a class="xref" href="#svn.reposadmin.create.bdb" title="Berkeley DB Configuration">the section called “Berkeley DB Configuration”</a> for more information about database configuration.</p><p>Without some sort of automatic logfile removal in place, logfiles will accumulate as you use your repository. This is actually somewhat of a feature of the database system—you should be able to recreate your entire database using nothing but the logfiles, so these files can be useful for catastrophic database recovery. But typically, you'll want to archive the logfiles that are no longer in use by Berkeley DB, and then remove them from disk to conserve space. Use the <span class="command"><strong>svnadmin list-unused-dblogs</strong></span> command to list the unused logfiles:</p><div class="informalexample"><pre class="screen"> $ svnadmin list-unused-dblogs /var/svn/repos /var/svn/repos/log.0000000031 /var/svn/repos/log.0000000032 /var/svn/repos/log.0000000033 … $ rm `svnadmin list-unused-dblogs /var/svn/repos` ## disk space reclaimed! </pre></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>BDB-backed repositories whose logfiles are used as part of a backup or disaster recovery plan should <span class="emphasis"><em>not</em></span> make use of the logfile autoremoval feature. Reconstruction of a repository's data from logfiles can only be accomplished only when <span class="emphasis"><em>all</em></span> the logfiles are available. If some of the logfiles are removed from disk before the backup system has a chance to copy them elsewhere, the incomplete set of backed-up logfiles is essentially useless.</p></td></tr></table></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.diskspace.fsfspacking"></a>Packing FSFS filesystems</h4></div></div></div><p>As described in the sidebar <a class="xref" href="#svn.reposadmin.basics.backends.fsfs.revfiles" title="Revision files and shards">Revision files and shards</a>, FSFS-backed Subversion repositories create, by default, a new on-disk file for each revision added to the repository. Having thousands of these files present on your Subversion server—even when housed in separate shard directories—can lead to inefficiencies.</p><p>The first problem is that the operating system has to reference many different files over a short period of time. This leads to inefficient use of disk caches and, as a result, more time spent seeking across large disks. Because of this, Subversion pays a performance penalty when accessing your versioned data.</p><p>The second problem is a bit more subtle. Because of the ways that most filesystems allocate disk space, each file claims more space on the disk than it actually uses. The amount of extra space required to house a single file can average anywhere from 2 to 16 kilobytes <span class="emphasis"><em>per file</em></span>, depending on the underlying filesystem in use. This translates directly into a per-revision disk usage penalty for FSFS-backed repositories. The effect is most pronounced in repositories which have many small revisions, since the overhead involved in storing the revision file quickly outgrows the size of the actual data being stored.</p><p>To solve these problems, Subversion 1.6 introduced the <span class="command"><strong>svnadmin pack</strong></span> command. By concatenating all the files of a completed shard into a single <span class="quote">“<span class="quote">pack</span>”</span> file and then removing the original per-revision files, <span class="command"><strong>svnadmin pack</strong></span> reduces the file count within a given shard down to just a single file. In doing so, it aids filesystem caches and reduces (to one) the number of times a file storage overhead penalty is paid.</p><p>Subversion can pack existing sharded repositories which have been upgraded to the 1.6 filesystem format or later (see <a class="xref" href="#svn.ref.svnadmin.c.upgrade" title="svnadmin upgrade">svnadmin upgrade</a>) in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>. To do so, just run <span class="command"><strong>svnadmin pack</strong></span> on the repository:</p><div class="informalexample"><pre class="screen"> $ svnadmin pack /var/svn/repos Packing shard 0...done. Packing shard 1...done. Packing shard 2...done. … Packing shard 34...done. Packing shard 35...done. Packing shard 36...done. $ </pre></div><p>Because the packing process obtains the required locks before doing its work, you can run it on live repositories, or even as part of a post-commit hook. Repacking packed shards is legal, but will have no effect on the disk usage of the repository.</p><p><span class="command"><strong>svnadmin pack</strong></span> has no effect on BDB-backed Subversion repositories.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.maint.recovery"></a>Berkeley DB Recovery</h3></div></div></div><p>As mentioned in <a class="xref" href="#svn.reposadmin.basics.backends.bdb" title="Berkeley DB">the section called “Berkeley DB”</a>, a Berkeley DB repository can sometimes be left in a frozen state if not closed properly. When this happens, an administrator needs to rewind the database back into a consistent state. This is unique to BDB-backed repositories, though—if you are using FSFS-backed ones instead, this won't apply to you. And for those of you using Subversion 1.4 with Berkeley DB 4.4 or later, you should find that Subversion has become much more resilient in these types of situations. Still, wedged Berkeley DB repositories do occur, and an administrator needs to know how to safely deal with this circumstance.</p><p>To protect the data in your repository, Berkeley DB uses a locking mechanism. This mechanism ensures that portions of the database are not simultaneously modified by multiple database accessors, and that each process sees the data in the correct state when that data is being read from the database. When a process needs to change something in the database, it first checks for the existence of a lock on the target data. If the data is not locked, the process locks the data, makes the change it wants to make, and then unlocks the data. Other processes are forced to wait until that lock is removed before they are permitted to continue accessing that section of the database. (This has nothing to do with the locks that you, as a user, can apply to versioned files within the repository; we try to clear up the confusion caused by this terminology collision in the sidebar <a class="xref" href="#svn.advanced.locking.meanings" title="The Three Meanings of “Lock”">The Three Meanings of <span class="quote">“<span class="quote">Lock</span>”</span></a>.)</p><p>In the course of using your Subversion repository, fatal errors or interruptions can prevent a process from having the chance to remove the locks it has placed in the database. The result is that the backend database system gets <span class="quote">“<span class="quote">wedged.</span>”</span> When this happens, any attempts to access the repository hang indefinitely (since each new accessor is waiting for a lock to go away—which isn't going to happen).</p><p>If this happens to your repository, don't panic. The Berkeley DB filesystem takes advantage of database transactions, checkpoints, and prewrite journaling to ensure that only the most catastrophic of events<a href="#ftn.idm5572" class="footnote" id="idm5572"><sup class="footnote">[44]</sup></a> can permanently destroy a database environment. A sufficiently paranoid repository administrator will have made off-site backups of the repository data in some fashion, but don't head off to the tape backup storage closet just yet.</p><p>Instead, use the following recipe to attempt to <span class="quote">“<span class="quote">unwedge</span>”</span> your repository:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Make sure no processes are accessing (or attempting to access) the repository. For networked repositories, this also means shutting down the Apache HTTP Server or svnserve daemon.</p></li><li class="listitem"><p>Become the user who owns and manages the repository. This is important, as recovering a repository while running as the wrong user can tweak the permissions of the repository's files in such a way that your repository will still be inaccessible even after it is <span class="quote">“<span class="quote">unwedged.</span>”</span></p></li><li class="listitem"><p>Run the command <strong class="userinput"><code>svnadmin recover /var/svn/repos</code></strong>. You should see output such as this:</p><div class="informalexample"><pre class="screen"> Repository lock acquired. Please wait; recovering the repository may take some time... Recovery completed. The latest repos revision is 19. </pre></div><p>This command may take many minutes to complete.</p></li><li class="listitem"><p>Restart the server process.</p></li></ol></div><p>This procedure fixes almost every case of repository wedging. Make sure that you run this command as the user that owns and manages the database, not just as <code class="literal">root</code>. Part of the recovery process might involve re-creating from scratch various database files (shared memory regions, e.g.). Recovering as <code class="literal">root</code> will create those files such that they are owned by <code class="literal">root</code>, which means that even after you restore connectivity to your repository, regular users will be unable to access it.</p><p>If the previous procedure, for some reason, does not successfully unwedge your repository, you should do two things. First, move your broken repository directory aside (perhaps by renaming it to something like <code class="filename">repos.BROKEN</code>) and then restore your latest backup of it. Then, send an email to the Subversion users mailing list (at <code class="email">&lt;<a class="email" href="mailto:users@subversion.apache.org">users@subversion.apache.org</a>&gt;</code>) describing your problem in detail. Data integrity is an extremely high priority to the Subversion developers.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.maint.migrate"></a>Migrating Repository Data Elsewhere</h3></div></div></div><p>A Subversion filesystem has its data spread throughout files in the repository, in a fashion generally understood by (and of interest to) only the Subversion developers themselves. However, circumstances may arise that call for all, or some subset, of that data to be copied or moved into another repository.</p><p>Subversion provides such functionality by way of <em class="firstterm">repository dump streams</em>. A repository dump stream (often referred to as a <span class="quote">“<span class="quote">dump file</span>”</span> when stored as a file on disk) is a portable, flat file format that describes the various revisions in your repository—what was changed, by whom, when, and so on. This dump stream is the primary mechanism used to marshal versioned history—in whole or in part, with or without modification—between repositories. And Subversion provides the tools necessary for creating and loading these dump streams: the <span class="command"><strong>svnadmin dump</strong></span> and <span class="command"><strong>svnadmin load</strong></span> subcommands, respectively, and the <span class="command"><strong>svnrdump</strong></span> program.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>While the Subversion repository dump format contains human-readable portions and a familiar structure (it resembles an RFC 822 format, the same type of format used for most email), it is <span class="emphasis"><em>not</em></span> a plain-text file format. It is a binary file format, highly sensitive to meddling. For example, many text editors will corrupt the file by automatically converting line endings.</p></td></tr></table></div><p>There are many reasons for dumping and loading Subversion repository data. Early in Subversion's life, the most common reason was due to the evolution of Subversion itself. As Subversion matured, there were times when changes made to the backend database schema caused compatibility issues with previous versions of the repository, so users had to dump their repository data using the previous version of Subversion and load it into a freshly created repository with the new version of Subversion. Now, these types of schema changes haven't occurred since Subversion's 1.0 release, and the Subversion developers promise not to force users to dump and load their repositories when upgrading between minor versions (such as from 1.3 to 1.4) of Subversion. But there are still other reasons for dumping and loading, including re-deploying a Berkeley DB repository on a new OS or CPU architecture, switching between the Berkeley DB and FSFS backends, or (as we'll cover later in this chapter in <a class="xref" href="#svn.reposadmin.maint.filtering" title="Filtering Repository History">the section called “Filtering Repository History”</a>) purging versioned data from repository history.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The Subversion repository dump format describes versioned repository changes only. It will not carry any information about uncommitted transactions, user locks on filesystem paths, repository or server configuration customizations (including hook scripts), and so on.</p></td></tr></table></div><p>The Subversion repository dump format also enables conversion from a different storage mechanism or version control system altogether. Because the dump file format is, for the most part, human-readable, it should be relatively easy to describe generic sets of changes—each of which should be treated as a new revision—using this file format. In fact, the <span class="command"><strong>cvs2svn</strong></span> utility (see <a class="xref" href="#svn.forcvs.convert" title="Converting a Repository from CVS to Subversion">the section called “Converting a Repository from CVS to Subversion”</a>) uses the dump format to represent the contents of a CVS repository so that those contents can be copied into a Subversion repository.</p><p>For now, we'll concern ourselves only with migration of repository data between Subversion repositories, which we'll describe in detail in the sections which follow.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.migrate.svnadmin"></a>Repository data migration using svnadmin</h4></div></div></div><p>Whatever your reason for migrating repository history, using the <span class="command"><strong>svnadmin dump</strong></span> and <span class="command"><strong>svnadmin load</strong></span> subcommands is straightforward. <span class="command"><strong>svnadmin dump</strong></span> will output a range of repository revisions that are formatted using Subversion's custom filesystem dump format. The dump format is printed to the standard output stream, while informative messages are printed to the standard error stream. This allows you to redirect the output stream to a file while watching the status output in your terminal window. For example:</p><div class="informalexample"><pre class="screen"> $ svnlook youngest myrepos 26 $ svnadmin dump myrepos &gt; dumpfile * Dumped revision 0. * Dumped revision 1. * Dumped revision 2. … * Dumped revision 25. * Dumped revision 26. </pre></div><p>At the end of the process, you will have a single file (<code class="filename">dumpfile</code> in the previous example) that contains all the data stored in your repository in the requested range of revisions. Note that <span class="command"><strong>svnadmin dump</strong></span> is reading revision trees from the repository just like any other <span class="quote">“<span class="quote">reader</span>”</span> process would (e.g., <span class="command"><strong>svn checkout</strong></span>), so it's safe to run this command at any time.</p><p>The other subcommand in the pair, <span class="command"><strong>svnadmin load</strong></span>, parses the standard input stream as a Subversion repository dump file and effectively replays those dumped revisions into the target repository for that operation. It also gives informative feedback, this time using the standard output stream:</p><div class="informalexample"><pre class="screen"> $ svnadmin load newrepos &lt; dumpfile &lt;&lt;&lt; Started new txn, based on original revision 1 * adding path : A ... done. * adding path : A/B ... done. … ------- Committed new rev 1 (loaded from original rev 1) &gt;&gt;&gt; &lt;&lt;&lt; Started new txn, based on original revision 2 * editing path : A/mu ... done. * editing path : A/D/G/rho ... done. ------- Committed new rev 2 (loaded from original rev 2) &gt;&gt;&gt; … &lt;&lt;&lt; Started new txn, based on original revision 25 * editing path : A/D/gamma ... done. ------- Committed new rev 25 (loaded from original rev 25) &gt;&gt;&gt; &lt;&lt;&lt; Started new txn, based on original revision 26 * adding path : A/Z/zeta ... done. * editing path : A/mu ... done. ------- Committed new rev 26 (loaded from original rev 26) &gt;&gt;&gt; </pre></div><p>The result of a load is new revisions added to a repository—the same thing you get by making commits against that repository from a regular Subversion client. Just as in a commit, you can use hook programs to perform actions before and after each of the commits made during a load process. By passing the <code class="option">--use-pre-commit-hook</code> and <code class="option">--use-post-commit-hook</code> options to <span class="command"><strong>svnadmin load</strong></span>, you can instruct Subversion to execute the pre-commit and post-commit hook programs, respectively, for each loaded revision. You might use these, for example, to ensure that loaded revisions pass through the same validation steps that regular commits pass through. Of course, you should use these options with care—if your post-commit hook sends emails to a mailing list for each new commit, you might not want to spew hundreds or thousands of commit emails in rapid succession at that list! You can read more about the use of hook scripts in <a class="xref" href="#svn.reposadmin.create.hooks" title="Implementing Repository Hooks">the section called “Implementing Repository Hooks”</a>.</p><p>Note that because <span class="command"><strong>svnadmin</strong></span> uses standard input and output streams for the repository dump and load processes, people who are feeling especially saucy can try things such as this (perhaps even using different versions of <span class="command"><strong>svnadmin</strong></span> on each side of the pipe):</p><div class="informalexample"><pre class="screen"> $ svnadmin create newrepos $ svnadmin dump oldrepos | svnadmin load newrepos </pre></div><p>By default, the dump file will be quite large—much larger than the repository itself. That's because by default every version of every file is expressed as a full text in the dump file. This is the fastest and simplest behavior, and it's nice if you're piping the dump data directly into some other process (such as a compression program, filtering program, or loading process). But if you're creating a dump file for longer-term storage, you'll likely want to save disk space by using the <code class="option">--deltas</code> option. With this option, successive revisions of files will be output as compressed, binary differences—just as file revisions are stored in a repository. This option is slower, but it results in a dump file much closer in size to the original repository.</p><p>We mentioned previously that <span class="command"><strong>svnadmin dump</strong></span> outputs a range of revisions. Use the <code class="option">--revision</code> (<code class="option">-r</code>) option to specify a single revision, or a range of revisions, to dump. If you omit this option, all the existing repository revisions will be dumped.</p><div class="informalexample"><pre class="screen"> $ svnadmin dump myrepos -r 23 &gt; rev-23.dumpfile $ svnadmin dump myrepos -r 100:200 &gt; revs-100-200.dumpfile </pre></div><p>As Subversion dumps each new revision, it outputs only enough information to allow a future loader to re-create that revision based on the previous one. In other words, for any given revision in the dump file, only the items that were changed in that revision will appear in the dump. The only exception to this rule is the first revision that is dumped with the current <span class="command"><strong>svnadmin dump</strong></span> command.</p><p>By default, Subversion will not express the first dumped revision as merely differences to be applied to the previous revision. For one thing, there is no previous revision in the dump file! And second, Subversion cannot know the state of the repository into which the dump data will be loaded (if it ever is). To ensure that the output of each execution of <span class="command"><strong>svnadmin dump</strong></span> is self-sufficient, the first dumped revision is, by default, a full representation of every directory, file, and property in that revision of the repository.</p><p>However, you can change this default behavior. If you add the <code class="option">--incremental</code> option when you dump your repository, <span class="command"><strong>svnadmin</strong></span> will compare the first dumped revision against the previous revision in the repository—the same way it treats every other revision that gets dumped. It will then output the first revision exactly as it does the rest of the revisions in the dump range—mentioning only the changes that occurred in that revision. The benefit of this is that you can create several small dump files that can be loaded in succession, instead of one large one, like so:</p><div class="informalexample"><pre class="screen"> $ svnadmin dump myrepos -r 0:1000 &gt; dumpfile1 $ svnadmin dump myrepos -r 1001:2000 --incremental &gt; dumpfile2 $ svnadmin dump myrepos -r 2001:3000 --incremental &gt; dumpfile3 </pre></div><p>These dump files could be loaded into a new repository with the following command sequence:</p><div class="informalexample"><pre class="screen"> $ svnadmin load newrepos &lt; dumpfile1 $ svnadmin load newrepos &lt; dumpfile2 $ svnadmin load newrepos &lt; dumpfile3 </pre></div><p>Another neat trick you can perform with this <code class="option">--incremental</code> option involves appending to an existing dump file a new range of dumped revisions. For example, you might have a post-commit hook that simply appends the repository dump of the single revision that triggered the hook. Or you might have a script that runs nightly to append dump file data for all the revisions that were added to the repository since the last time the script ran. Used like this, <span class="command"><strong>svnadmin dump</strong></span> can be one way to back up changes to your repository over time in case of a system crash or some other catastrophic event.</p><p>The dump format can also be used to merge the contents of several different repositories into a single repository. By using the <code class="option">--parent-dir</code> option of <span class="command"><strong>svnadmin load</strong></span>, you can specify a new virtual root directory for the load process. That means if you have dump files for three repositories—say <code class="filename">calc-dumpfile</code>, <code class="filename">cal-dumpfile</code>, and <code class="filename">ss-dumpfile</code>—you can first create a new repository to hold them all:</p><div class="informalexample"><pre class="screen"> $ svnadmin create /var/svn/projects $ </pre></div><p>Then, make new directories in the repository that will encapsulate the contents of each of the three previous repositories:</p><div class="informalexample"><pre class="screen"> $ svn mkdir -m "Initial project roots" \ file:///var/svn/projects/calc \ file:///var/svn/projects/calendar \ file:///var/svn/projects/spreadsheet Committed revision 1. $ </pre></div><p>Lastly, load the individual dump files into their respective locations in the new repository:</p><div class="informalexample"><pre class="screen"> $ svnadmin load /var/svn/projects --parent-dir calc &lt; calc-dumpfile … $ svnadmin load /var/svn/projects --parent-dir calendar &lt; cal-dumpfile … $ svnadmin load /var/svn/projects --parent-dir spreadsheet &lt; ss-dumpfile … $ </pre></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.migrate.svnrdump"></a>Repository data migration using svnrdump</h4></div></div></div><p>In Subversion 1.7, <span class="command"><strong>svnrdump</strong></span> joined the set of stock Subversion tools. It offers fairly specialized functionality, essentially as a network-aware version of the <span class="command"><strong>svnadmin dump</strong></span> and <span class="command"><strong>svnadmin load</strong></span> commands which we discuss in depth in <a class="xref" href="#svn.reposadmin.maint.migrate.svnadmin" title="Repository data migration using svnadmin">the section called “Repository data migration using svnadmin”</a>. <span class="command"><strong>svnrdump dump</strong></span> will generate a dump stream from a remote repository, spewing it to standard output; <span class="command"><strong>svnrdump load</strong></span> will read a dump stream from standard input and load it into a remote repository. Using <span class="command"><strong>svnrdump</strong></span>, you can generate incremental dumps just as you might with <span class="command"><strong>svnadmin dump</strong></span>. You can even dump a subtree of the repository—something that <span class="command"><strong>svnadmin dump</strong></span> cannot do.</p><p>The primary difference is that instead of requiring direct access to the repository, <span class="command"><strong>svnrdump</strong></span> operates remotely, using the very same Repository Access (RA) protocols that the Subversion client does. As such, you might need to provide authentication credentials. Also, your remote interations are subject to any authorization limitations configured on the Subversion server.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p><span class="command"><strong>svnrdump dump</strong></span> requires that the remote server be running Subversion 1.4 or newer. It currently generates dump streams only of the sort which are created when you pass the <code class="option">--deltas</code> option to <span class="command"><strong>svnadmin dump</strong></span>. This isn't interesting in the typical use-cases, but might impact specific types of custom transformations you might wish to apply to the resulting dump stream.</p></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Because it modifies revision properties after committing new revisions, <span class="command"><strong>svnrdump load</strong></span> requires that the target repository have revision property changes enabled via the pre-revprop-change hook. See <a class="xref" href="#svn.ref.reposhooks.pre-revprop-change" title="pre-revprop-change">pre-revprop-change</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a> for details.</p></td></tr></table></div><p>As you might expect, you can use <span class="command"><strong>svnadmin</strong></span> and <span class="command"><strong>svnrdump</strong></span> in concert. You can, for example, use <span class="command"><strong>svnrdump dump</strong></span> to generate a dump stream from a remote repository, and pipe the results thereof through <span class="command"><strong>svnadmin load</strong></span> to copy all that repository history into a local repository. Or you can do the reverse, copying history from a local repository into a remote one.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>By using <code class="literal">file://</code> URLs, <span class="command"><strong>svnrdump</strong></span> can also access local repositories, but it will be doing so via Subversion's Repository Access (RA) abstraction layer—you'll get better performance out of <span class="command"><strong>svnadmin</strong></span> in such situations.</p></td></tr></table></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.maint.filtering"></a>Filtering Repository History</h3></div></div></div><p>Since Subversion stores your versioned history using, at the very least, binary differencing algorithms and data compression (optionally in a completely opaque database system), attempting manual tweaks is unwise if not quite difficult, and at any rate strongly discouraged. And once data has been stored in your repository, Subversion generally doesn't provide an easy way to remove that data.<a href="#ftn.idm5718" class="footnote" id="idm5718"><sup class="footnote">[45]</sup></a> But inevitably, there will be times when you would like to manipulate the history of your repository. You might need to strip out all instances of a file that was accidentally added to the repository (and shouldn't be there for whatever reason).<a href="#ftn.idm5720" class="footnote" id="idm5720"><sup class="footnote">[46]</sup></a> Or, perhaps you have multiple projects sharing a single repository, and you decide to split them up into their own repositories. To accomplish tasks such as these, administrators need a more manageable and malleable representation of the data in their repositories—the Subversion repository dump format.</p><p>As we described earlier in <a class="xref" href="#svn.reposadmin.maint.migrate" title="Migrating Repository Data Elsewhere">the section called “Migrating Repository Data Elsewhere”</a>, the Subversion repository dump format is a human-readable representation of the changes that you've made to your versioned data over time. Use the <span class="command"><strong>svnadmin dump</strong></span> or <span class="command"><strong>svnrdump dump</strong></span> command to generate the dump data, and <span class="command"><strong>svnadmin load</strong></span> or <span class="command"><strong>svnrdump load</strong></span> to populate a new repository with it. The great thing about the human-readability aspect of the dump format is that, if you aren't careless about it, you can manually inspect and modify it. Of course, the downside is that if you have three years' worth of repository activity encapsulated in what is likely to be a very large dump file, it could take you a long, long time to manually inspect and modify it.</p><p>That's where <span class="command"><strong>svndumpfilter</strong></span> becomes useful. This program acts as a path-based filter for repository dump streams. Simply give it either a list of paths you wish to keep or a list of paths you wish to not keep, and then pipe your repository dump data through this filter. The result will be a modified stream of dump data that contains only the versioned paths you (explicitly or implicitly) requested.</p><p>Let's look at a realistic example of how you might use this program. Earlier in this chapter (see <a class="xref" href="#svn.reposadmin.projects.chooselayout" title="Planning Your Repository Organization">the section called “Planning Your Repository Organization”</a>), we discussed the process of deciding how to choose a layout for the data in your repositories—using one repository per project or combining them, arranging stuff within your repository, and so on. But sometimes after new revisions start flying in, you rethink your layout and would like to make some changes. A common change is the decision to move multiple projects that are sharing a single repository into separate repositories for each project.</p><p>Our imaginary repository contains three projects: <code class="literal">calc</code>, <code class="literal">calendar</code>, and <code class="literal">spreadsheet</code>. They have been living side-by-side in a layout like this:</p><div class="informalexample"><div class="literallayout"><p><br></br> /<br></br>    calc/<br></br>       trunk/<br></br>       branches/<br></br>       tags/<br></br>    calendar/<br></br>       trunk/<br></br>       branches/<br></br>       tags/<br></br>    spreadsheet/<br></br>       trunk/<br></br>       branches/<br></br>       tags/<br></br> </p></div></div><p>To get these three projects into their own repositories, we first dump the whole repository:</p><div class="informalexample"><pre class="screen"> $ svnadmin dump /var/svn/repos &gt; repos-dumpfile * Dumped revision 0. * Dumped revision 1. * Dumped revision 2. * Dumped revision 3. … $ </pre></div><p>Next, run that dump file through the filter, each time including only one of our top-level directories. This results in three new dump files:</p><div class="informalexample"><pre class="screen"> $ svndumpfilter include calc &lt; repos-dumpfile &gt; calc-dumpfile … $ svndumpfilter include calendar &lt; repos-dumpfile &gt; cal-dumpfile … $ svndumpfilter include spreadsheet &lt; repos-dumpfile &gt; ss-dumpfile … $ </pre></div><p>At this point, you have to make a decision. Each of your dump files will create a valid repository, but will preserve the paths exactly as they were in the original repository. This means that even though you would have a repository solely for your <code class="literal">calc</code> project, that repository would still have a top-level directory named <code class="filename">calc</code>. If you want your <code class="filename">trunk</code>, <code class="filename">tags</code>, and <code class="filename">branches</code> directories to live in the root of your repository, you might wish to edit your dump files, tweaking the <code class="literal">Node-path</code> and <code class="literal">Node-copyfrom-path</code> headers so that they no longer have that first <code class="filename">calc/</code> path component. Also, you'll want to remove the section of dump data that creates the <code class="filename">calc</code> directory. It will look something like the following:</p><div class="informalexample"><pre class="programlisting"> Node-path: calc Node-action: add Node-kind: dir Content-length: 0 </pre></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>If you do plan on manually editing the dump file to remove a top-level directory, make sure your editor is not set to automatically convert end-of-line characters to the native format (e.g., <code class="literal">\r\n</code> to <code class="literal">\n</code>), as the content will then not agree with the metadata. This will render the dump file useless.</p></td></tr></table></div><p>All that remains now is to create your three new repositories, and load each dump file into the right repository, ignoring the UUID found in the dump stream:</p><div class="informalexample"><pre class="screen"> $ svnadmin create calc $ svnadmin load --ignore-uuid calc &lt; calc-dumpfile &lt;&lt;&lt; Started new transaction, based on original revision 1 * adding path : Makefile ... done. * adding path : button.c ... done. … $ svnadmin create calendar $ svnadmin load --ignore-uuid calendar &lt; cal-dumpfile &lt;&lt;&lt; Started new transaction, based on original revision 1 * adding path : Makefile ... done. * adding path : cal.c ... done. … $ svnadmin create spreadsheet $ svnadmin load --ignore-uuid spreadsheet &lt; ss-dumpfile &lt;&lt;&lt; Started new transaction, based on original revision 1 * adding path : Makefile ... done. * adding path : ss.c ... done. … $ </pre></div><p>Both of <span class="command"><strong>svndumpfilter</strong></span>'s subcommands accept options for deciding how to deal with <span class="quote">“<span class="quote">empty</span>”</span> revisions. If a given revision contains only changes to paths that were filtered out, that now-empty revision could be considered uninteresting or even unwanted. So to give the user control over what to do with those revisions, <span class="command"><strong>svndumpfilter</strong></span> provides the following command-line options:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--drop-empty-revs</code></span></dt><dd><p>Do not generate empty revisions at all—just omit them.</p></dd><dt><span class="term"><code class="option">--renumber-revs</code></span></dt><dd><p>If empty revisions are dropped (using the <code class="option">--drop-empty-revs</code> option), change the revision numbers of the remaining revisions so that there are no gaps in the numeric sequence.</p></dd><dt><span class="term"><code class="option">--preserve-revprops</code></span></dt><dd><p>If empty revisions are not dropped, preserve the revision properties (log message, author, date, custom properties, etc.) for those empty revisions. Otherwise, empty revisions will contain only the original datestamp, and a generated log message that indicates that this revision was emptied by <span class="command"><strong>svndumpfilter</strong></span>.</p></dd></dl></div><p>While <span class="command"><strong>svndumpfilter</strong></span> can be very useful and a huge timesaver, there are unfortunately a couple of gotchas. First, this utility is overly sensitive to path semantics. Pay attention to whether paths in your dump file are specified with or without leading slashes. You'll want to look at the <code class="literal">Node-path</code> and <code class="literal">Node-copyfrom-path</code> headers.</p><div class="informalexample"><pre class="programlisting"> … Node-path: spreadsheet/Makefile … </pre></div><p>If the paths have leading slashes, you should include leading slashes in the paths you pass to <span class="command"><strong>svndumpfilter include</strong></span> and <span class="command"><strong>svndumpfilter exclude</strong></span> (and if they don't, you shouldn't). Further, if your dump file has an inconsistent usage of leading slashes for some reason,<a href="#ftn.idm5795" class="footnote" id="idm5795"><sup class="footnote">[47]</sup></a> you should probably normalize those paths so that they all have, or all lack, leading slashes.</p><p>Also, copied paths can give you some trouble. Subversion supports copy operations in the repository, where a new path is created by copying some already existing path. It is possible that at some point in the lifetime of your repository, you might have copied a file or directory from some location that <span class="command"><strong>svndumpfilter</strong></span> is excluding, to a location that it is including. To make the dump data self-sufficient, <span class="command"><strong>svndumpfilter</strong></span> needs to still show the addition of the new path—including the contents of any files created by the copy—and not represent that addition as a copy from a source that won't exist in your filtered dump data stream. But because the Subversion repository dump format shows only what was changed in each revision, the contents of the copy source might not be readily available. If you suspect that you have any copies of this sort in your repository, you might want to rethink your set of included/excluded paths, perhaps including the paths that served as sources of your troublesome copy operations, too.</p><p>Finally, <span class="command"><strong>svndumpfilter</strong></span> takes path filtering quite literally. If you are trying to copy the history of a project rooted at <code class="filename">trunk/my-project</code> and move it into a repository of its own, you would, of course, use the <span class="command"><strong>svndumpfilter include</strong></span> command to keep all the changes in and under <code class="filename">trunk/my-project</code>. But the resultant dump file makes no assumptions about the repository into which you plan to load this data. Specifically, the dump data might begin with the revision that added the <code class="filename">trunk/my-project</code> directory, but it will <span class="emphasis"><em>not</em></span> contain directives that would create the <code class="filename">trunk</code> directory itself (because <code class="filename">trunk</code> doesn't match the include filter). You'll need to make sure that any directories that the new dump stream expects to exist actually do exist in the target repository before trying to load the stream into that repository.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.maint.replication"></a>Repository Replication</h3></div></div></div><p>There are several scenarios in which it is quite handy to have a Subversion repository whose version history is exactly the same as some other repository's. Perhaps the most obvious one is the maintenance of a simple backup repository, used when the primary repository has become inaccessible due to a hardware failure, network outage, or other such annoyance. Other scenarios include deploying mirror repositories to distribute heavy Subversion load across multiple servers, use as a soft-upgrade mechanism, and so on.</p><p>Subversion provides a program for managing scenarios such as these. <span class="command"><strong>svnsync</strong></span> works by essentially asking the Subversion server to <span class="quote">“<span class="quote">replay</span>”</span> revisions, one at a time. It then uses that revision information to mimic a commit of the same to another repository. Neither repository needs to be locally accessible to the machine on which <span class="command"><strong>svnsync</strong></span> is running—its parameters are repository URLs, and it does all its work through Subversion's Repository Access (RA) interfaces. All it requires is read access to the source repository and read/write access to the destination repository.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>When using <span class="command"><strong>svnsync</strong></span> against a remote source repository, the Subversion server for that repository must be running Subversion version 1.4 or later.</p></td></tr></table></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.replication.svnsync"></a>Replication with svnsync</h4></div></div></div><p>Assuming you already have a source repository that you'd like to mirror, the next thing you need is a target repository that will actually serve as that mirror. This target repository can use either of the available filesystem data-store backends (see <a class="xref" href="#svn.reposadmin.basics.backends" title="Choosing a Data Store">the section called “Choosing a Data Store”</a>)—Subversion's abstraction layers ensure that such details don't matter. But by default, it must not yet have any version history in it. (We'll discuss an exception to this later in this section.)</p><p>The protocol that <span class="command"><strong>svnsync</strong></span> uses to communicate revision information is highly sensitive to mismatches between the versioned histories contained in the source and target repositories. For this reason, while <span class="command"><strong>svnsync</strong></span> cannot <span class="emphasis"><em>demand</em></span> that the target repository be read-only,<a href="#ftn.idm5828" class="footnote" id="idm5828"><sup class="footnote">[48]</sup></a> allowing the revision history in the target repository to change by any mechanism other than the mirroring process is a recipe for disaster.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Do <span class="emphasis"><em>not</em></span> modify a mirror repository in such a way as to cause its version history to deviate from that of the repository it mirrors. The only commits and revision property modifications that ever occur on that mirror repository should be those performed by the <span class="command"><strong>svnsync</strong></span> tool.</p></td></tr></table></div><p>Another requirement of the target repository is that the <span class="command"><strong>svnsync</strong></span> process be allowed to modify revision properties. Because <span class="command"><strong>svnsync</strong></span> works within the framework of that repository's hook system, the default state of the repository (which is to disallow revision property changes; see <a class="xref" href="#svn.ref.reposhooks.pre-revprop-change" title="pre-revprop-change">pre-revprop-change</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>) is insufficient. You'll need to explicitly implement the pre-revprop-change hook, and your script must allow <span class="command"><strong>svnsync</strong></span> to set and change revision properties. With those provisions in place, you are ready to start mirroring repository revisions.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>It's a good idea to implement authorization measures that allow your repository replication process to perform its tasks while preventing other users from modifying the contents of your mirror repository at all.</p></td></tr></table></div><p>Let's walk through the use of <span class="command"><strong>svnsync</strong></span> in a somewhat typical mirroring scenario. We'll pepper this discourse with practical recommendations, which you are free to disregard if they aren't required by or suitable for your environment.</p><p>We will be mirroring the public Subversion repository which houses the source code for this very book and exposing that mirror publicly on the Internet, hosted on a different machine than the one on which the original Subversion source code repository lives. This remote host has a global configuration that permits anonymous users to read the contents of repositories on the host, but requires users to authenticate to modify those repositories. (Please forgive us for glossing over the details of Subversion server configuration for the moment—those are covered thoroughly in <a class="xref" href="#svn.serverconfig" title="Chapter 6. Server Configuration">Chapter 6, <em>Server Configuration</em></a>.) And for no other reason than that it makes for a more interesting example, we'll be driving the replication process from a third machine—the one that we currently find ourselves using.</p><p>First, we'll create the repository which will be our mirror. This and the next couple of steps do require shell access to the machine on which the mirror repository will live. Once the repository is all configured, though, we shouldn't need to touch it directly again.</p><div class="informalexample"><pre class="screen"> $ ssh admin@svn.example.com "svnadmin create /var/svn/svn-mirror" admin@svn.example.com's password: ******** $ </pre></div><p>At this point, we have our repository, and due to our server's configuration, that repository is now <span class="quote">“<span class="quote">live</span>”</span> on the Internet. Now, because we don't want anything modifying the repository except our replication process, we need a way to distinguish that process from other would-be committers. To do so, we use a dedicated username for our process. Only commits and revision property modifications performed by the special username <code class="literal">syncuser</code> will be allowed.</p><p>We'll use the repository's hook system both to allow the replication process to do what it needs to do and to enforce that only it is doing those things. We accomplish this by implementing two of the repository event hooks—pre-revprop-change and start-commit. Our pre-revprop-change hook script is found in <a class="xref" href="#svn.reposadmin.maint.replication.pre-revprop-change" title="Example 5.2. Mirror repository's pre-revprop-change hook script">Example 5.2, “Mirror repository's pre-revprop-change hook script”</a>, and basically verifies that the user attempting the property changes is our <code class="literal">syncuser</code> user. If so, the change is allowed; otherwise, it is denied.</p><div class="example"><a id="svn.reposadmin.maint.replication.pre-revprop-change"></a><p class="title"><strong>Example 5.2. Mirror repository's pre-revprop-change hook script</strong></p><div class="example-contents"><pre class="programlisting"> #!/bin/sh USER="$3" if [ "$USER" = "syncuser" ]; then exit 0; fi echo "Only the syncuser user may change revision properties" &gt;&amp;2 exit 1 </pre></div></div><br class="example-break"></br><p>That covers revision property changes. Now we need to ensure that only the <code class="literal">syncuser</code> user is permitted to commit new revisions to the repository. We do this using a start-commit hook script such as the one in <a class="xref" href="#svn.reposadmin.maint.replication.start-commit" title="Example 5.3. Mirror repository's start-commit hook script">Example 5.3, “Mirror repository's start-commit hook script”</a>.</p><div class="example"><a id="svn.reposadmin.maint.replication.start-commit"></a><p class="title"><strong>Example 5.3. Mirror repository's start-commit hook script</strong></p><div class="example-contents"><pre class="programlisting"> #!/bin/sh USER="$2" if [ "$USER" = "syncuser" ]; then exit 0; fi echo "Only the syncuser user may commit new revisions" &gt;&amp;2 exit 1 </pre></div></div><br class="example-break"></br><p>After installing our hook scripts and ensuring that they are executable by the Subversion server, we're finished with the setup of the mirror repository. Now, we get to actually do the mirroring.</p><p>The first thing we need to do with <span class="command"><strong>svnsync</strong></span> is to register in our target repository the fact that it will be a mirror of the source repository. We do this using the <span class="command"><strong>svnsync initialize</strong></span> subcommand. The URLs we provide point to the root directories of the target and source repositories, respectively. In Subversion 1.4, this is required—only full mirroring of repositories is permitted. Beginning with Subversion 1.5, though, you can use <span class="command"><strong>svnsync</strong></span> to mirror only some subtree of the repository, too.</p><div class="informalexample"><pre class="screen"> $ svnsync help init initialize (init): usage: svnsync initialize DEST_URL SOURCE_URL Initialize a destination repository for synchronization from another repository. … $ svnsync initialize http://svn.example.com/svn-mirror \ https://svn.code.sf.net/p/svnbook/source \ --sync-username syncuser --sync-password syncpass Copied properties for revision 0 (svn:sync-* properties skipped). NOTE: Normalized svn:* properties to LF line endings (1 rev-props, 0 node-props). $ </pre></div><p>Our target repository will now remember that it is a mirror of the public Subversion source code repository. Notice that we provided a username and password as arguments to <span class="command"><strong>svnsync</strong></span>—that was required by the pre-revprop-change hook on our mirror repository.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>In Subversion 1.4, the values given to <span class="command"><strong>svnsync</strong></span>'s <code class="option">--username</code> and <code class="option">--password</code> command-line options were used for authentication against both the source and destination repositories. This caused problems when a user's credentials weren't exactly the same for both repositories, especially when running in noninteractive mode (with the <code class="option">--non-interactive</code> option). This was fixed in Subversion 1.5 with the introduction of two new pairs of options. Use <code class="option">--source-username</code> and <code class="option">--source-password</code> to provide authentication credentials for the source repository; use <code class="option">--sync-username</code> and <code class="option">--sync-password</code> to provide credentials for the destination repository. (The old <code class="option">--username</code> and <code class="option">--password</code> options still exist for compatibility, but we advise against using them.)</p></td></tr></table></div><p>And now comes the fun part. With a single subcommand, we can tell <span class="command"><strong>svnsync</strong></span> to copy all the as-yet-unmirrored revisions from the source repository to the target.<a href="#ftn.idm5888" class="footnote" id="idm5888"><sup class="footnote">[49]</sup></a> The <span class="command"><strong>svnsync synchronize</strong></span> subcommand will peek into the special revision properties previously stored on the target repository and determine how much of the source repository has been previously mirrored—in this case, the most recently mirrored revision is r0. Then it will query the source repository and determine what the latest revision in that repository is. Finally, it asks the source repository's server to start replaying all the revisions between 0 and that latest revision. As <span class="command"><strong>svnsync</strong></span> gets the resultant response from the source repository's server, it begins forwarding those revisions to the target repository's server as new commits.</p><div class="informalexample"><pre class="screen"> $ svnsync help synchronize synchronize (sync): usage: svnsync synchronize DEST_URL [SOURCE_URL] Transfer all pending revisions to the destination from the source with which it was initialized. … $ svnsync synchronize http://svn.example.com/svn-mirror \ https://svn.code.sf.net/p/svnbook/source Committed revision 1. Copied properties for revision 1. Committed revision 2. Copied properties for revision 2. Transmitting file data . Committed revision 3. Copied properties for revision 3. … Transmitting file data . Committed revision 4063. Copied properties for revision 4063. Transmitting file data . Committed revision 4064. Copied properties for revision 4064. Transmitting file data .... Committed revision 4065. Copied properties for revision 4065. $ </pre></div><p>Of particular interest here is that for each mirrored revision, there is first a commit of that revision to the target repository, and then property changes follow. This two-phase replication is required because the initial commit is performed by (and attributed to) the user <code class="literal">syncuser</code> and is datestamped with the time as of that revision's creation. <span class="command"><strong>svnsync</strong></span> has to follow up with an immediate series of property modifications that copy into the target repository all the original revision properties found for that revision in the source repository, which also has the effect of fixing the author and datestamp of the revision to match that of the source repository.</p><p>Also noteworthy is that <span class="command"><strong>svnsync</strong></span> performs careful bookkeeping that allows it to be safely interrupted and restarted without ruining the integrity of the mirrored data. If a network glitch occurs while mirroring a repository, simply repeat the <span class="command"><strong>svnsync synchronize</strong></span> command, and it will happily pick up right where it left off. In fact, as new revisions appear in the source repository, this is exactly what you do to keep your mirror up to date.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>As part of its bookkeeping, <span class="command"><strong>svnsync</strong></span> records in the mirror repository the URL with which the mirror was initialized. Because of this, invocations of <span class="command"><strong>svnsync</strong></span> which follow the initialization step do not <span class="emphasis"><em>require</em></span> that you provide the source URL on the command line again. However, for security purposes, we recommend that you continue to do so. Depending on how it is deployed, it may not be safe for <span class="command"><strong>svnsync</strong></span> to trust the source URL which it retrieves from the mirror repository, and from which it pulls versioned data.</p></td></tr></table></div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>svnsync Bookkeeping</strong></p></div></div></div><p><span class="command"><strong>svnsync</strong></span> needs to be able to set and modify revision properties on the mirror repository because those properties are part of the data it is tasked with mirroring. As those properties change in the source repository, those changes need to be reflected in the mirror repository, too. But <span class="command"><strong>svnsync</strong></span> also uses a set of custom revision properties—stored in revision 0 of the mirror repository—for its own internal bookkeeping. These properties contain information such as the URL and UUID of the source repository, plus some additional state-tracking information.</p><p>One of those pieces of state-tracking information is a flag that essentially just means <span class="quote">“<span class="quote">there's a synchronization in progress right now.</span>”</span> This is used to prevent multiple <span class="command"><strong>svnsync</strong></span> processes from colliding with each other while trying to mirror data to the same destination repository. Now, generally you won't need to pay any attention whatsoever to <span class="emphasis"><em>any</em></span> of these special properties (all of which begin with the prefix <code class="literal">svn:sync-</code>). Occasionally, though, if a synchronization fails unexpectedly, Subversion never has a chance to remove this particular state flag. This causes all future synchronization attempts to fail because it appears that a synchronization is still in progress when, in fact, none is. Fortunately, recovering from this situation is easy to do. In Subversion 1.7, you can use the newly introduced <code class="option">--steal-lock</code> option with <span class="command"><strong>svnsync</strong></span>'s commands. In previous Subversion versions, you need only to remove the <code class="literal">svn:sync-lock</code> property which serves as this flag from revision 0 of the mirror repository:</p><div class="informalexample"><pre class="screen"> $ svn propdel --revprop -r0 svn:sync-lock http://svn.example.com/svn-mirror property 'svn:sync-lock' deleted from repository revision 0 $ </pre></div><p>Also, <span class="command"><strong>svnsync</strong></span> stores the source repository URL provided at mirror initialization time in a bookkeeping property on the mirror repository. Future synchronization operations against that mirror which omit the source URL at the command line will consult the special <code class="literal">svn:sync-from-url</code> property stored on the mirror itself to know where to synchronize from. This value is used literally by the synchronization process, though. Be wary of using non-fully-qualified domain names (such as referring to <code class="literal">svnbook.red-bean.com</code> as simply <code class="literal">svnbook</code> because that happens to work when you are connected directly to the <code class="literal">red-bean.com</code> network), domain names which don't resolve or resolve differently depending on where you happen to be operating from, or IP addresses (which can change over time). But here again, if you need an existing mirror to start referring to a different URL for the same source repository, you can change the bookkeeping property which houses that information. Users of Subversion 1.7 or better can use <span class="command"><strong>svnsync init --allow-non-empty</strong></span> to reinitialize their mirrors with new source URL:</p><div class="informalexample"><pre class="screen"> $ svnsync initialize --allow-non-empty http://svn.example.com/svn-mirror \ <em class="replaceable"><code>NEW-SOURCE-URL</code></em> Copied properties for revision 4065. $ </pre></div><p>If you are running an older version of Subversion, you'll need to manually tweak the <code class="literal">svn:sync-from-url</code> bookkeeping property:</p><div class="informalexample"><pre class="screen"> $ svn propset --revprop -r0 svn:sync-from-url <em class="replaceable"><code>NEW-SOURCE-URL</code></em> \ http://svn.example.com/svn-mirror property 'svn:sync-from-url' set on repository revision 0 $ </pre></div><p>Another interesting thing about these special bookkeeping properties is that <span class="command"><strong>svnsync</strong></span> will not attempt to mirror any of those properties when they are found in the source repository. The reason is probably obvious, but basically boils down to <span class="command"><strong>svnsync</strong></span> not being able to distinguish the special properties it has merely copied from the source repository from those it needs to consult and maintain for its own bookkeeping needs. This situation could occur if, for example, you were maintaining a mirror of a mirror of a third repository. When <span class="command"><strong>svnsync</strong></span> sees its own special properties in revision 0 of the source repository, it simply ignores them.</p><p>An <span class="command"><strong>svnsync info</strong></span> subcommand was added in Subversion 1.6 to easily display the special bookkeeping properties in the destination repository.</p><div class="informalexample"><pre class="screen"> $ svnsync help info info: usage: svnsync info DEST_URL Print information about the synchronization destination repository located at DEST_URL. … $ svnsync info http://svn.example.com/svn-mirror Source URL: https://svn.code.sf.net/p/svnbook/source Source Repository UUID: 931749d0-5854-0410-9456-f14be4d6b398 Last Merged Revision: 4065 $ </pre></div></div><p>There is, however, one bit of inelegance in the process. Because Subversion revision properties can be changed at any time throughout the lifetime of the repository, and because they don't leave an audit trail that indicates when they were changed, replication processes have to pay special attention to them. If you've already mirrored the first 15 revisions of a repository and someone then changes a revision property on revision 12, <span class="command"><strong>svnsync</strong></span> won't know to go back and patch up its copy of revision 12. You'll need to tell it to do so manually by using (or with some additional tooling around) the <span class="command"><strong>svnsync copy-revprops</strong></span> subcommand, which simply rereplicates all the revision properties for a particular revision or range thereof.</p><div class="informalexample"><pre class="screen"> $ svnsync help copy-revprops copy-revprops: usage: 1. svnsync copy-revprops DEST_URL [SOURCE_URL] 2. svnsync copy-revprops DEST_URL REV[:REV2] … $ svnsync copy-revprops http://svn.example.com/svn-mirror 12 Copied properties for revision 12. $ </pre></div><p>That's repository replication via <span class="command"><strong>svnsync</strong></span> in a nutshell. You'll likely want some automation around such a process. For example, while our example was a pull-and-push setup, you might wish to have your primary repository push changes to one or more blessed mirrors as part of its post-commit and post-revprop-change hook implementations. This would enable the mirror to be up to date in as near to real time as is likely possible.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.replication.svnsync-partial"></a>Partial replication with svnsync</h4></div></div></div><p><span class="command"><strong>svnsync</strong></span> isn't limited to full copies of everything which lives in a repository. It can handle various shades of partial replication, too. For example, while it isn't very commonplace to do so, <span class="command"><strong>svnsync</strong></span> does gracefully mirror repositories in which the user as whom it authenticates has only partial read access. It simply copies only the bits of the repository that it is permitted to see. Obviously, such a mirror is not useful as a backup solution.</p><p>As of Subversion 1.5, <span class="command"><strong>svnsync</strong></span> also has the ability to mirror a subset of a repository rather than the whole thing. The process of setting up and maintaining such a mirror is exactly the same as when mirroring a whole repository, except that instead of specifying the source repository's root URL when running <span class="command"><strong>svnsync init</strong></span>, you specify the URL of some subdirectory within that repository. Synchronization to that mirror will now copy only the bits that changed under that source repository subdirectory. There are some limitations to this support, though. First, you can't mirror multiple disjoint subdirectories of the source repository into a single mirror repository—you'd need to instead mirror some parent directory that is common to both. Second, the filtering logic is entirely path-based, so if the subdirectory you are mirroring was renamed at some point in the past, your mirror would contain only the revisions since the directory appeared at the URL you specified. And likewise, if the source subdirectory is renamed in the future, your synchronization processes will stop mirroring data at the point that the source URL you specified is no longer valid.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.replication.svnsync-init-nonempty"></a>A quick trick for mirror creation</h4></div></div></div><p>We mentioned previously the cost of setting up an initial mirror of an existing repository. For many folks, the sheer cost of transmitting thousands—or millions—of revisions of history to a new mirror repository via <span class="command"><strong>svnsync</strong></span> is a show-stopper. Fortunately, Subversion 1.7 provides a workaround by way of a new <code class="option">--allow-non-empty</code> option to <span class="command"><strong>svnsync initialize</strong></span>. This option allows you to initialize one repository as a mirror of another while bypassing the verification that the to-be-initialized mirror has no version history present in it. Per our previous warnings about the sensitivity of this whole replication process, you should rightly discern that this is an option to be used only with great caution. But it's wonderfully handy when you have administrative access to the source repository, where you can simply make a physical copy of the repository and then initialize that copy as a new mirror:</p><div class="informalexample"><pre class="screen"> $ svnadmin hotcopy /path/to/repos /path/to/mirror-repos $ ### create /path/to/mirror-repos/hooks/pre-revprop-change $ svnsync initialize file:///path/to/mirror-repos \ file:///path/to/repos svnsync: E000022: Destination repository already contains revision history; co nsider using --allow-non-empty if the repository's revisions are known to mirr or their respective revisions in the source repository $ svnsync initialize --allow-non-empty file:///path/to/mirror-repos \ file:///path/to/repos Copied properties for revision 32042. $ </pre></div><p>Admins who are running a version of Subversion prior to 1.7 (and thus do not have access to <span class="command"><strong>svnsync initialize</strong></span>'s <code class="option">--allow-non-empty</code> feature) can accomplish effectively the same thing that that feature does through <span class="emphasis"><em>careful</em></span> manipulation of the r0 revision properties on the copy of the repository which is slated to become a mirror of the original. Use <span class="command"><strong>svnadmin setrevprop</strong></span> to create the same bookkeeping properties that <span class="command"><strong>svnsync</strong></span> would have created there.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.reposadmin.maint.replication.wrapup"></a>Replication wrap-up</h4></div></div></div><p>We've discussed a couple of ways to replicate revision history from one repository to another. So let's look now at the user end of these operations. How does replication and the various situations which call for it affect Subversion clients?</p><p>As far as user interaction with repositories and mirrors goes, it <span class="emphasis"><em>is</em></span> possible to have a single working copy that interacts with both, but you'll have to jump through some hoops to make it happen. First, you need to ensure that both the primary and mirror repositories have the same repository UUID (which is not the case by default). See <a class="xref" href="#svn.reposadmin.maint.uuids" title="Managing Repository UUIDs">the section called “Managing Repository UUIDs”</a> later in this chapter for more about this.</p><p>Once the two repositories have the same UUID, you can use <span class="command"><strong>svn relocate</strong></span> to point your working copy to whichever of the repositories you wish to operate against, a process that is described in <a class="xref" href="#svn.ref.svn.c.relocate" title="svn relocate">svn relocate</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>. There is a possible danger here, though, in that if the primary and mirror repositories aren't in close synchronization, a working copy up to date with, and pointing to, the primary repository will, if relocated to point to an out-of-date mirror, become confused about the apparent sudden loss of revisions it fully expects to be present, and it will throw errors to that effect. If this occurs, you can relocate your working copy back to the primary repository and then either wait until the mirror repository is up to date, or backdate your working copy to a revision you know is present in the sync repository, and then retry the relocation.</p><p>Finally, be aware that the revision-based replication provided by <span class="command"><strong>svnsync</strong></span> is only that—replication of revisions. Only the kinds of information carried by the Subversion repository dump file format are available for replication. As such, tools such as <span class="command"><strong>svnsync</strong></span> (and <span class="command"><strong>svnrdump</strong></span>, which we discuss in <a class="xref" href="#svn.reposadmin.maint.migrate.svnrdump" title="Repository data migration using svnrdump">the section called “Repository data migration using svnrdump”</a>) are limited in ways similar to that of the repository dump stream. They do not include in their replicated information such things as the hook implementations, repository or server configuration data, uncommitted transactions, or information about user locks on repository paths.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.maint.backup"></a>Repository Backup</h3></div></div></div><p>Despite numerous advances in technology since the birth of the modern computer, one thing unfortunately rings true with crystalline clarity—sometimes things go very, very awry. Power outages, network connectivity dropouts, corrupt RAM, and crashed hard drives are but a taste of the evil that Fate is poised to unleash on even the most conscientious administrator. And so we arrive at a very important topic—how to make backup copies of your repository data.</p><p>There are two types of backup methods available for Subversion repository administrators—full and incremental. A full backup of the repository involves squirreling away in one sweeping action all the information required to fully reconstruct that repository in the event of a catastrophe. Usually, it means, quite literally, the duplication of the entire repository directory (which includes either a Berkeley DB or FSFS environment). Incremental backups are lesser things: backups of only the portion of the repository data that has changed since the previous backup.</p><p>As far as full backups go, the naïve approach might seem like a sane one, but unless you temporarily disable all other access to your repository, simply doing a recursive directory copy runs the risk of generating a faulty backup. In the case of Berkeley DB, the documentation describes a certain order in which database files can be copied that will guarantee a valid backup copy. A similar ordering exists for FSFS data. But you don't have to implement these algorithms yourself, because the Subversion development team has already done so. The <span class="command"><strong>svnadmin hotcopy</strong></span> command takes care of the minutia involved in making a hot backup of your repository. And its invocation is as trivial as the Unix <span class="command"><strong>cp</strong></span> or Windows <span class="command"><strong>copy</strong></span> operations:</p><div class="informalexample"><pre class="screen"> $ svnadmin hotcopy /var/svn/repos /var/svn/repos-backup </pre></div><p>The resultant backup is a fully functional Subversion repository, able to be dropped in as a replacement for your live repository should something go horribly wrong.</p><p>When making copies of a Berkeley DB repository, you can even instruct <span class="command"><strong>svnadmin hotcopy</strong></span> to purge any unused Berkeley DB logfiles (see <a class="xref" href="#svn.reposadmin.maint.diskspace.bdblogs" title="Purging unused Berkeley DB logfiles">the section called “Purging unused Berkeley DB logfiles”</a>) from the original repository upon completion of the copy. Simply provide the <code class="option">--clean-logs</code> option on the command line.</p><div class="informalexample"><pre class="screen"> $ svnadmin hotcopy --clean-logs /var/svn/bdb-repos /var/svn/bdb-repos-backup </pre></div><p>Additional tooling around this command is available, too. The <code class="filename">tools/backup/</code> directory of the Subversion source distribution holds the <span class="command"><strong>hot-backup.py</strong></span> script. This script adds a bit of backup management atop <span class="command"><strong>svnadmin hotcopy</strong></span>, allowing you to keep only the most recent configured number of backups of each repository. It will automatically manage the names of the backed-up repository directories to avoid collisions with previous backups and will <span class="quote">“<span class="quote">rotate off</span>”</span> older backups, deleting them so that only the most recent ones remain. Even if you also have an incremental backup, you might want to run this program on a regular basis. For example, you might consider using <span class="command"><strong>hot-backup.py</strong></span> from a program scheduler (such as <span class="command"><strong>cron</strong></span> on Unix systems), which can cause it to run nightly (or at whatever granularity of time you deem safe).</p><p>Some administrators use a different backup mechanism built around generating and storing repository dump data. We described in <a class="xref" href="#svn.reposadmin.maint.migrate" title="Migrating Repository Data Elsewhere">the section called “Migrating Repository Data Elsewhere”</a> how to use <span class="command"><strong>svnadmin dump</strong></span> with the <code class="option">--incremental</code> option to perform an incremental backup of a given revision or range of revisions. And of course, you can achieve a full backup variation of this by omitting the <code class="option">--incremental</code> option to that command. There is some value in these methods, in that the format of your backed-up information is flexible—it's not tied to a particular platform, versioned filesystem type, or release of Subversion or Berkeley DB. But that flexibility comes at a cost, namely that restoring that data can take a long time—longer with each new revision committed to your repository. Also, as is the case with so many of the various backup methods, revision property changes that are made to already backed-up revisions won't get picked up by a nonoverlapping, incremental dump generation. For these reasons, we recommend against relying solely on dump-based backup approaches.</p><p>As you can see, each of the various backup types and methods has its advantages and disadvantages. The easiest is by far the full hot backup, which will always result in a perfect working replica of your repository. Should something bad happen to your live repository, you can restore from the backup with a simple recursive directory copy. Unfortunately, if you are maintaining multiple backups of your repository, these full copies will each eat up just as much disk space as your live repository. Incremental backups, by contrast, tend to be quicker to generate and smaller to store. But the restoration process can be a pain, often involving applying multiple incremental backups. And other methods have their own peculiarities. Administrators need to find the balance between the cost of making the backup and the cost of restoring it.</p><p>The <span class="command"><strong>svnsync</strong></span> program (see <a class="xref" href="#svn.reposadmin.maint.replication" title="Repository Replication">the section called “Repository Replication”</a>) actually provides a rather handy middle-ground approach. If you are regularly synchronizing a read-only mirror with your main repository, in a pinch your read-only mirror is probably a good candidate for replacing that main repository if it falls over. The primary disadvantage of this method is that only the versioned repository data gets synchronized—repository configuration files, user-specified repository path locks, and other items that might live in the physical repository directory but not <span class="emphasis"><em>inside</em></span> the repository's virtual versioned filesystem are not handled by <span class="command"><strong>svnsync</strong></span>.</p><p>In any backup scenario, repository administrators need to be aware of how modifications to unversioned revision properties affect their backups. Since these changes do not themselves generate new revisions, they will not trigger post-commit hooks, and may not even trigger the pre-revprop-change and post-revprop-change hooks.<a href="#ftn.idm6024" class="footnote" id="idm6024"><sup class="footnote">[50]</sup></a> And since you can change revision properties without respect to chronological order—you can change any revision's properties at any time—an incremental backup of the latest few revisions might not catch a property modification to a revision that was included as part of a previous backup.</p><p>Generally speaking, only the truly paranoid would need to back up their entire repository, say, every time a commit occurred. However, assuming that a given repository has some other redundancy mechanism in place with relatively fine granularity (such as per-commit emails or incremental dumps), a hot backup of the database might be something that a repository administrator would want to include as part of a system-wide nightly backup. It's your data—protect it as much as you'd like.</p><p>Often, the best approach to repository backups is a diversified one that leverages combinations of the methods described here. The Subversion developers, for example, back up the Subversion source code repository nightly using <span class="command"><strong>hot-backup.py</strong></span> and an off-site <span class="command"><strong>rsync</strong></span> of those full backups; keep multiple archives of all the commit and property change notification emails; and have repository mirrors maintained by various volunteers using <span class="command"><strong>svnsync</strong></span>. Your solution might be similar, but should be catered to your needs and that delicate balance of convenience with paranoia. And whatever you do, validate your backups from time to time—what good is a spare tire that has a hole in it? While all of this might not save your hardware from the iron fist of Fate,<a href="#ftn.idm6032" class="footnote" id="idm6032"><sup class="footnote">[51]</sup></a> it should certainly help you recover from those trying times.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.reposadmin.maint.uuids"></a>Managing Repository UUIDs</h3></div></div></div><p>Subversion repositories have a universally unique identifier (UUID) associated with them. This is used by Subversion clients to verify the identity of a repository when other forms of verification aren't good enough (such as checking the repository URL, which can change over time). Most Subversion repository administrators rarely, if ever, need to think about repository UUIDs as anything more than a trivial implementation detail of Subversion. Sometimes, however, there is cause for attention to this detail.</p><p>As a general rule, you want the UUIDs of your live repositories to be unique. That is, after all, the point of having UUIDs. But there are times when you want the repository UUIDs of two repositories to be exactly the same. For example, if you make a copy of a repository for backup purposes, you want the backup to be a perfect replica of the original so that, in the event that you have to restore that backup and replace the live repository, users don't suddenly see what looks like a different repository. When dumping and loading repository history (as described earlier in <a class="xref" href="#svn.reposadmin.maint.migrate" title="Migrating Repository Data Elsewhere">the section called “Migrating Repository Data Elsewhere”</a>), you get to decide whether to apply the UUID encapsulated in the data dump stream to the repository in which you are loading the data. The particular circumstance will dictate the correct behavior.</p><p>There are a couple of ways to set (or reset) a repository's UUID, should you need to. As of Subversion 1.5, this is as simple as using the <span class="command"><strong>svnadmin setuuid</strong></span> command. If you provide this subcommand with an explicit UUID, it will validate that the UUID is well-formed and then set the repository UUID to that value. If you omit the UUID, a brand-new UUID will be generated for your repository.</p><div class="informalexample"><pre class="screen"> $ svnlook uuid /var/svn/repos cf2b9d22-acb5-11dc-bc8c-05e83ce5dbec $ svnadmin setuuid /var/svn/repos # generate a new UUID $ svnlook uuid /var/svn/repos 3c3c38fe-acc0-11dc-acbc-1b37ff1c8e7c $ svnadmin setuuid /var/svn/repos \ cf2b9d22-acb5-11dc-bc8c-05e83ce5dbec # restore the old UUID $ svnlook uuid /var/svn/repos cf2b9d22-acb5-11dc-bc8c-05e83ce5dbec $ </pre></div><p>For folks using versions of Subversion earlier than 1.5, these tasks are a little more complicated. You can explicitly set a repository's UUID by piping a repository dump file stub that carries the new UUID specification through <strong class="userinput"><code>svnadmin load --force-uuid <em class="replaceable"><code>REPOS-PATH</code></em></code></strong>.</p><div class="informalexample"><pre class="screen"> $ svnadmin load --force-uuid /var/svn/repos &lt;&lt;EOF SVN-fs-dump-format-version: 2 UUID: cf2b9d22-acb5-11dc-bc8c-05e83ce5dbec EOF $ svnlook uuid /var/svn/repos cf2b9d22-acb5-11dc-bc8c-05e83ce5dbec $ </pre></div><p>Having older versions of Subversion generate a brand-new UUID is not quite as simple to do, though. Your best bet here is to find some other way to generate a UUID, and then explicitly set the repository's UUID to that value.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.reposadmin.maint.moving-and-removing"></a>Moving and Removing Repositories</h2></div></div></div><p>Subversion repository data is wholly contained within the repository directory. As such, you can move a Subversion repository to some other location on disk, rename a repository, copy a repository, or delete a repository altogether using the tools provided by your operating system for manipulating directories—<span class="command"><strong>mv</strong></span>, <span class="command"><strong>cp -a</strong></span>, and <span class="command"><strong>rm -r</strong></span> on Unix platforms; <span class="command"><strong>copy</strong></span>, <span class="command"><strong>move</strong></span>, and <span class="command"><strong>rmdir /s /q</strong></span> on Windows; vast numbers of mouse and menu gyrations in various graphical file explorer applications, and so on.</p><p>Of course, there's often still more to be done when trying to cleanly affect changes such as this. For example, you might need to update your Subversion server configuration to point to the new location of a relocated repository or to remove configuration bits for a now-deleted repository. If you have automated processes that publish information from or about your repositories, they may need to be updated. Hook scripts might need to be reconfigured. Users may need to be notified. The list can go on indefinitely, or at least to the extent that you've built processes and procedures around your Subversion repository.</p><p>In the case of a copied repository, you should also consider the fact that Subversion uses repository UUIDs to distinguish repositories. If you copy a Subversion repository using a typical shell recursive copy command, you'll wind up with two repositories that are identical in every way—including their UUIDs. In some circumstances, this might be desirable. But in the instances where it is not, you'll need to generate a new UUID for one of these identical repositories. See <a class="xref" href="#svn.reposadmin.maint.uuids" title="Managing Repository UUIDs">the section called “Managing Repository UUIDs”</a> for more about managing repository UUIDs.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.reposadmin.summary"></a>Summary</h2></div></div></div><p>By now you should have a basic understanding of how to create, configure, and maintain Subversion repositories. We introduced you to the various tools that will assist you with this task. Throughout the chapter, we noted common administration pitfalls and offered suggestions for avoiding them.</p><p>All that remains is for you to decide what exciting data to store in your repository, and finally, how to make it available over a network. The next chapter is all about networking.</p></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm5000" class="footnote"><p><a href="#idm5000" class="para"><sup class="para">[37] </sup></a>This may sound really prestigious and lofty, but we're just talking about anyone who is interested in that mysterious realm beyond the working copy where everyone's data hangs out.</p></div><div id="ftn.idm5019" class="footnote"><p><a href="#idm5019" class="para"><sup class="para">[38] </sup></a>Strictly speaking, Subversion doesn't dictate that the versioned data live here, and there are known (albeit proprietary) alternative backend storage implementations which do not, in fact, store data in this directory.</p></div><div id="ftn.idm5071" class="footnote"><p><a href="#idm5071" class="para"><sup class="para">[39] </sup></a>Whether founded in ignorance or in poorly considered concepts about how to derive legitimate software development metrics, global revision numbers are a silly thing to fear, and <span class="emphasis"><em>not</em></span> the kind of thing you should weigh when deciding how to arrange your projects and repositories.</p></div><div id="ftn.idm5083" class="footnote"><p><a href="#idm5083" class="para"><sup class="para">[40] </sup></a>The <code class="filename">trunk</code>, <code class="filename">tags</code>, and <code class="filename">branches</code> trio is sometimes referred to as <span class="quote">“<span class="quote">the TTB directories.</span>”</span></p></div><div id="ftn.idm5116" class="footnote"><p><a href="#idm5116" class="para"><sup class="para">[41] </sup></a>Often pronounced <span class="quote">“<span class="quote">fuzz-fuzz,</span>”</span> if Jack Repenning has anything to say about it. (This book, however, assumes that the reader is thinking <span class="quote">“<span class="quote">eff-ess-eff-ess.</span>”</span>)</p></div><div id="ftn.idm5199" class="footnote"><p><a href="#idm5199" class="para"><sup class="para">[42] </sup></a>Berkeley DB requires that the underlying filesystem implement strict POSIX locking semantics, and more importantly, the ability to map files directly into process memory.</p></div><div id="ftn.idm5421" class="footnote"><p><a href="#idm5421" class="para"><sup class="para">[43] </sup></a>Or is that, the <span class="quote">“<span class="quote">sync</span>”</span>?</p></div><div id="ftn.idm5572" class="footnote"><p><a href="#idm5572" class="para"><sup class="para">[44] </sup></a>For example, hard drive + huge electromagnet = disaster.</p></div><div id="ftn.idm5718" class="footnote"><p><a href="#idm5718" class="para"><sup class="para">[45] </sup></a>That's rather the reason you use version control at all, right?</p></div><div id="ftn.idm5720" class="footnote"><p><a href="#idm5720" class="para"><sup class="para">[46] </sup></a>Conscious, cautious removal of certain bits of versioned data is actually supported by real use cases. That's why an <span class="quote">“<span class="quote">obliterate</span>”</span> feature has been one of the most highly requested Subversion features, and one which the Subversion developers hope to soon provide.</p></div><div id="ftn.idm5795" class="footnote"><p><a href="#idm5795" class="para"><sup class="para">[47] </sup></a>While <span class="command"><strong>svnadmin dump</strong></span> has a consistent leading slash policy (to not include them), other programs that generate dump data might not be so consistent.</p></div><div id="ftn.idm5828" class="footnote"><p><a href="#idm5828" class="para"><sup class="para">[48] </sup></a>In fact, it can't truly be read-only, or <span class="command"><strong>svnsync</strong></span> itself would have a tough time copying revision history into it.</p></div><div id="ftn.idm5888" class="footnote"><p><a href="#idm5888" class="para"><sup class="para">[49] </sup></a>Be forewarned that while it will take only a few seconds for the average reader to parse this paragraph and the sample output that follows it, the actual time required to complete such a mirroring operation is, shall we say, quite a bit longer.</p></div><div id="ftn.idm6024" class="footnote"><p><a href="#idm6024" class="para"><sup class="para">[50] </sup></a><span class="command"><strong>svnadmin setlog</strong></span> can be called in a way that bypasses the hook interface altogether.</p></div><div id="ftn.idm6032" class="footnote"><p><a href="#idm6032" class="para"><sup class="para">[51] </sup></a>You know—the collective term for all of her <span class="quote">“<span class="quote">fickle fingers.</span>”</span></p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="svn.serverconfig"></a>Chapter 6. Server Configuration</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.serverconfig.overview">Overview</a></span></dt><dt><span class="sect1"><a href="#svn.serverconfig.choosing">Choosing a Server Configuration</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.serverconfig.choosing.svnserve">The svnserve Server</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.choosing.svn-ssh">svnserve over SSH</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.choosing.apache">The Apache HTTP Server</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.choosing.recommendations">Recommendations</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.serverconfig.svnserve">svnserve, a Custom Server</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.serverconfig.svnserve.invoking">Invoking the Server</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.invoking.daemon">svnserve as daemon</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.invoking.inetd">svnserve via inetd</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.invoking.tunnel">svnserve over a tunnel</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.invoking.winservice">svnserve as a Windows service</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.invoking.launchd">svnserve as a launchd job</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.serverconfig.svnserve.auth">Built-in Authentication and Authorization</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.auth.users">Create a users file and realm</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.auth.general">Set access controls</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.serverconfig.svnserve.sasl">Using <span class="command"><strong>svnserve</strong></span> with SASL</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.sasl.authn">Authenticating with SASL</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.sasl.encryption">SASL encryption</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.serverconfig.svnserve.sshauth">Tunneling over SSH</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.svnserve.sshtricks">SSH Configuration Tricks</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.sshtricks.setup">Initial setup</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.svnserve.sshtricks.fixedcmd">Controlling the invoked command</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.serverconfig.httpd">httpd, the Apache HTTP Server</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.serverconfig.httpd.prereqs">Prerequisites</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.httpd.basic">Basic Apache Configuration</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.httpd.authn">Authentication Options</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.httpd.authn.basic">Basic authentication</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.authn.digest">Digest authentication</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.serverconfig.httpd.authz">Authorization Options</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.httpd.authz.blanket">Blanket access control</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.authz.perdir">Per-directory access control</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.authz.pathauthzoff">Disabling path-based checks</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.serverconfig.httpd.ssl">Protecting network traffic with SSL</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.httpd.ssl.server">Subversion server SSL certificate configuration</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.ssl.client">Subversion client SSL certificate management</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.serverconfig.httpd.extra">Extra Goodies</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.serverconfig.httpd.extra.browsing">Repository browsing</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.extra.logging">Apache logging</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.extra.writethruproxy">Write-through proxying</a></span></dt><dt><span class="sect3"><a href="#svn.serverconfig.httpd.extra.other">Other Apache features</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.serverconfig.pathbasedauthz">Path-Based Authorization</a></span></dt><dt><span class="sect1"><a href="#svn.serverconfig.operational-logging">High-level Logging</a></span></dt><dt><span class="sect1"><a href="#svn.serverconfig.optimization">Server Optimization</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.serverconfig.optimization.caching">Data Caching</a></span></dt><dt><span class="sect2"><a href="#svn.serverconfig.optimization.compression">Network Compression of Data</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.serverconfig.multimethod">Supporting Multiple Repository Access Methods</a></span></dt></dl></div><p>A Subversion repository can be accessed simultaneously by clients running on the same machine on which the repository resides using URLs carrying the <code class="literal">file://</code> scheme. But the typical Subversion setup involves a single server machine being accessed from clients on computers all over the office—or, perhaps, all over the world.</p><p>This chapter describes how to get your Subversion repository exposed outside its host machine for use by remote clients. We will cover Subversion's currently available server mechanisms, discussing the configuration and use of each. After reading this chapter, you should be able to decide which networking setup is right for your needs, as well as understand how to enable such a setup on your host computer.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.serverconfig.overview"></a>Overview</h2></div></div></div><p>Subversion was designed with an abstract repository access layer. This means that a repository can be programmatically accessed by any sort of server process, and the client <span class="quote">“<span class="quote">repository access</span>”</span> API allows programmers to write plug-ins that speak relevant network protocols. In theory, Subversion can use an infinite number of network implementations. In practice, there are only two Subversion servers in widespread use today.</p><p>Apache is an extremely popular web server; using the <span class="command"><strong>mod_dav_svn</strong></span> module, Apache can access a repository and make it available to clients via the WebDAV/DeltaV protocol, which is an extension of HTTP. Because Apache is an extremely extensible server, it provides a number of features <span class="quote">“<span class="quote">for free,</span>”</span> such as encrypted SSL communication, logging, integration with a number of third-party authentication systems, and limited built-in web browsing of repositories.</p><p>In the other corner is <span class="command"><strong>svnserve</strong></span>: a small, lightweight server program that speaks a custom protocol with clients. Because its protocol is explicitly designed for Subversion and is stateful (unlike HTTP), it provides significantly faster network operations—but at the cost of some features as well. While it can use SASL to provide a variety of authentication and encryption options, it has no logging or built-in web browsing. It is, however, extremely easy to set up and is often the best option for small teams just starting out with Subversion.</p><p>The network protocol which <span class="command"><strong>svnserve</strong></span> speaks may also be tunneled over an SSH connection. This deployment option for <span class="command"><strong>svnserve</strong></span> differs quite a bit in features from a traditional <span class="command"><strong>svnserve</strong></span> deployment. SSH is used to encrypt all communication. SSH is also used exclusively to authenticate, so real system accounts are required on the server host (unlike vanilla <span class="command"><strong>svnserve</strong></span>, which has its own private user accounts). Finally, because this setup requires that each user spawn a private, temporary <span class="command"><strong>svnserve</strong></span> process, it's equivalent (from a permissions point of view) to allowing a group of local users to all access the repository via <code class="literal">file://</code> URLs. Path-based access control has no meaning, since each user is accessing the repository database files directly.</p><p><a class="xref" href="#svn.serverconfig.overview.tbl-1" title="Table 6.1. Comparison of subversion server options">Table 6.1, “Comparison of subversion server options”</a> provides a quick summary of the three typical server deployments.</p><div class="table"><a id="svn.serverconfig.overview.tbl-1"></a><p class="title"><strong>Table 6.1. Comparison of subversion server options</strong></p><div class="table-contents"><table class="table" summary="Comparison of subversion server options" border="1"><colgroup><col></col><col></col><col></col><col></col></colgroup><thead><tr><th>Feature</th><th>Apache + mod_dav_svn</th><th>svnserve</th><th>svnserve over SSH</th></tr></thead><tbody><tr><td>Authentication options</td><td>HTTP Basic or Digest auth, X.509 certificates, LDAP, NTLM, or any other mechanism available to Apache httpd</td><td>CRAM-MD5 by default; LDAP, NTLM, or any other mechanism available to SASL</td><td>SSH</td></tr><tr><td>User account options</td><td>Private <span class="quote">“<span class="quote">users</span>”</span> file, or other mechanisms available to Apache httpd (LDAP, SQL, etc.)</td><td>Private <span class="quote">“<span class="quote">users</span>”</span> file, or other mechanisms available to SASL (LDAP, SQL, etc.)</td><td>System accounts</td></tr><tr><td>Authorization options</td><td>Read/write access can be granted over the whole repository, or specified per path</td><td>Read/write access can be granted over the whole repository, or specified per path</td><td>Read/write access only grantable over the whole repository</td></tr><tr><td>Encryption</td><td>Available via optional SSL (https)</td><td>Available via optional SASL features</td><td>Inherent in SSH connection</td></tr><tr><td>Logging</td><td>High-level operational logging of Subversion operations plus detailed logging at the per-HTTP-request level</td><td>High-level operational logging only</td><td>High-level operational logging only</td></tr><tr><td>Interoperability</td><td>Accessible by other WebDAV clients</td><td>Talks only to svn clients</td><td>Talks only to svn clients</td></tr><tr><td>Web viewing</td><td>Limited built-in support, or via third-party tools such as ViewVC</td><td>Only via third-party tools such as ViewVC</td><td>Only via third-party tools such as ViewVC</td></tr><tr><td>Master-slave server replication</td><td>Transparent write-proxying available from slave to master</td><td>Can only create read-only slave servers</td><td>Can only create read-only slave servers</td></tr><tr><td>Speed</td><td>Somewhat slower</td><td>Somewhat faster</td><td>Somewhat faster</td></tr><tr><td>Initial setup</td><td>Somewhat complex</td><td>Extremely simple</td><td>Moderately simple</td></tr></tbody></table></div></div><br class="table-break"></br></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.serverconfig.choosing"></a>Choosing a Server Configuration</h2></div></div></div><p>So, which server should you use? Which is best?</p><p>Obviously, there's no right answer to that question. Every team has different needs, and the different servers all represent different sets of trade-offs. The Subversion project itself doesn't endorse one server or another, or consider either server more <span class="quote">“<span class="quote">official</span>”</span> than another.</p><p>Here are some reasons why you might choose one deployment over another, as well as reasons you might <span class="emphasis"><em>not</em></span> choose one.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.choosing.svnserve"></a>The svnserve Server</h3></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">Why you might want to use it:</span></dt><dd><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Quick and easy to set up.</p></li><li class="listitem"><p>Network protocol is stateful and noticeably faster than WebDAV.</p></li><li class="listitem"><p>No need to create system accounts on server.</p></li><li class="listitem"><p>Password is not passed over the network.</p></li></ul></div></dd><dt><span class="term">Why you might want to avoid it:</span></dt><dd><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>By default, only one authentication method is available, the network protocol is not encrypted, and the server stores clear text passwords. (All these things can be changed by configuring SASL, but it's a bit more work to do.)</p></li><li class="listitem"><p>No advanced logging facilities.</p></li><li class="listitem"><p>No built-in web browsing. (You'd have to install a separate web server and repository browsing software to add this.)</p></li></ul></div></dd></dl></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.choosing.svn-ssh"></a>svnserve over SSH</h3></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">Why you might want to use it:</span></dt><dd><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>The network protocol is stateful and noticeably faster than WebDAV.</p></li><li class="listitem"><p>You can take advantage of existing SSH accounts and user infrastructure.</p></li><li class="listitem"><p>All network traffic is encrypted.</p></li></ul></div></dd><dt><span class="term">Why you might want to avoid it:</span></dt><dd><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Only one choice of authentication method is available.</p></li><li class="listitem"><p>No advanced logging facilities.</p></li><li class="listitem"><p>It requires users to be in the same system group, or use a shared SSH key.</p></li><li class="listitem"><p>If used improperly, it can lead to file permission problems.</p></li></ul></div></dd></dl></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.choosing.apache"></a>The Apache HTTP Server</h3></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">Why you might want to use it:</span></dt><dd><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>It allows Subversion to use any of the numerous authentication systems already integrated with Apache.</p></li><li class="listitem"><p>There is no need to create system accounts on the server.</p></li><li class="listitem"><p>Full Apache logging is available.</p></li><li class="listitem"><p>Network traffic can be encrypted via SSL.</p></li><li class="listitem"><p>HTTP(S) can usually go through corporate firewalls.</p></li><li class="listitem"><p>Built-in repository browsing is available via web browser.</p></li><li class="listitem"><p>The repository can be mounted as a network drive for transparent version control (see <a class="xref" href="#svn.webdav.autoversioning" title="Autoversioning">the section called “Autoversioning”</a>).</p></li></ul></div></dd><dt><span class="term">Why you might want to avoid it:</span></dt><dd><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Noticeably slower than <span class="command"><strong>svnserve</strong></span>, because HTTP is a stateless protocol and requires more network turnarounds.</p></li><li class="listitem"><p>Initial setup can be complex.</p></li></ul></div></dd></dl></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.choosing.recommendations"></a>Recommendations</h3></div></div></div><p>In general, the authors of this book recommend a vanilla <span class="command"><strong>svnserve</strong></span> installation for small teams just trying to get started with a Subversion server; it's the simplest to set up and has the fewest maintenance issues. You can always switch to a more complex server deployment as your needs change.</p><p>Here are some general recommendations and tips, based on years of supporting users:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>If you're trying to set up the simplest possible server for your group, a vanilla <span class="command"><strong>svnserve</strong></span> installation is the easiest, fastest route. Note, however, that your repository data will be transmitted in the clear over the network. If your deployment is entirely within your company's LAN or VPN, this isn't an issue. If the repository is exposed to the wide-open Internet, you might want to make sure that either the repository's contents aren't sensitive (e.g., it contains only open source code), or that you go the extra mile in configuring SASL to encrypt network communications.</p></li><li class="listitem"><p>If you need to integrate with existing legacy identity systems (LDAP, Active Directory, NTLM, X.509, etc.), you must use either the Apache-based server or <span class="command"><strong>svnserve</strong></span> configured with SASL.</p></li><li class="listitem"><p>If you've decided to use either Apache or stock <span class="command"><strong>svnserve</strong></span>, create a single <span class="command"><strong>svn</strong></span> user on your system and run the server process as that user. Be sure to make the repository directory wholly owned by the <span class="command"><strong>svn</strong></span> user as well. From a security point of view, this keeps the repository data nicely siloed and protected by operating system filesystem permissions, changeable by only the Subversion server process itself.</p></li><li class="listitem"><p>If you have an existing infrastructure that is heavily based on SSH accounts, and if your users already have system accounts on your server machine, it makes sense to deploy an <span class="command"><strong>svnserve</strong></span>-over-SSH solution. Otherwise, we don't widely recommend this option to the public. It's generally considered safer to have your users access the repository via (imaginary) accounts managed by <span class="command"><strong>svnserve</strong></span> or Apache, rather than by full-blown system accounts. If your deep desire for encrypted communication still draws you to this option, we recommend using Apache with SSL or <span class="command"><strong>svnserve</strong></span> with SASL encryption instead.</p></li><li class="listitem"><p>Do <span class="emphasis"><em>not</em></span> be seduced by the simple idea of having all of your users access a repository directly via <code class="literal">file://</code> URLs. Even if the repository is readily available to everyone via a network share, this is a bad idea. It removes any layers of protection between the users and the repository: users can accidentally (or intentionally) corrupt the repository database, it becomes hard to take the repository offline for inspection or upgrade, and it can lead to a mess of file permission problems (see <a class="xref" href="#svn.serverconfig.multimethod" title="Supporting Multiple Repository Access Methods">the section called “Supporting Multiple Repository Access Methods”</a>). Note that this is also one of the reasons we warn against accessing repositories via <code class="literal">svn+ssh://</code> URLs—from a security standpoint, it's effectively the same as local users accessing via <code class="literal">file://</code>, and it can entail all the same problems if the administrator isn't careful.</p></li></ul></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.serverconfig.svnserve"></a>svnserve, a Custom Server</h2></div></div></div><p>The <span class="command"><strong>svnserve</strong></span> program is a lightweight server, capable of speaking to clients over TCP/IP using a custom, stateful protocol. Clients contact an <span class="command"><strong>svnserve</strong></span> server by using URLs that begin with the <code class="literal">svn://</code> or <code class="literal">svn+ssh://</code> scheme. This section will explain the different ways of running <span class="command"><strong>svnserve</strong></span>, how clients authenticate themselves to the server, and how to configure appropriate access control to your repositories.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.svnserve.invoking"></a>Invoking the Server</h3></div></div></div><p>There are a few different ways to run the <span class="command"><strong>svnserve</strong></span> program:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Run <span class="command"><strong>svnserve</strong></span> as a standalone daemon, listening for requests.</p></li><li class="listitem"><p>Have the Unix <span class="command"><strong>inetd</strong></span> daemon temporarily spawn <span class="command"><strong>svnserve</strong></span> whenever a request comes in on a certain port.</p></li><li class="listitem"><p>Have SSH invoke a temporary <span class="command"><strong>svnserve</strong></span> over an encrypted tunnel.</p></li><li class="listitem"><p>Run <span class="command"><strong>svnserve</strong></span> as a Microsoft Windows service.</p></li><li class="listitem"><p>Run <span class="command"><strong>svnserve</strong></span> as a launchd job.</p></li></ul></div><p>The following sections will cover in detail these various deployment options for <span class="command"><strong>svnserve</strong></span>.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.svnserve.invoking.daemon"></a>svnserve as daemon</h4></div></div></div><p>The easiest option is to run <span class="command"><strong>svnserve</strong></span> as a standalone <span class="quote">“<span class="quote">daemon</span>”</span> process. Use the <code class="option">-d</code> option for this:</p><div class="informalexample"><pre class="screen"> $ svnserve -d $ # svnserve is now running, listening on port 3690 </pre></div><p>When running <span class="command"><strong>svnserve</strong></span> in daemon mode, you can use the <code class="option">--listen-port</code> and <code class="option">--listen-host</code> options to customize the exact port and hostname to <span class="quote">“<span class="quote">bind</span>”</span> to.</p><p>Once we successfully start <span class="command"><strong>svnserve</strong></span> as explained previously, it makes every repository on your system available to the network. A client needs to specify an <span class="emphasis"><em>absolute</em></span> path in the repository URL. For example, if a repository is located at <code class="filename">/var/svn/project1</code>, a client would reach it via <code class="uri">svn://host.example.com/var/svn/project1</code>. To increase security, you can pass the <code class="option">-r</code> option to <span class="command"><strong>svnserve</strong></span>, which restricts it to exporting only repositories below that path. For example:</p><div class="informalexample"><pre class="screen"> $ svnserve -d -r /var/svn … </pre></div><p>Using the <code class="option">-r</code> option effectively modifies the location that the program treats as the root of the remote filesystem space. Clients then use URLs that have that path portion removed from them, leaving much shorter (and much less revealing) URLs:</p><div class="informalexample"><pre class="screen"> $ svn checkout svn://host.example.com/project1 … </pre></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.svnserve.invoking.inetd"></a>svnserve via inetd</h4></div></div></div><p>If you want <span class="command"><strong>inetd</strong></span> to launch the process, you need to pass the <code class="option">-i</code> (<code class="option">--inetd</code>) option. In the following example, we've shown the output from running <code class="literal">svnserve -i</code> at the command line, but note that this isn't how you actually start the daemon; see the paragraphs following the example for how to configure <span class="command"><strong>inetd</strong></span> to start <span class="command"><strong>svnserve</strong></span>.</p><div class="informalexample"><pre class="screen"> $ svnserve -i ( success ( 2 2 ( ) ( edit-pipeline svndiff1 absent-entries commit-revprops d\ epth log-revprops atomic-revprops partial-replay ) ) ) </pre></div><p>When invoked with the <code class="option">--inetd</code> option, <span class="command"><strong>svnserve</strong></span> attempts to speak with a Subversion client via <code class="filename">stdin</code> and <code class="filename">stdout</code> using a custom protocol. This is the standard behavior for a program being run via <span class="command"><strong>inetd</strong></span>. The IANA has reserved port 3690 for the Subversion protocol, so on a Unix-like system you can add lines to <code class="filename">/etc/services</code> such as these (if they don't already exist):</p><div class="informalexample"><pre class="programlisting"> svn 3690/tcp # Subversion svn 3690/udp # Subversion </pre></div><p>If your system is using a classic Unix-like <span class="command"><strong>inetd</strong></span> daemon, you can add this line to <code class="filename">/etc/inetd.conf</code>:</p><div class="informalexample"><pre class="programlisting"> svn stream tcp nowait svnowner /usr/bin/svnserve svnserve -i </pre></div><p>Make sure <span class="quote">“<span class="quote">svnowner</span>”</span> is a user that has appropriate permissions to access your repositories. Now, when a client connection comes into your server on port 3690, <span class="command"><strong>inetd</strong></span> will spawn an <span class="command"><strong>svnserve</strong></span> process to service it. Of course, you may also want to add <code class="option">-r</code> to the configuration line as well, to restrict which repositories are exported.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.svnserve.invoking.tunnel"></a>svnserve over a tunnel</h4></div></div></div><p>Another way to invoke <span class="command"><strong>svnserve</strong></span> is in tunnel mode, using the <code class="option">-t</code> option. This mode assumes that a remote-service program such as <span class="command"><strong>rsh</strong></span> or <span class="command"><strong>ssh</strong></span> has successfully authenticated a user and is now invoking a private <span class="command"><strong>svnserve</strong></span> process <span class="emphasis"><em>as that user</em></span>. (Note that you, the user, will rarely, if ever, have reason to invoke <span class="command"><strong>svnserve</strong></span> with the <code class="option">-t</code> at the command line; instead, the SSH daemon does so for you.) The <span class="command"><strong>svnserve</strong></span> program behaves normally (communicating via <code class="filename">stdin</code> and <code class="filename">stdout</code>) and assumes that the traffic is being automatically redirected over some sort of tunnel back to the client. When <span class="command"><strong>svnserve</strong></span> is invoked by a tunnel agent like this, be sure that the authenticated user has full read and write access to the repository database files. It's essentially the same as a local user accessing the repository via <code class="literal">file://</code> URLs.</p><p>This option is described in much more detail later in this chapter in <a class="xref" href="#svn.serverconfig.svnserve.sshauth" title="Tunneling over SSH">the section called “Tunneling over SSH”</a>.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.svnserve.invoking.winservice"></a>svnserve as a Windows service</h4></div></div></div><p>If your Windows system is a descendant of Windows NT (Windows 2000 or newer), you can run <span class="command"><strong>svnserve</strong></span> as a standard Windows service. This is typically a much nicer experience than running it as a standalone daemon with the <code class="option">--daemon</code> (<code class="option">-d</code>) option. Using daemon mode requires launching a console, typing a command, and then leaving the console window running indefinitely. A Windows service, however, runs in the background, can start at boot time automatically, and can be started and stopped using the same consistent administration interface as other Windows services.</p><p>You'll need to define the new service using the command-line tool <span class="command"><strong>SC.EXE</strong></span>. Much like the <span class="command"><strong>inetd</strong></span> configuration line, you must specify an exact invocation of <span class="command"><strong>svnserve</strong></span> for Windows to run at startup time:</p><div class="informalexample"><pre class="screen"> C:\&gt; sc create svn binpath= "C:\svn\bin\svnserve.exe --service -r C:\repos" displayname= "Subversion Server" depend= Tcpip start= auto </pre></div><p>This defines a new Windows service named <code class="literal">svn</code> which executes a particular <span class="command"><strong>svnserve.exe</strong></span> command when started (in this case, rooted at <code class="filename">C:\repos</code>). There are a number of caveats in the prior example, however.</p><p>First, notice that the <span class="command"><strong>svnserve.exe</strong></span> program must always be invoked with the <code class="option">--service</code> option. Any other options to <span class="command"><strong>svnserve</strong></span> must then be specified on the same line, but you cannot add conflicting options such as <code class="option">--daemon</code> (<code class="option">-d</code>), <code class="option">--tunnel</code>, or <code class="option">--inetd</code> (<code class="option">-i</code>). Options such as <code class="option">-r</code> or <code class="option">--listen-port</code> are fine, though. Second, be careful about spaces when invoking the <span class="command"><strong>SC.EXE</strong></span> command: the <code class="literal">key= value</code> patterns must have no spaces between <code class="literal">key=</code> and must have exactly one space before the <code class="literal">value</code>. Lastly, be careful about spaces in your command line to be invoked. If a directory name contains spaces (or other characters that need escaping), place the entire inner value of <code class="literal">binpath</code> in double quotes, by escaping them:</p><div class="informalexample"><pre class="screen"> C:\&gt; sc create svn binpath= "\"C:\program files\svn\bin\svnserve.exe\" --service -r C:\repos" displayname= "Subversion Server" depend= Tcpip start= auto </pre></div><p>Also note that the word <code class="literal">binpath</code> is misleading—its value is a <span class="emphasis"><em>command line</em></span>, not the path to an executable. That's why you need to surround it with quotes if it contains embedded spaces.</p><p>Once the service is defined, it can be stopped, started, or queried using standard GUI tools (the Services administrative control panel), or at the command line:</p><div class="informalexample"><pre class="screen"> C:\&gt; net stop svn C:\&gt; net start svn </pre></div><p>The service can also be uninstalled (i.e., undefined) by deleting its definition: <strong class="userinput"><code>sc delete svn</code></strong>. Just be sure to stop the service first! The <span class="command"><strong>SC.EXE</strong></span> program has many other subcommands and options; run <strong class="userinput"><code>sc /?</code></strong> to learn more about it.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.svnserve.invoking.launchd"></a>svnserve as a launchd job</h4></div></div></div><p>Mac OS X (10.4 and higher) uses <span class="command"><strong>launchd</strong></span> to manage processes (including daemons) both system-wide and per-user. A <span class="command"><strong>launchd</strong></span> job is specified by parameters in an XML property list file, and the <span class="command"><strong>launchctl</strong></span> command is used to manage the lifecycle of those jobs.</p><p>When configured to run as a <span class="command"><strong>launchd</strong></span> job, <span class="command"><strong>svnserve</strong></span> is automatically launched on demand whenever incoming Subversion <code class="literal">svn://</code> network traffic needs to be handled. This is far more convenient than a configuration which requires you to manually invoke <span class="command"><strong>svnserve</strong></span> as a long-running background process.</p><p>To configure <span class="command"><strong>svnserve</strong></span> as a <span class="command"><strong>launchd</strong></span> job, first create a job definition file named <code class="filename">/Library/LaunchDaemons/org.apache.subversion.svnserve.plist</code>. <a class="xref" href="#svn.serverconfig.svnserve.invoking.launchd.ex-1" title="Example 6.1. A sample svnserve launchd job definition">Example 6.1, “A sample svnserve launchd job definition”</a> provides an example of such a file.</p><div class="example"><a id="svn.serverconfig.svnserve.invoking.launchd.ex-1"></a><p class="title"><strong>Example 6.1. A sample svnserve launchd job definition</strong></p><div class="example-contents"><pre class="programlisting"> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;dict&gt; &lt;key&gt;Label&lt;/key&gt; &lt;string&gt;org.apache.subversion.svnserve&lt;/string&gt; &lt;key&gt;ServiceDescription&lt;/key&gt; &lt;string&gt;Host Subversion repositories using svn:// scheme&lt;/string&gt; &lt;key&gt;ProgramArguments&lt;/key&gt; &lt;array&gt; &lt;string&gt;/usr/bin/svnserve&lt;/string&gt; &lt;string&gt;--inetd&lt;/string&gt; &lt;string&gt;--root=/var/svn&lt;/string&gt; &lt;/array&gt; &lt;key&gt;UserName&lt;/key&gt; &lt;string&gt;svn&lt;/string&gt; &lt;key&gt;GroupName&lt;/key&gt; &lt;string&gt;svn&lt;/string&gt; &lt;key&gt;inetdCompatibility&lt;/key&gt; &lt;dict&gt; &lt;key&gt;Wait&lt;/key&gt; &lt;false/&gt; &lt;/dict&gt; &lt;key&gt;Sockets&lt;/key&gt; &lt;dict&gt; &lt;key&gt;Listeners&lt;/key&gt; &lt;array&gt; &lt;dict&gt; &lt;key&gt;SockServiceName&lt;/key&gt; &lt;string&gt;svn&lt;/string&gt; &lt;key&gt;Bonjour&lt;/key&gt; &lt;true/&gt; &lt;/dict&gt; &lt;/array&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/plist&gt; </pre></div></div><br class="example-break"></br><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>The <span class="command"><strong>launchd</strong></span> system can be somewhat challenging to learn. Fortunately, documentation exists for the commands described in this section. For example, run <strong class="userinput"><code>man launchd</code></strong> from the command line to see the manual page for <span class="command"><strong>launchd</strong></span> itself, <strong class="userinput"><code>man launchd.plist</code></strong> to read about the job definition format, etc.</p></td></tr></table></div><p>Once your job definition file is created, you can activate the job using <span class="command"><strong>launchctl load</strong></span>:</p><div class="informalexample"><pre class="screen"> $ sudo launchctl load \ -w /Library/LaunchDaemons/org.apache.subversion.svnserve.plist </pre></div><p>To be clear, this action doesn't actually launch <span class="command"><strong>svnserve</strong></span> yet. It simply tells <span class="command"><strong>launchd</strong></span> how to fire up <span class="command"><strong>svnserve</strong></span> when incoming networking traffic arrives on the <code class="literal">svn</code> network port; it will be terminated it after the traffic has been handled.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Because we want <span class="command"><strong>svnserve</strong></span> to be a system-wide daemon process, we need to use <span class="command"><strong>sudo</strong></span> to manage this job as an administrator. Note also that the <code class="literal">UserName</code> and <code class="literal">GroupName</code> keys in the definition file are optional—if omitted, the job will run as the user who loaded the job.</p></td></tr></table></div><p>Deactivating the job is just as easy to do—use <span class="command"><strong>launchctl unload</strong></span>:</p><div class="informalexample"><pre class="screen"> $ sudo launchctl unload \ -w /Library/LaunchDaemons/org.apache.subversion.svnserve.plist </pre></div><p><span class="command"><strong>launchctl</strong></span> also provides a way for you to query the status of jobs. If the job is loaded, there will be line which matches the <code class="literal">Label</code> specified in the job definition file:</p><div class="informalexample"><pre class="screen"> $ sudo launchctl list | grep org.apache.subversion.svnserve - 0 org.apache.subversion.svnserve $ </pre></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.svnserve.auth"></a>Built-in Authentication and Authorization</h3></div></div></div><p>When a client connects to an <span class="command"><strong>svnserve</strong></span> process, the following things happen:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>The client selects a specific repository.</p></li><li class="listitem"><p>The server processes the repository's <code class="filename">conf/svnserve.conf</code> file and begins to enforce any authentication and authorization policies it describes.</p></li><li class="listitem"><p>Depending on the defined policies, one of the following may occur:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>The client may be allowed to make requests anonymously, without ever receiving an authentication challenge.</p></li><li class="listitem"><p>The client may be challenged for authentication at any time.</p></li><li class="listitem"><p>If operating in tunnel mode, the client will declare itself to be already externally authenticated (typically by SSH).</p></li></ul></div></li></ul></div><p>The <span class="command"><strong>svnserve</strong></span> server, by default, knows only how to send a CRAM-MD5<a href="#ftn.idm6487" class="footnote" id="idm6487"><sup class="footnote">[52]</sup></a> authentication challenge. In essence, the server sends a small amount of data to the client. The client uses the MD5 hash algorithm to create a fingerprint of the data and password combined, and then sends the fingerprint as a response. The server performs the same computation with the stored password to verify that the result is identical. <span class="emphasis"><em>At no point does the actual password travel over the network.</em></span></p><p>If your <span class="command"><strong>svnserve</strong></span> server was built with SASL support, it not only knows how to send CRAM-MD5 challenges, but also likely knows a whole host of other authentication mechanisms. See <a class="xref" href="#svn.serverconfig.svnserve.sasl" title="Using svnserve with SASL">the section called “Using <span class="command"><strong>svnserve</strong></span> with SASL”</a> later in this chapter to learn how to configure SASL authentication and encryption.</p><p>It's also possible, of course, for the client to be externally authenticated via a tunnel agent, such as <span class="command"><strong>ssh</strong></span>. In that case, the server simply examines the user it's running as, and uses this name as the authenticated username. For more on this, see the later section, <a class="xref" href="#svn.serverconfig.svnserve.sshauth" title="Tunneling over SSH">the section called “Tunneling over SSH”</a>.</p><p>As you've already guessed, a repository's <code class="filename">svnserve.conf</code> file is the central mechanism for controlling access to the repository. When used in conjunction with other supplemental files described in this section, this configuration file offers an administrator a complete solution for governing user authentication and authorization policies. Each of the files we'll discuss uses the format common to other configuration files (see <a class="xref" href="#svn.advanced.confarea" title="Runtime Configuration Area">the section called “Runtime Configuration Area”</a>): section names are marked by square brackets (<code class="literal">[</code> and <code class="literal">]</code>), comments begin with hashes (<code class="literal">#</code>), and each section contains specific variables that can be set (<code class="literal">variable = value</code>). Let's walk through these files now and learn how to use them.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.svnserve.auth.users"></a>Create a users file and realm</h4></div></div></div><p>For now, the <code class="literal">[general]</code> section of <code class="filename">svnserve.conf</code> has all the variables you need. Begin by changing the values of those variables: choose a name for a file that will contain your usernames and passwords and choose an authentication realm:</p><div class="informalexample"><pre class="programlisting"> [general] password-db = userfile realm = example realm </pre></div><p>The <code class="literal">realm</code> is a name that you define. It tells clients which sort of <span class="quote">“<span class="quote">authentication namespace</span>”</span> they're connecting to; the Subversion client displays it in the authentication prompt and uses it as a key (along with the server's hostname and port) for caching credentials on disk (see <a class="xref" href="#svn.serverconfig.netmodel.credcache" title="Caching credentials">the section called “Caching credentials”</a>). The <code class="literal">password-db</code> variable points to a separate file that contains a list of usernames and passwords, using the same familiar format. For example:</p><div class="informalexample"><pre class="programlisting"> [users] harry = foopassword sally = barpassword </pre></div><p>The value of <code class="literal">password-db</code> can be an absolute or relative path to the users file. For many admins, it's easy to keep the file right in the <code class="filename">conf/</code> area of the repository, alongside <code class="filename">svnserve.conf</code>. On the other hand, it's possible you may want to have two or more repositories share the same users file; in that case, the file should probably live in a more public place. The repositories sharing the users file should also be configured to have the same realm, since the list of users essentially defines an authentication realm. Wherever the file lives, be sure to set the file's read and write permissions appropriately. If you know which user(s) <span class="command"><strong>svnserve</strong></span> will run as, restrict read access to the users file as necessary.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.svnserve.auth.general"></a>Set access controls</h4></div></div></div><p>There are two more variables to set in the <code class="filename">svnserve.conf</code> file: they determine what unauthenticated (anonymous) and authenticated users are allowed to do. The variables <code class="literal">anon-access</code> and <code class="literal">auth-access</code> can be set to the value <code class="literal">none</code>, <code class="literal">read</code>, or <code class="literal">write</code>. Setting the value to <code class="literal">none</code> prohibits both reading and writing; <code class="literal">read</code> allows read-only access to the repository, and <code class="literal">write</code> allows complete read/write access to the repository. For example:</p><div class="informalexample"><pre class="programlisting"> [general] password-db = userfile realm = example realm # anonymous users can only read the repository anon-access = read # authenticated users can both read and write auth-access = write </pre></div><p>The example settings are, in fact, the default values of the variables, should you forget to define them. If you want to be even more conservative, you can block anonymous access completely:</p><div class="informalexample"><pre class="programlisting"> [general] password-db = userfile realm = example realm # anonymous users aren't allowed anon-access = none # authenticated users can both read and write auth-access = write </pre></div><p>The server process understands not only these <span class="quote">“<span class="quote">blanket</span>”</span> access controls to the repository, but also finer-grained access restrictions placed on specific files and directories within the repository. To make use of this feature, you need to define a file containing more detailed rules, and then set the <code class="literal">authz-db</code> variable to point to it:</p><div class="informalexample"><pre class="programlisting"> [general] password-db = userfile realm = example realm # Specific access rules for specific locations authz-db = authzfile </pre></div><p>We discuss the syntax of the <code class="filename">authzfile</code> file in detail later in this chapter, in <a class="xref" href="#svn.serverconfig.pathbasedauthz" title="Path-Based Authorization">the section called “Path-Based Authorization”</a>. Note that the <code class="literal">authz-db</code> variable isn't mutually exclusive with the <code class="literal">anon-access</code> and <code class="literal">auth-access</code> variables; if all the variables are defined at once, <span class="emphasis"><em>all</em></span> of the rules must be satisfied before access is allowed.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.svnserve.sasl"></a>Using <span class="command"><strong>svnserve</strong></span> with SASL</h3></div></div></div><p>For many teams, the built-in CRAM-MD5 authentication is all they need from <span class="command"><strong>svnserve</strong></span>. However, if your server (and your Subversion clients) were built with the Cyrus Simple Authentication and Security Layer (SASL) library, you have a number of authentication and encryption options available to you.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>What Is SASL?</strong></p></div></div></div><p>The Cyrus Simple Authentication and Security Layer is open source software written by Carnegie Mellon University. It adds generic authentication and encryption capabilities to any network protocol, and as of Subversion 1.5 and later, both the <span class="command"><strong>svnserve</strong></span> server and <span class="command"><strong>svn</strong></span> client know how to make use of this library. It may or may not be available to you: if you're building Subversion yourself, you'll need to have at least version 2.1 of SASL installed on your system, and you'll need to make sure that it's detected during Subversion's build process. The Subversion command-line client will report the availability of Cyrus SASL when you run <strong class="userinput"><code>svn --version</code></strong>; if you're using some other Subversion client, you might need to check with the package maintainer as to whether SASL support was compiled in.</p><p>SASL comes with a number of pluggable modules that represent different authentication systems: Kerberos (GSSAPI), NTLM, One-Time-Passwords (OTP), DIGEST-MD5, LDAP, Secure-Remote-Password (SRP), and others. Certain mechanisms may or may not be available to you; be sure to check which modules are provided.</p><p>You can download Cyrus SASL (both code and documentation) from <a class="ulink" href="http://asg.web.cmu.edu/sasl/sasl-library.html" target="_top">http://asg.web.cmu.edu/sasl/sasl-library.html</a>.</p></div><p>Normally, when a subversion client connects to <span class="command"><strong>svnserve</strong></span>, the server sends a greeting that advertises a list of the capabilities it supports, and the client responds with a similar list of capabilities. If the server is configured to require authentication, it then sends a challenge that lists the authentication mechanisms available; the client responds by choosing one of the mechanisms, and then authentication is carried out in some number of round-trip messages. Even when SASL capabilities aren't present, the client and server inherently know how to use the CRAM-MD5 and ANONYMOUS mechanisms (see <a class="xref" href="#svn.serverconfig.svnserve.auth" title="Built-in Authentication and Authorization">the section called “Built-in Authentication and Authorization”</a>). If server and client were linked against SASL, a number of other authentication mechanisms may also be available. However, you'll need to explicitly configure SASL on the server side to advertise them.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.svnserve.sasl.authn"></a>Authenticating with SASL</h4></div></div></div><p>To activate specific SASL mechanisms on the server, you'll need to do two things. First, create a <code class="literal">[sasl]</code> section in your repository's <code class="filename">svnserve.conf</code> file with an initial key-value pair:</p><div class="informalexample"><pre class="programlisting"> [sasl] use-sasl = true </pre></div><p>Second, create a main SASL configuration file called <code class="filename">svn.conf</code> in a place where the SASL library can find it—typically in the directory where SASL plug-ins are located. You'll have to locate the plug-in directory on your particular system, such as <code class="filename">/usr/lib/sasl2/</code> or <code class="filename">/etc/sasl2/</code>. (Note that this is <span class="emphasis"><em>not</em></span> the <code class="filename">svnserve.conf</code> file that lives within a repository!)</p><p>On a Windows server, you'll also have to edit the system registry (using a tool such as <span class="command"><strong>regedit</strong></span>) to tell SASL where to find things. Create a registry key named <code class="literal">[HKEY_LOCAL_MACHINE\SOFTWARE\Carnegie Mellon\Project Cyrus\SASL Library]</code>, and place two keys inside it: a key called <code class="literal">SearchPath</code> (whose value is a path to the directory containing the SASL <code class="filename">sasl*.dll</code> plug-in libraries), and a key called <code class="literal">ConfFile</code> (whose value is a path to the parent directory containing the <code class="filename">svn.conf</code> file you created).</p><p>Because SASL provides so many different kinds of authentication mechanisms, it would be foolish (and far beyond the scope of this book) to try to describe every possible server-side configuration. Instead, we recommend that you read the documentation supplied in the <code class="filename">doc/</code> subdirectory of the SASL source code. It goes into great detail about every mechanism and how to configure the server appropriately for each. For the purposes of this discussion, we'll just demonstrate a simple example of configuring the DIGEST-MD5 mechanism. For example, if your <code class="filename">svn.conf</code> file contains the following:</p><div class="informalexample"><pre class="programlisting"> pwcheck_method: auxprop auxprop_plugin: sasldb sasldb_path: /etc/my_sasldb mech_list: DIGEST-MD5 </pre></div><p>you've told SASL to advertise the DIGEST-MD5 mechanism to clients and to check user passwords against a private password database located at <code class="filename">/etc/my_sasldb</code>. A system administrator can then use the <span class="command"><strong>saslpasswd2</strong></span> program to add or modify usernames and passwords in the database:</p><div class="informalexample"><pre class="screen"> $ saslpasswd2 -c -f /etc/my_sasldb -u realm username </pre></div><p>A few words of warning: first, make sure the <span class="quote">“<span class="quote">realm</span>”</span> argument to <span class="command"><strong>saslpasswd2</strong></span> matches the same realm you've defined in your repository's <code class="filename">svnserve.conf</code> file; if they don't match, authentication will fail. Also, due to a shortcoming in SASL, the common realm must be a string with no space characters. Finally, if you decide to go with the standard SASL password database, make sure the <span class="command"><strong>svnserve</strong></span> program has read access to the file (and possibly write access as well, if you're using a mechanism such as OTP).</p><p>This is just one simple way of configuring SASL. Many other authentication mechanisms are available, and passwords can be stored in other places such as in LDAP or a SQL database. Consult the full SASL documentation for details.</p><p>Remember that if you configure your server to only allow certain SASL authentication mechanisms, this forces all connecting clients to have SASL support as well. Any Subversion client built without SASL support (which includes all pre-1.5 clients) will be unable to authenticate. On the one hand, this sort of restriction may be exactly what you want (<span class="quote">“<span class="quote">My clients must all use Kerberos!</span>”</span>). However, if you still want non-SASL clients to be able to authenticate, be sure to advertise the CRAM-MD5 mechanism as an option. All clients are able to use CRAM-MD5, whether they have SASL capabilities or not.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.svnserve.sasl.encryption"></a>SASL encryption</h4></div></div></div><p>SASL is also able to perform data encryption if a particular mechanism supports it. The built-in CRAM-MD5 mechanism doesn't support encryption, but DIGEST-MD5 does, and mechanisms such as SRP actually require use of the OpenSSL library. To enable or disable different levels of encryption, you can set two values in your repository's <code class="filename">svnserve.conf</code> file:</p><div class="informalexample"><pre class="programlisting"> [sasl] use-sasl = true min-encryption = 128 max-encryption = 256 </pre></div><p>The <code class="literal">min-encryption</code> and <code class="literal">max-encryption</code> variables control the level of encryption demanded by the server. To disable encryption completely, set both values to 0. To enable simple checksumming of data (i.e., prevent tampering and guarantee data integrity without encryption), set both values to 1. If you wish to allow—but not require—encryption, set the minimum value to 0, and the maximum value to some bit length. To require encryption unconditionally, set both values to numbers greater than 1. In our previous example, we require clients to do at least 128-bit encryption, but no more than 256-bit encryption.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.svnserve.sshauth"></a>Tunneling over SSH</h3></div></div></div><p><span class="command"><strong>svnserve</strong></span>'s built-in authentication (and SASL support) can be very handy, because it avoids the need to create real system accounts. On the other hand, some administrators already have well-established SSH authentication frameworks in place. In these situations, all of the project's users already have system accounts and the ability to <span class="quote">“<span class="quote">SSH into</span>”</span> the server machine.</p><p>It's easy to use SSH in conjunction with <span class="command"><strong>svnserve</strong></span>. The client simply uses the <code class="literal">svn+ssh://</code> URL scheme to connect:</p><div class="informalexample"><pre class="screen"> $ whoami harry $ svn list svn+ssh://host.example.com/repos/project harryssh@host.example.com's password: ***** foo bar baz … </pre></div><p>In this example, the Subversion client is invoking a local <span class="command"><strong>ssh</strong></span> process, connecting to <code class="literal">host.example.com</code>, authenticating as the user <code class="literal">harryssh</code> (according to SSH user configuration), then spawning a private <span class="command"><strong>svnserve</strong></span> process on the remote machine running as the user <code class="literal">harryssh</code>. The <span class="command"><strong>svnserve</strong></span> command is being invoked in tunnel mode (<code class="option">-t</code>), and its network protocol is being <span class="quote">“<span class="quote">tunneled</span>”</span> over the encrypted connection by <span class="command"><strong>ssh</strong></span>, the tunnel agent. If the client performs a commit, the authenticated username <code class="literal">harryssh</code> will be used as the author of the new revision.</p><p>The important thing to understand here is that the Subversion client is <span class="emphasis"><em>not</em></span> connecting to a running <span class="command"><strong>svnserve</strong></span> daemon. This method of access doesn't require a daemon, nor does it notice one if present. It relies wholly on the ability of <span class="command"><strong>ssh</strong></span> to spawn a temporary <span class="command"><strong>svnserve</strong></span> process, which then terminates when the network connection is closed.</p><p>When using <code class="literal">svn+ssh://</code> URLs to access a repository, remember that it's the <span class="command"><strong>ssh</strong></span> program prompting for authentication, and <span class="emphasis"><em>not</em></span> the <span class="command"><strong>svn</strong></span> client program. That means there's no automatic password-caching going on (see <a class="xref" href="#svn.serverconfig.netmodel.credcache" title="Caching credentials">the section called “Caching credentials”</a>). The Subversion client often makes multiple connections to the repository, though users don't normally notice this due to the password caching feature. When using <code class="literal">svn+ssh://</code> URLs, however, users may be annoyed by <span class="command"><strong>ssh</strong></span> repeatedly asking for a password for every outbound connection. The solution is to use a separate SSH password-caching tool such as <span class="command"><strong>ssh-agent</strong></span> on a Unix-like system, or <span class="command"><strong>pageant</strong></span> on Windows.</p><p>When running over a tunnel, authorization is primarily controlled by operating system permissions to the repository's database files; it's very much the same as if Harry were accessing the repository directly via a <code class="literal">file://</code> URL. If multiple system users are going to be accessing the repository directly, you may want to place them into a common group, and you'll need to be careful about umasks (be sure to read <a class="xref" href="#svn.serverconfig.multimethod" title="Supporting Multiple Repository Access Methods">the section called “Supporting Multiple Repository Access Methods”</a> later in this chapter). But even in the case of tunneling, you can still use the <code class="filename">svnserve.conf</code> file to block access, by simply setting <code class="literal">auth-access = read</code> or <code class="literal">auth-access = none</code>.<a href="#ftn.idm6657" class="footnote" id="idm6657"><sup class="footnote">[53]</sup></a></p><p>You'd think that the story of SSH tunneling would end here, but it doesn't. Subversion allows you to create custom tunnel behaviors in your runtime <code class="filename">config</code> file (see <a class="xref" href="#svn.advanced.confarea" title="Runtime Configuration Area">the section called “Runtime Configuration Area”</a>). For example, suppose you want to use RSH instead of SSH.<a href="#ftn.idm6663" class="footnote" id="idm6663"><sup class="footnote">[54]</sup></a> In the <code class="literal">[tunnels]</code> section of your <code class="filename">config</code> file, simply define it like this:</p><div class="informalexample"><pre class="programlisting"> [tunnels] rsh = rsh -- </pre></div><p>And now, you can use this new tunnel definition by using a URL scheme that matches the name of your new variable: <code class="literal">svn+rsh://host/path</code>. When using the new URL scheme, the Subversion client will actually be running the command <strong class="userinput"><code>rsh -- host svnserve -t</code></strong> behind the scenes. If you include a username in the URL (e.g., <code class="literal">svn+rsh://username@host/path</code>), the client will also include that in its command (<strong class="userinput"><code>rsh -- username@host svnserve -t</code></strong>).</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Notice that when defining an RSH-based tunnel, we've added the <code class="literal">--</code> end-of-options argument to the tunnel command line. This is to prevent a malformed hostname from being treated as another option to the tunnel command. You should do the same for other tunnel programs (for example, SSH).</p></td></tr></table></div><p>But you can define new tunneling schemes to be much more clever than that:</p><div class="informalexample"><pre class="programlisting"> [tunnels] joessh = $JOESSH /opt/alternate/ssh -p 29934 -- </pre></div><p>This example demonstrates a couple of things. First, it shows how to make the Subversion client launch a very specific tunneling binary (the one located at <code class="filename">/opt/alternate/ssh</code>) with specific options. In this case, accessing an <code class="literal">svn+joessh://</code> URL would invoke the particular SSH binary with <code class="option">-p 29934</code> as arguments—useful if you want the tunnel program to connect to a nonstandard port.</p><p>Second, it shows how to define a custom environment variable that can override the name of the tunneling program. Setting the <code class="literal">SVN_SSH</code> environment variable is a convenient way to override the default SSH tunnel agent. But if you need to have several different overrides for different servers, each perhaps contacting a different port or passing a different set of options to SSH, you can use the mechanism demonstrated in this example. Now if we were to set the <code class="literal">JOESSH</code> environment variable, its value would override the entire value of the tunnel variable—<span class="command"><strong>$JOESSH</strong></span> would be executed instead of <strong class="userinput"><code>/opt/alternate/ssh -p 29934</code></strong>.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.svnserve.sshtricks"></a>SSH Configuration Tricks</h3></div></div></div><p>It's possible to control not only the way in which the client invokes <span class="command"><strong>ssh</strong></span>, but also to control the behavior of <span class="command"><strong>sshd</strong></span> on your server machine. In this section, we'll show how to control the exact <span class="command"><strong>svnserve</strong></span> command executed by <span class="command"><strong>sshd</strong></span>, as well as how to have multiple users share a single system account.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.svnserve.sshtricks.setup"></a>Initial setup</h4></div></div></div><p>To begin, locate the home directory of the account you'll be using to launch <span class="command"><strong>svnserve</strong></span>. Make sure the account has an SSH public/private keypair installed, and that the user can log in via public-key authentication. Password authentication will not work, since all of the following SSH tricks revolve around using the SSH <code class="filename">authorized_keys</code> file.</p><p>If it doesn't already exist, create the <code class="filename">authorized_keys</code> file (on Unix, typically <code class="filename">~/.ssh/authorized_keys</code>). Each line in this file describes a public key that is allowed to connect. The lines are typically of the form:</p><div class="informalexample"><pre class="programlisting"> ssh-dsa AAAABtce9euch… user@example.com </pre></div><p>The first field describes the type of key, the second field is the base64-encoded key itself, and the third field is a comment. However, it's a lesser known fact that the entire line can be preceded by a <code class="literal">command</code> field:</p><div class="informalexample"><pre class="programlisting"> command="program" ssh-dsa AAAABtce9euch… user@example.com </pre></div><p>When the <code class="literal">command</code> field is set, the SSH daemon will run the named program instead of the typical tunnel-mode <span class="command"><strong>svnserve</strong></span> invocation that the Subversion client asks for. This opens the door to a number of server-side tricks. In the following examples, we abbreviate the lines of the file as:</p><div class="informalexample"><pre class="programlisting"> command="program" TYPE KEY COMMENT </pre></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.svnserve.sshtricks.fixedcmd"></a>Controlling the invoked command</h4></div></div></div><p>Because we can specify the executed server-side command, it's easy to name a specific <span class="command"><strong>svnserve</strong></span> binary to run and to pass it extra arguments:</p><div class="informalexample"><pre class="programlisting"> command="/path/to/svnserve -t -r /virtual/root" TYPE KEY COMMENT </pre></div><p>In this example, <code class="filename">/path/to/svnserve</code> might be a custom wrapper script around <span class="command"><strong>svnserve</strong></span> which sets the umask (see <a class="xref" href="#svn.serverconfig.multimethod" title="Supporting Multiple Repository Access Methods">the section called “Supporting Multiple Repository Access Methods”</a>). It also shows how to anchor <span class="command"><strong>svnserve</strong></span> in a virtual root directory, just as one often does when running <span class="command"><strong>svnserve</strong></span> as a daemon process. This might be done either to restrict access to parts of the system, or simply to relieve the user of having to type an absolute path in the <code class="literal">svn+ssh://</code> URL.</p><p>It's also possible to have multiple users share a single account. Instead of creating a separate system account for each user, generate a public/private key pair for each person. Then place each public key into the <code class="filename">authorized_keys</code> file, one per line, and use the <code class="option">--tunnel-user</code> option:</p><div class="informalexample"><pre class="programlisting"> command="svnserve -t --tunnel-user=harry" TYPE1 KEY1 harry@example.com command="svnserve -t --tunnel-user=sally" TYPE2 KEY2 sally@example.com </pre></div><p>This example allows both Harry and Sally to connect to the same account via public key authentication. Each of them has a custom command that will be executed; the <code class="option">--tunnel-user</code> option tells <span class="command"><strong>svnserve</strong></span> to assume that the named argument is the authenticated user. Without <code class="option">--tunnel-user</code>, it would appear as though all commits were coming from the one shared system account.</p><p>A final word of caution: giving a user access to the server via public-key in a shared account might still allow other forms of SSH access, even if you've set the <code class="literal">command</code> value in <code class="filename">authorized_keys</code>. For example, the user may still get shell access through SSH or be able to perform X11 or general port forwarding through your server. To give the user as little permission as possible, you may want to specify a number of restrictive options immediately after the <code class="literal">command</code>:</p><div class="informalexample"><pre class="programlisting"> command="svnserve -t --tunnel-user=harry",no-port-forwarding,no-agent-forw arding,no-X11-forwarding,no-pty TYPE1 KEY1 harry@example.com </pre></div><p>Note that this all must be on one line—truly on one line—since SSH <code class="filename">authorized_keys</code> files do not even allow the conventional backslash character (<code class="literal">\</code>) for line continuation. The only reason we've shown it with a line break is to fit it on the physical page of a book.</p></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.serverconfig.httpd"></a>httpd, the Apache HTTP Server</h2></div></div></div><p>The Apache HTTP Server is a <span class="quote">“<span class="quote">heavy-duty</span>”</span> network server that Subversion can leverage. Via a custom module, <span class="command"><strong>httpd</strong></span> makes Subversion repositories available to clients via the WebDAV/DeltaV<a href="#ftn.idm6751" class="footnote" id="idm6751"><sup class="footnote">[55]</sup></a> protocol, which is an extension to HTTP 1.1. This protocol takes the ubiquitous HTTP protocol that is the core of the World Wide Web, and adds writing—specifically, versioned writing—capabilities. The result is a standardized, robust system that is conveniently packaged as part of the Apache 2.0 software, supported by numerous operating systems and third-party products, and doesn't require network administrators to open up yet another custom port.<a href="#ftn.idm6754" class="footnote" id="idm6754"><sup class="footnote">[56]</sup></a> While an Apache-Subversion server has more features than <span class="command"><strong>svnserve</strong></span>, it's also a bit more difficult to set up. With flexibility often comes more complexity.</p><p>Much of the following discussion includes references to Apache configuration directives. While some examples are given of the use of these directives, describing them in full is outside the scope of this chapter. The Apache team maintains excellent documentation, publicly available on their web site at <a class="ulink" href="http://httpd.apache.org" target="_top">http://httpd.apache.org</a>. For example, a general reference for the configuration directives is located at <a class="ulink" href="http://httpd.apache.org/docs-2.0/mod/directives.html" target="_top">http://httpd.apache.org/docs-2.0/mod/directives.html</a>.</p><p>Also, as you make changes to your Apache setup, it is likely that somewhere along the way a mistake will be made. If you are not already familiar with Apache's logging subsystem, you should become aware of it. In your <code class="filename">httpd.conf</code> file are directives that specify the on-disk locations of the access and error logs generated by Apache (the <code class="literal">CustomLog</code> and <code class="literal">ErrorLog</code> directives, respectively). Subversion's <span class="command"><strong>mod_dav_svn</strong></span> uses Apache's error logging interface as well. You can always browse the contents of those files for information that might reveal the source of a problem that is not clearly noticeable otherwise.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.httpd.prereqs"></a>Prerequisites</h3></div></div></div><p>To network your repository over HTTP, you basically need four components, available in two packages. You'll need Apache <span class="command"><strong>httpd</strong></span> 2.0 or newer, the <span class="command"><strong>mod_dav</strong></span> DAV module that comes with it, Subversion, and the <span class="command"><strong>mod_dav_svn</strong></span> filesystem provider module distributed with Subversion. Once you have all of those components, the process of networking your repository is as simple as:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Getting httpd up and running with the <span class="command"><strong>mod_dav</strong></span> module</p></li><li class="listitem"><p>Installing the <span class="command"><strong>mod_dav_svn</strong></span> backend to <span class="command"><strong>mod_dav</strong></span>, which uses Subversion's libraries to access the repository</p></li><li class="listitem"><p>Configuring your <code class="filename">httpd.conf</code> file to export (or expose) the repository</p></li></ul></div><p>You can accomplish the first two items either by compiling <span class="command"><strong>httpd</strong></span> and Subversion from source code or by installing prebuilt binary packages of them on your system. For the most up-to-date information on how to compile Subversion for use with the Apache HTTP Server, as well as how to compile and configure Apache itself for this purpose, see the <code class="filename">INSTALL</code> file in the top level of the Subversion source code tree.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.httpd.basic"></a>Basic Apache Configuration</h3></div></div></div><p>Once you have all the necessary components installed on your system, all that remains is the configuration of Apache via its <code class="filename">httpd.conf</code> file. Instruct Apache to load the <span class="command"><strong>mod_dav_svn</strong></span> module using the <code class="literal">LoadModule</code> directive. This directive must precede any other Subversion-related configuration items. If your Apache was installed using the default layout, your <span class="command"><strong>mod_dav_svn</strong></span> module should have been installed in the <code class="filename">modules</code> subdirectory of the Apache install location (often <code class="filename">/usr/local/apache2</code>). The <code class="literal">LoadModule</code> directive has a simple syntax, mapping a named module to the location of a shared library on disk:</p><div class="informalexample"><pre class="programlisting"> LoadModule dav_svn_module modules/mod_dav_svn.so </pre></div><p>Apache interprets the <code class="literal">LoadModule</code> configuration item's library path as relative to its own server root. If configured as previously shown, Apache will look for the Subversion DAV module shared library in its own <code class="filename">modules/</code> subdirectory. Depending on how Subversion was installed on your system, you might need to specify a different path for this library altogether, perhaps even an absolute path such as in the following example:</p><div class="informalexample"><pre class="programlisting"> LoadModule dav_svn_module C:/Subversion/lib/mod_dav_svn.so </pre></div><p>Note that if <span class="command"><strong>mod_dav</strong></span> was compiled as a shared object (instead of statically linked directly to the <span class="command"><strong>httpd</strong></span> binary), you'll need a similar <code class="literal">LoadModule</code> statement for it, too. Be sure that it comes before the <span class="command"><strong>mod_dav_svn</strong></span> line:</p><div class="informalexample"><pre class="programlisting"> LoadModule dav_module modules/mod_dav.so LoadModule dav_svn_module modules/mod_dav_svn.so </pre></div><p>At a later location in your configuration file, you now need to tell Apache where you keep your Subversion repository (or repositories). The <code class="literal">Location</code> directive has an XML-like notation, starting with an opening tag and ending with a closing tag, with various other configuration directives in the middle. The purpose of the <code class="literal">Location</code> directive is to instruct Apache to do something special when handling requests that are directed at a given URL or one of its children. In the case of Subversion, you want Apache to simply hand off support for URLs that point at versioned resources to the DAV layer. You can instruct Apache to delegate the handling of all URLs whose path portions (the part of the URL that follows the server's name and the optional port number) begin with <code class="filename">/repos/</code> to a DAV provider whose repository is located at <code class="filename">/var/svn/repository</code> using the following <code class="filename">httpd.conf</code> syntax:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /repos&gt; DAV svn SVNPath /var/svn/repository &lt;/Location&gt; </pre></div><p>If you plan to support multiple Subversion repositories that will reside in the same parent directory on your local disk, you can use an alternative directive—<code class="literal">SVNParentPath</code>—to indicate that common parent directory. For example, if you know you will be creating multiple Subversion repositories in a directory <code class="filename">/var/svn</code> that would be accessed via URLs such as <code class="uri">http://my.server.com/svn/repos1</code>, <code class="uri">http://my.server.com/svn/repos2</code>, and so on, you could use the <code class="filename">httpd.conf</code> configuration syntax in the following example:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn&gt; DAV svn # Automatically map any "/svn/foo" URL to repository /var/svn/foo SVNParentPath /var/svn &lt;/Location&gt; </pre></div><p>Using this syntax, Apache will delegate the handling of all URLs whose path portions begin with <code class="filename">/svn/</code> to the Subversion DAV provider, which will then assume that any items in the directory specified by the <code class="literal">SVNParentPath</code> directive are actually Subversion repositories. This is a particularly convenient syntax in that, unlike the use of the <code class="literal">SVNPath</code> directive, you don't have to restart Apache to add or remove hosted repositories.</p><p>Be sure that when you define your new <code class="literal">Location</code>, it doesn't overlap with other exported locations. For example, if your main <code class="literal">DocumentRoot</code> is exported to <code class="filename">/www</code>, do not export a Subversion repository in <code class="literal">&lt;Location /www/repos&gt;</code>. If a request comes in for the URI <code class="filename">/www/repos/foo.c</code>, Apache won't know whether to look for a file <code class="filename">repos/foo.c</code> in the <code class="literal">DocumentRoot</code>, or whether to delegate <span class="command"><strong>mod_dav_svn</strong></span> to return <code class="filename">foo.c</code> from the Subversion repository. The result is often an error from the server of the form <code class="literal">301 Moved Permanently</code>.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Server Names and the COPY Request</strong></p></div></div></div><p>Subversion makes use of the <code class="literal">COPY</code> request type to perform server-side copies of files and directories. As part of the sanity checking done by the Apache modules, the source of the copy is expected to be located on the same machine as the destination of the copy. To satisfy this requirement, you might need to tell <span class="command"><strong>mod_dav</strong></span> the name you use as the hostname of your server. Generally, you can use the <code class="literal">ServerName</code> directive in <code class="filename">httpd.conf</code> to accomplish this.</p><div class="informalexample"><pre class="programlisting"> ServerName svn.example.com </pre></div><p>If you are using Apache's virtual hosting support via the <code class="literal">NameVirtualHost</code> directive, you may need to use the <code class="literal">ServerAlias</code> directive to specify additional names by which your server is known. Again, refer to the Apache documentation for full details.</p></div><p>At this stage, you should strongly consider the question of permissions. If you've been running Apache for some time now as your regular web server, you probably already have a collection of content—web pages, scripts, and such. These items have already been configured with a set of permissions that allows them to work with Apache, or more appropriately, that allows Apache to work with those files. Apache, when used as a Subversion server, will also need the correct permissions to read and write to your Subversion repository.</p><p>You will need to determine a permission system setup that satisfies Subversion's requirements without messing up any previously existing web page or script installations. This might mean changing the permissions on your Subversion repository to match those in use by other things that Apache serves for you, or it could mean using the <code class="literal">User</code> and <code class="literal">Group</code> directives in <code class="filename">httpd.conf</code> to specify that Apache should run as the user and group that owns your Subversion repository. There is no single correct way to set up your permissions, and each administrator will have different reasons for doing things a certain way. Just be aware that permission-related problems are perhaps the most common oversight when configuring a Subversion repository for use with Apache.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.httpd.authn"></a>Authentication Options</h3></div></div></div><p>At this point, if you configured <code class="filename">httpd.conf</code> to contain something such as the following:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn&gt; DAV svn SVNParentPath /var/svn &lt;/Location&gt; </pre></div><p>your repository is <span class="quote">“<span class="quote">anonymously</span>”</span> accessible to the world. Until you configure some authentication and authorization policies, the Subversion repositories that you make available via the <code class="literal">Location</code> directive will be generally accessible to everyone. In other words:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Anyone can use a Subversion client to check out a working copy of a repository URL (or any of its subdirectories).</p></li><li class="listitem"><p>Anyone can interactively browse the repository's latest revision simply by pointing a web browser to the repository URL.</p></li><li class="listitem"><p>Anyone can commit to the repository.</p></li></ul></div><p>Of course, you might have already set up a pre-commit hook script to prevent commits (see <a class="xref" href="#svn.reposadmin.create.hooks" title="Implementing Repository Hooks">the section called “Implementing Repository Hooks”</a>). But as you read on, you'll see that it's also possible to use Apache's built-in methods to restrict access in specific ways.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Requiring authentication defends against invalid users directly accessing the repository, but does not guard the privacy of valid users' network activity. See <a class="xref" href="#svn.serverconfig.httpd.ssl" title="Protecting network traffic with SSL">the section called “Protecting network traffic with SSL”</a> for how to configure your server to support SSL encryption, which can provide that extra layer of protection.</p></td></tr></table></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.httpd.authn.basic"></a>Basic authentication</h4></div></div></div><p>The easiest way to authenticate a client is via the HTTP Basic authentication mechanism, which simply uses a username and password to verify a user's identity. Apache provides the <span class="command"><strong>htpasswd</strong></span> utility<a href="#ftn.idm6882" class="footnote" id="idm6882"><sup class="footnote">[57]</sup></a> for managing files containing usernames and passwords.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Basic authentication is <span class="emphasis"><em>extremely</em></span> insecure, because it sends passwords over the network in very nearly plain text. See <a class="xref" href="#svn.serverconfig.httpd.authn.digest" title="Digest authentication">the section called “Digest authentication”</a> for details on using the much safer Digest mechanism.</p></td></tr></table></div><p>First, create a password file and grant access to users Harry and Sally:</p><div class="informalexample"><pre class="screen"> $ ### First time: use -c to create the file $ ### Use -m to use MD5 encryption of the password, which is more secure $ htpasswd -c -m /etc/svn-auth.htpasswd harry New password: ***** Re-type new password: ***** Adding password for user harry $ htpasswd -m /etc/svn-auth.htpasswd sally New password: ******* Re-type new password: ******* Adding password for user sally $ </pre></div><p>Next, ensure that Apache has access to the modules which provide the Basic authentication and related functionality: <span class="command"><strong>mod_auth_basic</strong></span>, <span class="command"><strong>mod_authn_file</strong></span>, and <span class="command"><strong>mod_authz_user</strong></span>. In many cases, these modules are compiled into <span class="command"><strong>httpd</strong></span> itself, but if not, you might need to explicitly load one or more of them using the <code class="literal">LoadModule</code> directive:</p><div class="informalexample"><pre class="programlisting"> LoadModule auth_basic_module modules/mod_auth_basic.so LoadModule authn_file_module modules/mod_authn_file.so LoadModule authz_user_module moduels/mod_authz_user.so </pre></div><p>After ensuring the Apache has access to the required functionality, you'll need to add some more directives inside the <code class="literal">&lt;Location&gt;</code> block to tell Apache what type of authentication you wish to use, and just how to do so:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn&gt; DAV svn SVNParentPath /var/svn # Authentication: Basic AuthName "Subversion repository" AuthType Basic AuthBasicProvider file AuthUserFile /etc/svn-auth.htpasswd &lt;/Location&gt; </pre></div><p>These directives work as follows:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><code class="literal">AuthName</code> is an arbitrary name that you choose for the authentication domain. Most browsers display this name in the dialog box when prompting for username and password.</p></li><li class="listitem"><p><code class="literal">AuthType</code> specifies the type of authentication to use.</p></li><li class="listitem"><p><code class="literal">AuthBasicProvider</code> specifies the Basic authentication provider to use for the location. In our example, we wish to consult a local password file.</p></li><li class="listitem"><p><code class="literal">AuthUserFile</code> specifies the location of the password file to use.</p></li></ul></div><p>However, this <code class="literal">&lt;Location&gt;</code> block doesn't yet do anything useful. It merely tells Apache that <span class="emphasis"><em>if</em></span> authorization were required, it should challenge the Subversion client for a username and password. (When authorization is required, Apache requires authentication as well.) What's missing here, however, are directives that tell Apache <span class="emphasis"><em>which sorts</em></span> of client requests require authorization; currently, none do. The simplest thing is to specify that <span class="emphasis"><em>all</em></span> requests require authorization by adding <code class="literal">Require valid-user</code> to the block:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn&gt; DAV svn SVNParentPath /var/svn # Authentication: Basic AuthName "Subversion repository" AuthType Basic AuthBasicProvider file AuthUserFile /etc/svn-auth.htpasswd # Authorization: Authenticated users only Require valid-user &lt;/Location&gt; </pre></div><p>Refer to <a class="xref" href="#svn.serverconfig.httpd.authz" title="Authorization Options">the section called “Authorization Options”</a> for more detail on the <code class="literal">Require</code> directive and other ways to set authorization policies.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The default value of the <code class="literal">AuthBasicProvider</code> option is <code class="literal">file</code>, so we won't bother including it in future examples. Just know that if in a broader context you've set this value to something else, you'll need to explicitly reset it to <code class="literal">file</code> within your Subversion <code class="literal">&lt;Location&gt;</code> block in order to get that behavior.</p></td></tr></table></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.httpd.authn.digest"></a>Digest authentication</h4></div></div></div><p>Digest authentication is an improvement on Basic authentication which allows the server to verify a client's identity without sending the password over the network unprotected. Both client and server create a non-reversible MD5 hash of the username, password, requested URI, and a <em class="firstterm">nonce</em> (number used once) provided by the server and changed each time authentication is required. The client sends its hash to the server, and the server then verifies that the hashes match.</p><p>Configuring Apache to use Digest authentication is straightforward. You'll need to ensure that the <span class="command"><strong>mod_auth_digest</strong></span> module is available (instead of <span class="command"><strong>mod_auth_basic</strong></span>), and then make a few small variations on our prior example:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn&gt; DAV svn SVNParentPath /var/svn # Authentication: Digest AuthName "Subversion repository" AuthType Digest AuthDigestProvider file AuthUserFile /etc/svn-auth.htdigest # Authorization: Authenticated users only Require valid-user &lt;/Location&gt; </pre></div><p>Notice that <code class="literal">AuthType</code> is now set to <code class="literal">Digest</code>, and we specify a different path for <code class="literal">AuthUserFile</code>. Digest authentication uses a different file format than Basic authentication, created and managed using Apache's <span class="command"><strong>htdigest</strong></span> utility<a href="#ftn.idm6949" class="footnote" id="idm6949"><sup class="footnote">[58]</sup></a> rather than <span class="command"><strong>htpasswd</strong></span>. Digest authentication also has the additional concept of a <span class="quote">“<span class="quote">realm</span>”</span>, which must match the value of the <code class="literal">AuthName</code> directive.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>For Digest authentication, the authentication provider is selected using the <code class="literal">AuthDigestProvider</code> as shown in the previous example. As was the case with the <code class="literal">AuthBasicProvider</code> directive, <code class="literal">file</code> is the default value of the <code class="literal">AuthDigestProvider</code> option, so this line is not strictly required unless you need to override a different value thereof inherited from a broader configuration context.</p></td></tr></table></div><p>The password file can be created as follows:</p><div class="informalexample"><pre class="screen"> $ ### First time: use -c to create the file $ htdigest -c /etc/svn-auth.htdigest "Subversion repository" harry Adding password for harry in realm Subversion repository. New password: ***** Re-type new password: ***** $ htdigest /etc/svn-auth.htdigest "Subversion repository" sally Adding user sally in realm Subversion repository New password: ******* Re-type new password: ******* $ </pre></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.httpd.authz"></a>Authorization Options</h3></div></div></div><p>At this point, you've configured authentication, but not authorization. Apache is able to challenge clients and confirm identities, but it has not been told how to allow or restrict access to the clients bearing those identities. This section describes two strategies for controlling access to your repositories.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.httpd.authz.blanket"></a>Blanket access control</h4></div></div></div><p>The simplest form of access control is to authorize certain users for either read-only access to a repository or read/write access to a repository.</p><p>You can restrict access on all repository operations by adding <code class="literal">Require valid-user</code> directly inside the <code class="literal">&lt;Location&gt;</code> block. The example from <a class="xref" href="#svn.serverconfig.httpd.authn.digest" title="Digest authentication">the section called “Digest authentication”</a> allows only clients that successfully authenticate to do anything with the Subversion repository:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn&gt; DAV svn SVNParentPath /var/svn # Authentication: Digest AuthName "Subversion repository" AuthType Digest AuthUserFile /etc/svn-auth.htdigest # Authorization: Authenticated users only Require valid-user &lt;/Location&gt; </pre></div><p>Sometimes you don't need to run such a tight ship. For example, Subversion's own source code repository at <a class="ulink" href="http://svn.collab.net/repos/svn" target="_top">http://svn.collab.net/repos/svn</a> allows anyone in the world to perform read-only repository tasks (such as checking out working copies and browsing the repository), but restricts write operations to authenticated users. The <code class="literal">Limit</code> and <code class="literal">LimitExcept</code> directives allow for this type of selective restriction. Like the <code class="literal">Location</code> directive, these blocks have starting and ending tags, and you would nest them inside your <code class="literal">&lt;Location&gt;</code> block.</p><p>The parameters present on the <code class="literal">Limit</code> and <code class="literal">LimitExcept</code> directives are HTTP request types that are affected by that block. For example, to allow anonymous read-only operations, you would use the <code class="literal">LimitExcept</code> directive (passing the <code class="literal">GET</code>, <code class="literal">PROPFIND</code>, <code class="literal">OPTIONS</code>, and <code class="literal">REPORT</code> request type parameters) and place the previously mentioned <code class="literal">Require valid-user</code> directive inside the <code class="literal">&lt;LimitExcept&gt;</code> block instead of just inside the <code class="literal">&lt;Location&gt;</code> block.</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn&gt; DAV svn SVNParentPath /var/svn # Authentication: Digest AuthName "Subversion repository" AuthType Digest AuthUserFile /etc/svn-auth.htdigest # Authorization: Authenticated users only for non-read-only # (write) operations; allow anonymous reads &lt;LimitExcept GET PROPFIND OPTIONS REPORT&gt; Require valid-user &lt;/LimitExcept&gt; &lt;/Location&gt; </pre></div><p>These are only a few simple examples. For more in-depth information about Apache access control and the <code class="literal">Require</code> directive, take a look at the <code class="literal">Security</code> section of the Apache documentation's tutorials collection at <a class="ulink" href="http://httpd.apache.org/docs-2.0/misc/tutorials.html" target="_top">http://httpd.apache.org/docs-2.0/misc/tutorials.html</a>.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.httpd.authz.perdir"></a>Per-directory access control</h4></div></div></div><p>It's possible to set up finer-grained permissions using <span class="command"><strong>mod_authz_svn</strong></span>. This Apache module grabs the various opaque URLs passing from client to server, asks <span class="command"><strong>mod_dav_svn</strong></span> to decode them, and then possibly vetoes requests based on access policies defined in a configuration file.</p><p>If you've built Subversion from source code, <span class="command"><strong>mod_authz_svn</strong></span> is automatically built and installed alongside <span class="command"><strong>mod_dav_svn</strong></span>. Many binary distributions install it automatically as well. To verify that it's installed correctly, make sure it comes right after <span class="command"><strong>mod_dav_svn</strong></span>'s <code class="literal">LoadModule</code> directive in <code class="filename">httpd.conf</code>:</p><div class="informalexample"><pre class="programlisting"> LoadModule dav_module modules/mod_dav.so LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so </pre></div><p>To activate this module, you need to configure your <code class="literal">&lt;Location&gt;</code> block to use the <code class="literal">AuthzSVNAccessFile</code> directive, which specifies a file containing the permissions policy for paths within your repositories. (In a moment, we'll discuss the format of that file.)</p><p>Apache is flexible, so you have the option to configure your block in one of three general patterns. To begin, choose one of these basic configuration patterns. (The following examples are very simple; look at Apache's own documentation for much more detail on Apache authentication and authorization options.)</p><p>The most open approach is to allow access to everyone. This means Apache never sends authentication challenges, and all users are treated as <span class="quote">“<span class="quote">anonymous</span>”</span>. (See <a class="xref" href="#svn.serverconfig.httpd.authz.perdir.ex-1" title="Example 6.2. A sample configuration for anonymous access">Example 6.2, “A sample configuration for anonymous access”</a>.)</p><div class="example"><a id="svn.serverconfig.httpd.authz.perdir.ex-1"></a><p class="title"><strong>Example 6.2. A sample configuration for anonymous access</strong></p><div class="example-contents"><pre class="programlisting"> &lt;Location /repos&gt; DAV svn SVNParentPath /var/svn # Authentication: None # Authorization: Path-based access control AuthzSVNAccessFile /path/to/access/file &lt;/Location&gt; </pre></div></div><br class="example-break"></br><p>On the opposite end of the paranoia scale, you can configure Apache to authenticate all clients. This block unconditionally requires authentication via the <code class="literal">Require valid-user</code> directive, and defines a means to authenticate valid users. (See <a class="xref" href="#svn.serverconfig.httpd.authz.perdir.ex-2" title="Example 6.3. A sample configuration for authenticated access">Example 6.3, “A sample configuration for authenticated access”</a>.)</p><div class="example"><a id="svn.serverconfig.httpd.authz.perdir.ex-2"></a><p class="title"><strong>Example 6.3. A sample configuration for authenticated access</strong></p><div class="example-contents"><pre class="programlisting"> &lt;Location /repos&gt; DAV svn SVNParentPath /var/svn # Authentication: Digest AuthName "Subversion repository" AuthType Digest AuthUserFile /etc/svn-auth.htdigest # Authorization: Path-based access control; authenticated users only AuthzSVNAccessFile /path/to/access/file Require valid-user &lt;/Location&gt; </pre></div></div><br class="example-break"></br><p>A third very popular pattern is to allow a combination of authenticated and anonymous access. For example, many administrators want to allow anonymous users to read certain repository directories, but restrict access to more sensitive areas to authenticated users. In this setup, all users start out accessing the repository anonymously. If your access control policy demands a real username at any point, Apache will demand authentication from the client. To do this, use both the <code class="literal">Satisfy Any</code> and <code class="literal">Require valid-user</code> directives. (See <a class="xref" href="#svn.serverconfig.httpd.authz.perdir.ex-3" title="Example 6.4. A sample configuration for mixed authenticated/anonymous access">Example 6.4, “A sample configuration for mixed authenticated/anonymous access”</a>.)</p><div class="example"><a id="svn.serverconfig.httpd.authz.perdir.ex-3"></a><p class="title"><strong>Example 6.4. A sample configuration for mixed authenticated/anonymous access</strong></p><div class="example-contents"><pre class="programlisting"> &lt;Location /repos&gt; DAV svn SVNParentPath /var/svn # Authentication: Digest AuthName "Subversion repository" AuthType Digest AuthUserFile /etc/svn-auth.htdigest # Authorization: Path-based access control; try anonymous access # first, but authenticate if necessary AuthzSVNAccessFile /path/to/access/file Satisfy Any Require valid-user &lt;/Location&gt; </pre></div></div><br class="example-break"></br><p>The next step is to create the authorization file containing access rules for particular paths within the repository. We describe how later in this chapter, in <a class="xref" href="#svn.serverconfig.pathbasedauthz" title="Path-Based Authorization">the section called “Path-Based Authorization”</a>.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.httpd.authz.pathauthzoff"></a>Disabling path-based checks</h4></div></div></div><p>The <span class="command"><strong>mod_dav_svn</strong></span> module goes through a lot of work to make sure that data you've marked <span class="quote">“<span class="quote">unreadable</span>”</span> doesn't get accidentally leaked. This means it needs to closely monitor all of the paths and file-contents returned by commands such as <span class="command"><strong>svn checkout</strong></span> and <span class="command"><strong>svn update</strong></span>. If these commands encounter a path that isn't readable according to some authorization policy, the path is typically omitted altogether. In the case of history or rename tracing—for example, running a command such as <strong class="userinput"><code>svn cat -r OLD foo.c</code></strong> on a file that was renamed long ago—the rename tracking will simply halt if one of the object's former names is determined to be read-restricted.</p><p>All of this path checking can sometimes be quite expensive, especially in the case of <span class="command"><strong>svn log</strong></span>. When retrieving a list of revisions, the server looks at every changed path in each revision and checks it for readability. If an unreadable path is discovered, it's omitted from the list of the revision's changed paths (normally seen with the <code class="option">--verbose</code> (<code class="option">-v</code>) option), and the whole log message is suppressed. Needless to say, this can be time-consuming on revisions that affect a large number of files. This is the cost of security: even if you haven't configured a module such as <span class="command"><strong>mod_authz_svn</strong></span> at all, the <span class="command"><strong>mod_dav_svn</strong></span> module is still asking Apache <span class="command"><strong>httpd</strong></span> to run authorization checks on every path. The <span class="command"><strong>mod_dav_svn</strong></span> module has no idea what authorization modules have been installed, so all it can do is ask Apache to invoke whatever might be present.</p><p>On the other hand, there's also an escape hatch of sorts, which allows you to trade security features for speed. If you're not enforcing any sort of per-directory authorization (i.e., not using <span class="command"><strong>mod_authz_svn</strong></span> or similar module), you can disable all of this path checking. In your <code class="filename">httpd.conf</code> file, use the <code class="literal">SVNPathAuthz</code> directive as shown in <a class="xref" href="#svn.serverconfig.httpd.authz.pathauthzoff.ex-1" title="Example 6.5. Disabling path checks altogether">Example 6.5, “Disabling path checks altogether”</a>.</p><div class="example"><a id="svn.serverconfig.httpd.authz.pathauthzoff.ex-1"></a><p class="title"><strong>Example 6.5. Disabling path checks altogether</strong></p><div class="example-contents"><pre class="programlisting"> &lt;Location /repos&gt; DAV svn SVNParentPath /var/svn SVNPathAuthz off &lt;/Location&gt; </pre></div></div><br class="example-break"></br><p>The <code class="literal">SVNPathAuthz</code> directive is <span class="quote">“<span class="quote">on</span>”</span> by default. When set to <span class="quote">“<span class="quote">off,</span>”</span> all path-based authorization checking is disabled; <span class="command"><strong>mod_dav_svn</strong></span> stops invoking authorization checks on every path it discovers.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.httpd.ssl"></a>Protecting network traffic with SSL</h3></div></div></div><p>Connecting to a repository via <code class="literal">http://</code> means that all Subversion activity is sent across the network in the clear. This means that actions such as checkouts, commits, and updates could potentially be intercepted by an unauthorized party <span class="quote">“<span class="quote">sniffing</span>”</span> network traffic. Encrypting traffic using SSL is a good way to protect potentially sensitive information over the network.</p><p>If a Subversion client is compiled to use OpenSSL, it gains the ability to speak to an Apache server via <code class="literal">https://</code> URLs, so all traffic is encrypted with a per-connection session key. The WebDAV library used by the Subversion client is not only able to verify server certificates, but can also supply client certificates when challenged by the server.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.httpd.ssl.server"></a>Subversion server SSL certificate configuration</h4></div></div></div><p>It's beyond the scope of this book to describe how to generate client and server SSL certificates and how to configure Apache to use them. Many other references, including Apache's own documentation, describe the process.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>SSL certificates from well-known entities generally cost money, but at a bare minimum, you can configure Apache to use a self-signed certificate generated with a tool such as OpenSSL (<a class="ulink" href="http://openssl.org" target="_top">http://openssl.org</a>).<a href="#ftn.idm7079" class="footnote" id="idm7079"><sup class="footnote">[59]</sup></a></p></td></tr></table></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.httpd.ssl.client"></a>Subversion client SSL certificate management</h4></div></div></div><p>When connecting to Apache via <code class="literal">https://</code>, a Subversion client can receive two different types of responses:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>A server certificate</p></li><li class="listitem"><p>A challenge for a client certificate</p></li></ul></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.serverconfig.httpd.ssl.client.servercert"></a>Server certificate</h5></div></div></div><p>When the client receives a server certificate, it needs to verify that the server is who it claims to be. OpenSSL does this by examining the signer of the server certificate, or <em class="firstterm">certificate authority</em> (CA). If OpenSSL is unable to automatically trust the CA, or if some other problem occurs (such as an expired certificate or hostname mismatch), the Subversion command-line client will ask you whether you want to trust the server certificate anyway:</p><div class="informalexample"><pre class="screen"> $ svn list https://host.example.com/repos/project Error validating server certificate for 'https://host.example.com:443': - The certificate is not issued by a trusted authority. Use the fingerprint to validate the certificate manually! Certificate information: - Hostname: host.example.com - Valid: from Jan 30 19:23:56 2004 GMT until Jan 30 19:23:56 2006 GMT - Issuer: CA, example.com, Sometown, California, US - Fingerprint: 7d:e1:a9:34:33:39:ba:6a:e9:a5:c4:22:98:7b:76:5c:92:a0:9c:7b (R)eject, accept (t)emporarily or accept (p)ermanently? </pre></div><p>This dialogue is essentially the same question you may have seen coming from your web browser (which is just another HTTP client like Subversion). If you choose the <code class="literal">(p)</code>ermanent option, Subversion will cache the server certificate in your private runtime <code class="filename">auth/</code> area, just as your username and password are cached (see <a class="xref" href="#svn.serverconfig.netmodel.credcache" title="Caching credentials">the section called “Caching credentials”</a>), and will automatically trust the certificate in the future.</p><p>Your runtime <code class="filename">servers</code> file also gives you the ability to make your Subversion client automatically trust specific CAs, either globally or on a per-host basis. Simply set the <code class="literal">ssl-authority-files</code> variable to a semicolon-separated list of PEM-encoded CA certificates:</p><div class="informalexample"><pre class="programlisting"> [global] ssl-authority-files = /path/to/CAcert1.pem;/path/to/CAcert2.pem </pre></div><p>Many OpenSSL installations also have a predefined set of <span class="quote">“<span class="quote">default</span>”</span> CAs that are nearly universally trusted. To make the Subversion client automatically trust these standard authorities, set the <code class="literal">ssl-trust-default-ca</code> variable to <code class="literal">true</code>.</p></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.serverconfig.httpd.ssl.client.clientcert"></a>Client certificate challenge</h5></div></div></div><p>If the client receives a challenge for a certificate, the server is asking the client to prove its identity. The client must send back a certificate signed by a CA that the server trusts, along with a <em class="firstterm">challenge response</em> which proves that the client owns the private key associated with the certificate. The private key and certificate are usually stored in an encrypted format on disk, protected by a passphrase. When Subversion receives this challenge, it will ask you for the path to the encrypted file and the passphrase that protects it:</p><div class="informalexample"><pre class="screen"> $ svn list https://host.example.com/repos/project Authentication realm: https://host.example.com:443 Client certificate filename: /path/to/my/cert.p12 Passphrase for '/path/to/my/cert.p12': ******** </pre></div><p>Notice that the client credentials are stored in a <code class="literal">.p12</code> file. To use a client certificate with Subversion, it must be in PKCS#12 format, which is a portable standard. Most web browsers are able to import and export certificates in that format. Another option is to use the OpenSSL command-line tools to convert existing certificates into PKCS#12.</p><p>The runtime <code class="filename">servers</code> file also allows you to automate this challenge on a per-host basis. If you set the <code class="literal">ssl-client-cert-file</code> and <code class="literal">ssl-client-cert-password</code> variables, Subversion can automatically respond to a client certificate challenge without prompting you:</p><div class="informalexample"><pre class="programlisting"> [groups] examplehost = host.example.com [examplehost] ssl-client-cert-file = /path/to/my/cert.p12 ssl-client-cert-password = somepassword </pre></div><p>More security-conscious folk might want to exclude <code class="literal">ssl-client-cert-password</code> to avoid storing the passphrase in the clear on disk.</p></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.httpd.extra"></a>Extra Goodies</h3></div></div></div><p>We've covered most of the authentication and authorization options for Apache and <span class="command"><strong>mod_dav_svn</strong></span>. But there are a few other nice features that Apache provides.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.httpd.extra.browsing"></a>Repository browsing</h4></div></div></div><p>One of the most useful benefits of an Apache/WebDAV configuration for your Subversion repository is that your versioned files and directories are immediately available for viewing via a regular web browser. Since Subversion uses URLs to identify versioned resources, those URLs used for HTTP-based repository access can be typed directly into a web browser. Your browser will issue an HTTP <code class="literal">GET</code> request for that URL; based on whether that URL represents a versioned directory or file, <span class="command"><strong>mod_dav_svn</strong></span> will respond with a directory listing or with file contents.</p><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.serverconfig.httpd.extra.browsing.syntax"></a>URL syntax</h5></div></div></div><p>If the URLs do not contain any information about which version of the resource you wish to see, <span class="command"><strong>mod_dav_svn</strong></span> will answer with the youngest version. This functionality has the wonderful side effect that you can pass around Subversion URLs to your peers as references to documents, and those URLs will always point at the latest manifestation of that document. Of course, you can even use the URLs as hyperlinks from other web sites, too.</p><p>As of Subversion 1.6, <span class="command"><strong>mod_dav_svn</strong></span> supports a public URI syntax for examining older revisions of both files and directories. The syntax uses the query string portion of the URL to specify either or both of a peg revision and operative revision, which Subversion will then use to determine which version of the file or directory to display to your web browser. Add the query string name/value pair <code class="literal">p=<em class="replaceable"><code>PEGREV</code></em></code>, where <em class="replaceable"><code>PEGREV</code></em> is a revision number, to specify the peg revision you wish to apply to the request. Use <code class="literal">r=<em class="replaceable"><code>REV</code></em></code>, where <em class="replaceable"><code>REV</code></em> is a revision number, to specify an operative revision.</p><p>For example, if you wish to see the latest version of a <code class="filename">README.txt</code> file located in your project's <code class="filename">/trunk</code>, point your web browser to that file's repository URL, which might look something like the following:</p><div class="informalexample"><pre class="programlisting"> http://host.example.com/repos/project/trunk/README.txt </pre></div><p>If you now wish to see some older version of that file, add an operative revision to the URL's query string:</p><div class="informalexample"><pre class="programlisting"> http://host.example.com/repos/project/trunk/README.txt?r=1234 </pre></div><p>What if the thing you're trying to view no longer exists in the youngest revision of the repository? That's where a peg revision is handy:</p><div class="informalexample"><pre class="programlisting"> http://host.example.com/repos/project/trunk/deleted-thing.txt?p=321 </pre></div><p>And of course, you can combine peg revision and operative revision specifiers to fine-tune the exact item you wish to view:</p><div class="informalexample"><pre class="programlisting"> http://host.example.com/repos/project/trunk/renamed-thing.txt?p=123&amp;r=21 </pre></div><p>The previous URL would display revision 21 of the object which, in revision 123, was located at <code class="filename">/trunk/renamed-thing.txt</code> in the repository. See <a class="xref" href="#svn.advanced.pegrevs" title="Peg and Operative Revisions">the section called “Peg and Operative Revisions”</a> for a detailed explanation of these <span class="quote">“<span class="quote">peg revision</span>”</span> and <span class="quote">“<span class="quote">operative revision</span>”</span> concepts. They can be a bit tricky to wrap your head around.</p><p>As a reminder, this feature of <span class="command"><strong>mod_dav_svn</strong></span> offers only a limited repository browsing experience. You can see directory listings and file contents, but no revision properties (such as commit log messages) or file/directory properties. For folks who require more extensive browsing of repositories and their history, there are several third-party software packages which offer this. Some examples include ViewVC (<a class="ulink" href="http://viewvc.tigris.org" target="_top">http://viewvc.tigris.org</a>), Trac (<a class="ulink" href="http://trac.edgewall.org" target="_top">http://trac.edgewall.org</a>) and WebSVN (<a class="ulink" href="http://websvnphp.github.io" target="_top">http://websvnphp.github.io</a>). These third-party tools don't affect <span class="command"><strong>mod_dav_svn</strong></span>'s built-in <span class="quote">“<span class="quote">browseability</span>”</span>, and generally offer a much wider set of features, including the display of the aforementioned property sets, display of content differences between file revisions, and so on.</p></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.serverconfig.httpd.extra.browsing.mimetype"></a>Proper MIME type</h5></div></div></div><p>When browsing a Subversion repository, the web browser gets a clue about how to render a file's contents by looking at the <code class="literal">Content-Type:</code> header returned in Apache's response to the HTTP <code class="literal">GET</code> request. The value of this header is some sort of MIME type. By default, Apache will tell the web browsers that all repository files are of the <span class="quote">“<span class="quote">default</span>”</span> MIME type, typically <code class="literal">text/plain</code>. This can be frustrating, however, if a user wishes repository files to render as something more meaningful—for example, it might be nice to have a <code class="filename">foo.html</code> file in the repository actually render as HTML when browsing.</p><p>To make this happen, you need only to make sure that your files have the proper <code class="literal">svn:mime-type</code> set. We discuss this in more detail in <a class="xref" href="#svn.advanced.props.special.mime-type" title="File Content Type">the section called “File Content Type”</a>, and you can even configure your client to automatically attach proper <code class="literal">svn:mime-type</code> properties to files entering the repository for the first time; see <a class="xref" href="#svn.advanced.props.auto" title="Automatic Property Setting">the section called “Automatic Property Setting”</a>.</p><p>Continuing our example, if one were to set the <code class="literal">svn:mime-type</code> property to <code class="literal">text/html</code> on file <code class="filename">foo.html</code>, Apache would properly tell your web browser to render the file as HTML. One could also attach proper <code class="literal">image/*</code> MIME-type properties to image files and ultimately get an entire web site to be viewable directly from a repository! There's generally no problem with this, as long as the web site doesn't contain any dynamically generated content.</p></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.serverconfig.httpd.extra.browsing.xslt"></a>Customizing the look</h5></div></div></div><p>You generally will get more use out of URLs to versioned files—after all, that's where the interesting content tends to lie. But you might have occasion to browse a Subversion directory listing, where you'll quickly note that the generated HTML used to display that listing is very basic, and certainly not intended to be aesthetically pleasing (or even interesting). To enable customization of these directory displays, Subversion provides an XML index feature. A single <code class="literal">SVNIndexXSLT</code> directive in your repository's <code class="literal">Location</code> block of <code class="filename">httpd.conf</code> will instruct <span class="command"><strong>mod_dav_svn</strong></span> to generate XML output when displaying a directory listing, and to reference the XSLT stylesheet of your choice:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn&gt; DAV svn SVNParentPath /var/svn SVNIndexXSLT "/svnindex.xsl" … &lt;/Location&gt; </pre></div><p>Using the <code class="literal">SVNIndexXSLT</code> directive and a creative XSLT stylesheet, you can make your directory listings match the color schemes and imagery used in other parts of your web site. Or, if you'd prefer, you can use the sample stylesheets provided in the Subversion source distribution's <code class="filename">tools/xslt/</code> directory. Keep in mind that the path provided to the <code class="literal">SVNIndexXSLT</code> directive is actually a URL path—browsers need to be able to read your stylesheets to make use of them!</p></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.serverconfig.httpd.extra.browsing.reposlisting"></a>Listing repositories</h5></div></div></div><p>If you're serving a collection of repositories from a single URL via the <code class="literal">SVNParentPath</code> directive, then it's also possible to have Apache display all available repositories to a web browser. Just activate the <code class="literal">SVNListParentPath</code> directive:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn&gt; DAV svn SVNParentPath /var/svn SVNListParentPath on … &lt;/Location&gt; </pre></div><p>If a user now points her web browser to the URL <code class="literal">http://host.example.com/svn/</code>, she'll see a list of all Subversion repositories sitting in <code class="filename">/var/svn</code>. Obviously, this can be a security problem, so this feature is turned off by default.</p></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.httpd.extra.logging"></a>Apache logging</h4></div></div></div><p>Because Apache is an HTTP server at heart, it contains fantastically flexible logging features. It's beyond the scope of this book to discuss all of the ways logging can be configured, but we should point out that even the most generic <code class="filename">httpd.conf</code> file will cause Apache to produce two logs: <code class="filename">error_log</code> and <code class="filename">access_log</code>. These logs may appear in different places, but are typically created in the logging area of your Apache installation. (On Unix, they often live in <code class="filename">/usr/local/apache2/logs/</code>.)</p><p>The <code class="filename">error_log</code> describes any internal errors that Apache runs into as it works. The <code class="filename">access_log</code> file records every incoming HTTP request received by Apache. This makes it easy to see, for example, which IP addresses Subversion clients are coming from, how often particular clients use the server, which users are authenticating properly, and which requests succeed or fail.</p><p>Unfortunately, because HTTP is a stateless protocol, even the simplest Subversion client operation generates multiple network requests. It's very difficult to look at the <code class="filename">access_log</code> and deduce what the client was doing—most operations look like a series of cryptic <code class="literal">PROPPATCH</code>, <code class="literal">GET</code>, <code class="literal">PUT</code>, and <code class="literal">REPORT</code> requests. To make things worse, many client operations send nearly identical series of requests, so it's even harder to tell them apart.</p><p><span class="command"><strong>mod_dav_svn</strong></span>, however, can come to your aid. By activating an <span class="quote">“<span class="quote">operational logging</span>”</span> feature, you can ask <span class="command"><strong>mod_dav_svn</strong></span> to create a separate log file describing what sort of high-level operations your clients are performing.</p><p>To do this, you need to make use of Apache's <code class="literal">CustomLog</code> directive (which is explained in more detail in Apache's own documentation). Be sure to invoke this directive <span class="emphasis"><em>outside</em></span> your Subversion <code class="literal">Location</code> block:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn&gt; DAV svn … &lt;/Location&gt; CustomLog logs/svn_logfile "%t %u %{SVN-ACTION}e" env=SVN-ACTION </pre></div><p>In this example, we're asking Apache to create a special logfile, <code class="filename">svn_logfile</code>, in the standard Apache <code class="filename">logs</code> directory. The <code class="literal">%t</code> and <code class="literal">%u</code> variables are replaced by the time and username of the request, respectively. The really important parts are the two instances of <code class="literal">SVN-ACTION</code>. When Apache sees that variable, it substitutes the value of the <code class="literal">SVN-ACTION</code> environment variable, which is automatically set by <span class="command"><strong>mod_dav_svn</strong></span> whenever it detects a high-level client action.</p><p>So, instead of having to interpret a traditional <code class="filename">access_log</code> like this:</p><div class="informalexample"><pre class="programlisting"> [26/Jan/2007:22:25:29 -0600] "PROPFIND /svn/calc/!svn/vcc/default HTTP/1.1" 207 398 [26/Jan/2007:22:25:29 -0600] "PROPFIND /svn/calc/!svn/bln/59 HTTP/1.1" 207 449 [26/Jan/2007:22:25:29 -0600] "PROPFIND /svn/calc HTTP/1.1" 207 647 [26/Jan/2007:22:25:29 -0600] "REPORT /svn/calc/!svn/vcc/default HTTP/1.1" 200 607 [26/Jan/2007:22:25:31 -0600] "OPTIONS /svn/calc HTTP/1.1" 200 188 [26/Jan/2007:22:25:31 -0600] "MKACTIVITY /svn/calc/!svn/act/e6035ef7-5df0-4ac0-b811-4be7c823f998 HTTP/1.1" 201 227 … </pre></div><p>you can peruse a much more intelligible <code class="filename">svn_logfile</code> like this:</p><div class="informalexample"><pre class="programlisting"> [26/Jan/2007:22:24:20 -0600] - get-dir /tags r1729 props [26/Jan/2007:22:24:27 -0600] - update /trunk r1729 depth=infinity [26/Jan/2007:22:25:29 -0600] - status /trunk/foo r1729 depth=infinity [26/Jan/2007:22:25:31 -0600] sally commit r1730 </pre></div><p>In addition to the <code class="literal">SVN-ACTION</code> environment variable, <span class="command"><strong>mod_dav_svn</strong></span> also populates the <code class="literal">SVN-REPOS</code> and <code class="literal">SVN-REPOS-NAME</code> variables, which carry the filesystem path to the repository and the basename thereof, respectively. You might wish to include references to one or both of these variables in your <code class="literal">CustomLog</code> format string, too, especially if you are combining usage information from multiple repositories into a single log file.</p><p>For an exhaustive list of all actions logged, see <a class="xref" href="#svn.serverconfig.operational-logging" title="High-level Logging">the section called “High-level Logging”</a>.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.httpd.extra.writethruproxy"></a>Write-through proxying</h4></div></div></div><p>One of the nice advantages of using Apache as a Subversion server is that it can be set up for simple replication. For example, suppose that your team is distributed across four offices around the globe. The Subversion repository can exist only in one of those offices, which means the other three offices will not enjoy accessing it—they're likely to experience significantly slower traffic and response times when updating and committing code. A powerful solution is to set up a system consisting of one <em class="firstterm">master</em> Apache server and several <em class="firstterm">slave</em> Apache servers. If you place a slave server in each office, users can check out a working copy from whichever slave is closest to them. All read requests go to their local slave. Write requests get automatically routed to the single master server. When the commit completes, the master then automatically <span class="quote">“<span class="quote">pushes</span>”</span> the new revision to each slave server using the <span class="command"><strong>svnsync</strong></span> replication tool.</p><p>This configuration creates a huge perceptual speed increase for your users, because Subversion client traffic is typically 80–90% read requests. And if those requests are coming from a <span class="emphasis"><em>local</em></span> server, it's a huge win.</p><p>In this section, we'll walk you through a standard setup of this single-master/multiple-slave system. However, keep in mind that your servers must be running at least Apache 2.2.0 (with <span class="command"><strong>mod_proxy</strong></span> loaded) and Subversion 1.5 (<span class="command"><strong>mod_dav_svn</strong></span>).</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Ours is just one example of how you might setup a Subversion write-through proxy configuration. There are other approaches. For example, rather than having the master server push changes out to every slave server, the slaves could periodically pull those changes from the master. Or perhaps the master could push changes to a single slave, which then pushes the same change to the next slave, and so on down the line. Administrators are encouraged to use this section for basic understanding of what happens in a Subversion WebDAV proxy deployment scenario, and then implement the specific approach that works best for their organization.</p></td></tr></table></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.serverconfig.httpd.extra.writethruproxy.configure"></a>Configure the servers</h5></div></div></div><p>First, configure your master server's <code class="filename">httpd.conf</code> file in the usual way. Make the repository available at a certain URI location, and configure authentication and authorization however you'd like. After that's done, configure each of your <span class="quote">“<span class="quote">slave</span>”</span> servers in the exact same way, but add the special <code class="literal">SVNMasterURI</code> directive to the block:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn&gt; DAV svn SVNPath /var/svn/repos SVNMasterURI http://master.example.com/svn … &lt;/Location&gt; </pre></div><p>This new directive tells a slave server to redirect all write requests to the master. (This is done automatically via Apache's <span class="command"><strong>mod_proxy</strong></span> module.) Ordinary read requests, however, are still serviced by the slaves. Be sure that your master and slave servers all have matching authentication and authorization configurations; if they fall out of sync, it can lead to big headaches.</p><p>Next, we need to deal with the problem of infinite recursion. With the current configuration, imagine what will happen when a Subversion client performs a commit to the master server. After the commit completes, the server uses <span class="command"><strong>svnsync</strong></span> to replicate the new revision to each slave. But because <span class="command"><strong>svnsync</strong></span> appears to be just another Subversion client performing a commit, the slave will immediately attempt to proxy the incoming write request back to the master! Hilarity ensues.</p><p>The solution to this problem is to have the master push revisions to a different <code class="literal">&lt;Location&gt;</code> on the slaves. This location is configured to <span class="emphasis"><em>not</em></span> proxy write requests at all, but to accept normal commits from (and only from) the master's IP address:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn-proxy-sync&gt; DAV svn SVNPath /var/svn/repos Order deny,allow Deny from all # Only let the server's IP address access this Location: Allow from 10.20.30.40 … &lt;/Location&gt; </pre></div></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.serverconfig.httpd.extra.writethruproxy.replicate"></a>Set up replication</h5></div></div></div><p>Now that you've configured your <code class="literal">Location</code> blocks on master and slaves, you need to configure the master to replicate to the slaves. Our walkthough uses <span class="command"><strong>svnsync</strong></span>, which is covered in more detail in <a class="xref" href="#svn.reposadmin.maint.replication.svnsync" title="Replication with svnsync">the section called “Replication with svnsync”</a>.</p><p>First, make sure that each slave repository has a pre-revprop-change hook script which allows remote revision property changes. (This is standard procedure for being on the receiving end of <span class="command"><strong>svnsync</strong></span>.) Then log into the master server and configure each of the slave repository URIs to receive data from the master repository on the local disk:</p><div class="informalexample"><pre class="screen"> $ svnsync init http://slave1.example.com/svn-proxy-sync \ file:///var/svn/repos Copied properties for revision 0. $ svnsync init http://slave2.example.com/svn-proxy-sync \ file:///var/svn/repos Copied properties for revision 0. $ svnsync init http://slave3.example.com/svn-proxy-sync \ file:///var/svn/repos Copied properties for revision 0. # Perform the initial replication $ svnsync sync http://slave1.example.com/svn-proxy-sync \ file:///var/svn/repos Transmitting file data .... Committed revision 1. Copied properties for revision 1. Transmitting file data ....... Committed revision 2. Copied properties for revision 2. … $ svnsync sync http://slave2.example.com/svn-proxy-sync \ file:///var/svn/repos Transmitting file data .... Committed revision 1. Copied properties for revision 1. Transmitting file data ....... Committed revision 2. Copied properties for revision 2. … $ svnsync sync http://slave3.example.com/svn-proxy-sync \ file:///var/svn/repos Transmitting file data .... Committed revision 1. Copied properties for revision 1. Transmitting file data ....... Committed revision 2. Copied properties for revision 2. … </pre></div><p>After this is done, we configure the master server's post-commit hook script to invoke <span class="command"><strong>svnsync</strong></span> on each slave server:</p><div class="informalexample"><pre class="programlisting"> #!/bin/sh # Post-commit script to replicate newly committed revision to slaves svnsync sync http://slave1.example.com/svn-proxy-sync \ file:///var/svn/repos &gt; /dev/null 2&gt;&amp;1 &amp; svnsync sync http://slave2.example.com/svn-proxy-sync \ file:///var/svn/repos &gt; /dev/null 2&gt;&amp;1 &amp; svnsync sync http://slave3.example.com/svn-proxy-sync \ file:///var/svn/repos &gt; /dev/null 2&gt;&amp;1 &amp; </pre></div><p>The extra bits on the end of each line aren't necessary, but they're a sneaky way to allow the sync commands to run in the background so that the Subversion client isn't left waiting forever for the commit to finish. In addition to this post-commit hook, you'll need a post-revprop-change hook as well so that when a user, say, modifies a log message, the slave servers get that change also:</p><div class="informalexample"><pre class="programlisting"> #!/bin/sh # Post-revprop-change script to replicate revprop-changes to slaves REV=${2} svnsync copy-revprops http://slave1.example.com/svn-proxy-sync \ file:///var/svn/repos \ -r ${REV} &gt; /dev/null 2&gt;&amp;1 &amp; svnsync copy-revprops http://slave2.example.com/svn-proxy-sync \ file:///var/svn/repos \ -r ${REV} &gt; /dev/null 2&gt;&amp;1 &amp; svnsync copy-revprops http://slave3.example.com/svn-proxy-sync \ file:///var/svn/repos \ -r ${REV} &gt; /dev/null 2&gt;&amp;1 &amp; </pre></div><p>The only thing we've left out here is what to do about user-level locks (of the <span class="command"><strong>svn lock</strong></span> variety). Locks are enforced by the master server during commit operations; but all the information about locks is distributed during read operations such as <span class="command"><strong>svn update</strong></span> and <span class="command"><strong>svn status</strong></span> by the slave server. As such, a fully functioning proxy setup needs to perfectly replicate lock information from the master server to the slave servers. Unfortunately, most of the mechanisms that one might employ to accomplish this replication fall short in one way or another<a href="#ftn.idm7317" class="footnote" id="idm7317"><sup class="footnote">[60]</sup></a>. Many teams don't use Subversion's locking features at all, so this may be a nonissue for you. Sadly, for those teams which do use locks, we have no recommendations on how to gracefully work around this shortcoming.</p></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a id="svn.serverconfig.httpd.extra.writethruproxy.caveats"></a>Caveats</h5></div></div></div><p>Your master/slave replication system should now be ready to use. A couple of words of warning are in order, however. Remember that this replication isn't entirely robust in the face of computer or network crashes. For example, if one of the automated <span class="command"><strong>svnsync</strong></span> commands fails to complete for some reason, the slaves will begin to fall behind. For example, your remote users will see that they've committed revision 100, but then when they run <span class="command"><strong>svn update</strong></span>, their local server will tell them that revision 100 doesn't yet exist! Of course, the problem will be automatically fixed the next time another commit happens and the subsequent <span class="command"><strong>svnsync</strong></span> is successful—the sync will replicate all waiting revisions. But still, you may want to set up some sort of out-of-band monitoring to notice synchronization failures and force <span class="command"><strong>svnsync</strong></span> to run when things go wrong.</p><p>Another limitation of the write-through proxy deployment model involves version mismatches—of the version of Subversion which is installed, that is—between the master and slave servers. Each new release of Subversion may (and often does) add new features to the network protocol used between the clients and servers. Since feature negotiation happens against the slave, it is the slave's protocol version and feature set which is used. But write operations are passed through to the master server quite literally. Therefore, there is always a risk that the slave server will answer a feature negotiation request from the client in way that is true for the slave, but untrue for the master if the master is running an older version of Subversion. This could result in the client trying to use a new feature that the master doesn't understand, and failing. There are a couple of known problems of this sort in Subversion 1.7, which introduced a major revision of its HTTP protocol. If you are deploying a Subversion 1.7 slave server in front of a pre-1.7 master, you'll want to configure your slave server's Subversion <code class="literal">&lt;Location&gt;</code> block with the <code class="literal">SVNAdvertiseV2Protocol Off</code> directive.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>For the best results possible, try to run the same version of Subversion on your master and slave servers.</p></td></tr></table></div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Can We Set Up Replication with svnserve?</strong></p></div></div></div><p>If you're using <span class="command"><strong>svnserve</strong></span> instead of Apache as your server, you can certainly configure your repository's hook scripts to invoke <span class="command"><strong>svnsync</strong></span> as we've shown here, thereby causing automatic replication from master to slaves. Unfortunately, at the time of this writing there is no way to make slave <span class="command"><strong>svnserve</strong></span> servers automatically proxy write requests back to the master server. This means your users would only be able to check out read-only working copies from the slave servers. You'd have to configure your slave servers to disallow write access completely. This might be useful for creating read-only <span class="quote">“<span class="quote">mirrors</span>”</span> of popular open source projects, but it's not a transparent proxying system.</p></div></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.serverconfig.httpd.extra.other"></a>Other Apache features</h4></div></div></div><p>Several of the features already provided by Apache in its role as a robust web server can be leveraged for increased functionality or security in Subversion as well. The Subversion client is able to use SSL (the Secure Sockets Layer, discussed earlier). If your Subversion client is built to support SSL, it can access your Apache server using <code class="literal">https://</code> and enjoy a high-quality encrypted network session.</p><p>Equally useful are other features of the Apache and Subversion relationship, such as the ability to specify a custom port (instead of the default HTTP port 80) or a virtual domain name by which the Subversion repository should be accessed, or the ability to access the repository through an HTTP proxy.</p><p>Finally, because <span class="command"><strong>mod_dav_svn</strong></span> is speaking a subset of the WebDAV/DeltaV protocol, it's possible to access the repository via third-party DAV clients. Most modern operating systems (Win32, OS X, and Linux) have the built-in ability to mount a DAV server as a standard network <span class="quote">“<span class="quote">shared folder.</span>”</span> This is a complicated topic, but also wondrous when implemented. For details, read <a class="xref" href="#svn.webdav" title="Appendix C. WebDAV and Autoversioning">Appendix C, <em>WebDAV and Autoversioning</em></a>.</p><p>Note that there are a number of other small tweaks one can make to <span class="command"><strong>mod_dav_svn</strong></span> that are too obscure to mention in this chapter. For a complete list of all <code class="filename">httpd.conf</code> directives that <span class="command"><strong>mod_dav_svn</strong></span> responds to, see <a class="xref" href="#svn.ref.mod_dav_svn.conf.directives" title="Directives">the section called “Directives”</a> in <a class="xref" href="#svn.ref" title="Chapter 9. Subversion Complete Reference">Chapter 9, <em>Subversion Complete Reference</em></a>.</p></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.serverconfig.pathbasedauthz"></a>Path-Based Authorization</h2></div></div></div><p>Both Apache and <span class="command"><strong>svnserve</strong></span> are capable of granting (or denying) permissions to users. Typically this is done over the entire repository: a user can read the repository (or not), and she can write to the repository (or not). It's also possible, however, to define finer-grained access rules. One set of users may have permission to write to a certain directory in the repository, but not others; another directory might not even be readable by all but a few special people. As files are paths, too, it's even possible to restrict access on a per file basis.</p><p>Both servers use a common file format to describe these path-based access rules. In the case of Apache, one needs to load the <span class="command"><strong>mod_authz_svn</strong></span> module and then add the <code class="literal">AuthzSVNAccessFile</code> directive (within the <code class="filename">httpd.conf</code> file) pointing to your own access rules file. (For a full explanation, see <a class="xref" href="#svn.serverconfig.httpd.authz.perdir" title="Per-directory access control">the section called “Per-directory access control”</a>.) If you're using <span class="command"><strong>svnserve</strong></span>, you need to make the <code class="literal">authz-db</code> variable (within <code class="filename">svnserve.conf</code>) point to your access rules file.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Do You Really Need Path-Based Access Control?</strong></p></div></div></div><p>A lot of administrators setting up Subversion for the first time tend to jump into path-based access control without giving it a lot of thought. The administrator usually knows which teams of people are working on which projects, so it's easy to jump in and grant certain teams access to certain directories and not others. It seems like a natural thing, and it appeases the administrator's desire to maintain tight control of the repository.</p><p>Note, though, that there are often invisible (and visible!) costs associated with this feature. In the visible category, the server needs to do a lot more work to ensure that the user has the right to read or write each specific path; in certain situations, there's very noticeable performance loss. In the invisible category, consider the culture you're creating. Most of the time, while certain users <span class="emphasis"><em>shouldn't</em></span> be committing changes to certain parts of the repository, that social contract doesn't need to be technologically enforced. Teams can sometimes spontaneously collaborate with each other; someone may want to help someone else out by committing to an area she doesn't normally work on. By preventing this sort of thing at the server level, you're setting up barriers to unexpected collaboration. You're also creating a bunch of rules that need to be maintained as projects develop, new users are added, and so on. It's a bunch of extra work to maintain.</p><p>Remember that this is a version control system! Even if somebody accidentally commits a change to something she shouldn't, it's easy to undo the change. And if a user commits to the wrong place with deliberate malice, it's a social problem anyway, and that the problem needs to be dealt with outside Subversion.</p><p>So, before you begin restricting users' access rights, ask yourself whether there's a real, honest need for this, or whether it's just something that <span class="quote">“<span class="quote">sounds good</span>”</span> to an administrator. Decide whether it's worth sacrificing some server speed, and remember that there's very little risk involved; it's bad to become dependent on technology as a crutch for social problems.<a href="#ftn.idm7374" class="footnote" id="idm7374"><sup class="footnote">[61]</sup></a></p><p>As an example to ponder, consider that the Subversion project itself has always had a notion of who is allowed to commit where, but it's always been enforced socially. This is a good model of community trust, especially for open source projects. Of course, sometimes there <span class="emphasis"><em>are</em></span> truly legitimate needs for path-based access control; within corporations, for example, certain types of data really can be sensitive, and access needs to be genuinely restricted to small groups of people.</p></div><p>Once your server knows where to find your access file, it's time to define the rules.</p><p>The syntax of the file is the same familiar one used by <code class="filename">svnserve.conf</code> and the runtime configuration files. Lines that start with a hash (<code class="literal">#</code>) are ignored. In its simplest form, each section names a repository and path within it, as well as the authenticated usernames are the option names within each section. The value of each option describes the user's level of access to the repository path: either <code class="literal">r</code> (read-only) or <code class="literal">rw</code> (read/write). If the user is not mentioned at all, no access is allowed.</p><p>To be more specific: the value of the section names is either of the form <code class="literal">[repos-name:path]</code> or of the form <code class="literal">[path]</code>.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Prior to version 1.7, Subversion treated repository names and paths in a case-insensitive fashion for the purposes of access control, converting them to lower case internally before comparing them against the contents of your access file. It now does these comparisons case-sensitively. If you upgraded to Subversion 1.7 from an older version, you should review your access files for case correctness.</p></td></tr></table></div><p>If you're using the <code class="literal">SVNParentPath</code> directive, it's important to specify the repository names in your sections. If you omit them, a section such as <code class="literal">[/some/dir]</code> will match the path <code class="filename">/some/dir</code> in <span class="emphasis"><em>every</em></span> repository. If you're using the <code class="literal">SVNPath</code> directive, however, it's fine to only define paths in your sections—after all, there's only one repository.</p><div class="informalexample"><pre class="programlisting"> [calc:/branches/calc/bug-142] harry = rw sally = r </pre></div><p>In this first example, the user <code class="literal">harry</code> has full read and write access on the <code class="filename">/branches/calc/bug-142</code> directory in the <code class="literal">calc</code> repository, but the user <code class="literal">sally</code> has read-only access. Any other users are blocked from accessing this directory.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p><span class="command"><strong>mod_dav_svn</strong></span> offers a directive, <code class="literal">SVNReposName</code>, which allows administrators to define a more human-friendly name, of sorts, for a repository:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /svn/calc&gt; SVNPath /var/svn/calc SVNReposName "Calculator Application" … </pre></div><p>This allows <span class="command"><strong>mod_dav_svn</strong></span> to identify the repository by something other than merely its server directory basename—<code class="filename">calc</code>, in the previous example—when providing directory listings of repository content. Be aware, however, that when consulting the access file for authorization rules, Subversion uses this repository basename for comparison, <span class="emphasis"><em>not</em></span> any configured human-friendly name.</p></td></tr></table></div><p>Of course, permissions are inherited from parent to child directory. That means we can specify a subdirectory with a different access policy for Sally:</p><div class="informalexample"><pre class="programlisting"> [calc:/branches/calc/bug-142] harry = rw sally = r # give sally write access only to the 'testing' subdir [calc:/branches/calc/bug-142/testing] sally = rw </pre></div><p>Now Sally can write to the <code class="filename">testing</code> subdirectory of the branch, but can still only read other parts. Harry, meanwhile, continues to have complete read/write access to the whole branch.</p><p>It's also possible to explicitly deny permission to someone via inheritance rules, by setting the username variable to nothing:</p><div class="informalexample"><pre class="programlisting"> [calc:/branches/calc/bug-142] harry = rw sally = r [calc:/branches/calc/bug-142/secret] harry = </pre></div><p>In this example, Harry has read/write access to the entire <code class="filename">bug-142</code> tree, but has absolutely no access at all to the <code class="filename">secret</code> subdirectory within it.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>The thing to remember is that the most specific path always matches first. The server tries to match the path itself, and then the parent of the path, then the parent of that, and so on. The net effect is that mentioning a specific path in the access file will always override any permissions inherited from parent directories.</p></td></tr></table></div><p>By default, nobody has any access to the repository at all. That means that if you're starting with an empty file, you'll probably want to give at least read permission to all users at the root of the repository. You can do this by using the asterisk variable (<code class="literal">*</code>), which means <span class="quote">“<span class="quote">all users</span>”</span>:</p><div class="informalexample"><pre class="programlisting"> [/] * = r </pre></div><p>This is a common setup; notice that no repository name is mentioned in the section name. This makes all repositories world-readable to all users. Once all users have read access to the repositories, you can give explicit <code class="literal">rw</code> permission to certain users on specific subdirectories within specific repositories.</p><p>The access file also allows you to define whole groups of users, much like the Unix <code class="filename">/etc/group</code> file:</p><div class="informalexample"><pre class="programlisting"> [groups] calc-developers = harry, sally, joe paint-developers = frank, sally, jane everyone = harry, sally, joe, frank, jane </pre></div><p>Groups can be granted access control just like users. Distinguish them with an <span class="quote">“<span class="quote">at</span>”</span> (<code class="literal">@</code>) prefix:</p><div class="informalexample"><pre class="programlisting"> [calc:/projects/calc] @calc-developers = rw [paint:/projects/paint] jane = r @paint-developers = rw </pre></div><p>Another important fact is that group permissions are not overridden by individual user permissions. Rather, the <span class="emphasis"><em>combination</em></span> of all matching permissions is granted. In the prior example, Jane is a member of the <code class="literal">paint-developers</code> group, which has read/write access. Combined with the <code class="literal">jane = r</code> rule, this still gives Jane read/write access. Permissions for group members can only be extended beyond the permissions the group already has. Restricting users who are part of a group to less than their group's permissions is impossible.</p><p>Groups can also be defined to contain other groups:</p><div class="informalexample"><pre class="programlisting"> [groups] calc-developers = harry, sally, joe paint-developers = frank, sally, jane everyone = @calc-developers, @paint-developers </pre></div><p>Subversion 1.5 brought several useful features to the access file syntax—username aliases, authentication class tokens, and a new rule exclusion mechanism—all of which further simplify the maintenance of the access file. We'll describe first the username aliases feature.</p><p>Some authentication systems expect and carry relatively short usernames of the sorts we've been describing here—<code class="literal">harry</code>, <code class="literal">sally</code>, <code class="literal">joe</code>, and so on. But other authentication systems—such as those which use LDAP stores or SSL client certificates—may carry much more complex usernames. For example, Harry's username in an LDAP-protected system might be <code class="literal">CN=Harold Hacker,OU=Engineers,DC=red-bean,DC=com</code>. With usernames like that, the access file can become quite bloated with long or obscure usernames that are easy to mistype. Fortunately, username aliases allow you to have to type the correct complex username only once, in a statement which assigns to it a more easily digestable alias.</p><div class="informalexample"><pre class="programlisting"> [aliases] harry = CN=Harold Hacker,OU=Engineers,DC=red-bean,DC=com sally = CN=Sally Swatterbug,OU=Engineers,DC=red-bean,DC=com joe = CN=Gerald I. Joseph,OU=Engineers,DC=red-bean,DC=com … </pre></div><p>Once you've defined a set of aliases, you can refer to the users elsewhere in the access file via their aliases in all the same places you could have instead used their actual usernames. Simply prepend an ampersand to the alias to distinguish it from a regular username:</p><div class="informalexample"><pre class="programlisting"> [groups] calc-developers = &amp;harry, &amp;sally, &amp;joe paint-developers = &amp;frank, &amp;sally, &amp;jane everyone = @calc-developers, @paint-developers </pre></div><p>You might also choose to use aliases if your users' usernames change frequently. Doing so allows you to need to update only the aliases table when these username changes occur, instead of doing global-search-and-replace operations on the whole access file.</p><p>Subversion also supports some <span class="quote">“<span class="quote">magic</span>”</span> tokens for helping you to make rule assignments based on the user's authentication class. One such token is the <code class="literal">$authenticated</code> token. Use this token where you would otherwise specify a username, alias, or group name in your authorization rules to declare the permissions granted to any user who has authenticated with any username at all. Similarly employed is the <code class="literal">$anonymous</code> token, except that it matches everyone who has <span class="emphasis"><em>not</em></span> authenticated with a username.</p><div class="informalexample"><pre class="programlisting"> [calendar:/projects/calendar] $anonymous = r $authenticated = rw </pre></div><p>Finally, another handy bit of access file syntax magic is the use of the tilde (<code class="literal">~</code>) character as an exclusion marker. In your authorization rules, prefixing a username, alias, group name, or authentication class token with a tilde character will cause Subversion to apply the rule to users who do <span class="emphasis"><em>not</em></span> match the rule. Though somewhat unnecessarily obfuscated, the following block is equivalent to the one in the previous example:</p><div class="informalexample"><pre class="programlisting"> [calendar:/projects/calendar] ~$authenticated = r ~$anonymous = rw </pre></div><p>A less obvious example might be as follows:</p><div class="informalexample"><pre class="programlisting"> [groups] calc-developers = &amp;harry, &amp;sally, &amp;joe calc-owners = &amp;hewlett, &amp;packard calc = @calc-developers, @calc-owners # Any calc participant has read-write access... [calc:/projects/calc] @calc = rw # ...but only allow the owners to make and modify release tags. [calc:/projects/calc/tags] ~@calc-owners = r </pre></div><p>All of the above examples use directories, because defining access rules on them is the most common case. But is similarly able to restrict access on file paths, too.</p><div class="informalexample"><pre class="programlisting"> [calendar:/projects/calendar/manager.ics] harry = rw sally = r </pre></div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Partial Readability and Checkouts</strong></p></div></div></div><p>If you're using Apache as your Subversion server and have made certain subdirectories of your repository unreadable to certain users, you need to be aware of a possible nonoptimal behavior with <span class="command"><strong>svn checkout</strong></span>.</p><p>When the client requests a checkout or update over HTTP, it makes a single server request and receives a single (often large) server response. When the server receives the request, that is the <span class="emphasis"><em>only</em></span> opportunity Apache has to demand user authentication. This has some odd side effects. For example, if a certain subdirectory of the repository is readable only by user Sally, and user Harry checks out a parent directory, his client will respond to the initial authentication challenge as Harry. As the server generates the large response, there's no way it can resend an authentication challenge when it reaches the special subdirectory; thus the subdirectory is skipped altogether, rather than asking the user to reauthenticate as Sally at the right moment. In a similar way, if the root of the repository is anonymously world-readable, the entire checkout will be done without authentication—again, skipping the unreadable directory, rather than asking for authentication partway through.<a href="#ftn.idm7484" class="footnote" id="idm7484"><sup class="footnote">[62]</sup></a></p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.serverconfig.operational-logging"></a>High-level Logging</h2></div></div></div><p>Both the Apache <span class="command"><strong>httpd</strong></span> and <span class="command"><strong>svnserve</strong></span> Subversion servers provide support for high-level logging of Subversion operations. Configuring each of the server options to provide this level of logging is done differently, of course, but the output from each is designed to conform to a uniform syntax.</p><p>To enable high-level logging in <span class="command"><strong>svnserve</strong></span>, you need only use the <code class="option">--log-file</code> command-line option when starting the server, passing as the value to the option the file to which <span class="command"><strong>svnserve</strong></span> should write its log output.</p><div class="informalexample"><pre class="screen"> $ svnserve -d -r /path/to/repositories --log-file /var/log/svn.log </pre></div><p>Enabling the same in Apache is a bit more involved, but is essentially an extension of Apache's stock log output configuration mechanisms—see <a class="xref" href="#svn.serverconfig.httpd.extra.logging" title="Apache logging">the section called “Apache logging”</a> for details.</p><p>The following is a list of Subversion action log messages produced by its high-level logging mechanism, followed by one or more examples of the log message as it appears in the log output.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">Checkout or export</span></dt><dd><pre class="programlisting"> checkout-or-export /path r62 depth=infinity </pre></dd><dt><span class="term">Commit</span></dt><dd><pre class="programlisting"> commit harry r100 </pre></dd><dt><span class="term">Diffs</span></dt><dd><pre class="programlisting"> diff /path r15:20 depth=infinity ignore-ancestry diff /path1@15 /path2@20 depth=infinity ignore-ancestry </pre></dd><dt><span class="term">Fetch a directory</span></dt><dd><pre class="programlisting"> get-dir /trunk r17 text </pre></dd><dt><span class="term">Fetch a file</span></dt><dd><pre class="programlisting"> get-file /path r20 props </pre></dd><dt><span class="term">Fetch a file revision</span></dt><dd><pre class="programlisting"> get-file-revs /path r12:15 include-merged-revisions </pre></dd><dt><span class="term">Fetch merge information</span></dt><dd><pre class="programlisting"> get-mergeinfo (/path1 /path2) </pre></dd><dt><span class="term">Lock</span></dt><dd><pre class="programlisting"> lock /path steal </pre></dd><dt><span class="term">Log</span></dt><dd><pre class="programlisting"> log (/path1,/path2,/path3) r20:90 discover-changed-paths revprops=() </pre></dd><dt><span class="term">Replay revisions (svnsync)</span></dt><dd><pre class="programlisting"> replay /path r19 </pre></dd><dt><span class="term">Revision property change</span></dt><dd><pre class="programlisting"> change-rev-prop r50 propertyname </pre></dd><dt><span class="term">Revision property list</span></dt><dd><pre class="programlisting"> rev-proplist r34 </pre></dd><dt><span class="term">Status</span></dt><dd><pre class="programlisting"> status /path r62 depth=infinity </pre></dd><dt><span class="term">Switch</span></dt><dd><pre class="programlisting"> switch /pathA /pathB@50 depth=infinity </pre></dd><dt><span class="term">Unlock</span></dt><dd><pre class="programlisting"> unlock /path break </pre></dd><dt><span class="term">Update</span></dt><dd><pre class="programlisting"> update /path r17 send-copyfrom-args </pre></dd></dl></div><p>As a convenience to administrators who wish to post-process their Subversion high-level logging output (perhaps for reporting or analysis purposes), Subversion source code distributions provide a Python module (located at <code class="filename">tools/server-side/svn_server_log_parse.py</code>) which can be used to parse Subversion's log output.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.serverconfig.optimization"></a>Server Optimization</h2></div></div></div><p>Part of the due diligence when offering a service such as a Subversion server involves capacity planning and performance tuning. Subversion doesn't tend to be particularly greedy in terms of server resources such as CPU cycles and memory, but any service can benefit from optimizations, especially when usage of the service skyrockets<a href="#ftn.idm7572" class="footnote" id="idm7572"><sup class="footnote">[63]</sup></a>. In this section, we'll discuss some ways you can tweak your Subversion server configuration to offer even better performance and scalability.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.optimization.caching"></a>Data Caching</h3></div></div></div><p>Generally speaking, the most expensive part of a Subversion server's job is fetching data from the repository. Subversion 1.6 attempted to offset this cost by introducing some in-memory caching of certain classes of data read from the repository. But Subversion 1.7 takes this a step further, not only caching the results of some of the more costly operations, but also by providing in each of the available servers the means by which fine-tune the size and some behaviors of the cache.</p><p>For <span class="command"><strong>svnserve</strong></span>, you can specify the size of the cache using the <code class="option">--memory-cache-size</code> (<code class="option">-M</code>) command-line option. You can also dictate whether <span class="command"><strong>svnserve</strong></span> should attempt to cache content fulltexts and deltas via the boolean <code class="option">--cache-fulltexts</code> and <code class="option">--cache-txdeltas</code> options, respectively.</p><div class="informalexample"><pre class="screen"> $ svnserve -d -r /path/to/repositories \ --memory-cache-size 1024 \ --cache-txdeltas yes \ --cache-fulltexts yes … $ </pre></div><p><span class="command"><strong>mod_dav_svn</strong></span> provides the same degree of cache configurability via <code class="filename">httpd.conf</code> directives. The <code class="literal">SVNInMemoryCacheSize</code>, <code class="literal">SVNCacheFullTexts</code>, and <code class="literal">SVNCacheTextDeltas</code> directives may be used at the server configuration level to control Subversion's data cache characteristics:</p><div class="informalexample"><pre class="programlisting"> &lt;IfModule dav_svn_module&gt; # Enable a 1 Gb Subversion data cache for both fulltext and deltas. SVNInMemoryCacheSize 1048576 SVNCacheTextDeltas On SVNCacheFullTexts On &lt;/IfModule&gt; </pre></div><p>So what settings should you use? Certainly you need to consider what resources are available on your server. To get any benefit out of the cache at all, you'll probably want to let the cache be at least large enough to hold all the files which are most commonly accessed in your repository (for example, your project's <code class="filename">trunk</code> directory tree).</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Setting the memory cache size to <code class="literal">0</code> will disable this enhanced caching mechanism and cause Subversion to fall back to using the older cache mechanisms introduced in Subversion 1.6.</p></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Currently, only repositories which make use of the FSFS backend data store make use of this data caching functionality.</p></td></tr></table></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.serverconfig.optimization.compression"></a>Network Compression of Data</h3></div></div></div><p>Compressing the data transmitted across the wire can greatly reduce the size of those network transmissions, but comes at the cost of server (and client) CPU cycles. Depending on your server's CPU capacity, the typical access patterns of the clients who use your servers, and the bandwidth of the networks between them, you might wish to fine tune just how hard your server will work to compress the data it sends across the wire. To assist with this fine tuning process, Subversion 1.7 offers the <code class="option">--compression</code> (<code class="option">-c</code>) option to <span class="command"><strong>svnserve</strong></span> and the <code class="literal">SVNCompressionLevel</code> directive for <span class="command"><strong>mod_dav_svn</strong></span>. Both accept a value which is an integer between 0 and 9 (inclusive), where 9 offers the best compression of wire data, and 0 disables compression altogether.</p><p>For example, on a local area network (LAN) with 1-Gigabit connections, it might not make sense to have the server compress its network transmissions (which also forces the clients to decompress them), as the network itself is so fast that users won't really benefit from the smaller overall network payload. On the other hand, servers which are accessed primarily by clients with low-bandwidth connections would be doing those clients a favor by minimizing the overall size of its network communications.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.serverconfig.multimethod"></a>Supporting Multiple Repository Access Methods</h2></div></div></div><p>You've seen how a repository can be accessed in many different ways. But is it possible—or safe—for your repository to be accessed by multiple methods simultaneously? The answer is yes, provided you use a bit of foresight.</p><p>At any given time, these processes may require read and write access to your repository:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Regular system users using a Subversion client (as themselves) to access the repository directly via <code class="literal">file://</code> URLs</p></li><li class="listitem"><p>Regular system users connecting to SSH-spawned private <span class="command"><strong>svnserve</strong></span> processes (running as themselves), which access the repository</p></li><li class="listitem"><p>An <span class="command"><strong>svnserve</strong></span> process—either a daemon or one launched by <span class="command"><strong>inetd</strong></span>—running as a particular fixed user</p></li><li class="listitem"><p>An Apache <span class="command"><strong>httpd</strong></span> process, running as a particular fixed user</p></li></ul></div><p>The most common problem administrators run into is repository ownership and permissions. Does every process (or user) in the preceding list have the rights to read and write the repository's underlying data files? Assuming you have a Unix-like operating system, a straightforward approach might be to place every potential repository user into a new <code class="literal">svn</code> group, and make the repository wholly owned by that group. But even that's not enough, because a process may write to the database files using an unfriendly umask—one that prevents access by other users.</p><p>So the next step beyond setting up a common group for repository users is to force every repository-accessing process to use a sane umask. For users accessing the repository directly, you can make the <span class="command"><strong>svn</strong></span> program into a wrapper script that first runs <strong class="userinput"><code>umask 002</code></strong> and then runs the real <span class="command"><strong>svn</strong></span> client program. You can write a similar wrapper script for the <span class="command"><strong>svnserve</strong></span> program, and add a <strong class="userinput"><code>umask 002</code></strong> command to Apache's own startup script, <code class="filename">apachectl</code>. For example:</p><div class="informalexample"><pre class="screen"> $ cat /usr/bin/svn #!/bin/sh umask 002 /usr/bin/svn-real "$@" </pre></div><p>Another common problem is often encountered on Unix-like systems. If your repository is backed by Berkeley DB, for example, it occasionally creates new log files to journal its actions. Even if the Berkeley DB repository is wholly owned by the <span class="command"><strong>svn</strong></span> group, these newly created log files won't necessarily be owned by that same group, which then creates more permissions problems for your users. A good workaround is to set the group SUID bit on the repository's <code class="filename">db</code> directory. This causes all newly created log files to have the same group owner as the parent directory.</p><p>Once you've jumped through these hoops, your repository should be accessible by all the necessary processes. It may seem a bit messy and complicated, but the problems of having multiple users sharing write access to common files are classic ones that are not often elegantly solved.</p><p>Fortunately, most repository administrators will never <span class="emphasis"><em>need</em></span> to have such a complex configuration. Users who wish to access repositories that live on the same machine are not limited to using <code class="literal">file://</code> access URLs—they can typically contact the Apache HTTP server or <span class="command"><strong>svnserve</strong></span> using <code class="literal">localhost</code> for the server name in their <code class="literal">http://</code> or <code class="literal">svn://</code> URL. And maintaining multiple server processes for your Subversion repositories is likely to be more of a headache than necessary. We recommend that you choose a single server that best meets your needs and stick with it!</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>The svn+ssh:// Server Checklist</strong></p></div></div></div><p>It can be quite tricky to get a bunch of users with existing SSH accounts to share a repository without permissions problems. If you're confused about all the things that you (as an administrator) need to do on a Unix-like system, here's a quick checklist that resummarizes some of the topics discussed in this section:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>All of your SSH users need to be able to read and write to the repository, so put all the SSH users into a single group.</p></li><li class="listitem"><p>Make the repository wholly owned by that group.</p></li><li class="listitem"><p>Set the group permissions to read/write.</p></li><li class="listitem"><p>Your users need to use a sane umask when accessing the repository, so make sure <span class="command"><strong>svnserve</strong></span> (<code class="filename">/usr/bin/svnserve</code>, or wherever it lives in <code class="literal">$PATH</code>) is actually a wrapper script that runs <strong class="userinput"><code>umask 002</code></strong> and executes the real <span class="command"><strong>svnserve</strong></span> binary.</p></li><li class="listitem"><p>Take similar measures when using <span class="command"><strong>svnlook</strong></span> and <span class="command"><strong>svnadmin</strong></span>. Either run them with a sane umask or wrap them as just described.</p></li></ul></div></div></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm6487" class="footnote"><p><a href="#idm6487" class="para"><sup class="para">[52] </sup></a>See RFC 2195.</p></div><div id="ftn.idm6657" class="footnote"><p><a href="#idm6657" class="para"><sup class="para">[53] </sup></a>Note that using any sort of <span class="command"><strong>svnserve</strong></span>-enforced access control at all is a bit pointless; the user already has direct access to the repository database.</p></div><div id="ftn.idm6663" class="footnote"><p><a href="#idm6663" class="para"><sup class="para">[54] </sup></a>We don't actually recommend this, since RSH is notably less secure than SSH.</p></div><div id="ftn.idm6751" class="footnote"><p><a href="#idm6751" class="para"><sup class="para">[55] </sup></a>See <a class="ulink" href="http://www.webdav.org/" target="_top">http://www.webdav.org/</a>.</p></div><div id="ftn.idm6754" class="footnote"><p><a href="#idm6754" class="para"><sup class="para">[56] </sup></a>They really hate doing that.</p></div><div id="ftn.idm6882" class="footnote"><p><a href="#idm6882" class="para"><sup class="para">[57] </sup></a>See <a class="ulink" href="http://httpd.apache.org/docs/current/programs/htpasswd.html" target="_top">http://httpd.apache.org/docs/current/programs/htpasswd.html</a>.</p></div><div id="ftn.idm6949" class="footnote"><p><a href="#idm6949" class="para"><sup class="para">[58] </sup></a>See <a class="ulink" href="http://httpd.apache.org/docs/current/programs/htdigest.html" target="_top">http://httpd.apache.org/docs/current/programs/htdigest.html</a>.</p></div><div id="ftn.idm7079" class="footnote"><p><a href="#idm7079" class="para"><sup class="para">[59] </sup></a>While self-signed certificates are still vulnerable to a <span class="quote">“<span class="quote">man-in-the-middle</span>”</span> attack, such an attack is much more difficult for a casual observer to pull off, compared to sniffing unprotected passwords.</p></div><div id="ftn.idm7317" class="footnote"><p><a href="#idm7317" class="para"><sup class="para">[60] </sup></a><a class="ulink" href="http://subversion.tigris.org/issues/show_bug.cgi?id=3457" target="_top">http://subversion.tigris.org/issues/show_bug.cgi?id=3457</a> tracks these problems.</p></div><div id="ftn.idm7374" class="footnote"><p><a href="#idm7374" class="para"><sup class="para">[61] </sup></a>A common theme in this book!</p></div><div id="ftn.idm7484" class="footnote"><p><a href="#idm7484" class="para"><sup class="para">[62] </sup></a>For more on this, see the blog post <span class="emphasis"><em>Authz and Anon Authn Agony</em></span> at <a class="ulink" href="https://subversion.apache.org/blog/2007-03-27-authz-and-anon-authn-agony.html" target="_top">https://subversion.apache.org/blog/2007-03-27-authz-and-anon-authn-agony.html</a>.</p></div><div id="ftn.idm7572" class="footnote"><p><a href="#idm7572" class="para"><sup class="para">[63] </sup></a>In Subversion's case, the skyrocketing affect is, of course, due to its cool name. Well, that and its popularity, reliability, ease of use….</p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="svn.customization"></a>Chapter 7. Customizing Your Subversion Experience</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.advanced.confarea">Runtime Configuration Area</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.confarea.layout">Configuration Area Layout</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.confarea.windows-registry">Configuration and the Windows Registry</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.confarea.opts">Configuration Options</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.advanced.confarea.opts.servers">Servers</a></span></dt><dt><span class="sect3"><a href="#svn.advanced.confarea.opts.config">Config</a></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.advanced.l10n">Localization</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.l10n.understanding">Understanding Locales</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.l10n.svnuse">Subversion's Use of Locales</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.advanced.externaleditors">Using External Editors</a></span></dt><dt><span class="sect1"><a href="#svn.advanced.externaldifftools">Using External Differencing and Merge Tools</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.advanced.externaldifftools.diff">External diff</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.externaldifftools.diff3">External diff3</a></span></dt><dt><span class="sect2"><a href="#svn.advanced.externaldifftools.merge">External merge</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.customization.summary">Summary</a></span></dt></dl></div><p>Version control can be a complex subject, as much art as science, that offers myriad ways of getting stuff done. Throughout this book, you've read of the various Subversion command-line client subcommands and the options that modify their behavior. In this chapter, we'll look into still more ways to customize the way Subversion works for you—setting up the Subversion runtime configuration, using external helper applications, Subversion's interaction with the operating system's configured locale, and so on.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.confarea"></a>Runtime Configuration Area</h2></div></div></div><p>Subversion provides many optional behaviors that the user can control. Many of these options are of the kind that a user would wish to apply to all Subversion operations. So, rather than forcing users to remember command-line arguments for specifying these options and to use them for every operation they perform, Subversion uses configuration files, segregated into a Subversion configuration area.</p><p>The Subversion <em class="firstterm">configuration area</em> is a two-tiered hierarchy of option names and their values. Usually, this boils down to a special directory that contains <em class="firstterm">configuration files</em> (the first tier), which are just text files in standard INI format where <span class="quote">“<span class="quote">sections</span>”</span> provide the second tier. You can easily edit these files using your favorite text editor (such as Emacs or vi), and they contain directives read by the client to determine which of several optional behaviors the user prefers.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.confarea.layout"></a>Configuration Area Layout</h3></div></div></div><p>The first time the <span class="command"><strong>svn</strong></span> command-line client is executed, it creates a per-user configuration area. On Unix-like systems, this area appears as a directory named <code class="filename">.subversion</code> in the user's home directory. On Win32 systems, Subversion creates a folder named <code class="filename">Subversion</code>, typically inside the <code class="filename">Application Data</code> area of the user's profile directory (which, by the way, is usually a hidden directory). However, on this platform, the exact location differs from system to system and is dictated by the Windows Registry.<a href="#ftn.idm7688" class="footnote" id="idm7688"><sup class="footnote">[64]</sup></a> We will refer to the per-user configuration area using its Unix name, <code class="filename">.subversion</code>.</p><p>In addition to the per-user configuration area, Subversion also recognizes the existence of a system-wide configuration area. This gives system administrators the ability to establish defaults for all users on a given machine. Note that the system-wide configuration area alone does not dictate mandatory policy—the settings in the per-user configuration area override those in the system-wide one, and command-line arguments supplied to the <span class="command"><strong>svn</strong></span> program have the final word on behavior. On Unix-like platforms, the system-wide configuration area is expected to be the <code class="filename">/etc/subversion</code> directory; on Windows machines, it looks for a <code class="filename">Subversion</code> directory inside the common <code class="filename">Application Data</code> location (again, as specified by the Windows Registry). Unlike the per-user case, the <span class="command"><strong>svn</strong></span> program does not attempt to create the system-wide configuration area.</p><p>The per-user configuration area currently contains three files—two configuration files (<code class="filename">config</code> and <code class="filename">servers</code>), and a <code class="filename">README.txt</code> file, which describes the INI format. At the time of their creation, the files contain default values for each of the supported Subversion options, mostly commented out and grouped with textual descriptions about how the values for the key affect Subversion's behavior. To change a certain behavior, you need only to load the appropriate configuration file into a text editor, and to modify the desired option's value. If at any time you wish to have the default configuration settings restored, you can simply remove (or rename) your configuration directory and then run some innocuous <span class="command"><strong>svn</strong></span> command, such as <strong class="userinput"><code>svn --version</code></strong>. A new configuration directory with the default contents will be created.</p><p>Subversion also allows you to override individual configuration option values at the command line via the <code class="option">--config-option</code> option, which is especially useful if you need to make a (very) temporary change in behavior. For more about this option's proper usage, see <a class="xref" href="#svn.ref.svn.sw" title="svn Options">the section called “svn Options”</a>.</p><p>The per-user configuration area also contains a cache of authentication data. The <code class="filename">auth</code> directory holds a set of subdirectories that contain pieces of cached information used by Subversion's various supported authentication methods. This directory is created in such a way that only the user herself has permission to read its contents.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.confarea.windows-registry"></a>Configuration and the Windows Registry</h3></div></div></div><p>In addition to the usual INI-based configuration area, Subversion clients running on Windows platforms may also use the Windows Registry to hold the configuration data. The option names and their values are the same as in the INI files. The <span class="quote">“<span class="quote">file/section</span>”</span> hierarchy is preserved as well, though addressed in a slightly different fashion—in this schema, files and sections are just levels in the Registry key tree.</p><p>Subversion looks for system-wide configuration values under the <code class="literal">HKEY_LOCAL_MACHINE\Software\Tigris.org\Subversion</code> key. For example, the <code class="literal">global-ignores</code> option, which is in the <code class="literal">miscellany</code> section of the <code class="filename">config</code> file, would be found at <code class="literal">HKEY_LOCAL_MACHINE\Software\Tigris.org\Subversion\Config\Miscellany\global-ignores</code>. Per-user configuration values should be stored under <code class="literal">HKEY_CURRENT_USER\Software\Tigris.org\Subversion</code>.</p><p>Registry-based configuration options are parsed <span class="emphasis"><em>before</em></span> their file-based counterparts, so they are overridden by values found in the configuration files. In other words, Subversion looks for configuration information in the following locations on a Windows system; lower-numbered locations take precedence over higher-numbered locations:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Command-line options</p></li><li class="listitem"><p>The per-user INI files</p></li><li class="listitem"><p>The per-user Registry values</p></li><li class="listitem"><p>The system-wide INI files</p></li><li class="listitem"><p>The system-wide Registry values</p></li></ol></div><p>Also, the Windows Registry doesn't really support the notion of something being <span class="quote">“<span class="quote">commented out.</span>”</span> However, Subversion will ignore any option key whose name begins with a hash (<code class="literal">#</code>) character. This allows you to effectively comment out a Subversion option without deleting the entire key from the Registry, obviously simplifying the process of restoring that option.</p><p>The <span class="command"><strong>svn</strong></span> command-line client never attempts to write to the Windows Registry and will not attempt to create a default configuration area there. You can create the keys you need using the <span class="command"><strong>REGEDIT</strong></span> program. Alternatively, you can create a <code class="filename">.reg</code> file (such as the one in <a class="xref" href="#svn.advanced.confarea.windows-registry.ex-1" title="Example 7.1. Sample registration entries (.reg) file">Example 7.1, “Sample registration entries (.reg) file”</a>), and then double-click on that file's icon in the Explorer shell, which will cause the data to be merged into your Registry.</p><div class="example"><a id="svn.advanced.confarea.windows-registry.ex-1"></a><p class="title"><strong>Example 7.1. Sample registration entries (.reg) file</strong></p><div class="example-contents"><pre class="programlisting"> REGEDIT4 [HKEY_LOCAL_MACHINE\Software\Tigris.org\Subversion\Servers\groups] [HKEY_LOCAL_MACHINE\Software\Tigris.org\Subversion\Servers\global] "#http-auth-types"="basic;digest;negotiate" "#http-compression"="yes" "#http-library"="" "#http-proxy-exceptions"="" "#http-proxy-host"="" "#http-proxy-password"="" "#http-proxy-port"="" "#http-proxy-username"="" "#http-timeout"="0" "#neon-debug-mask"="" "#ssl-authority-files"="" "#ssl-client-cert-file"="" "#ssl-client-cert-password"="" "#ssl-pkcs11-provider"="" "#ssl-trust-default-ca"="" "#store-auth-creds"="yes" "#store-passwords"="yes" "#store-plaintext-passwords"="ask" "#store-ssl-client-cert-pp"="yes" "#store-ssl-client-cert-pp-plaintext"="ask" "#username"="" [HKEY_CURRENT_USER\Software\Tigris.org\Subversion\Config\auth] "#password-stores"="windows-cryptoapi" [HKEY_CURRENT_USER\Software\Tigris.org\Subversion\Config\helpers] "#diff-cmd"="" "#diff-extensions"="-u" "#diff3-cmd"="" "#diff3-has-program-arg"="" "#editor-cmd"="notepad" "#merge-tool-cmd"="" [HKEY_CURRENT_USER\Software\Tigris.org\Subversion\Config\tunnels] [HKEY_CURRENT_USER\Software\Tigris.org\Subversion\Config\miscellany] "#enable-auto-props"="no" "#global-ignores"="*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store" "#interactive-conflicts"="yes" "#log-encoding"="" "#mime-types-file"="" "#no-unlock"="no" "#preserved-conflict-file-exts"="doc ppt xls od?" "#use-commit-times"="no" [HKEY_CURRENT_USER\Software\Tigris.org\Subversion\Config\auto-props] </pre></div></div><br class="example-break"></br><p><a class="xref" href="#svn.advanced.confarea.windows-registry.ex-1" title="Example 7.1. Sample registration entries (.reg) file">Example 7.1, “Sample registration entries (.reg) file”</a> shows the contents of a <code class="filename">.reg</code> file, which contains some of the most commonly used configuration options and their default values. Note the presence of both system-wide (for network proxy-related options) and per-user settings (editor programs and password storage, among others). Also note that all the options are effectively commented out. You need only to remove the hash (<code class="literal">#</code>) character from the beginning of the option names and set the values as you desire.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.confarea.opts"></a>Configuration Options</h3></div></div></div><p>In this section, we will discuss the specific runtime configuration options that Subversion currently supports.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.advanced.confarea.opts.servers"></a>Servers</h4></div></div></div><p>The <code class="filename">servers</code> file contains Subversion configuration options related to the network layers. There are two special sections in this file—<code class="literal">[groups]</code> and <code class="literal">[global]</code>. The <code class="literal">[groups]</code> section is essentially a cross-reference table. The keys in this section are the names of other sections in the file; their values are <em class="firstterm">globs</em>—textual tokens that possibly contain wildcard characters—that are compared against the hostnames of the machine to which Subversion requests are sent.</p><div class="informalexample"><pre class="programlisting"> [groups] beanie-babies = *.red-bean.com collabnet = svn.collab.net [beanie-babies] … [collabnet] … </pre></div><p>When Subversion is used over a network, it attempts to match the name of the server it is trying to reach with a group name under the <code class="literal">[groups]</code> section. If a match is made, Subversion then looks for a section in the <code class="filename">servers</code> file whose name is the matched group's name. From that section, it reads the actual network configuration settings.</p><p>The <code class="literal">[global]</code> section contains the settings that are meant for all of the servers not matched by one of the globs under the <code class="literal">[groups]</code> section. The options available in this section are exactly the same as those that are valid for the other server sections in the file (except, of course, the special <code class="literal">[groups]</code> section), and are as follows:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">http-auth-types</code></span></dt><dd><p>This is a semicolon-delimited list of HTTP authentication types which the client will deem acceptable. Valid types are <code class="literal">basic</code>, <code class="literal">digest</code>, and <code class="literal">negotiate</code>, with the default behavior being acceptance of any these authentication types. A client which insists on not transmitting authentication credentials in cleartext might, for example, be configured such that the value of this option is <code class="literal">digest;negotiate</code>—omitting <code class="literal">basic</code> from the list. (Note that this setting is only honored by Subversion's Neon-based HTTP provider module.)</p></dd><dt><span class="term"><code class="literal">http-compression</code></span></dt><dd><p>This specifies whether Subversion should attempt to compress network requests made to DAV-ready servers. The default value is <code class="literal">yes</code> (though compression will occur only if that capability is compiled into the network layer). Set this to <code class="literal">no</code> to disable compression, such as when debugging network transmissions.</p></dd><dt><span class="term"><code class="literal">http-library</code></span></dt><dd><p>Subversion provides a pair of repository access modules that understand its WebDAV network protocol. The original one, which shipped with Subversion 1.0, is <code class="literal">libsvn_ra_neon</code> (though back then it was called <code class="literal">libsvn_ra_dav</code>). Newer Subversion versions also provide <code class="literal">libsvn_ra_serf</code>, which uses a different underlying implementation and aims to support some of the newer HTTP concepts.</p><p>At this point, <code class="literal">libsvn_ra_serf</code> is still considered experimental, though it appears to work in the common cases quite well. To encourage experimentation, Subversion provides the <code class="literal">http-library</code> runtime configuration option to allow users to specify (generally, or in a per-server-group fashion) which WebDAV access module they'd prefer to use—<code class="literal">neon</code> or <code class="literal">serf</code>.</p></dd><dt><span class="term"><code class="literal">http-proxy-exceptions</code></span></dt><dd><p>This specifies a comma-separated list of patterns for repository hostnames that should be accessed directly, without using the proxy machine. The pattern syntax is the same as is used in the Unix shell for filenames. A repository hostname matching any of these patterns will not be proxied.</p></dd><dt><span class="term"><code class="literal">http-proxy-host</code></span></dt><dd><p>This specifies the hostname of the proxy computer through which your HTTP-based Subversion requests must pass. It defaults to an empty value, which means that Subversion will not attempt to route HTTP requests through a proxy computer, and will instead attempt to contact the destination machine directly.</p></dd><dt><span class="term"><code class="literal">http-proxy-password</code></span></dt><dd><p>This specifies the password to supply to the proxy machine. It defaults to an empty value.</p></dd><dt><span class="term"><code class="literal">http-proxy-port</code></span></dt><dd><p>This specifies the port number on the proxy host to use. It defaults to an empty value.</p></dd><dt><span class="term"><code class="literal">http-proxy-username</code></span></dt><dd><p>This specifies the username to supply to the proxy machine. It defaults to an empty value.</p></dd><dt><span class="term"><code class="literal">http-timeout</code></span></dt><dd><p>This specifies the amount of time, in seconds, to wait for a server response. If you experience problems with a slow network connection causing Subversion operations to time out, you should increase the value of this option. The default value is <code class="literal">0</code>, which instructs the underlying HTTP library, Neon, to use its default timeout setting.</p></dd><dt><span class="term"><code class="literal">neon-debug-mask</code></span></dt><dd><p>This is an integer mask that the underlying HTTP library, Neon, uses for choosing what type of debugging output to yield. The default value is <code class="literal">0</code>, which will silence all debugging output. For more information about how Subversion makes use of Neon, see <a class="xref" href="#svn.developer" title="Chapter 8. Embedding Subversion">Chapter 8, <em>Embedding Subversion</em></a>.</p></dd><dt><span class="term"><code class="literal">ssl-authority-files</code></span></dt><dd><p>This is a semicolon-delimited list of paths to files containing certificates of the certificate authorities (or CAs) that are accepted by the Subversion client when accessing the repository over HTTPS.</p></dd><dt><span class="term"><code class="literal">ssl-client-cert-file</code></span></dt><dd><p>If a host (or set of hosts) requires an SSL client certificate, you'll normally be prompted for a path to your certificate. By setting this variable to that same path, Subversion will be able to find your client certificate automatically without prompting you. There's no standard place to store your certificate on disk; Subversion will grab it from any path you specify.</p></dd><dt><span class="term"><code class="literal">ssl-client-cert-password</code></span></dt><dd><p>If your SSL client certificate file is encrypted by a passphrase, Subversion will prompt you for the passphrase whenever the certificate is used. If you find this annoying (and don't mind storing the password in the <code class="filename">servers</code> file), you can set this variable to the certificate's passphrase. You won't be prompted anymore.</p></dd><dt><span class="term"><code class="literal">ssl-pkcs11-provider</code></span></dt><dd><p>The value of this option is the name of the PKCS#11 provider from which an SSL client certificate will be drawn (if the server asks for one). This setting is only honored by Subversion's Neon-based HTTP provider module.</p></dd><dt><span class="term"><code class="literal">ssl-trust-default-ca</code></span></dt><dd><p>Set this variable to <code class="literal">yes</code> if you want Subversion to automatically trust the set of default CAs that ship with OpenSSL.</p></dd><dt><span class="term"><code class="literal">store-auth-creds</code></span></dt><dd><p>This setting is the same as <code class="literal">store-passwords</code>, except that it enables or disables on-disk caching of <span class="emphasis"><em>all</em></span> authentication information: usernames, passwords, server certificates, and any other types of cacheable credentials.</p></dd><dt><span class="term"><code class="literal">store-passwords</code></span></dt><dd><p>This instructs Subversion to cache, or not to cache, passwords that are supplied by the user in response to server authentication challenges. The default value is <code class="literal">yes</code>. Set this to <code class="literal">no</code> to disable this on-disk password caching. You can override this option for a single instance of the <span class="command"><strong>svn</strong></span> command using the <code class="option">--no-auth-cache</code> command-line parameter (for those subcommands that support it). For more information regarding that, see <a class="xref" href="#svn.serverconfig.netmodel.credcache" title="Caching credentials">the section called “Caching credentials”</a>. Note that regardless of how this option is configured, Subversion will not store passwords in plaintext unless the <code class="literal">store-plaintext-passwords</code> option is also set to <code class="literal">yes</code>.</p></dd><dt><span class="term"><code class="literal">store-plaintext-passwords</code></span></dt><dd><p>This variable is only important on UNIX-like systems. It controls what the Subversion client does in case the password for the current authentication realm can only be cached on disk in unencrypted form, in the <code class="filename">~/.subversion/auth/</code> caching area. You can set it to <code class="literal">yes</code> or <code class="literal">no</code> to enable or disable caching of passwords in unencrypted form, respectively. The default setting is <code class="literal">ask</code>, which causes the Subversion client to ask you each time a <span class="emphasis"><em>new</em></span> password is about to be added to the <code class="filename">~/.subversion/auth/</code> caching area.</p></dd><dt><span class="term"><code class="literal">store-ssl-client-cert-pp</code></span></dt><dd><p>This option controls whether Subversion will cache SSL client certificate passphrases provided by the user. Its value defaults to <code class="literal">yes</code>. Set this to <code class="literal">no</code> to disable this passphrase caching.</p></dd><dt><span class="term"><code class="literal">store-ssl-client-cert-pp-plaintext</code></span></dt><dd><p>This option controls whether Subversion, when attempting to cache an SSL client certificate passphrase, will be allowed to do so using its on-disk plaintext storage mechanism. The default value of this option is <code class="literal">ask</code>, which causes the Subversion client to ask you each time a <span class="emphasis"><em>new</em></span> client certificate passphrase is about to be added to the <code class="filename">~/.subversion/auth/</code> caching area. Set this option's value to <code class="literal">yes</code> or <code class="literal">no</code> to indicate your preference and avoid related prompts.</p></dd></dl></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.advanced.confarea.opts.config"></a>Config</h4></div></div></div><p>The <code class="filename">config</code> file contains the rest of the currently available Subversion runtime options—those not related to networking. There are only a few options in use as of this writing, but they are again grouped into sections in expectation of future additions.</p><p>The <code class="literal">[auth]</code> section contains settings related to Subversion's authentication and authorization against the repository. It contains the following:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">password-stores</code></span></dt><dd><p>This comma-delimited list specifies which (if any) system-provided password stores Subversion should attempt to use when saving and retrieving cached authentication credentials, and in what order Subversion should prefer them. The default value is <code class="literal">gnome-keyring, kwallet, keychain, windows-crypto-api</code>, representing the GNOME Keyring, KDE Wallet, Mac OS X Keychain, and Microsoft Windows cryptography API, respectively. Listed stores which are not available on the system are ignored.</p></dd><dt><span class="term"><code class="literal">store-passwords</code></span></dt><dd><p>This option has been deprecated from the <code class="filename">config</code> file. It now lives as a per-server configuration item in the <code class="filename">servers</code> configuration area. See <a class="xref" href="#svn.advanced.confarea.opts.servers" title="Servers">the section called “Servers”</a> for details.</p></dd><dt><span class="term"><code class="literal">store-auth-creds</code></span></dt><dd><p>This option has been deprecated from the <code class="filename">config</code> file. It now lives as a per-server configuration item in the <code class="filename">servers</code> configuration area. See <a class="xref" href="#svn.advanced.confarea.opts.servers" title="Servers">the section called “Servers”</a> for details.</p></dd></dl></div><p>The <code class="literal">[helpers]</code> section controls which external applications Subversion uses to accomplish its tasks. Valid options in this section are:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">diff-cmd</code></span></dt><dd><p>This specifies the absolute path of a differencing program, used when Subversion generates <span class="quote">“<span class="quote">diff</span>”</span> output (such as when using the <span class="command"><strong>svn diff</strong></span> command). By default, Subversion uses an internal differencing library—setting this option will cause it to perform this task using an external program. See <a class="xref" href="#svn.advanced.externaldifftools" title="Using External Differencing and Merge Tools">the section called “Using External Differencing and Merge Tools”</a> for more details on using such programs.</p></dd><dt><span class="term"><code class="literal">diff-extensions</code></span></dt><dd><p>Like the <code class="option">--extensions</code> (<code class="option">-x</code>) command-line option, this specifies additional options passed to the file content differencing engine. The set of meaningful extension options differs depending on whether the client is using Subversion's internal differencing engine or an external mechanism. See the output of <strong class="userinput"><code>svn help diff</code></strong> for details. The default value for this option is <code class="literal">-u</code>.</p></dd><dt><span class="term"><code class="literal">diff3-cmd</code></span></dt><dd><p>This specifies the absolute path of a three-way differencing program. Subversion uses this program to merge changes made by the user with those received from the repository. By default, Subversion uses an internal differencing library—setting this option will cause it to perform this task using an external program. See <a class="xref" href="#svn.advanced.externaldifftools" title="Using External Differencing and Merge Tools">the section called “Using External Differencing and Merge Tools”</a> for more details on using such programs.</p></dd><dt><span class="term"><code class="literal">diff3-has-program-arg</code></span></dt><dd><p>This flag should be set to <code class="literal">true</code> if the program specified by the <code class="literal">diff3-cmd</code> option accepts a <code class="option">--diff-program</code> command-line parameter.</p></dd><dt><span class="term"><code class="literal">editor-cmd</code></span></dt><dd><p>This specifies the program Subversion will use to query the user for certain types of textual metadata or when interactively resolving conflicts. See <a class="xref" href="#svn.advanced.externaleditors" title="Using External Editors">the section called “Using External Editors”</a> for more details on using external text editors with Subversion.</p></dd><dt><span class="term"><code class="literal">merge-tool-cmd</code></span></dt><dd><p>This specifies the program that Subversion will use to perform three-way merge operations on your versioned files. See <a class="xref" href="#svn.advanced.externaldifftools" title="Using External Differencing and Merge Tools">the section called “Using External Differencing and Merge Tools”</a> for more details on using such programs.</p></dd></dl></div><p>The <code class="literal">[tunnels]</code> section allows you to define new tunnel schemes for use with <span class="command"><strong>svnserve</strong></span> and <code class="literal">svn://</code> client connections. For more details, see <a class="xref" href="#svn.serverconfig.svnserve.sshauth" title="Tunneling over SSH">the section called “Tunneling over SSH”</a>.</p><p>The <code class="literal">miscellany</code> section is where everything that doesn't belong elsewhere winds up.<a href="#ftn.idm7995" class="footnote" id="idm7995"><sup class="footnote">[65]</sup></a> In this section, you can find:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">enable-auto-props</code></span></dt><dd><p>This instructs Subversion to automatically set properties on newly added or imported files. The default value is <code class="literal">no</code>, so set this to <code class="literal">yes</code> to enable this feature. The <code class="literal">[auto-props]</code> section of this file specifies which properties are to be set on which files.</p></dd><dt><span class="term"><code class="literal">global-ignores</code></span></dt><dd><p>When running the <span class="command"><strong>svn status</strong></span> command, Subversion lists unversioned files and directories along with the versioned ones, annotating them with a <code class="literal">?</code> character (see <a class="xref" href="#svn.tour.cycle.examine.status" title="See an overview of your changes">the section called “See an overview of your changes”</a>). Sometimes it can be annoying to see uninteresting, unversioned items—for example, object files that result from a program's compilation—in this display. The <code class="literal">global-ignores</code> option is a list of whitespace-delimited globs that describe the names of files and directories that Subversion should not display unless they are versioned. The default value is <code class="literal">*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store</code>.</p><p>As well as <span class="command"><strong>svn status</strong></span>, the <span class="command"><strong>svn add</strong></span> and <span class="command"><strong>svn import</strong></span> commands also ignore files that match the list when they are scanning a directory. You can override this behavior for a single instance of any of these commands by explicitly specifying the filename, or by using the <code class="option">--no-ignore</code> command-line flag.</p><p>For information on finer-grained control of ignored items, see <a class="xref" href="#svn.advanced.props.special.ignore" title="Ignoring Unversioned Items">the section called “Ignoring Unversioned Items”</a>.</p></dd><dt><span class="term"><code class="literal">interactive-conflicts</code></span></dt><dd><p>This is a Boolean option that specifies whether Subversion should try to resolve conflicts interactively. If its value is <code class="literal">yes</code> (which is the default value), Subversion will prompt the user for how to handle conflicts in the manner demonstrated in <a class="xref" href="#svn.tour.cycle.resolve" title="Resolve Any Conflicts">the section called “Resolve Any Conflicts”</a>. Otherwise, it will simply flag the conflict and continue its operation, postponing resolution to a later time.</p></dd><dt><span class="term"><code class="literal">log-encoding</code></span></dt><dd><p>This variable sets the default character set encoding for commit log messages. It's a permanent form of the <code class="option">--encoding</code> option (see <a class="xref" href="#svn.ref.svn.sw" title="svn Options">the section called “svn Options”</a>). The Subversion repository stores log messages in UTF-8 and assumes that your log message is written using your operating system's native locale. You should specify a different encoding if your commit messages are written in any other encoding.</p></dd><dt><span class="term"><code class="literal">mime-types-file</code></span></dt><dd><p>This option, new to Subversion 1.5, specifies the path of a MIME types mapping file, such as the <code class="filename">mime.types</code> file provided by the Apache HTTP Server. Subversion uses this file to assign MIME types to newly added or imported files. See <a class="xref" href="#svn.advanced.props.auto" title="Automatic Property Setting">the section called “Automatic Property Setting”</a> and <a class="xref" href="#svn.advanced.props.special.mime-type" title="File Content Type">the section called “File Content Type”</a> for more about Subversion's detection and use of file content types.</p></dd><dt><span class="term"><code class="literal">no-unlock</code></span></dt><dd><p>This Boolean option corresponds to <span class="command"><strong>svn commit</strong></span>'s <code class="option">--no-unlock</code> option, which tells Subversion not to release locks on files you've just committed. If this runtime option is set to <code class="literal">yes</code>, Subversion will never release locks automatically, leaving you to run <span class="command"><strong>svn unlock</strong></span> explicitly. It defaults to <code class="literal">no</code>.</p></dd><dt><span class="term"><code class="literal">preserved-conflict-file-exts</code></span></dt><dd><p>The value of this option is a space-delimited list of file extensions that Subversion should preserve when generating conflict filenames. By default, the list is empty. This option is new to Subversion 1.5.</p><p>When Subversion detects conflicting file content changes, it defers resolution of those conflicts to the user. To assist in the resolution, Subversion keeps pristine copies of the various competing versions of the file in the working copy. By default, those conflict files have names constructed by appending to the original filename a custom extension such as <code class="filename">.mine</code> or <code class="filename">.<em class="replaceable"><code>REV</code></em></code> (where <em class="replaceable"><code>REV</code></em> is a revision number). A mild annoyance with this naming scheme is that on operating systems where a file's extension determines the default application used to open and edit that file, appending a custom extension prevents the file from being easily opened by its native application. For example, if the file <code class="filename">ReleaseNotes.pdf</code> was conflicted, the conflict files might be named <code class="filename">ReleaseNotes.pdf.mine</code> or <code class="filename">ReleaseNotes.pdf.r4231</code>. While your system might be configured to use Adobe's Acrobat Reader to open files whose extensions are <code class="filename">.pdf</code>, there probably isn't an application configured on your system to open all files whose extensions are <code class="filename">.r4231</code>.</p><p>You can fix this annoyance by using this configuration option, though. For files with one of the specified extensions, Subversion will append to the conflict file names the custom extension just as before, but then also reappend the file's original extension. Using the previous example, and assuming that <code class="literal">pdf</code> is one of the extensions configured in this list thereof, the conflict files generated for <code class="filename">ReleaseNotes.pdf</code> would instead be named <code class="filename">ReleaseNotes.pdf.mine.pdf</code> and <code class="filename">ReleaseNotes.pdf.r4231.pdf</code>. Because each file ends in <code class="filename">.pdf</code>, the correct default application will be used to view them.</p></dd><dt><span class="term"><code class="literal">use-commit-times</code></span></dt><dd><p>Normally your working copy files have timestamps that reflect the last time they were touched by any process, whether your own editor or some <span class="command"><strong>svn</strong></span> subcommand. This is generally convenient for people developing software, because build systems often look at timestamps as a way of deciding which files need to be recompiled.</p><p>In other situations, however, it's sometimes nice for the working copy files to have timestamps that reflect the last time they were changed in the repository. The <span class="command"><strong>svn export</strong></span> command always places these <span class="quote">“<span class="quote">last-commit timestamps</span>”</span> on trees that it produces. By setting this config variable to <code class="literal">yes</code>, the <span class="command"><strong>svn checkout</strong></span>, <span class="command"><strong>svn update</strong></span>, <span class="command"><strong>svn switch</strong></span>, and <span class="command"><strong>svn revert</strong></span> commands will also set last-commit timestamps on files that they touch.</p></dd></dl></div><p>The <code class="literal">[auto-props]</code> section controls the Subversion client's ability to automatically set properties on files when they are added or imported. It contains any number of key-value pairs in the format <code class="literal"><em class="replaceable"><code>PATTERN</code></em> = <em class="replaceable"><code>PROPNAME</code></em>=<em class="replaceable"><code>VALUE</code></em>[;<em class="replaceable"><code>PROPNAME</code></em>=<em class="replaceable"><code>VALUE</code></em> ...]</code>, where <em class="replaceable"><code>PATTERN</code></em> is a file pattern that matches one or more filenames and the rest of the line is a semicolon-delimited set of property assignments. (If you need to use a semicolon in your property's name or value, you can escape it by doubling it.)</p><div class="informalexample"><pre class="screen"> $ cat ~/.subversion/config … [auto-props] *.c = svn:eol-style=native *.html = svn:eol-style=native;svn:mime-type=text/html;; charset=UTF8 *.sh = svn:eol-style=native;svn:executable … $ cd projects/myproject $ svn status ? www/index.html $ svn add www/index.html A www/index.html $ svn diff www/index.html … Property changes on: www/index.html ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/html; charset=UTF8 Added: svn:eol-style ## -0,0 +1 ## +native $ </pre></div><p>Multiple matches on a file will result in multiple propsets for that file; however, there is no guarantee that auto-props will be applied in the order in which they are listed in the config file, so you can't have one rule <span class="quote">“<span class="quote">override</span>”</span> another. You can find several examples of auto-props usage in the <code class="filename">config</code> file. Lastly, don't forget to set <code class="literal">enable-auto-props</code> to <code class="literal">yes</code> in the <code class="literal">miscellany</code> section if you want to enable auto-props.</p></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.l10n"></a>Localization</h2></div></div></div><p><em class="firstterm">Localization</em> is the act of making programs behave in a region-specific way. When a program formats numbers or dates in a way specific to your part of the world or prints messages (or accepts input) in your native language, the program is said to be <em class="firstterm">localized</em>. This section describes steps Subversion has made toward localization.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.l10n.understanding"></a>Understanding Locales</h3></div></div></div><p>Most modern operating systems have a notion of the <span class="quote">“<span class="quote">current locale</span>”</span>—that is, the region or country whose localization conventions are honored. These conventions—typically chosen by some runtime configuration mechanism on the computer—affect the way in which programs present data to the user, as well as the way in which they accept user input.</p><p>On most Unix-like systems, you can check the values of the locale-related runtime configuration options by running the <span class="command"><strong>locale</strong></span> command:</p><div class="informalexample"><pre class="screen"> $ locale LANG= LC_COLLATE="C" LC_CTYPE="C" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL="C" $ </pre></div><p>The output is a list of locale-related environment variables and their current values. In this example, the variables are all set to the default <code class="literal">C</code> locale, but users can set these variables to specific country/language code combinations. For example, if one were to set the <code class="literal">LC_TIME</code> variable to <code class="literal">fr_CA</code>, programs would know to present time and date information formatted according to a French-speaking Canadian's expectations. And if one were to set the <code class="literal">LC_MESSAGES</code> variable to <code class="literal">zh_TW</code>, programs would know to present human-readable messages in Traditional Chinese. Setting the <code class="literal">LC_ALL</code> variable has the effect of changing every locale variable to the same value. The value of <code class="literal">LANG</code> is used as a default value for any locale variable that is unset. To see the list of available locales on a Unix system, run the command <strong class="userinput"><code>locale -a</code></strong>.</p><p>On Windows, locale configuration is done via the <span class="quote">“<span class="quote">Regional and Language Options</span>”</span> control panel item. There you can view and select the values of individual settings from the available locales, and even customize (at a sickening level of detail) several of the display formatting conventions.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.l10n.svnuse"></a>Subversion's Use of Locales</h3></div></div></div><p>The Subversion client, <span class="command"><strong>svn</strong></span>, honors the current locale configuration in two ways. First, it notices the value of the <code class="literal">LC_MESSAGES</code> variable and attempts to print all messages in the specified language. For example:</p><div class="informalexample"><pre class="screen"> $ export LC_MESSAGES=de_DE $ svn help cat cat: Gibt den Inhalt der angegebenen Dateien oder URLs aus. Aufruf: cat ZIEL[@REV]... … </pre></div><p>This behavior works identically on both Unix and Windows systems. Note, though, that while your operating system might have support for a certain locale, the Subversion client still may not be able to speak the particular language. In order to produce localized messages, human volunteers must provide translations for each language. The translations are written using the GNU gettext package, which results in translation modules that end with the <code class="filename">.mo</code> filename extension. For example, the German translation file is named <code class="filename">de.mo</code>. These translation files are installed somewhere on your system. On Unix, they typically live in <code class="filename">/usr/share/locale/</code>, while on Windows they're often found in the <code class="filename">share\locale\</code> folder in Subversion's installation area. Once installed, a module is named after the program for which it provides translations. For example, the <code class="filename">de.mo</code> file may ultimately end up installed as <code class="filename">/usr/share/locale/de/LC_MESSAGES/subversion.mo</code>. By browsing the installed <code class="filename">.mo</code> files, you can see which languages the Subversion client is able to speak.</p><p>The second way in which the locale is honored involves how <span class="command"><strong>svn</strong></span> interprets your input. The repository stores all paths, filenames, and log messages in Unicode, encoded as UTF-8. In that sense, the repository is <em class="firstterm">internationalized</em>—that is, the repository is ready to accept input in any human language. This means, however, that the Subversion client is responsible for sending only UTF-8 filenames and log messages into the repository. To do this, it must convert the data from the native locale into UTF-8.</p><p>For example, suppose you create a file named <code class="filename">caffè.txt</code>, and then when committing the file, you write the log message as <span class="quote">“<span class="quote">Adesso il caffè è più forte.</span>”</span> Both the filename and the log message contain non-ASCII characters, but because your locale is set to <code class="literal">it_IT</code>, the Subversion client knows to interpret them as Italian. It uses an Italian character set to convert the data to UTF-8 before sending it off to the repository.</p><p>Note that while the repository demands UTF-8 filenames and log messages, it <span class="emphasis"><em>does not</em></span> pay attention to file contents. Subversion treats file contents as opaque strings of bytes, and neither client nor server makes an attempt to understand the character set or encoding of the contents.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Character Set Conversion Errors</strong></p></div></div></div><p>While using Subversion, you might get hit with an error related to character set conversions:</p><div class="informalexample"><pre class="screen"> svn: E000022: Can't convert string from native encoding to 'UTF-8': … svn: E000022: Can't convert string from 'UTF-8' to native encoding: … </pre></div><p>Errors such as this typically occur when the Subversion client has received a UTF-8 string from the repository, but not all of the characters in that string can be represented using the encoding of the current locale. For example, if your locale is <code class="literal">en_US</code> but a collaborator has committed a Japanese filename, you're likely to see this error when you receive the file during an <span class="command"><strong>svn update</strong></span>.</p><p>The solution is either to set your locale to something that <span class="emphasis"><em>can</em></span> represent the incoming UTF-8 data, or to change the filename or log message in the repository. (And don't forget to slap your collaborator's hand—projects should decide on common languages ahead of time so that all participants are using the same locale.)</p></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.externaleditors"></a>Using External Editors</h2></div></div></div><p>The most obvious way to get data into Subversion is through the addition of files to version control, committing changes to those files, and so on. But other pieces of information besides merely versioned file data live in your Subversion repository. Some of these bits of information—commit log messages, lock comments, and some property values—tend to be textual in nature and are provided explicitly by users. Most of this information can be provided to the Subversion command-line client using the <code class="option">--message</code> (<code class="option">-m</code>) and <code class="option">--file</code> (<code class="option">-F</code>) options with the appropriate subcommands.</p><p>Each of these options has its pros and cons. For example, when performing a commit, <code class="option">--file</code> (<code class="option">-F</code>) works well if you've already prepared a text file that holds your commit log message. If you didn't, though, you can use <code class="option">--message</code> (<code class="option">-m</code>) to provide a log message on the command line. Unfortunately, it can be tricky to compose anything more than a simple one-line message on the command line. Users want more flexibility—multiline, free-form log message editing on demand.</p><p>Subversion supports this by allowing you to specify an external text editor that it will launch as necessary to give you a more powerful input mechanism for this textual metadata. There are several ways to tell Subversion which editor you'd like use. Subversion checks the following things, in the order specified, when it wants to launch such an editor:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p><code class="literal">--editor-cmd</code> command-line option</p></li><li class="listitem"><p><code class="literal">SVN_EDITOR</code> environment variable</p></li><li class="listitem"><p><code class="literal">editor-cmd</code> runtime configuration option</p></li><li class="listitem"><p><code class="literal">VISUAL</code> environment variable</p></li><li class="listitem"><p><code class="literal">EDITOR</code> environment variable</p></li><li class="listitem"><p>Possibly, a fallback value built into the Subversion libraries (not present in the official builds)</p></li></ol></div><p>The value of any of these options or variables is the beginning of a command line to be executed by the shell. Subversion appends to that command line a space and the pathname of a temporary file to be edited. So, to be used with Subversion, the configured or specified editor needs to support an invocation in which its last command-line parameter is a file to be edited, and it should be able to save the file in place and return a zero exit code to indicate success.</p><p>As noted, external editors can be used to provide commit log messages to any of the committing subcommands (such as <span class="command"><strong>svn commit</strong></span> or <span class="command"><strong>import</strong></span>, <span class="command"><strong>svn mkdir</strong></span> or <span class="command"><strong>delete</strong></span> when provided a URL target, etc.), and Subversion will try to launch the editor automatically if you don't specify either of the <code class="option">--message</code> (<code class="option">-m</code>) or <code class="option">--file</code> (<code class="option">-F</code>) options. The <span class="command"><strong>svn propedit</strong></span> command is built almost entirely around the use of an external editor. And beginning in version 1.5, Subversion will also use the configured external text editor when the user asks it to launch an editor during interactive conflict resolution. Oddly, there doesn't appear to be a way to use external editors to interactively provide lock comments.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.advanced.externaldifftools"></a>Using External Differencing and Merge Tools</h2></div></div></div><p>The interface between Subversion and external two- and three-way differencing tools harkens back to a time when Subversion's only contextual differencing capabilities were built around invocations of the GNU diffutils toolchain, specifically the <span class="command"><strong>diff</strong></span> and <span class="command"><strong>diff3</strong></span> utilities. To get the kind of behavior Subversion needed, it called these utilities with more than a handful of options and parameters, most of which were quite specific to the utilities. Some time later, Subversion grew its own internal differencing library, and as a failover mechanism, the <code class="option">--diff-cmd</code> and <code class="option">--diff3-cmd</code> options were added to the Subversion command-line client so that users could more easily indicate that they preferred to use the GNU diff and diff3 utilities instead of the newfangled internal diff library. If those options were used, Subversion would simply ignore the internal diff library, and fall back to running those external programs, lengthy argument lists and all. And that's where things remain today.</p><p>It didn't take long for folks to realize that having such easy configuration mechanisms for specifying that Subversion should use the external GNU diff and diff3 utilities located at a particular place on the system could be applied toward the use of other differencing tools, too. After all, Subversion didn't actually verify that the things it was being told to run were members of the GNU diffutils toolchain. But the only configurable aspect of using those external tools is their location on the system—not the option set, parameter order, and so on. Subversion continues to throw all those GNU utility options at your external diff tool regardless of whether that program can understand those options. And that's where things get unintuitive for most users.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The decision on when to fire off a contextual two- or three-way diff as part of a larger Subversion operation is made entirely by Subversion and is affected by, among other things, whether the files being operated on are human-readable as determined by their <code class="literal">svn:mime-type</code> property. This means, for example, that even if you had the niftiest Microsoft Word-aware differencing or merging tool in the universe, it would never be invoked by Subversion as long as your versioned Word documents had a configured MIME type that denoted that they were not human-readable (such as <code class="literal">application/msword</code>). For more about MIME type settings, see <a class="xref" href="#svn.advanced.props.special.mime-type" title="File Content Type">the section called “File Content Type”</a></p></td></tr></table></div><p>Much later, Subversion 1.5 introduced interactive resolution of conflicts (described in <a class="xref" href="#svn.tour.cycle.resolve" title="Resolve Any Conflicts">the section called “Resolve Any Conflicts”</a>). One of the options that this feature provides to users is the ability to interactively launch a third-party merge tool. If this action is taken, Subversion will check to see if the user has specified such a tool for use in this way. Subversion will first check the <code class="literal">SVN_MERGE</code> environment variable for the name of an external merge tool. If that variable is not set, it will look for the same information in the value of the <code class="literal">merge-tool-cmd</code> runtime configuration option. Upon finding a configured external merge tool, it will invoke that tool.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>While the general purposes of the three-way differencing and merge tools are roughly the same (finding a way to make separate-but-overlapping file changes live in harmony), Subversion exercises each of these options at different times and for different reasons. The internal three-way differencing engine and its optional external replacement are used when interaction with the user is <span class="emphasis"><em>not</em></span> expected. In fact, significant delay introduced by such a tool can actually result in the failure of some time-sensitive Subversion operations. It's the external merge tool that is intended to be invoked interactively.</p></td></tr></table></div><p>Now, while the interface between Subversion and an external merge tool is significantly less convoluted than that between Subversion and the diff and diff3 tools, the likelihood of finding such a tool whose calling conventions exactly match what Subversion expects is still quite low. The key to using external differencing and merge tools with Subversion is to use wrapper scripts, which convert the input from Subversion into something that your specific differencing tool can understand, and then convert the output of your tool back into a format that Subversion expects. The following sections cover the specifics of those expectations.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.externaldifftools.diff"></a>External diff</h3></div></div></div><p>Subversion calls external diff programs with parameters suitable for the GNU diff utility, and expects only that the external program will return with a successful error code per the GNU diff definition thereof. For most alternative diff programs, only the sixth and seventh arguments—the paths of the files that represent the left and right sides of the diff, respectively—are of interest. Note that Subversion runs the diff program once per modified file covered by the Subversion operation, so if your program runs in an asynchronous fashion (or is <span class="quote">“<span class="quote">backgrounded</span>”</span>), you might have several instances of it all running simultaneously. Finally, Subversion expects that your program return an error code of 1 if your program detected differences, or 0 if it did not—any other error code is considered a fatal error.<a href="#ftn.idm8232" class="footnote" id="idm8232"><sup class="footnote">[66]</sup></a></p><p><a class="xref" href="#svn.advanced.externaldifftools.diff.ex-1" title="Example 7.2. diffwrap.py">Example 7.2, “diffwrap.py”</a> and <a class="xref" href="#svn.advanced.externaldifftools.diff.ex-2" title="Example 7.3. diffwrap.bat">Example 7.3, “diffwrap.bat”</a> are templates for external diff tool wrappers in the Python and Windows batch scripting languages, respectively.</p><div class="example"><a id="svn.advanced.externaldifftools.diff.ex-1"></a><p class="title"><strong>Example 7.2. diffwrap.py</strong></p><div class="example-contents"><pre class="programlisting"> #!/usr/bin/env python import sys import os # Configure your favorite diff program here. DIFF = "/usr/local/bin/my-diff-tool" # Subversion provides the paths we need as the last two parameters. LEFT = sys.argv[-2] RIGHT = sys.argv[-1] # Call the diff command (change the following line to make sense for # your diff program). cmd = [DIFF, '--left', LEFT, '--right', RIGHT] os.execv(cmd[0], cmd) # Return an errorcode of 0 if no differences were detected, 1 if some were. # Any other errorcode will be treated as fatal. </pre></div></div><br class="example-break"></br><div class="example"><a id="svn.advanced.externaldifftools.diff.ex-2"></a><p class="title"><strong>Example 7.3. diffwrap.bat</strong></p><div class="example-contents"><pre class="programlisting"> @ECHO OFF REM Configure your favorite diff program here. SET DIFF="C:\Program Files\Funky Stuff\My Diff Tool.exe" REM Subversion provides the paths we need as the last two parameters. REM These are parameters 6 and 7 (unless you use svn diff -x, in REM which case, all bets are off). SET LEFT=%6 SET RIGHT=%7 REM Call the diff command (change the following line to make sense for REM your diff program). %DIFF% --left %LEFT% --right %RIGHT% REM Return an errorcode of 0 if no differences were detected, 1 if some were. REM Any other errorcode will be treated as fatal. </pre></div></div><br class="example-break"></br></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.externaldifftools.diff3"></a>External diff3</h3></div></div></div><p>Subversion invokes three-way differencing programs to perform non-interactive merges. When configured to use an external three-way differencing program, it executes that program with parameters suitable for the GNU diff3 utility, expecting that the external program will return with a successful error code and that the full file contents that result from the completed merge operation are printed on the standard output stream (so that Subversion can redirect them into the appropriate version-controlled file). For most alternative merge programs, only the ninth, tenth, and eleventh arguments, the paths of the files which represent the <span class="quote">“<span class="quote">mine</span>”</span>, <span class="quote">“<span class="quote">older</span>”</span>, and <span class="quote">“<span class="quote">yours</span>”</span> inputs, respectively, are of interest. Note that because Subversion depends on the output of your merge program, your wrapper script must not exit before that output has been delivered to Subversion. When it finally does exit, it should return an error code of 0 if the merge was successful, or 1 if unresolved conflicts remain in the output—any other error code is considered a fatal error.</p><p><a class="xref" href="#svn.advanced.externaldifftools.diff3.ex-1" title="Example 7.4. diff3wrap.py">Example 7.4, “diff3wrap.py”</a> and <a class="xref" href="#svn.advanced.externaldifftools.diff3.ex-2" title="Example 7.5. diff3wrap.bat">Example 7.5, “diff3wrap.bat”</a> are templates for external three-way differencing tool wrappers in the Python and Windows batch scripting languages, respectively.</p><div class="example"><a id="svn.advanced.externaldifftools.diff3.ex-1"></a><p class="title"><strong>Example 7.4. diff3wrap.py</strong></p><div class="example-contents"><pre class="programlisting"> #!/usr/bin/env python import sys import os # Configure your favorite three-way diff program here. DIFF3 = "/usr/local/bin/my-diff3-tool" # Subversion provides the paths we need as the last three parameters. MINE = sys.argv[-3] OLDER = sys.argv[-2] YOURS = sys.argv[-1] # Call the three-way diff command (change the following line to make # sense for your three-way diff program). cmd = [DIFF3, '--older', OLDER, '--mine', MINE, '--yours', YOURS] os.execv(cmd[0], cmd) # After performing the merge, this script needs to print the contents # of the merged file to stdout. Do that in whatever way you see fit. # Return an errorcode of 0 on successful merge, 1 if unresolved conflicts # remain in the result. Any other errorcode will be treated as fatal. </pre></div></div><br class="example-break"></br><div class="example"><a id="svn.advanced.externaldifftools.diff3.ex-2"></a><p class="title"><strong>Example 7.5. diff3wrap.bat</strong></p><div class="example-contents"><pre class="programlisting"> @ECHO OFF REM Configure your favorite three-way diff program here. SET DIFF3="C:\Program Files\Funky Stuff\My Diff3 Tool.exe" REM Subversion provides the paths we need as the last three parameters. REM These are parameters 9, 10, and 11. But we have access to only REM nine parameters at a time, so we shift our nine-parameter window REM twice to let us get to what we need. SHIFT SHIFT SET MINE=%7 SET OLDER=%8 SET YOURS=%9 REM Call the three-way diff command (change the following line to make REM sense for your three-way diff program). %DIFF3% --older %OLDER% --mine %MINE% --yours %YOURS% REM After performing the merge, this script needs to print the contents REM of the merged file to stdout. Do that in whatever way you see fit. REM Return an errorcode of 0 on successful merge, 1 if unresolved conflicts REM remain in the result. Any other errorcode will be treated as fatal. </pre></div></div><br class="example-break"></br></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.advanced.externaldifftools.merge"></a>External merge</h3></div></div></div><p>Subversion optionally invokes an external merge tool as part of its support for interactive conflict resolution. It provides as arguments to the merge tool the following: the path of the unmodified base file, the path of the <span class="quote">“<span class="quote">theirs</span>”</span> file (which contains upstream changes), the path of the <span class="quote">“<span class="quote">mine</span>”</span> file (which contains local modifications), the path of the file into which the final resolved contents should be stored by the merge tool, and the working copy path of the conflicted file (relative to the original target of the merge operation). The merge tool is expected to return an error code of 0 to indicate success, or 1 to indicate failure.</p><p><a class="xref" href="#svn.advanced.externaldifftools.merge.ex-1" title="Example 7.6. mergewrap.py">Example 7.6, “mergewrap.py”</a> and <a class="xref" href="#svn.advanced.externaldifftools.merge.ex-2" title="Example 7.7. mergewrap.bat">Example 7.7, “mergewrap.bat”</a> are templates for external merge tool wrappers in the Python and Windows batch scripting languages, respectively.</p><div class="example"><a id="svn.advanced.externaldifftools.merge.ex-1"></a><p class="title"><strong>Example 7.6. mergewrap.py</strong></p><div class="example-contents"><pre class="programlisting"> #!/usr/bin/env python import sys import os # Configure your favorite merge program here. MERGE = "/usr/local/bin/my-merge-tool" # Get the paths provided by Subversion. BASE = sys.argv[1] THEIRS = sys.argv[2] MINE = sys.argv[3] MERGED = sys.argv[4] WCPATH = sys.argv[5] # Call the merge command (change the following line to make sense for # your merge program). cmd = [MERGE, '--base', BASE, '--mine', MINE, '--theirs', THEIRS, '--outfile', MERGED] os.execv(cmd[0], cmd) # Return an errorcode of 0 if the conflict was resolved; 1 otherwise. # Any other errorcode will be treated as fatal. </pre></div></div><br class="example-break"></br><div class="example"><a id="svn.advanced.externaldifftools.merge.ex-2"></a><p class="title"><strong>Example 7.7. mergewrap.bat</strong></p><div class="example-contents"><pre class="programlisting"> @ECHO OFF REM Configure your favorite merge program here. SET MERGE="C:\Program Files\Funky Stuff\My Merge Tool.exe" REM Get the paths provided by Subversion. SET BASE=%1 SET THEIRS=%2 SET MINE=%3 SET MERGED=%4 SET WCPATH=%5 REM Call the merge command (change the following line to make sense for REM your merge program). %MERGE% --base %BASE% --mine %MINE% --theirs %THEIRS% --outfile %MERGED% REM Return an errorcode of 0 if the conflict was resolved; 1 otherwise. REM Any other errorcode will be treated as fatal. </pre></div></div><br class="example-break"></br></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.customization.summary"></a>Summary</h2></div></div></div><p>Sometimes there's a single right way to do things; sometimes there are many. Subversion's developers understand that while the majority of its exact behaviors are acceptable to most of its users, there are some corners of its functionality where such a universally pleasing approach doesn't exist. In those places, Subversion offers users the opportunity to tell it how <span class="emphasis"><em>they</em></span> want it to behave.</p><p>In this chapter, we explored Subversion's runtime configuration system and other mechanisms by which users can control those configurable behaviors. If you are a developer, though, the next chapter will take you one step further. It describes how you can further customize your Subversion experience by writing your own software against Subversion's libraries.</p></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm7688" class="footnote"><p><a href="#idm7688" class="para"><sup class="para">[64] </sup></a>The <code class="literal">APPDATA</code> environment variable points to the <code class="filename">Application Data</code> area, so you can always refer to this folder as <code class="filename">%APPDATA%\Subversion</code>.</p></div><div id="ftn.idm7995" class="footnote"><p><a href="#idm7995" class="para"><sup class="para">[65] </sup></a>Anyone for potluck dinner?</p></div><div id="ftn.idm8232" class="footnote"><p><a href="#idm8232" class="para"><sup class="para">[66] </sup></a>The GNU diff manual page puts it this way: <span class="quote">“<span class="quote">An exit status of 0 means no differences were found, 1 means some differences were found, and 2 means trouble.</span>”</span></p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="svn.developer"></a>Chapter 8. Embedding Subversion</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.developer.layerlib">Layered Library Design</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.developer.layerlib.repos">Repository Layer</a></span></dt><dt><span class="sect2"><a href="#svn.developer.layerlib.ra">Repository Access Layer</a></span></dt><dt><span class="sect2"><a href="#svn.developer.layerlib.client">Client Layer</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.developer.usingapi">Using the APIs</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.developer.usingapi.apr">The Apache Portable Runtime Library</a></span></dt><dt><span class="sect2"><a href="#svn.developer.usingapi.funcsbatons">Functions and Batons</a></span></dt><dt><span class="sect2"><a href="#svn.developer.usingapi.urlpath">URL and Path Requirements</a></span></dt><dt><span class="sect2"><a href="#svn.developer.usingapi.otherlangs">Using Languages Other Than C and C++</a></span></dt><dt><span class="sect2"><a href="#svn.developer.usingapi.codesamples">Code Samples</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.developer.summary">Summary</a></span></dt></dl></div><p>Subversion has a modular design: it's implemented as a collection of libraries written in C. Each library has a well-defined purpose and application programming interface (API), and that interface is available not only for Subversion itself to use, but for any software that wishes to embed or otherwise programmatically control Subversion. Additionally, Subversion's API is available not only to other C programs, but also to programs written in higher-level languages such as Python, Perl, Java, and Ruby.</p><p>This chapter is for those who wish to interact with Subversion through its public API or its various language bindings. If you wish to write robust wrapper scripts around Subversion functionality to simplify your own life, are trying to develop more complex integrations between Subversion and other pieces of software, or just have an interest in Subversion's various library modules and what they offer, this chapter is for you. If, however, you don't foresee yourself participating with Subversion at such a level, feel free to skip this chapter with the confidence that your experience as a Subversion user will not be affected.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.developer.layerlib"></a>Layered Library Design</h2></div></div></div><p>Each of Subversion's core libraries can be said to exist in one of three main layers—the Repository layer, the Repository Access (RA) layer, or the Client layer (see <a class="xref" href="#svn.intro.architecture.dia-1" title="Figure 1. Subversion's architecture">Figure 1, “Subversion's architecture”</a> in the Preface). We will examine these layers shortly, but first, let's briefly summarize Subversion's various libraries. For the sake of consistency, we will refer to the libraries by their extensionless Unix library names (<code class="filename">libsvn_fs</code>, <code class="filename">libsvn_wc</code>, <code class="filename">mod_dav_svn</code>, etc.).</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">libsvn_client</span></dt><dd><p>Primary interface for client programs</p></dd><dt><span class="term">libsvn_delta</span></dt><dd><p>Tree and byte-stream differencing routines</p></dd><dt><span class="term">libsvn_diff</span></dt><dd><p>Contextual differencing and merging routines</p></dd><dt><span class="term">libsvn_fs</span></dt><dd><p>Filesystem commons and module loader</p></dd><dt><span class="term">libsvn_fs_base</span></dt><dd><p>The Berkeley DB filesystem backend</p></dd><dt><span class="term">libsvn_fs_fs</span></dt><dd><p>The native filesystem (FSFS) backend</p></dd><dt><span class="term">libsvn_ra</span></dt><dd><p>Repository Access commons and module loader</p></dd><dt><span class="term">libsvn_ra_local</span></dt><dd><p>The local Repository Access module</p></dd><dt><span class="term">libsvn_ra_neon</span></dt><dd><p>The WebDAV Repository Access module</p></dd><dt><span class="term">libsvn_ra_serf</span></dt><dd><p>Another (experimental) WebDAV Repository Access module</p></dd><dt><span class="term">libsvn_ra_svn</span></dt><dd><p>The custom protocol Repository Access module</p></dd><dt><span class="term">libsvn_repos</span></dt><dd><p>Repository interface</p></dd><dt><span class="term">libsvn_subr</span></dt><dd><p>Miscellaneous helpful subroutines</p></dd><dt><span class="term">libsvn_wc</span></dt><dd><p>The working copy management library</p></dd><dt><span class="term">mod_authz_svn</span></dt><dd><p>Apache authorization module for Subversion repositories access via WebDAV</p></dd><dt><span class="term">mod_dav_svn</span></dt><dd><p>Apache module for mapping WebDAV operations to Subversion ones</p></dd></dl></div><p>The fact that the word <span class="quote">“<span class="quote">miscellaneous</span>”</span> appears only once in the previous list is a good sign. The Subversion development team is serious about making sure that functionality lives in the right layer and libraries. Perhaps the greatest advantage of the modular design is its lack of complexity from a developer's point of view. As a developer, you can quickly formulate that kind of <span class="quote">“<span class="quote">big picture</span>”</span> that allows you to pinpoint the location of certain pieces of functionality with relative ease.</p><p>Another benefit of modularity is the ability to replace a given module with a whole new library that implements the same API without affecting the rest of the code base. In some sense, this happens within Subversion already. The <code class="filename">libsvn_ra_local</code>, <code class="filename">libsvn_ra_neon</code>, <code class="filename">libsvn_ra_serf</code>, and <code class="filename">libsvn_ra_svn</code> libraries each implement the same interface, all working as plug-ins to <code class="filename">libsvn_ra</code>. And all four communicate with the Repository layer—<code class="filename">libsvn_ra_local</code> connects to the repository directly; the other three do so over a network. The <code class="filename">libsvn_fs_base</code> and <code class="filename">libsvn_fs_fs</code> libraries are another pair of libraries that implement the same functionality in different ways—both are plug-ins to the common <code class="filename">libsvn_fs</code> library.</p><p>The client itself also highlights the benefits of modularity in the Subversion design. Subversion's <code class="filename">libsvn_client</code> library is a one-stop shop for most of the functionality necessary for designing a working Subversion client (see <a class="xref" href="#svn.developer.layerlib.client" title="Client Layer">the section called “Client Layer”</a>). So while the Subversion distribution provides only the <span class="command"><strong>svn</strong></span> command-line client program, several third-party programs provide various forms of graphical client UIs. These GUIs use the same APIs that the stock command-line client does. This type of modularity has played a large role in the proliferation of available Subversion clients and IDE integrations and, by extension, to the tremendous adoption rate of Subversion itself.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.developer.layerlib.repos"></a>Repository Layer</h3></div></div></div><p>When referring to Subversion's Repository layer, we're generally talking about two basic concepts—the versioned filesystem implementation (accessed via <code class="filename">libsvn_fs</code>, and supported by its <code class="filename">libsvn_fs_base</code> and <code class="filename">libsvn_fs_fs</code> plug-ins), and the repository logic that wraps it (as implemented in <code class="filename">libsvn_repos</code>). These libraries provide the storage and reporting mechanisms for the various revisions of your version-controlled data. This layer is connected to the Client layer via the Repository Access layer, and is, from the perspective of the Subversion user, the stuff at the <span class="quote">“<span class="quote">other end of the line.</span>”</span></p><p>The Subversion filesystem is not a kernel-level filesystem that one would install in an operating system (such as the Linux ext2 or NTFS), but instead is a virtual filesystem. Rather than storing <span class="quote">“<span class="quote">files</span>”</span> and <span class="quote">“<span class="quote">directories</span>”</span> as real files and directories (the kind you can navigate through using your favorite shell program), it uses one of two available abstract storage backends—either a Berkeley DB database environment or a flat-file representation. (To learn more about the two repository backends, see <a class="xref" href="#svn.reposadmin.basics.backends" title="Choosing a Data Store">the section called “Choosing a Data Store”</a>.) There has even been considerable interest by the development community in giving future releases of Subversion the ability to use other backend database systems, perhaps through a mechanism such as Open Database Connectivity (ODBC). In fact, Google did something similar to this before launching the Google Code Project Hosting service: they announced in mid-2006 that members of its open source team had written a new proprietary Subversion filesystem plug-in that used Google's ultra-scalable Bigtable database for its storage.</p><p>The filesystem API exported by <code class="filename">libsvn_fs</code> contains the kinds of functionality you would expect from any other filesystem API—you can create and remove files and directories, copy and move them around, modify file contents, and so on. It also has features that are not quite as common, such as the ability to add, modify, and remove metadata (<span class="quote">“<span class="quote">properties</span>”</span>) on each file or directory. Furthermore, the Subversion filesystem is a versioning filesystem, which means that as you make changes to your directory tree, Subversion remembers what your tree looked like before those changes. And before the previous changes. And the previous ones. And so on, all the way back through versioning time to (and just beyond) the moment you first started adding things to the filesystem.</p><p>All the modifications you make to your tree are done within the context of a Subversion commit transaction. The following is a simplified general routine for modifying your filesystem:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Begin a Subversion commit transaction.</p></li><li class="listitem"><p>Make your changes (adds, deletes, property modifications, etc.).</p></li><li class="listitem"><p>Commit your transaction.</p></li></ol></div><p>Once you have committed your transaction, your filesystem modifications are permanently stored as historical artifacts. Each of these cycles generates a single new revision of your tree, and each revision is forever accessible as an immutable snapshot of <span class="quote">“<span class="quote">the way things were.</span>”</span></p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>The Transaction Distraction</strong></p></div></div></div><p>The notion of a Subversion transaction can become easily confused with the transaction support provided by the underlying database itself, especially given the former's close proximity to the Berkeley DB database code in <code class="filename">libsvn_fs_base</code>. Both types of transaction exist to provide atomicity and isolation. In other words, transactions give you the ability to perform a set of actions in an all-or-nothing fashion—either all the actions in the set complete with success, or they all get treated as though <span class="emphasis"><em>none</em></span> of them ever happened—and in a way that does not interfere with other processes acting on the data.</p><p>Database transactions generally encompass small operations related specifically to the modification of data in the database itself (such as changing the contents of a table row). Subversion transactions are larger in scope, encompassing higher-level operations such as making modifications to a set of files and directories that are intended to be stored as the next revision of the filesystem tree. If that isn't confusing enough, consider the fact that Subversion uses a database transaction during the creation of a Subversion transaction (so that if the creation of a Subversion transaction fails, the database will look as though we had never attempted that creation in the first place)!</p><p>Fortunately for users of the filesystem API, the transaction support provided by the database system itself is hidden almost entirely from view (as should be expected from a properly modularized library scheme). It is only when you start digging into the implementation of the filesystem itself that such things become visible (or interesting).</p></div><p>Most of the functionality the filesystem interface provides deals with actions that occur on individual filesystem paths. That is, from outside the filesystem, the primary mechanism for describing and accessing the individual revisions of files and directories comes through the use of path strings such as <code class="filename">/foo/bar</code>, just as though you were addressing files and directories through your favorite shell program. You add new files and directories by passing their paths-to-be to the right API functions. You query for information about them by the same mechanism.</p><p>Unlike most filesystems, though, a path alone is not enough information to identify a file or directory in Subversion. Think of a directory tree as a two-dimensional system, where a node's siblings represent a sort of left-and-right motion, and navigating into the node's subdirectories represents a downward motion. <a class="xref" href="#svn.developer.layerlib.repos.dia-1" title="Figure 8.1. Files and directories in two dimensions">Figure 8.1, “Files and directories in two dimensions”</a> shows a typical representation of a tree as exactly that.</p><div class="figure"><a id="svn.developer.layerlib.repos.dia-1"></a><p class="title"><strong>Figure 8.1. Files and directories in two dimensions</strong></p><div class="figure-contents"><div><img src="images/ch08dia1.png" alt="Files and directories in two dimensions"></img></div></div></div><br class="figure-break"></br><p>The difference here is that the Subversion filesystem has a nifty third dimension that most filesystems do not have—Time!<a href="#ftn.idm8411" class="footnote" id="idm8411"><sup class="footnote">[67]</sup></a> In the filesystem interface, nearly every function that has a <em class="parameter"><code>path</code></em> argument also expects a <em class="parameter"><code>root</code></em> argument. This <code class="literal">svn_fs_root_t</code> argument describes either a revision or a Subversion transaction (which is simply a revision in the making) and provides that third dimension of context needed to understand the difference between <code class="filename">/foo/bar</code> in revision 32, and the same path as it exists in revision 98. <a class="xref" href="#svn.developer.layerlib.repos.dia-2" title="Figure 8.2. Versioning time—the third dimension!">Figure 8.2, “Versioning time—the third dimension!”</a> shows revision history as an added dimension to the Subversion filesystem universe.</p><div class="figure"><a id="svn.developer.layerlib.repos.dia-2"></a><p class="title"><strong>Figure 8.2. Versioning time—the third dimension!</strong></p><div class="figure-contents"><div><img src="images/ch08dia2.png" alt="Versioning time—the third dimension!"></img></div></div></div><br class="figure-break"></br><p>As we mentioned earlier, the <code class="filename">libsvn_fs</code> API looks and feels like any other filesystem, except that it has this wonderful versioning capability. It was designed to be usable by any program interested in a versioning filesystem. Not coincidentally, Subversion itself is interested in that functionality. But while the filesystem API should be sufficient for basic file and directory versioning support, Subversion wants more—and that is where <code class="filename">libsvn_repos</code> comes in.</p><p>The Subversion repository library (<code class="filename">libsvn_repos</code>) sits (logically speaking) atop the <code class="filename">libsvn_fs</code> API, providing additional functionality beyond that of the underlying versioned filesystem logic. It does not completely wrap each and every filesystem function—only certain major steps in the general cycle of filesystem activity are wrapped by the repository interface. Some of these include the creation and commit of Subversion transactions and the modification of revision properties. These particular events are wrapped by the repository layer because they have hooks associated with them. A repository hook system is not strictly related to implementing a versioning filesystem, so it lives in the repository wrapper library.</p><p>The hooks mechanism is but one of the reasons for the abstraction of a separate repository library from the rest of the filesystem code. The <code class="filename">libsvn_repos</code> API provides several other important utilities to Subversion. These include the abilities to:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Create, open, destroy, and perform recovery steps on a Subversion repository and the filesystem included in that repository.</p></li><li class="listitem"><p>Describe the differences between two filesystem trees.</p></li><li class="listitem"><p>Query for the commit log messages associated with all (or some) of the revisions in which a set of files was modified in the filesystem.</p></li><li class="listitem"><p>Generate a human-readable <span class="quote">“<span class="quote">dump</span>”</span> of the filesystem—a complete representation of the revisions in the filesystem.</p></li><li class="listitem"><p>Parse that dump format, loading the dumped revisions into a different Subversion repository.</p></li></ul></div><p>As Subversion continues to evolve, the repository library will grow with the filesystem library to offer increased functionality and configurable option support.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.developer.layerlib.ra"></a>Repository Access Layer</h3></div></div></div><p>If the Subversion Repository layer is at <span class="quote">“<span class="quote">the other end of the line,</span>”</span> the Repository Access (RA) layer is the line itself. Charged with marshaling data between the client libraries and the repository, this layer includes the <code class="filename">libsvn_ra</code> module loader library, the RA modules themselves (which currently includes <code class="filename">libsvn_ra_neon</code>, <code class="filename">libsvn_ra_local</code>, <code class="filename">libsvn_ra_serf</code>, and <code class="filename">libsvn_ra_svn</code>), and any additional libraries needed by one or more of those RA modules (such as the <code class="filename">mod_dav_svn</code> Apache module or <code class="filename">libsvn_ra_svn</code>'s server, <span class="command"><strong>svnserve</strong></span>).</p><p>Since Subversion uses URLs to identify its repository resources, the protocol portion of the URL scheme (usually <code class="literal">file://</code>, <code class="literal">http://</code>, <code class="literal">https://</code>, <code class="literal">svn://</code>, or <code class="literal">svn+ssh://</code>) is used to determine which RA module will handle the communications. Each module registers a list of the protocols it knows how to <span class="quote">“<span class="quote">speak</span>”</span> so that the RA loader can, at runtime, determine which module to use for the task at hand. You can determine which RA modules are available to the Subversion command-line client, and what protocols they claim to support, by running <strong class="userinput"><code>svn --version</code></strong>:</p><div class="informalexample"><pre class="screen"> $ svn --version svn, version 1.7.0 compiled Nov 15 2011, 10:10:24 Copyright (C) 2011 The Apache Software Foundation. This software consists of contributions made by many people; see the NOTICE file for more information. Subversion is open source software, see http://subversion.apache.org/ The following repository access (RA) modules are available: * ra_neon : Module for accessing a repository via WebDAV protocol using Neon. - handles 'http' scheme - handles 'https' scheme * ra_svn : Module for accessing a repository using the svn network protocol. - with Cyrus SASL authentication - handles 'svn' scheme * ra_local : Module for accessing a repository on local disk. - handles 'file' scheme * ra_serf : Module for accessing a repository via WebDAV protocol using serf. - handles 'http' scheme - handles 'https' scheme $ </pre></div><p>The public API exported by the RA layer contains functionality necessary for sending and receiving versioned data to and from the repository. And each of the available RA plug-ins is able to perform that task using a specific protocol—<code class="filename">libsvn_ra_neon</code> and <code class="filename">libsvn_ra_serf</code> speak HTTP/WebDAV (optionally using SSL encryption) with an Apache HTTP Server that is running the <code class="filename">mod_dav_svn</code> Subversion server module; <code class="filename">libsvn_ra_svn</code> speaks a custom network protocol with the <span class="command"><strong>svnserve</strong></span> program; and so on.</p><p>For those who wish to access a Subversion repository using still another protocol, that is precisely why the Repository Access layer is modularized! Developers can simply write a new library that implements the RA interface on one side and communicates with the repository on the other. Your new library can use existing network protocols or you can invent your own. You could use interprocess communication (IPC) calls, or—let's get crazy, shall we?—you could even implement an email-based protocol. Subversion supplies the APIs; you supply the creativity.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.developer.layerlib.client"></a>Client Layer</h3></div></div></div><p>On the client side, the Subversion working copy is where all the action takes place. The bulk of functionality implemented by the client-side libraries exists for the sole purpose of managing working copies—directories full of files and other subdirectories that serve as a sort of local, editable <span class="quote">“<span class="quote">reflection</span>”</span> of one or more repository locations—and propagating changes to and from the Repository Access layer.</p><p>Subversion's working copy library, <code class="filename">libsvn_wc</code>, is directly responsible for managing the data in the working copies. To accomplish this, the library stores administrative information about the working copy within a special subdirectory. This subdirectory, named <code class="filename">.svn</code>, is present in each working copy and contains various other files and directories that record state and provide a private workspace for administrative action. For those familiar with CVS, this <code class="filename">.svn</code> subdirectory is similar in purpose to the <code class="filename">CVS</code> administrative directories found in CVS working copies.</p><p>The Subversion client library, <code class="filename">libsvn_client</code>, has the broadest responsibility; its job is to mingle the functionality of the working copy library with that of the Repository Access layer, and then to provide the highest-level API to any application that wishes to perform general revision control actions. For example, the function <code class="function">svn_client_checkout()</code> takes a URL as an argument. It passes this URL to the RA layer and opens an authenticated session with a particular repository. It then asks the repository for a certain tree, and sends this tree into the working copy library, which then writes a full working copy to disk (<code class="filename">.svn</code> directories and all).</p><p>The client library is designed to be used by any application. While the Subversion source code includes a standard command-line client, it should be very easy to write any number of GUI clients on top of the client library. New GUIs (or any new client, really) for Subversion need not be clunky wrappers around the included command-line client—they have full access via the <code class="filename">libsvn_client</code> API to the same functionality, data, and callback mechanisms that the command-line client uses. In fact, the Subversion source code tree contains a small C program (which you can find at <code class="filename">tools/examples/minimal_client.c</code>) that exemplifies how to wield the Subversion API to create a simple client program.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Binding Directly—A Word About Correctness</strong></p></div></div></div><p>Why should your GUI program bind directly with a <code class="filename">libsvn_client</code> instead of acting as a wrapper around a command-line program? Besides simply being more efficient, it can be more correct as well. A command-line program (such as the one supplied with Subversion) that binds to the client library needs to effectively translate feedback and requested data bits from C types to some form of human-readable output. This type of translation can be lossy. That is, the program may not display all of the information harvested from the API or may combine bits of information for compact representation.</p><p>If you wrap such a command-line program with yet another program, the second program has access only to already interpreted (and as we mentioned, likely incomplete) information, which it must <span class="emphasis"><em>again</em></span> translate into <span class="emphasis"><em>its</em></span> representation format. With each layer of wrapping, the integrity of the original data is potentially tainted more and more, much like the result of making a copy of a copy (of a copy…) of a favorite audio or video cassette.</p><p>But the most compelling argument for binding directly to the APIs instead of wrapping other programs is that the Subversion project makes compatibility promises regarding its APIs. Across minor versions of those APIs (such as between 1.3 and 1.4), no function's prototype will change. In other words, you aren't forced to update your program's source code simply because you've upgraded to a new version of Subversion. Certain functions might be deprecated, but they still work, and this gives you a buffer of time to eventually embrace the newer APIs. These kinds of compatibility promises do not exist for Subversion command-line program output, which is subject to change from release to release.</p></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.developer.usingapi"></a>Using the APIs</h2></div></div></div><p>Developing applications against the Subversion library APIs is fairly straightforward. Subversion is primarily a set of C libraries, with header (<code class="filename">.h</code>) files that live in the <code class="filename">subversion/include</code> directory of the source tree. These headers are copied into your system locations (e.g., <code class="filename">/usr/local/include</code>) when you build and install Subversion itself from source. These headers represent the entirety of the functions and types meant to be accessible by users of the Subversion libraries. The Subversion developer community is meticulous about ensuring that the public API is well documented—refer directly to the header files for that documentation.</p><p>When examining the public header files, the first thing you might notice is that Subversion's datatypes and functions are namespace-protected. That is, every public Subversion symbol name begins with <code class="literal">svn_</code>, followed by a short code for the library in which the symbol is defined (such as <code class="literal">wc</code>, <code class="literal">client</code>, <code class="literal">fs</code>, etc.), followed by a single underscore (<code class="literal">_</code>), and then the rest of the symbol name. Semipublic functions (used among source files of a given library but not by code outside that library, and found inside the library directories themselves) differ from this naming scheme in that instead of a single underscore after the library code, they use a double underscore (<code class="literal">_ _</code>). Functions that are private to a given source file have no special prefixing and are declared <code class="literal">static</code>. Of course, a compiler isn't interested in these naming conventions, but they help to clarify the scope of a given function or datatype.</p><p>Another good source of information about programming against the Subversion APIs is the project's own hacking guidelines, which you can find at <a class="ulink" href="http://subversion.apache.org/docs/community-guide/" target="_top">http://subversion.apache.org/docs/community-guide/</a>. This document contains useful information, which, while aimed at developers and would-be developers of Subversion itself, is equally applicable to folks developing against Subversion as a set of third-party libraries.<a href="#ftn.idm8512" class="footnote" id="idm8512"><sup class="footnote">[68]</sup></a></p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.developer.usingapi.apr"></a>The Apache Portable Runtime Library</h3></div></div></div><p>Along with Subversion's own datatypes, you will see many references to datatypes that begin with <code class="literal">apr_</code>—symbols from the Apache Portable Runtime (APR) library. APR is Apache's portability library, originally carved out of its server code as an attempt to separate the OS-specific bits from the OS-independent portions of the code. The result was a library that provides a generic API for performing operations that differ mildly—or wildly—from OS to OS. While the Apache HTTP Server was obviously the first user of the APR library, the Subversion developers immediately recognized the value of using APR as well. This means that there is practically no OS-specific code in Subversion itself. Also, it means that the Subversion client compiles and runs anywhere that the Apache HTTP Server does. Currently, this list includes all flavors of Unix, Win32, BeOS, OS/2, and Mac OS X.</p><p>In addition to providing consistent implementations of system calls that differ across operating systems,<a href="#ftn.idm8519" class="footnote" id="idm8519"><sup class="footnote">[69]</sup></a> APR gives Subversion immediate access to many custom datatypes, such as dynamic arrays and hash tables. Subversion uses these types extensively. But perhaps the most pervasive APR datatype, found in nearly every Subversion API prototype, is the <code class="literal">apr_pool_t</code>—the APR memory pool. Subversion uses pools internally for all its memory allocation needs (unless an external library requires a different memory management mechanism for data passed through its API),<a href="#ftn.idm8522" class="footnote" id="idm8522"><sup class="footnote">[70]</sup></a> and while a person coding against the Subversion APIs is not required to do the same, she <span class="emphasis"><em>is</em></span> required to provide pools to the API functions that need them. This means that users of the Subversion API must also link against APR, must call <code class="function">apr_initialize()</code> to initialize the APR subsystem, and then must create and manage pools for use with Subversion API calls, typically by using <code class="function">svn_pool_create()</code>, <code class="function">svn_pool_clear()</code>, and <code class="function">svn_pool_destroy()</code>.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>Programming with Memory Pools</strong></p></div></div></div><p>Almost every developer who has used the C programming language has at some point sighed at the daunting task of managing memory usage. Allocating enough memory to use, keeping track of those allocations, freeing the memory when you no longer need it—these tasks can be quite complex. And of course, failure to do those things properly can result in a program that crashes itself, or worse, crashes the computer.</p><p>Higher-level languages, on the other hand, either take the job of memory management away from you completely or make it something you toy with only when doing extremely tight program optimization. Languages such as Java and Python use <em class="firstterm">garbage collection</em>, allocating memory for objects when needed, and automatically freeing that memory when the object is no longer in use.</p><p>APR provides a middle-ground approach called <em class="firstterm">pool-based memory management</em>. It allows the developer to control memory usage at a lower resolution—per chunk (or <span class="quote">“<span class="quote">pool</span>”</span>) of memory, instead of per allocated object. Rather than using <code class="function">malloc()</code> and friends to allocate enough memory for a given object, you ask APR to allocate the memory from a memory pool. When you're finished using the objects you've created in the pool, you destroy the entire pool, effectively de-allocating the memory consumed by <span class="emphasis"><em>all</em></span> the objects you allocated from it. Thus, rather than keeping track of individual objects that need to be de-allocated, your program simply considers the general lifetimes of those objects and allocates the objects in a pool whose lifetime (the time between the pool's creation and its deletion) matches the object's needs.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.developer.usingapi.funcsbatons"></a>Functions and Batons</h3></div></div></div><p>To facilitate <span class="quote">“<span class="quote">streamy</span>”</span> (asynchronous) behavior and provide consumers of the Subversion C API with hooks for handling information in customizable ways, many functions in the API accept pairs of parameters: a pointer to a callback function, and a pointer to a blob of memory called a <em class="firstterm">baton</em> that carries context information for that callback function. Batons are typically C structures with additional information that the callback function needs but which is not given directly to the callback function by the driving API function.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.developer.usingapi.urlpath"></a>URL and Path Requirements</h3></div></div></div><p>With remote version control operation as the whole point of Subversion's existence, it makes sense that some attention has been paid to internationalization (i18n) support. After all, while <span class="quote">“<span class="quote">remote</span>”</span> might mean <span class="quote">“<span class="quote">across the office,</span>”</span> it could just as well mean <span class="quote">“<span class="quote">across the globe.</span>”</span> To facilitate this, all of Subversion's public interfaces that accept path arguments expect those paths to be canonicalized—which is most easily accomplished by passing them through <code class="function">svn_dirent_canonicalize()</code> or <code class="function">svn_uri_canonicalize()</code> (depending on whether you are canonicalizing a local system path or a URL, respectively)—and encoded in UTF-8. This means, for example, that any new client binary that drives the <code class="filename">libsvn_client</code> interface needs to first convert paths from the locale-specific encoding to UTF-8 before passing those paths to the Subversion libraries, and then reconvert any resultant output paths from Subversion back into the locale's encoding before using those paths for non-Subversion purposes. Fortunately, Subversion provides a suite of functions (see <code class="filename">subversion/include/svn_utf.h</code>) that any program can use to do these conversions.</p><p>Also, Subversion APIs require all URL parameters to be properly URI-encoded. So, instead of passing <code class="uri">file:///home/username/My File.txt</code> as the URL of a file named <code class="filename">My File.txt</code>, you need to pass <code class="uri">file:///home/username/My%20File.txt</code>. Again, Subversion supplies helper functions that your application can use—<code class="function">svn_path_uri_encode()</code> and <code class="function">svn_path_uri_decode()</code>, for URI encoding and decoding, respectively.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.developer.usingapi.otherlangs"></a>Using Languages Other Than C and C++</h3></div></div></div><p>If you are interested in using the Subversion libraries in conjunction with something other than a C program—say, a Python or Perl script—Subversion has some support for this via the Simplified Wrapper and Interface Generator (SWIG). The SWIG bindings for Subversion are located in <code class="filename">subversion/bindings/swig</code>. They are still maturing, but they are usable. These bindings allow you to call Subversion API functions indirectly, using wrappers that translate the datatypes native to your scripting language into the datatypes needed by Subversion's C libraries.</p><p>Significant efforts have been made toward creating functional SWIG-generated bindings for Python, Perl, and Ruby. To some extent, the work done preparing the SWIG interface files for these languages is reusable in efforts to generate bindings for other languages supported by SWIG (which include versions of C#, Guile, Java, MzScheme, OCaml, PHP, and Tcl, among others). However, some extra programming is required to compensate for complex APIs that SWIG needs some help translating between languages. For more information on SWIG itself, see the project's web site at <a class="ulink" href="http://www.swig.org/" target="_top">http://www.swig.org/</a>.</p><p>Subversion also has language bindings for Java. The javahl bindings (located in <code class="filename">subversion/bindings/java</code> in the Subversion source tree) aren't SWIG-based, but are instead a mixture of Java and hand-coded JNI. Javahl covers most Subversion client-side APIs and is specifically targeted at implementors of Java-based Subversion clients and IDE integrations.</p><p>Subversion's language bindings tend to lack the level of developer attention given to the core Subversion modules, but can generally be trusted as production-ready. A number of scripts and applications, alternative Subversion GUI clients, and other third-party tools are successfully using Subversion's language bindings today to accomplish their Subversion integrations.</p><p>It's worth noting here that there are other options for interfacing with Subversion using other languages: alternative bindings for Subversion that aren't provided by the Subversion development community at all. There are a couple of popular ones we feel are especially noteworthy. First, Barry Scott's PySVN bindings (<a class="ulink" href="http://pysvn.tigris.org/" target="_top">http://pysvn.tigris.org/</a>) are a popular option for binding with Python. PySVN boasts of a more Pythonic interface than the more C-like APIs provided by Subversion's own Python bindings. And if you're looking for a pure Java implementation of Subversion, check out SVNKit (<a class="ulink" href="http://svnkit.com/" target="_top">http://svnkit.com/</a>), which is Subversion rewritten from the ground up in Java.</p><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong>SVNKit Versus javahl</strong></p></div></div></div><p>In 2005, a small company called TMate announced the 1.0.0 release of JavaSVN—a pure Java implementation of Subversion. Since then, the project has been renamed to SVNKit (available at <a class="ulink" href="http://svnkit.com/" target="_top">http://svnkit.com/</a>) and has seen great success as a provider of Subversion functionality to various Subversion clients, IDE integrations, and other third-party tools.</p><p>The SVNKit library is interesting in that, unlike the javahl library, it is not merely a wrapper around the official Subversion core libraries. In fact, it shares no code with Subversion at all. But while it is easy to confuse SVNKit with javahl, and easier still to not even realize which of these libraries you are using, folks should be aware that SVNKit differs from javahl in some significant ways. First, while SVNKit is developed as open source software just like Subversion, SVNKit's license is more restrictive than that of Subversion.<a href="#ftn.idm8577" class="footnote" id="idm8577"><sup class="footnote">[71]</sup></a> Finally, by aiming to be a pure Java Subversion library, SVNKit is limited in which portions of Subversion can be reasonably cloned while still keeping up with Subversion's releases. This has already happened once—SVNKit cannot access BDB-backed Subversion repositories via the <code class="literal">file://</code> protocol because there's no pure Java implementation of Berkeley DB that is file-format-compatible with the native implementation of that library.</p><p>That said, SVNKit has a well-established track record of reliability. And a pure Java solution is much more robust in the face of programming errors—a bug in SVNKit might raise a catchable Java Exception, but a bug in the Subversion core libraries as accessed via javahl can bring down your entire Java Runtime Environment. So, weigh the costs when choosing a Java-based Subversion implementation.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.developer.usingapi.codesamples"></a>Code Samples</h3></div></div></div><p><a class="xref" href="#svn.developer.layerlib.repos.ex-1" title="Example 8.1. Using the repository layer">Example 8.1, “Using the repository layer”</a> contains a code segment (written in C) that illustrates some of the concepts we've been discussing. It uses both the repository and filesystem interfaces (as can be determined by the prefixes <code class="literal">svn_repos_</code> and <code class="literal">svn_fs_</code> of the function names, respectively) to create a new revision in which a directory is added. You can see the use of an APR pool, which is passed around for memory allocation purposes. Also, the code reveals a somewhat obscure fact about Subversion error handling—all Subversion errors must be explicitly handled to avoid memory leakage (and in some cases, application failure).</p><div class="example"><a id="svn.developer.layerlib.repos.ex-1"></a><p class="title"><strong>Example 8.1. Using the repository layer</strong></p><div class="example-contents"><pre class="programlisting"> /* Convert a Subversion error into a simple boolean error code. * * NOTE: Subversion errors must be cleared (using svn_error_clear()) * because they are allocated from the global pool, else memory * leaking occurs. */ #define INT_ERR(expr) \ do { \ svn_error_t *__temperr = (expr); \ if (__temperr) \ { \ svn_error_clear(__temperr); \ return 1; \ } \ return 0; \ } while (0) /* Create a new directory at the path NEW_DIRECTORY in the Subversion * repository located at REPOS_PATH. Perform all memory allocation in * POOL. This function will create a new revision for the addition of * NEW_DIRECTORY. Return zero if the operation completes * successfully, nonzero otherwise. */ static int make_new_directory(const char *repos_path, const char *new_directory, apr_pool_t *pool) { svn_error_t *err; svn_repos_t *repos; svn_fs_t *fs; svn_revnum_t youngest_rev; svn_fs_txn_t *txn; svn_fs_root_t *txn_root; const char *conflict_str; /* Open the repository located at REPOS_PATH. */ INT_ERR(svn_repos_open(&amp;repos, repos_path, pool)); /* Get a pointer to the filesystem object that is stored in REPOS. */ fs = svn_repos_fs(repos); /* Ask the filesystem to tell us the youngest revision that * currently exists. */ INT_ERR(svn_fs_youngest_rev(&amp;youngest_rev, fs, pool)); /* Begin a new transaction that is based on YOUNGEST_REV. We are * less likely to have our later commit rejected as conflicting if we * always try to make our changes against a copy of the latest snapshot * of the filesystem tree. */ INT_ERR(svn_repos_fs_begin_txn_for_commit2(&amp;txn, repos, youngest_rev, apr_hash_make(pool), pool)); /* Now that we have started a new Subversion transaction, get a root * object that represents that transaction. */ INT_ERR(svn_fs_txn_root(&amp;txn_root, txn, pool)); /* Create our new directory under the transaction root, at the path * NEW_DIRECTORY. */ INT_ERR(svn_fs_make_dir(txn_root, new_directory, pool)); /* Commit the transaction, creating a new revision of the filesystem * which includes our added directory path. */ err = svn_repos_fs_commit_txn(&amp;conflict_str, repos, &amp;youngest_rev, txn, pool); if (! err) { /* No error? Excellent! Print a brief report of our success. */ printf("Directory '%s' was successfully added as new revision " "'%ld'.\n", new_directory, youngest_rev); } else if (err-&gt;apr_err == SVN_ERR_FS_CONFLICT) { /* Uh-oh. Our commit failed as the result of a conflict * (someone else seems to have made changes to the same area * of the filesystem that we tried to modify). Print an error * message. */ printf("A conflict occurred at path '%s' while attempting " "to add directory '%s' to the repository at '%s'.\n", conflict_str, new_directory, repos_path); } else { /* Some other error has occurred. Print an error message. */ printf("An error occurred while attempting to add directory '%s' " "to the repository at '%s'.\n", new_directory, repos_path); } INT_ERR(err); } </pre></div></div><br class="example-break"></br><p>Note that in <a class="xref" href="#svn.developer.layerlib.repos.ex-1" title="Example 8.1. Using the repository layer">Example 8.1, “Using the repository layer”</a>, the code could just as easily have committed the transaction using <code class="function">svn_fs_commit_txn()</code>. But the filesystem API knows nothing about the repository library's hook mechanism. If you want your Subversion repository to automatically perform some set of non-Subversion tasks every time you commit a transaction (e.g., sending an email that describes all the changes made in that transaction to your developer mailing list), you need to use the <code class="filename">libsvn_repos</code>-wrapped version of that function, which adds the hook triggering functionality—in this case, <code class="function">svn_repos_fs_commit_txn()</code>. (For more information regarding Subversion's repository hooks, see <a class="xref" href="#svn.reposadmin.create.hooks" title="Implementing Repository Hooks">the section called “Implementing Repository Hooks”</a>.)</p><p>Now let's switch languages. <a class="xref" href="#svn.developer.usingapi.otherlangs.ex-1" title="Example 8.2. Using the repository layer with Python">Example 8.2, “Using the repository layer with Python”</a> is a sample program that uses Subversion's SWIG Python bindings to recursively crawl the youngest repository revision, and to print the various paths reached during the crawl.</p><div class="example"><a id="svn.developer.usingapi.otherlangs.ex-1"></a><p class="title"><strong>Example 8.2. Using the repository layer with Python</strong></p><div class="example-contents"><pre class="programlisting"> #!/usr/bin/python """Crawl a repository, printing versioned object path names.""" import sys import os.path import svn.fs, svn.core, svn.repos def crawl_filesystem_dir(root, directory): """Recursively crawl DIRECTORY under ROOT in the filesystem, and return a list of all the paths at or below DIRECTORY.""" # Print the name of this path. print directory + "/" # Get the directory entries for DIRECTORY. entries = svn.fs.svn_fs_dir_entries(root, directory) # Loop over the entries. names = entries.keys() for name in names: # Calculate the entry's full path. full_path = directory + '/' + name # If the entry is a directory, recurse. The recursion will return # a list with the entry and all its children, which we will add to # our running list of paths. if svn.fs.svn_fs_is_dir(root, full_path): crawl_filesystem_dir(root, full_path) else: # Else it's a file, so print its path here. print full_path def crawl_youngest(repos_path): """Open the repository at REPOS_PATH, and recursively crawl its youngest revision.""" # Open the repository at REPOS_PATH, and get a reference to its # versioning filesystem. repos_obj = svn.repos.svn_repos_open(repos_path) fs_obj = svn.repos.svn_repos_fs(repos_obj) # Query the current youngest revision. youngest_rev = svn.fs.svn_fs_youngest_rev(fs_obj) # Open a root object representing the youngest (HEAD) revision. root_obj = svn.fs.svn_fs_revision_root(fs_obj, youngest_rev) # Do the recursive crawl. crawl_filesystem_dir(root_obj, "") if __name__ == "__main__": # Check for sane usage. if len(sys.argv) != 2: sys.stderr.write("Usage: %s REPOS_PATH\n" % (os.path.basename(sys.argv[0]))) sys.exit(1) # Canonicalize the repository path. repos_path = svn.core.svn_dirent_canonicalize(sys.argv[1]) # Do the real work. crawl_youngest(repos_path) </pre></div></div><br class="example-break"></br><p>This same program in C would need to deal with APR's memory pool system. But Python handles memory usage automatically, and Subversion's Python bindings adhere to that convention. In C, you'd be working with custom datatypes (such as those provided by the APR library) for representing the hash of entries and the list of paths, but Python has hashes (called <span class="quote">“<span class="quote">dictionaries</span>”</span>) and lists as built-in datatypes, and it provides a rich collection of functions for operating on those types. So SWIG (with the help of some customizations in Subversion's language bindings layer) takes care of mapping those custom datatypes into the native datatypes of the target language. This provides a more intuitive interface for users of that language.</p><p>The Subversion Python bindings can be used for working copy operations, too. In the previous section of this chapter, we mentioned the <code class="filename">libsvn_client</code> interface and how it exists for the sole purpose of simplifying the process of writing a Subversion client. <a class="xref" href="#svn.developer.usingapi.otherlangs.ex-2" title="Example 8.3. A Python status crawler">Example 8.3, “A Python status crawler”</a> is a brief example of how that library can be accessed via the SWIG Python bindings to re-create a scaled-down version of the <span class="command"><strong>svn status</strong></span> command.</p><div class="example"><a id="svn.developer.usingapi.otherlangs.ex-2"></a><p class="title"><strong>Example 8.3. A Python status crawler</strong></p><div class="example-contents"><pre class="programlisting"> #!/usr/bin/env python """Crawl a working copy directory, printing status information.""" import sys import os.path import getopt import svn.core, svn.client, svn.wc def generate_status_code(status): """Translate a status value into a single-character status code, using the same logic as the Subversion command-line client.""" code_map = { svn.wc.svn_wc_status_none : ' ', svn.wc.svn_wc_status_normal : ' ', svn.wc.svn_wc_status_added : 'A', svn.wc.svn_wc_status_missing : '!', svn.wc.svn_wc_status_incomplete : '!', svn.wc.svn_wc_status_deleted : 'D', svn.wc.svn_wc_status_replaced : 'R', svn.wc.svn_wc_status_modified : 'M', svn.wc.svn_wc_status_conflicted : 'C', svn.wc.svn_wc_status_obstructed : '~', svn.wc.svn_wc_status_ignored : 'I', svn.wc.svn_wc_status_external : 'X', svn.wc.svn_wc_status_unversioned : '?', } return code_map.get(status, '?') def do_status(wc_path, verbose, prefix): # Build a client context baton. ctx = svn.client.svn_client_create_context() def _status_callback(path, status): """A callback function for svn_client_status.""" # Print the path, minus the bit that overlaps with the root of # the status crawl text_status = generate_status_code(status.text_status) prop_status = generate_status_code(status.prop_status) prefix_text = '' if prefix is not None: prefix_text = prefix + " " print '%s%s%s %s' % (prefix_text, text_status, prop_status, path) # Do the status crawl, using _status_callback() as our callback function. revision = svn.core.svn_opt_revision_t() revision.type = svn.core.svn_opt_revision_head svn.client.svn_client_status2(wc_path, revision, _status_callback, svn.core.svn_depth_infinity, verbose, 0, 0, 1, ctx) def usage_and_exit(errorcode): """Print usage message, and exit with ERRORCODE.""" stream = errorcode and sys.stderr or sys.stdout stream.write("""Usage: %s OPTIONS WC-PATH Print working copy status, optionally with a bit of prefix text. Options: --help, -h : Show this usage message --prefix ARG : Print ARG, followed by a space, before each line of output --verbose, -v : Show all statuses, even uninteresting ones """ % (os.path.basename(sys.argv[0]))) sys.exit(errorcode) if __name__ == '__main__': # Parse command-line options. try: opts, args = getopt.getopt(sys.argv[1:], "hv", ["help", "prefix=", "verbose"]) except getopt.GetoptError: usage_and_exit(1) verbose = 0 prefix = None for opt, arg in opts: if opt in ("-h", "--help"): usage_and_exit(0) if opt in ("--prefix"): prefix = arg if opt in ("-v", "--verbose"): verbose = 1 if len(args) != 1: usage_and_exit(2) # Canonicalize the working copy path. wc_path = svn.core.svn_dirent_canonicalize(args[0]) # Do the real work. try: do_status(wc_path, verbose, prefix) except svn.core.SubversionException, e: sys.stderr.write("Error (%d): %s\n" % (e.apr_err, e.message)) sys.exit(1) </pre></div></div><br class="example-break"></br><p>As was the case in <a class="xref" href="#svn.developer.usingapi.otherlangs.ex-1" title="Example 8.2. Using the repository layer with Python">Example 8.2, “Using the repository layer with Python”</a>, this program is pool-free and uses, for the most part, normal Python datatypes.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Run user-provided paths through the appropriate canonicalization function (<code class="function">svn_dirent_canonicalize()</code> or <code class="function">svn_uri_canonicalize()</code>) before passing them to other API functions. Failure to do so can trigger assertions in the underlying Subversion C library which translate into rather immediate and unceremonious program abortion.</p></td></tr></table></div><p>Of particular interest to users of the Python flavor of Subversion's API is the implementation of callback functions. As previously mentioned, Subversion's C API makes liberal use of the callback function/baton paradigm. API functions which in C accept a function and baton pair only accept a callback function parameter in Python. How, then, does the caller pass arbitrary context information to the callback function? In Python, this is done by taking advantage of Python's scoping rules and default argument values. You can see this in action in <a class="xref" href="#svn.developer.usingapi.otherlangs.ex-2" title="Example 8.3. A Python status crawler">Example 8.3, “A Python status crawler”</a>. The <code class="function">svn_client_status2()</code> function is given a callback function (<code class="function">_status_callback()</code>) but no baton—<code class="function">_status_callback()</code> gets access to the user-provided prefix string because that variable falls into the scope of the function automatically.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.developer.summary"></a>Summary</h2></div></div></div><p>One of Subversion's greatest features isn't something you get from running its command-line client or other tools. It's the fact that Subversion was designed modularly and provides a stable, public API so that others—like yourself, perhaps—can write custom software that drives Subversion's core logic.</p><p>In this chapter, we took a closer look at Subversion's architecture, examining its logical layers and describing that public API, the very same API that Subversion's own layers use to communicate with each other. Many developers have found interesting uses for the Subversion API, from simple repository hook scripts, to integrations between Subversion and some other application, to completely different version control systems. What unique itch will <span class="emphasis"><em>you</em></span> scratch with it?</p></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm8411" class="footnote"><p><a href="#idm8411" class="para"><sup class="para">[67] </sup></a>We understand that this may come as a shock to sci-fi fans who have long been under the impression that Time was actually the <span class="emphasis"><em>fourth</em></span> dimension, and we apologize for any emotional trauma induced by our assertion of a different theory.</p></div><div id="ftn.idm8512" class="footnote"><p><a href="#idm8512" class="para"><sup class="para">[68] </sup></a>After all, Subversion uses Subversion's APIs, too.</p></div><div id="ftn.idm8519" class="footnote"><p><a href="#idm8519" class="para"><sup class="para">[69] </sup></a>Subversion uses ANSI system calls and datatypes as much as possible.</p></div><div id="ftn.idm8522" class="footnote"><p><a href="#idm8522" class="para"><sup class="para">[70] </sup></a>Neon and Berkeley DB are examples of such libraries.</p></div><div id="ftn.idm8577" class="footnote"><p><a href="#idm8577" class="para"><sup class="para">[71] </sup></a>Redistributions in any form must be accompanied by information on how to obtain complete source code for the software that uses SVNKit and any accompanying software that uses the software that uses SVNKit. See <a class="ulink" href="http://svnkit.com/license.html" target="_top">http://svnkit.com/license.html</a> for details.</p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="svn.ref"></a>Chapter 9. Subversion Complete Reference</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.ref.svn">svn—Subversion Command-Line Client</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svn.sw">svn Options</a></span></dt><dt><span class="sect2"><a href="#svn.ref.svn.c">svn Subcommands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.add">svn add</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.blame">svn blame (praise, annotate, ann)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.cat">svn cat</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.changelist">svn changelist (cl)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.checkout">svn checkout (co)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.cleanup">svn cleanup</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.commit">svn commit (ci)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.copy">svn copy (cp)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.delete">svn delete (del, remove, rm)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.diff">svn diff (di)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.export">svn export</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.help">svn help (h, ?)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.import">svn import</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.info">svn info</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.list">svn list (ls)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.lock">svn lock</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.log">svn log</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.merge">svn merge</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.mergeinfo">svn mergeinfo</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.mkdir">svn mkdir</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.move">svn move (mv)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.patch">svn patch</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.propdel">svn propdel (pdel, pd)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.propedit">svn propedit (pedit, pe)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.propget">svn propget (pget, pg)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.proplist">svn proplist (plist, pl)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.propset">svn propset (pset, ps)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.relocate">svn relocate</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.resolve">svn resolve</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.resolved">svn resolved</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.revert">svn revert</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.status">svn status (stat, st)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.switch">svn switch (sw)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.unlock">svn unlock</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.update">svn update (up)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svn.c.upgrade">svn upgrade</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.ref.svnadmin">svnadmin—Subversion Repository Administration</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svnadmin.sw">svnadmin Options</a></span></dt><dt><span class="sect2"><a href="#svn.ref.svnadmin.c">svnadmin Subcommands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.crashtest">svnadmin crashtest</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.create">svnadmin create</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.deltify">svnadmin deltify</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.dump">svnadmin dump</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.help">svnadmin help (h, ?)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.hotcopy">svnadmin hotcopy</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.list-dblogs">svnadmin list-dblogs</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.list-unused-dblogs">svnadmin list-unused-dblogs</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.load">svnadmin load</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.lslocks">svnadmin lslocks</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.lstxns">svnadmin lstxns</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.pack">svnadmin pack</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.recover">svnadmin recover</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.rmlocks">svnadmin rmlocks</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.rmtxns">svnadmin rmtxns</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.setlog">svnadmin setlog</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.setrevprop">svnadmin setrevprop</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.setuuid">svnadmin setuuid</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.upgrade">svnadmin upgrade</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnadmin.c.verify">svnadmin verify</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.ref.svnlook">svnlook—Subversion Repository Examination</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svnlook.sw">svnlook Options</a></span></dt><dt><span class="sect2"><a href="#svn.ref.svnlook.c">svnlook Subcommands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.author">svnlook author</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.cat">svnlook cat</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.changed">svnlook changed</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.date">svnlook date</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.diff">svnlook diff</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.dirs-changed">svnlook dirs-changed</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.filesize">svnlook filesize</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.help">svnlook help (h, ?)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.history">svnlook history</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.info">svnlook info</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.lock">svnlook lock</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.log">svnlook log</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.propget">svnlook propget (pget, pg)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.proplist">svnlook proplist (plist, pl)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.tree">svnlook tree</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.uuid">svnlook uuid</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnlook.c.youngest">svnlook youngest</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.ref.svnsync">svnsync—Subversion Repository Mirroring</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svnsync.sw">svnsync Options</a></span></dt><dt><span class="sect2"><a href="#svn.ref.svnsync.c">svnsync Subcommands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svnsync.c.copy-revprops">svnsync copy-revprops</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnsync.c.help">svnsync help</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnsync.c.info">svnsync info</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnsync.c.init">svnsync initialize (init)</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnsync.c.sync">svnsync synchronize (sync)</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.ref.svnrdump">svnrdump—Remote Subversion Repository Data Migration</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svnrdump.sw">svnrdump Options</a></span></dt><dt><span class="sect2"><a href="#svn.ref.svnrdump.c">svnrdump Subcommands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svnrdump.c.dump">svnrdump dump</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnrdump.c.help">svnrdump help</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svnrdump.c.load">svnrdump load</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.ref.svnserve">svnserve—Custom Subversion Server</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svnserve.sw">svnserve Options</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.ref.svndumpfilter">svndumpfilter—Subversion History Filtering</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.svndumpfilter.options">svndumpfilter Options</a></span></dt><dt><span class="sect2"><a href="#svn.ref.svndumpfilter.c">svndumpfilter Subcommands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svndumpfilter.commands.c.exclude">svndumpfilter exclude</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svndumpfilter.commands.c.include">svndumpfilter include</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.svndumpfilter.commands.c.help">svndumpfilter help</a></span><span class="refpurpose"></span></dt></dl></dd></dl></dd><dt><span class="sect1"><a href="#svn.ref.svnversion">svnversion—Subversion Working Copy Version Info</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.svnversion.re">svnversion</a></span><span class="refpurpose"></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.ref.mod_dav_svn">mod_dav_svn—Subversion Apache HTTP Server Module</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.mod_dav_svn.conf">mod_dav_svn Configuration Directives</a></span><span class="refpurpose"></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.ref.mod_authz_svn">mod_authz_svn—Subversion Apache HTTP Authorization Module</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.mod_authz_svn.conf">mod_authz_svn Configuration Directives</a></span><span class="refpurpose"></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.ref.properties">Subversion Properties</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.ref.properties.versioned-props">Versioned Properties</a></span></dt><dt><span class="sect2"><a href="#svn.ref.properties.unversioned-props">Unversioned Properties</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.ref.reposhooks">Repository Hooks</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.start-commit">start-commit</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.pre-commit">pre-commit</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.post-commit">post-commit</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.pre-revprop-change">pre-revprop-change</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.post-revprop-change">post-revprop-change</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.pre-lock">pre-lock</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.post-lock">post-lock</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.pre-unlock">pre-unlock</a></span><span class="refpurpose"></span></dt><dt><span class="refentrytitle"><a href="#svn.ref.reposhooks.post-unlock">post-unlock</a></span><span class="refpurpose"></span></dt></dl></dd></dl></div><p>This chapter is intended to be a complete reference to using Subversion. It includes command summaries and examples for all the command-line tools provided as part of the stock Subversion distribution, configuration information for the Subversion server modules, and other information that lends itself to a reference format.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.ref.svn"></a>svn—Subversion Command-Line Client</h2></div></div></div><p><span class="command"><strong>svn</strong></span> is the official command-line client of Subversion. Its functionality is offered via a collection of task-specific subcommands, most of which accept a number of options for fine-grained control of the program's behavior.</p><p>When using the <span class="command"><strong>svn</strong></span> program, subcommands and other non-option arguments must appear in a specified order on the command line. Options, on the other hand, may appear anywhere on the command line (after the program name, of course), and in general, their order is irrelevant. For example, all of the following are valid ways to use <span class="command"><strong>svn status</strong></span>, and are interpreted in exactly the same way:</p><div class="informalexample"><pre class="screen"> $ svn -vq status myfile $ svn status -v -q myfile $ svn -q status -v myfile $ svn status -vq myfile $ svn status myfile -qv </pre></div><p>The following sections describe each of the various subcommands and options provided by the <span class="command"><strong>svn</strong></span> command-line client program, including some examples of each subcommand's typical uses.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svn.sw"></a>svn Options</h3></div></div></div><p>While Subversion has different options for its subcommands, all options exist in a single namespace—that is, each option is guaranteed to mean the roughly same thing regardless of the subcommand you use it with. For example, <code class="option">--verbose</code> (<code class="option">-v</code>) always means <span class="quote">“<span class="quote">verbose output,</span>”</span> regardless of the subcommand you use it with.</p><p>The <span class="command"><strong>svn</strong></span> command-line client usually exits quickly with an error if you pass it an option which does not apply to the specified subcommand. But as of Subversion 1.5, several of the options which apply to all—or nearly all—of the subcommands have been deemed acceptable by all subcommands, even if they have no effect on some of them. (This change was made primarily to improve the client's ability to called from custom wrapping scripts.) These options appear grouped together in the command-line client's usage messages as global options, as can be seen in the following bit of output:</p><div class="informalexample"><pre class="screen"> $ svn help upgrade upgrade: Upgrade the metadata storage format for a working copy. usage: upgrade [WCPATH...] Local modifications are preserved. Valid options: -q [--quiet] : print nothing, or only summary information Global options: --username ARG : specify a username ARG --password ARG : specify a password ARG --no-auth-cache : do not cache authentication tokens --non-interactive : do no interactive prompting --trust-server-cert : accept SSL server certificates from unknown certificate authorities without prompting (but only with '--non-interactive') --config-dir ARG : read user configuration files from directory ARG --config-option ARG : set user configuration option in the format: FILE:SECTION:OPTION=[VALUE] For example: servers:global:http-library=serf $ </pre></div><p><span class="command"><strong>svn</strong></span> subcommands recognize the following global options:</p><div class="variablelist"><dl class="variablelist"><dt><a id="svn.ref.svn.sw.config_dir"></a><span class="term"><code class="option">--config-dir</code> <em class="replaceable"><code>DIR</code></em></span></dt><dd><p>Instructs Subversion to read configuration information from the specified directory instead of the default location (<code class="filename">.subversion</code> in the user's home directory).</p></dd><dt><a id="svn.ref.svn.sw.config_option"></a><span class="term"><code class="option">--config-option</code> <em class="replaceable"><code>CONFSPEC</code></em></span></dt><dd><p>Sets, for the duration of the command, the value of a runtime configuration option. <em class="replaceable"><code>CONFSPEC</code></em> is a string which specifies the configuration option namespace, name and value that you'd like to assign, formatted as <em class="replaceable"><code>FILE</code></em>:<em class="replaceable"><code>SECTION</code></em>:<em class="replaceable"><code>OPTION</code></em>=[<em class="replaceable"><code>VALUE</code></em>]. In this syntax, <em class="replaceable"><code>FILE</code></em> and <em class="replaceable"><code>SECTION</code></em> are the runtime configuration file (either <code class="literal">config</code> or <code class="literal">servers</code>) and the section thereof, respectively, which contain the option whose value you wish to change. <em class="replaceable"><code>OPTION</code></em> is, of course, the option itself, and <em class="replaceable"><code>VALUE</code></em> the value (if any) you wish to assign to the option. For example, to temporarily disable the use of the compression in the HTTP protocol, use <code class="option">--config-option=servers:global:http-compression=no</code>. You can use this option multiple times to change multiple option values simultaneously.</p></dd><dt><a id="svn.ref.svn.sw.no_auth_cache"></a><span class="term"><code class="option">--no-auth-cache</code></span></dt><dd><p>Prevents caching of authentication information (e.g., username and password) in the Subversion runtime configuration directories.</p></dd><dt><a id="svn.ref.svn.sw.non_interactive"></a><span class="term"><code class="option">--non-interactive</code></span></dt><dd><p>Disables all interactive prompting. Some examples of interactive prompting include requests for authentication credentials and conflict resolution decisions. This is useful if you're running Subversion inside an automated script and it's more appropriate to have Subversion fail than to prompt for more information.</p></dd><dt><a id="svn.ref.svn.sw.password"></a><span class="term"><code class="option">--password</code> <em class="replaceable"><code>PASSWD</code></em></span></dt><dd><p>Specifies the password to use when authenticating against a Subversion server. If not provided, or if incorrect, Subversion will prompt you for this information as needed.</p></dd><dt><a id="svn.ref.svn.sw.trust_server_cert"></a><span class="term"><code class="option">--trust-server-cert</code></span></dt><dd><p>When used with <code class="option">--non-interactive</code>, instructs Subversion to accept SSL server certificates issued by unknown certificate authorities without first prompting the user. For security's sake, you should use this option only when the integrity of the remote server and the network path between it and your client is known to be trustworthy.</p></dd><dt><a id="svn.ref.svn.sw.username"></a><span class="term"><code class="option">--username</code> <em class="replaceable"><code>NAME</code></em></span></dt><dd><p>Specifies the username to use when authenticating against a Subversion server. If not provided, or if incorrect, Subversion will prompt you for this information as needed.</p></dd></dl></div><p>The rest of the options apply and are accepted by only a subset of the subcommand. They are as follows:</p><div class="variablelist"><dl class="variablelist"><dt><a id="svn.ref.svn.sw.accept"></a><span class="term"><code class="option">--accept</code> <em class="replaceable"><code>ACTION</code></em></span></dt><dd><p>Specifies an action for automatic conflict resolution, disabling the interactive prompts which ask the user how to handle each conflict as it is noticed. Though which of the specific actions are applicable differs depending on which subcommand is in use, Subversion supports the following long (and short) values for <em class="replaceable"><code>ACTION</code></em>:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">postpone</code> (<code class="literal">p</code>)</span></dt><dd><p>Take no resolution action at all and instead allow the conflicts to be recorded for future resolution.</p></dd><dt><span class="term"><code class="literal">edit</code> (<code class="literal">e</code>)</span></dt><dd><p>Open each conflicted file in a text editor for manual resolution of line-based conflicts.</p></dd><dt><span class="term"><code class="literal">launch</code> (<code class="literal">l</code>)</span></dt><dd><p>Launch an interactive merge conflict resolution tool for each conflicted file.</p></dd><dt><span class="term"><code class="literal">base</code></span></dt><dd><p>Choose the file that was the (unmodified) <code class="literal">BASE</code> revision before you tried to integrate changes from the server into your working copy.</p></dd><dt><span class="term"><code class="literal">working</code></span></dt><dd><p>Assuming that you've manually handled the conflict resolution, choose the version of the file as it currently stands in your working copy.</p></dd><dt><span class="term"><code class="literal">mine-full</code> (<code class="literal">mf</code>)</span></dt><dd><p>Resolve conflicted files by preserving all local modifications and discarding all changes fetched from the server during the operation which caused the conflict.</p></dd><dt><span class="term"><code class="literal">theirs-full</code> (<code class="literal">tf</code>)</span></dt><dd><p>Resolve conflicted files by discarding all local modifications and integrating all changes fetched from the server during the operation which caused the conflict.</p></dd><dt><span class="term"><code class="literal">mine-conflict</code> (<code class="literal">mc</code>)</span></dt><dd><p>Resolve conflicted files by preferring local modifications over the changes fetched from the server in conflicting regions of each file's content.</p></dd><dt><span class="term"><code class="literal">theirs-conflict</code> (<code class="literal">tc</code>)</span></dt><dd><p>Resolve conflicted files by preferring the changes fetched from the server over local modifications in conflicting regions of each file's content.</p></dd></dl></div><p>Consult the output of <span class="command"><strong>svn help <em class="replaceable"><code>SUBCOMMAND</code></em></strong></span> to see exactly which actions are supported by the specific subcommand of interest.</p></dd><dt><a id="svn.ref.svn.sw.allow_mixed_revisions"></a><span class="term"><code class="option">--allow-mixed-revisions</code></span></dt><dd><p>Disables the verification—performed by default by <span class="command"><strong>svn merge</strong></span> as of Subversion 1.7—that the target of a merge operation and all of its children are at a uniform revision. While merging into a single-revision working copy target is the recommended best practice, this option may be used to permit merges into mixed-revision working copies as necessary.</p></dd><dt><a id="svn.ref.svn.sw.auto_props"></a><span class="term"><code class="option">--auto-props</code></span></dt><dd><p>Enables automatic property assignment (per runtime configuration rules), overriding the <code class="literal">enable-auto-props</code> runtime configuration directive.</p></dd><dt><a id="svn.ref.svn.sw.change"></a><span class="term"><code class="option">--change</code> (<code class="option">-c</code>) <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Perform the requested operation using a specific <span class="quote">“<span class="quote">change</span>”</span>. Generally speaking, this option is syntactic sugar for <strong class="userinput"><code>-r <em class="replaceable"><code>ARG-1</code></em>:<em class="replaceable"><code>ARG</code></em></code></strong>. Some subcommands permit a comma-separated list of revision number arguments (e.g., <strong class="userinput"><code>-c <em class="replaceable"><code>ARG1</code></em>,<em class="replaceable"><code>ARG2</code></em>,<em class="replaceable"><code>ARG3</code></em></code></strong>). Alternatively, you can provide two arguments separated by a dash (as in <strong class="userinput"><code>-c <em class="replaceable"><code>ARG1</code></em>-<em class="replaceable"><code>ARG2</code></em></code></strong>) to identify the range of revisions between <em class="replaceable"><code>ARG1</code></em> and <em class="replaceable"><code>ARG2</code></em>, inclusive. Finally, if the revision argument is negated, the implied revision range is reversed: <strong class="userinput"><code>-c -45</code></strong> is equivalent to <strong class="userinput"><code>-r 45:44</code></strong>.</p></dd><dt><a id="svn.ref.svn.sw.changelist"></a><span class="term"><code class="option">--changelist</code> (<code class="option">--cl</code>) <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Instructs Subversion to operate only on members of the changelist named <em class="replaceable"><code>ARG</code></em>. You can use this option multiple times to specify sets of changelists.</p></dd><dt><a id="svn.ref.svn.sw.depth"></a><span class="term"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Instructs Subversion to limit the scope of an operation to a particular tree depth. <em class="replaceable"><code>ARG</code></em> is one of <code class="literal">empty</code> (only the target itself), <code class="literal">files</code> (the target and any immediate file children thereof), <code class="literal">immediates</code> (the target and any immediate children thereof), or <code class="literal">infinity</code> (the target and all of its descendants—full recursion).</p></dd><dt><a id="svn.ref.svn.sw.diff"></a><span class="term"><code class="option">--diff</code></span></dt><dd><p>Enables a special output mode for <span class="command"><strong>svn log</strong></span> which includes a difference report (a la <span class="command"><strong>svn diff</strong></span>) as part of each revision's information.</p></dd><dt><a id="svn.ref.svn.sw.diff_cmd"></a><span class="term"><code class="option">--diff-cmd</code> <em class="replaceable"><code>CMD</code></em></span></dt><dd><p>Specifies an external program to use to show differences between files. When <span class="command"><strong>svn diff</strong></span> is invoked without this option, it uses Subversion's internal differencing engine, which provides unified diffs by default. If you want to use an external differencing program, use <code class="option">--diff-cmd</code>. You can then pass options to the specified program using the <code class="option">--extensions</code> (<code class="option">-x</code>) option.</p></dd><dt><a id="svn.ref.svn.sw.diff3_cmd"></a><span class="term"><code class="option">--diff3-cmd</code> <em class="replaceable"><code>CMD</code></em></span></dt><dd><p>Specifies an external 3-way differencing program (used to merge line-based changes into files).</p></dd><dt><a id="svn.ref.svn.sw.dry_run"></a><span class="term"><code class="option">--dry-run</code></span></dt><dd><p>Goes through all the motions of running a command, but makes no actual changes—either on disk or in the repository.</p></dd><dt><a id="svn.ref.svn.sw.editor_cmd"></a><span class="term"><code class="option">--editor-cmd</code> <em class="replaceable"><code>CMD</code></em></span></dt><dd><p>Specifies an external program to use to edit a log message or a property value. See the <code class="literal">editor-cmd</code> section in <a class="xref" href="#svn.advanced.confarea.opts.config" title="Config">the section called “Config”</a> for ways to specify a default editor.</p></dd><dt><a id="svn.ref.svn.sw.encoding"></a><span class="term"><code class="option">--encoding</code> <em class="replaceable"><code>ENC</code></em></span></dt><dd><p>Tells Subversion that your commit message is composed using the character encoding provided. The default character encoding is derived from your operating system's native locale; use this option if your commit message is composed using any other encoding.</p></dd><dt><a id="svn.ref.svn.sw.extensions"></a><span class="term"><code class="option">--extensions</code> (<code class="option">-x</code>) <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Specifies customizations which Subversion should make when performing difference calculations. Valid extensions include:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--ignore-space-change</code> (<code class="option">-b</code>)</span></dt><dd><p>Ignore changes in the amount of white space.</p></dd><dt><span class="term"><code class="option">--ignore-all-space</code> (<code class="option">-w</code>)</span></dt><dd><p>Ignore all white space.</p></dd><dt><span class="term"><code class="option">--ignore-eol-style</code></span></dt><dd><p>Ignore changes in EOL (end-of-line) style.</p></dd><dt><span class="term"><code class="option">--show-c-function</code> (<code class="option">-p</code>)</span></dt><dd><p>Show C function names in the diff output.</p></dd><dt><span class="term"><code class="option">--unified</code> (<code class="option">-u</code>)</span></dt><dd><p>Show three lines of unified diff context.</p></dd></dl></div><p>The default value of <em class="replaceable"><code>ARG</code></em> is <code class="literal">-u</code>. If you wish to pass multiple arguments, you must enclose all of them in quotes.</p><p>Note that when Subversion is configured to invoke an external diff command, the value of the <code class="option">--extension</code> (<code class="option">-x</code>) option isn't restricted to the previously mentioned options, but may be <span class="emphasis"><em>any</em></span> additional arguments which Subversion should pass to that command.</p></dd><dt><a id="svn.ref.svn.sw.file"></a><span class="term"><code class="option">--file</code> (<code class="option">-F</code>) <em class="replaceable"><code>FILENAME</code></em></span></dt><dd><p>Uses the contents of the named file for the specified subcommand. Different subcommands do different things with this content. For example, <span class="command"><strong>svn commit</strong></span> uses the content as a commit log message, whereas <span class="command"><strong>svn propset</strong></span> uses it as a property value.</p></dd><dt><a id="svn.ref.svn.sw.force"></a><span class="term"><code class="option">--force</code></span></dt><dd><p>Forces a particular command or operation to run. Subversion will prevent you from performing some operations in normal usage, but you can pass this option to tell Subversion <span class="quote">“<span class="quote">I know what I'm doing as well as the possible repercussions of doing it, so let me at 'em.</span>”</span> This option is the programmatic equivalent of doing your own electrical work with the power on—if you don't know what you're doing, you're likely to get a nasty shock.</p></dd><dt><a id="svn.ref.svn.sw.force_log"></a><span class="term"><code class="option">--force-log</code></span></dt><dd><p>Forces a suspicious parameter passed to the <code class="option">--message</code> (<code class="option">-m</code>) or <code class="option">--file</code> (<code class="option">-F</code>) option to be accepted as valid. By default, Subversion will produce an error if parameters to these options look like they might instead be targets of the subcommand. For example, if you pass a versioned file's path to the <code class="option">--file</code> (<code class="option">-F</code>) option, Subversion will assume you've made a mistake, that the path was instead intended as the target of the operation, and that you simply failed to provide some other—unversioned—file as the source of your log message. To assert your intent and override these types of errors, pass the <code class="option">--force-log</code> option to subcommands that accept log messages.</p></dd><dt><a id="svn.ref.svn.sw.git"></a><span class="term"><code class="option">--git</code></span></dt><dd><p>Enables a special output mode for <span class="command"><strong>svn diff</strong></span> designed for cross-compatibility with the popular Git distributed version control system.</p></dd><dt><a id="svn.ref.svn.sw.help"></a><span class="term"><code class="option">--help</code> (<code class="option">-h</code>, <code class="option">-?</code>)</span></dt><dd><p>If used with one or more subcommands, shows the built-in help text for each. If used alone, it displays the general client help text.</p></dd><dt><a id="svn.ref.svn.sw.ignore_ancestry"></a><span class="term"><code class="option">--ignore-ancestry</code></span></dt><dd><p>Tells Subversion to ignore ancestry when calculating differences (rely on path contents alone). Also disables <a class="xref" href="#svn.branchmerge.basicmerging.mergetracking" title="Merge Tracking">Merge Tracking</a> when used with the <span class="command"><strong>svn merge</strong></span> subcommand. </p></dd><dt><a id="svn.ref.svn.sw.ignore_externals"></a><span class="term"><code class="option">--ignore-externals</code></span></dt><dd><p>Tells Subversion to ignore externals definitions and the external working copies managed by them.</p></dd><dt><a id="svn.ref.svn.sw.ignore_keywords"></a><span class="term"><code class="option">--ignore-keywords</code></span></dt><dd><p>Disables keyword expansion.</p></dd><dt><a id="svn.ref.svn.sw.ignore_whitespace"></a><span class="term"><code class="option">--ignore-whitespace</code></span></dt><dd><p>Instructs <span class="command"><strong>svn patch</strong></span> to ignore whitespace when attempting to identify patch context.</p></dd><dt><a id="svn.ref.svn.sw.incremental"></a><span class="term"><code class="option">--incremental</code></span></dt><dd><p>Prints output in a format suitable for concatenation to prior similar output.</p></dd><dt><a id="svn.ref.svn.sw.internal_diff"></a><span class="term"><code class="option">--internal-diff</code></span></dt><dd><p>Instructs Subversion to use its built-in differencing engine despite any external differencing mechanism that may be specified for use in the user's runtime configuration.</p></dd><dt><a id="svn.ref.svn.sw.keep_changelists"></a><span class="term"><code class="option">--keep-changelists</code></span></dt><dd><p>Tells Subversion not to remove the changelist assigments from working copy items after committing.</p></dd><dt><a id="svn.ref.svn.sw.keep_local"></a><span class="term"><code class="option">--keep-local</code></span></dt><dd><p>Keeps the local copy of a file or directory (used with the <span class="command"><strong>svn delete</strong></span> command).</p></dd><dt><a id="svn.ref.svn.sw.limit"></a><span class="term"><code class="option">--limit</code> (<code class="option">-l</code>) <em class="replaceable"><code>NUM</code></em></span></dt><dd><p>Shows only the first <em class="replaceable"><code>NUM</code></em> log messages.</p></dd><dt><a id="svn.ref.svn.sw.message"></a><span class="term"><code class="option">--message</code> (<code class="option">-m</code>) <em class="replaceable"><code>MESSAGE</code></em></span></dt><dd><p>Indicates that you will specify either a log message or a lock comment on the command line, following this option. For example:</p><div class="informalexample"><pre class="screen"> $ svn commit -m "They don't make Sunday." </pre></div></dd><dt><a id="svn.ref.svn.sw.native_eol"></a><span class="term"><code class="option">--native-eol</code> <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Causes <span class="command"><strong>svn export</strong></span> to use a specific end-of-line sequence as if it was the native sequence for the client platform. <em class="replaceable"><code>ARG</code></em> may be one of <code class="literal">CR</code>, <code class="literal">LF</code>, or <code class="literal">CRLF</code>.</p></dd><dt><a id="svn.ref.svn.sw.new"></a><span class="term"><code class="option">--new</code> <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Uses <em class="replaceable"><code>ARG</code></em> as the newer target (for use with <span class="command"><strong>svn diff</strong></span>).</p></dd><dt><a id="svn.ref.svn.sw.no_auto_props"></a><span class="term"><code class="option">--no-auto-props</code></span></dt><dd><p>Disables automatic property setting, overriding the <code class="literal">enable-auto-props</code> runtime configuration directive.</p></dd><dt><a id="svn.ref.svn.sw.no_diff_deleted"></a><span class="term"><code class="option">--no-diff-deleted</code></span></dt><dd><p>Prevents Subversion from printing differences for deleted files. The default behavior when you remove a file is for <span class="command"><strong>svn diff</strong></span> to print the same differences that you would see if you had kept the file but removed all of its content.</p></dd><dt><a id="svn.ref.svn.sw.no_ignore"></a><span class="term"><code class="option">--no-ignore</code></span></dt><dd><p>Shows files in the status listing that would normally be omitted since they match a pattern in the <code class="literal">global-ignores</code> configuration option or the <code class="literal">svn:ignore</code> property. See <a class="xref" href="#svn.advanced.confarea.opts.config" title="Config">the section called “Config”</a> and <a class="xref" href="#svn.advanced.props.special.ignore" title="Ignoring Unversioned Items">the section called “Ignoring Unversioned Items”</a> for more information.</p></dd><dt><a id="svn.ref.svn.sw.no_unlock"></a><span class="term"><code class="option">--no-unlock</code></span></dt><dd><p>Tells Subversion not to automatically unlock files. (The default commit behavior is to unlock all files listed as part of the commit.) See <a class="xref" href="#svn.advanced.locking" title="Locking">the section called “Locking”</a> for more information.</p></dd><dt><a id="svn.ref.svn.sw.non_recursive"></a><span class="term"><code class="option">--non-recursive</code> (<code class="option">-N</code>)</span></dt><dd><p><span class="emphasis"><em>Deprecated</em></span>. Stops a subcommand from recursing into subdirectories. Most subcommands recurse by default, but some do not. Users should avoid this option and use the more precise <code class="option">--depth</code> option instead. For most subcommands, specifying <code class="option">--non-recursive</code> produces behavior which is the same as if you'd specified <code class="option">--depth=files</code>, but there are exceptions: non-recursive <span class="command"><strong>svn status</strong></span> operates at the <code class="literal">immediates</code> depth, and the non-recursive forms of <span class="command"><strong>svn revert</strong></span>, <span class="command"><strong>svn add</strong></span>, and <span class="command"><strong>svn commit</strong></span> operate at an <code class="literal">empty</code> depth.</p></dd><dt><a id="svn.ref.svn.sw.notice_ancestry"></a><span class="term"><code class="option">--notice-ancestry</code></span></dt><dd><p>Pays attention to ancestry when calculating differences.</p></dd><dt><a id="svn.ref.svn.sw.old"></a><span class="term"><code class="option">--old</code> <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Uses <em class="replaceable"><code>ARG</code></em> as the older target (for use with <span class="command"><strong>svn diff</strong></span>).</p></dd><dt><a id="svn.ref.svn.sw.parents"></a><span class="term"><code class="option">--parents</code></span></dt><dd><p>Creates and adds nonexistent or nonversioned parent subdirectories to the working copy or repository as part of an operation. This is useful for automatically creating multiple subdirectories where none currently exist. If performed on a URL, all the directories will be created in a single commit.</p></dd><dt><a id="svn.ref.svn.sw.quiet"></a><span class="term"><code class="option">--quiet</code> (<code class="option">-q</code>)</span></dt><dd><p>Requests that the client print only essential information while performing an operation.</p></dd><dt><a id="svn.ref.svn.sw.record_only"></a><span class="term"><code class="option">--record-only</code></span></dt><dd><p>Enables a special mode of <span class="command"><strong>svn merge</strong></span> in which the specified merge operation is recorded in the local merge tracking information, but is not actually performed.</p></dd><dt><a id="svn.ref.svn.sw.recursive"></a><span class="term"><code class="option">--recursive</code> (<code class="option">-R</code>)</span></dt><dd><p>Makes a subcommand recurse into subdirectories. (Most subcommands recurse by default.)</p></dd><dt><a id="svn.ref.svn.sw.reintegrate"></a><span class="term"><code class="option">--reintegrate</code></span></dt><dd><p>Used with the <span class="command"><strong>svn merge</strong></span> subcommand to merge all of the source URL's changes into the working copy. See <a class="xref" href="#svn.branchemerge.basicmerging.stayinsync" title="Keeping a Branch in Sync">the section called “Keeping a Branch in Sync”</a> for details.</p></dd><dt><a id="svn.ref.svn.sw.relocate"></a><span class="term"><code class="option">--relocate</code></span></dt><dd><p>Deprecated. When used with the <span class="command"><strong>svn switch</strong></span> subcommand, changes the location of the repository that your working copy references. The preferred approach as of Subversion 1.7, however, is to use the <span class="command"><strong>svn relocate</strong></span> subcommand. See <a class="xref" href="#svn.ref.svn.c.relocate" title="svn relocate">svn relocate</a> for more details and an example.</p></dd><dt><a id="svn.ref.svn.sw.remove"></a><span class="term"><code class="option">--remove</code></span></dt><dd><p>Used with <span class="command"><strong>svn changelist</strong></span> to disassociate—rather than associate (which is the default operation)—the target(s) from a changelist.</p></dd><dt><a id="svn.ref.svn.sw.reverse_diff"></a><span class="term"><code class="option">--reverse-diff</code></span></dt><dd><p>Causes <span class="command"><strong>svn patch</strong></span> to interpret the input patch instructions in reverse—treating added lines as removed ones and vice-versa.</p></dd><dt><a id="svn.ref.svn.sw.revision"></a><span class="term"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></span></dt><dd><p>Specifies a revision (or range of revisions) on with which to operate. You can provide revision numbers, keywords, or dates (in curly braces) as arguments to the revision option. If you wish to offer a range of revisions, you can provide two revisions separated by a colon. For example:</p><div class="informalexample"><pre class="screen"> $ svn log -r 1729 $ svn log -r 1729:HEAD $ svn log -r 1729:1744 $ svn log -r {2001-12-04}:{2002-02-17} $ svn log -r 1729:{2002-02-17} </pre></div><p>See <a class="xref" href="#svn.tour.revs.keywords" title="Revision Keywords">the section called “Revision Keywords”</a> for more information.</p></dd><dt><a id="svn.ref.svn.sw.revprop"></a><span class="term"><code class="option">--revprop</code></span></dt><dd><p>Operates on a revision property instead of a property specific to a file or directory. This option requires that you also pass a revision with the <code class="option">--revision</code> (<code class="option">-r</code>) option.</p></dd><dt><a id="svn.ref.svn.sw.set_depth"></a><span class="term"><code class="option">--set-depth</code> <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Sets the sticky depth on a directory in a working copy to one of <code class="literal">exclude</code>, <code class="literal">empty</code>, <code class="literal">files</code>, <code class="literal">immediates</code>, or <code class="literal">infinity</code>. For detailed coverage of what these mean and how to use this option, see <a class="xref" href="#svn.advanced.sparsedirs" title="Sparse Directories">the section called “Sparse Directories”</a>.</p></dd><dt><a id="svn.ref.svn.sw.show_copies_as_adds"></a><span class="term"><code class="option">--show-copies-as-adds</code></span></dt><dd><p>Enables a special output mode for <span class="command"><strong>svn diff</strong></span> in which the content difference for a file created via a copy operation appears as it would for a brand new file (with each line therein appearing as an addition to an empty file) rather than as a delta against the original file from which the copy was created.</p></dd><dt><a id="svn.ref.svn.sw.show_revs"></a><span class="term"><code class="option">--show-revs</code> <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Used to make <span class="command"><strong>svn mergeinfo</strong></span> display certain classes of merge tracking information. <em class="replaceable"><code>ARG</code></em> may be either <code class="literal">merged</code> or <code class="literal">eligible</code>, indicating a desire to see revisions either already merged or eligible for future merge from the specified source URL, respectively.</p></dd><dt><a id="svn.ref.svn.sw.show_updates"></a><span class="term"><code class="option">--show-updates</code> (<code class="option">-u</code>)</span></dt><dd><p>Causes the client to display information about which files in your working copy are out of date. This doesn't actually update any of your files—it just shows you which files will be updated if you then use <span class="command"><strong>svn update</strong></span>.</p></dd><dt><a id="svn.ref.svn.sw.stop_on_copy"></a><span class="term"><code class="option">--stop-on-copy</code></span></dt><dd><p>Causes a Subversion subcommand that traverses the history of a versioned resource to stop harvesting that historical information when a copy—that is, a location in history where that resource was copied from another location in the repository—is encountered.</p></dd><dt><a id="svn.ref.svn.sw.strict"></a><span class="term"><code class="option">--strict</code></span></dt><dd><p>Causes Subversion to use strict semantics, a notion that is rather vague unless talking about specific subcommands (namely, <span class="command"><strong>svn propget</strong></span>).</p></dd><dt><a id="svn.ref.svn.sw.strip"></a><span class="term"><code class="option">--strip</code> <em class="replaceable"><code>NUM</code></em></span></dt><dd><p>Used by <span class="command"><strong>svn patch</strong></span> to ignore <em class="replaceable"><code>NUM</code></em> leading path components found on paths specified in the patch input file.</p></dd><dt><a id="svn.ref.svn.sw.summarize"></a><span class="term"><code class="option">--summarize</code></span></dt><dd><p>Display only high-level summary notifications about the operation instead of its detailed output.</p></dd><dt><a id="svn.ref.svn.sw.targets"></a><span class="term"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></span></dt><dd><p>Tells Subversion to read additional target paths for the operation from <em class="replaceable"><code>FILENAME</code></em>. <em class="replaceable"><code>FILENAME</code></em> should contain one path per line, with each path expected to use the same encoding and formatting that it would if you had specified it directly as an argument on the command line.</p></dd><dt><a id="svn.ref.svn.sw.use_merge_history"></a><span class="term"><code class="option">--use-merge-history</code> (<code class="option">-g</code>)</span></dt><dd><p>Uses or displays additional information from merge history.</p></dd><dt><a id="svn.ref.svn.sw.verbose"></a><span class="term"><code class="option">--verbose</code> (<code class="option">-v</code>)</span></dt><dd><p>Requests that the client print out as much information as it can while running any subcommand. This may result in Subversion printing out additional fields, detailed information about every file, or additional information regarding its actions.</p></dd><dt><a id="svn.ref.svn.sw.version"></a><span class="term"><code class="option">--version</code></span></dt><dd><p>Prints the client version info. This information includes not only the version number of the client, but also a listing of all repository access modules that the client can use to access a Subversion repository. With <code class="option">--quiet</code> (<code class="option">-q</code>) it prints only the version number in a compact form.</p></dd><dt><a id="svn.ref.svn.sw.with_all_revprops"></a><span class="term"><code class="option">--with-all-revprops</code></span></dt><dd><p>Used with the <code class="option">--xml</code> option to <span class="command"><strong>svn log</strong></span>, instructs Subversion to retrieve and display all revision properties—the standard ones used internally by Subversion as well as any user-defined ones—in the log output.</p></dd><dt><a id="svn.ref.svn.sw.with_no_revprops"></a><span class="term"><code class="option">--with-no-revprops</code></span></dt><dd><p>Used with the <code class="option">--xml</code> option to <span class="command"><strong>svn log</strong></span>, instructs Subversion to omit all revision properties—including the standard log message, author, and revision datestamp—from the log output.</p></dd><dt><a id="svn.ref.svn.sw.with_revprop"></a><span class="term"><code class="option">--with-revprop</code> <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>When used with any command that writes to the repository, sets the revision property, using the <em class="replaceable"><code>NAME=VALUE</code></em> format, <em class="replaceable"><code>NAME</code></em> to <em class="replaceable"><code>VALUE</code></em>. When used with <span class="command"><strong>svn log</strong></span> in <code class="option">--xml</code> mode, this displays the value of <em class="replaceable"><code>ARG</code></em> in the log output.</p></dd><dt><a id="svn.ref.svn.sw.xml"></a><span class="term"><code class="option">--xml</code></span></dt><dd><p>Prints output in XML format.</p></dd></dl></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svn.c"></a>svn Subcommands</h3></div></div></div><p>Here are the various subcommands for the <span class="command"><strong>svn</strong></span> program. For the sake of brevity, we omit the global options (described in <a class="xref" href="#svn.ref.svn.sw" title="svn Options">the section called “svn Options”</a>) from the subcommand descriptions which follow.</p><div class="refentry"><a id="svn.ref.svn.c.add"></a><div class="titlepage"></div><a id="idm9279" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn add — Add files, directories, or symbolic links.</p></div><div class="refsect1"><a id="idm9286"></a><h2>Synopsis</h2><p><code class="literal">svn add PATH...</code></p></div><div class="refsect1"><a id="idm9290"></a><h2>Description</h2><p>Schedule files, directories, or symbolic links in your working copy for addition to the repository. They will be uploaded and added to the repository on your next commit. If you add something and change your mind before committing, you can unschedule the addition using <span class="command"><strong>svn revert</strong></span>.</p></div><div class="refsect1"><a id="idm9294"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.auto_props"><code class="option">--auto-props</code></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.no_auto_props"><code class="option">--no-auto-props</code></a> <a class="xref" href="#svn.ref.svn.sw.no_ignore"><code class="option">--no-ignore</code></a> <a class="xref" href="#svn.ref.svn.sw.parents"><code class="option">--parents</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> </pre></div></div><div class="refsect1"><a id="idm9306"></a><h2>Examples</h2><p>To add a file to your working copy:</p><div class="informalexample"><pre class="screen"> $ svn add foo.c A foo.c </pre></div><p>When adding a directory, the default behavior of <span class="command"><strong>svn add</strong></span> is to recurse:</p><div class="informalexample"><pre class="screen"> $ svn add testdir A testdir A testdir/a A testdir/b A testdir/c A testdir/d </pre></div><p>You can add a directory without adding its contents:</p><div class="informalexample"><pre class="screen"> $ svn add --depth=empty otherdir A otherdir </pre></div><p>Attempts to schedule the addition of an item which is already versioned will fail by default. This behavior foils the most common scenario under which users attempt this: when trying to get to Subversion to recursively examine a versioned directory and add any unversioned items inside of it. To override the default behavior and force Subversion to recurse into already-versioned directories, pass the <code class="option">--force</code> option:</p><div class="informalexample"><pre class="screen"> $ svn add versioned-dir svn: warning: W150002: '/home/cmpilato/projects/subversion/site' is already un\ der version control $ svn add versioned-dir --force A versioned-dir/foo.c A versioned-dir/somedir/bar.c A (bin) versioned-dir/otherdir/docs/baz.doc … </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.blame"></a><div class="titlepage"></div><a id="idm9323" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn blame (praise, annotate, ann) — Show author and revision information inline for the specified files or URLs.</p></div><div class="refsect1"><a id="idm9330"></a><h2>Synopsis</h2><p><code class="literal">svn blame TARGET[@REV]...</code></p></div><div class="refsect1"><a id="idm9334"></a><h2>Description</h2><p>Show author and revision information inline for the specified files or URLs. Each line of text is annotated at the beginning with the author (username) and the revision number for the last change to that line.</p></div><div class="refsect1"><a id="idm9337"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.extensions"><code class="option">--extensions</code> (<code class="option">-x</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.incremental"><code class="option">--incremental</code></a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.use_merge_history"><code class="option">--use-merge-history</code> (<code class="option">-g</code>)</a> <a class="xref" href="#svn.ref.svn.sw.verbose"><code class="option">--verbose</code> (<code class="option">-v</code>)</a> <a class="xref" href="#svn.ref.svn.sw.xml"><code class="option">--xml</code></a> </pre></div></div><div class="refsect1"><a id="idm9348"></a><h2>Examples</h2><p>If you want to see blame-annotated source for <code class="filename">readme.txt</code> in your test repository:</p><div class="informalexample"><pre class="screen"> $ svn blame http://svn.red-bean.com/repos/test/readme.txt 3 sally This is a README file. 5 harry Don't bother reading it. The boss is a knucklehead. 3 sally … </pre></div><p>Now, just because <span class="command"><strong>svn blame</strong></span> says that Harry last modified <code class="filename">readme.txt</code> in revision 5, understand that this subcommand is by default very picky about what constitutes a change. Before clubbing Harry over the head for what appears to be insubordination, first consider that perhaps the change he made to the file might have been only to its specific character content, not to its overall semantic meaning. Perhaps his changes were the result of blindly running a whitespace cleanup script on this file. You might need to examine the specific differences and related log message to understand exactly what Harry did to this file in revision 5.</p><div class="informalexample"><pre class="screen"> $ svn log -c 5 http://svn.red-bean.com/repos/test/readme.txt ------------------------------------------------------------------------ r5 | harry | 2008-05-29 07:26:12 -0600 (Thu, 29 May 2008) | 1 line Commit the results of 'double-space-after-period.sh'. ------------------------------------------------------------------------ $ svn diff -c 5 http://svn.red-bean.com/repos/test/readme.txt Index: http://svn.red-bean.com/repos/test/readme.txt =================================================================== --- http://svn.red-bean.com/repos/test/readme.txt (revision 4) +++ http://svn.red-bean.com/repos/test/readme.txt (revision 5) @@ -1,5 +1,5 @@ This is a README file. -Don't bother reading it. The boss is a knucklehead. +Don't bother reading it. The boss is a knucklehead. INSTRUCTIONS ============ $ </pre></div><p>Sure enough, Harry only changed the whitespace in that line. Fortunately, the <code class="option">--extensions</code> (<code class="option">-x</code>) option can help you better determine the last time that a <span class="emphasis"><em>meaningful</em></span> change was made to a given line of text. For example, here's how you can see the annotation information while disregarding mere whitespace changes:</p><div class="informalexample"><pre class="screen"> $ svn blame -x -b http://svn.red-bean.com/repos/test/readme.txt 3 sally This is a README file. 4 jess Don't bother reading it. The boss is a knucklehead. 3 sally … </pre></div><p>If you use the <code class="option">--xml</code> option, you can get XML output describing the blame annotations, but not the contents of the lines themselves:</p><div class="informalexample"><pre class="screen"> $ svn blame --xml http://svn.red-bean.com/repos/test/readme.txt &lt;?xml version="1.0"?&gt; &lt;blame&gt; &lt;target path="readme.txt"&gt; &lt;entry line-number="1"&gt; &lt;commit revision="3"&gt; &lt;author&gt;sally&lt;/author&gt; &lt;date&gt;2008-05-25T19:12:31.428953Z&lt;/date&gt; &lt;/commit&gt; &lt;/entry&gt; &lt;entry line-number="2"&gt; &lt;commit revision="5"&gt; &lt;author&gt;harry&lt;/author&gt; &lt;date&gt;2008-05-29T13:26:12.293121Z&lt;/date&gt; &lt;/commit&gt; &lt;/entry&gt; &lt;entry line-number="3"&gt; … &lt;/entry&gt; &lt;/target&gt; &lt;/blame&gt; $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.cat"></a><div class="titlepage"></div><a id="idm9370" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn cat — Output the contents of the specified files or URLs.</p></div><div class="refsect1"><a id="idm9377"></a><h2>Synopsis</h2><p><code class="literal">svn cat TARGET[@REV]...</code></p></div><div class="refsect1"><a id="idm9381"></a><h2>Description</h2><p>Output the contents of the specified files or URLs. For listing the contents of directories, see <span class="command"><strong>svn list</strong></span> later in this chapter.</p></div><div class="refsect1"><a id="idm9385"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> </pre></div></div><div class="refsect1"><a id="idm9390"></a><h2>Examples</h2><p>If you want to view <code class="filename">readme.txt</code> in your repository without checking it out:</p><div class="informalexample"><pre class="screen"> $ svn cat http://svn.red-bean.com/repos/test/readme.txt This is a README file. Don't bother reading it. The boss is a knucklehead. INSTRUCTIONS ============ Step 1: Do this. Step 2: Do that. $ </pre></div><p>You can view specific versions of files, too.</p><div class="informalexample"><pre class="screen"> $ svn cat -r 3 http://svn.red-bean.com/repos/test/readme.txt This is a README file. INSTRUCTIONS ============ Step 1: Do this. Step 2: Do that. $ </pre></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>You might develop a reflex action of using <span class="command"><strong>svn cat</strong></span> to view your working file contents. But keep in mind that the default peg revision for <span class="command"><strong>svn cat</strong></span> when used on a working copy file target is <code class="literal">BASE</code>, the unmodified base revision of that file. Don't be surprised when a simple <strong class="userinput"><code>svn cat /path/to/file</code></strong> invocation fails to display your local modifications to that file!</p></td></tr></table></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>If your working copy is out of date (or you have local modifications) and you want to see the <code class="literal">HEAD</code> revision of a file in your working copy, use the <code class="option">--revision</code> (<code class="option">-r</code>) option: <strong class="userinput"><code>svn cat -r HEAD <em class="replaceable"><code>FILENAME</code></em></code></strong></p></td></tr></table></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.changelist"></a><div class="titlepage"></div><a id="idm9413" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn changelist (cl) — Associate (or deassociate) local paths with a changelist.</p></div><div class="refsect1"><a id="idm9420"></a><h2>Synopsis</h2><p><code class="literal">changelist CLNAME TARGET...</code></p><p><code class="literal">changelist --remove TARGET...</code></p></div><div class="refsect1"><a id="idm9426"></a><h2>Description</h2><p>Used for dividing files in a working copy into a changelist (logical named grouping) in order to allow users to easily work on multiple file collections within a single working copy.</p></div><div class="refsect1"><a id="idm9429"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.changelist"><code class="option">--changelist</code> (<code class="option">--cl</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.recursive"><code class="option">--recursive</code> (<code class="option">-R</code>)</a> <a class="xref" href="#svn.ref.svn.sw.remove"><code class="option">--remove</code></a> <a class="xref" href="#svn.ref.svn.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> </pre></div></div><div class="refsect1"><a id="idm9439"></a><h2>Example</h2><p>Edit three files, add them to a changelist, then commit only files in that changelist:</p><div class="informalexample"><pre class="screen"> $ svn changelist issue1729 foo.c bar.c baz.c A [issue1729] foo.c A [issue1729] bar.c A [issue1729] baz.c $ svn status A someotherfile.c A test/sometest.c --- Changelist 'issue1729': A foo.c A bar.c A baz.c $ svn commit --changelist issue1729 -m "Fixing Issue 1729." Adding bar.c Adding baz.c Adding foo.c Transmitting file data ... Committed revision 2. $ svn status A someotherfile.c A test/sometest.c $ </pre></div><p>Note that in the previous example, only the files in changelist <code class="literal">issue1729</code> were committed.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.checkout"></a><div class="titlepage"></div><a id="idm9447" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn checkout (co) — Check out a working copy from a repository.</p></div><div class="refsect1"><a id="idm9454"></a><h2>Synopsis</h2><p><code class="literal">svn checkout URL[@REV]... [PATH]</code></p></div><div class="refsect1"><a id="idm9458"></a><h2>Description</h2><p>Check out a working copy from a repository. If <em class="replaceable"><code>PATH</code></em> is omitted, the basename of the URL will be used as the destination. If multiple URLs are given, each will be checked out into a subdirectory of <em class="replaceable"><code>PATH</code></em>, with the name of the subdirectory being the basename of the URL.</p></div><div class="refsect1"><a id="idm9463"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.ignore_externals"><code class="option">--ignore-externals</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> </pre></div></div><div class="refsect1"><a id="idm9472"></a><h2>Examples</h2><p>Check out a working copy into a directory called <code class="filename">mine</code>:</p><div class="informalexample"><pre class="screen"> $ svn checkout file:///var/svn/repos/test mine A mine/a A mine/b A mine/c A mine/d Checked out revision 20. $ ls mine $ </pre></div><p>Check out two different directories into two separate working copies:</p><div class="informalexample"><pre class="screen"> $ svn checkout file:///var/svn/repos/test \ file:///var/svn/repos/quiz A test/a A test/b A test/c A test/d Checked out revision 20. A quiz/l A quiz/m Checked out revision 13. $ ls quiz test $ </pre></div><p>Check out two different directories into two separate working copies, but place both into a directory called <code class="filename">working-copies</code>:</p><div class="informalexample"><pre class="screen"> $ svn checkout file:///var/svn/repos/test \ file:///var/svn/repos/quiz \ working-copies A working-copies/test/a A working-copies/test/b A working-copies/test/c A working-copies/test/d Checked out revision 20. A working-copies/quiz/l A working-copies/quiz/m Checked out revision 13. $ ls working-copies </pre></div><p>If you interrupt a checkout (or something else interrupts your checkout, such as loss of connectivity, etc.), you can restart it either by issuing the identical checkout command again or by updating the incomplete working copy:</p><div class="informalexample"><pre class="screen"> $ svn checkout file:///var/svn/repos/test mine A mine/a A mine/b ^C svn: E200015: Caught signal $ svn checkout file:///var/svn/repos/test mine A mine/c ^C svn: E200015: Caught signal $ svn update mine Updating 'mine': A mine/d Updated to revision 20. $ </pre></div><p>If you wish to check out some revision other than the most recent one, you can do so by providing the <code class="option">--revision</code> (<code class="option">-r</code>) option to the <span class="command"><strong>svn checkout</strong></span> command:</p><div class="informalexample"><pre class="screen"> $ svn checkout -r 2 file:///var/svn/repos/test mine A mine/a Checked out revision 2. $ </pre></div><p>Prior to version 1.7, Subversion would complain by default if you try to check out a directory atop an existing directory which contains files or subdirectories that the checkout itself would have created. Subversion 1.7 handles this situation differently, allowing the checkout to proceed but marking any obstructing objects as tree conflicts. Use the <code class="option">--force</code> option to override this safeguard. When you check out with the <code class="option">--force</code> option, any unversioned file in the checkout target tree which ordinarily would obstruct the checkout will still become versioned, but Subversion will preserve its contents as-is. If those contents differ from the repository file at that path (which was downloaded as part of the checkout), the file will appear to have local modifications—the changes required to transform the versioned file you checked out into the unversioned file you had before checking out—when the checkout completes.</p><div class="informalexample"><pre class="screen"> $ mkdir project $ mkdir project/lib $ touch project/lib/file.c $ svn checkout file:///var/svn/repos/project/trunk project --force E project/lib A project/lib/subdir E project/lib/file.c A project/lib/anotherfile.c A project/include/header.h Checked out revision 21. $ svn status wc M project/lib/file.c $ svn diff wc Index: project/lib/file.c =================================================================== --- project/lib/file.c (revision 1) +++ project/lib/file.c (working copy) @@ -3 +0,0 @@ -/* file.c: Code for acting file-ishly. */ -#include &lt;stdio.h&gt; -/* Not feeling particularly creative today. */ $ </pre></div><p>As in another other working copy, you have the choices typically available: reverting some or all of those local <span class="quote">“<span class="quote">modifications</span>”</span>, committing them, or continuing to modify your working copy.</p><p>This feature is especially useful for performing in-place imports of unversioned directory trees. By first importing the tree into the repository, and then checking out new repository location atop the unversioned tree with the <code class="option">--force</code> option, you effectively transform the unversioned tree into a working copy.</p><div class="informalexample"><pre class="screen"> $ svn mkdir -m "Create newproject project root." \ file://var/svn/repos/newproject $ svn import -m "Import initial newproject codebase." newproject \ file://var/svn/repos/newproject/trunk Adding newproject/include Adding newproject/include/newproject.h Adding newproject/lib Adding newproject/lib/helpers.c Adding newproject/lib/base.c Adding newproject/notes Adding newproject/notes/README Committed revision 22. $ svn checkout file://`pwd`/repos-1.6/newproject/trunk newproject --force E newproject/include E newproject/include/newproject.h E newproject/lib E newproject/lib/helpers.c E newproject/lib/base.c E newproject/notes E newproject/notes/README Checked out revision 2. $ svn status newproject $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.cleanup"></a><div class="titlepage"></div><a id="idm9506" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn cleanup — Recursively clean up the working copy</p></div><div class="refsect1"><a id="idm9513"></a><h2>Synopsis</h2><p><code class="literal">svn cleanup [PATH...]</code></p></div><div class="refsect1"><a id="idm9517"></a><h2>Description</h2><p>Recursively clean up the working copy, removing working copy locks and resuming unfinished operations. If you ever get a <code class="literal">working copy locked</code> error, run this command to remove stale locks and get your working copy into a usable state again.</p><p>If, for some reason, an <span class="command"><strong>svn update</strong></span> fails due to a problem running an external diff program (e.g., user input or network failure), pass the <code class="option">--diff3-cmd</code> to allow the cleanup process to complete any required merging using your external diff program. You can also specify any configuration directory with the <code class="option">--config-dir</code> option, but you should need these options extremely infrequently.</p></div><div class="refsect1"><a id="idm9525"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.diff3_cmd"><code class="option">--diff3-cmd</code> <em class="replaceable"><code>CMD</code></em></a> </pre></div></div><div class="refsect1"><a id="idm9530"></a><h2>Examples</h2><p>Well, there's not much to the examples here, as <span class="command"><strong>svn cleanup</strong></span> generates no output. If you pass no <em class="replaceable"><code>PATH</code></em>, then <span class="quote">“<span class="quote"><code class="filename">.</code></span>”</span> is used:</p><div class="informalexample"><pre class="screen"> $ svn cleanup $ svn cleanup /var/svn/working-copy </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.commit"></a><div class="titlepage"></div><a id="idm9540" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn commit (ci) — Send changes from your working copy to the repository.</p></div><div class="refsect1"><a id="idm9547"></a><h2>Synopsis</h2><p><code class="literal">svn commit [PATH...]</code></p></div><div class="refsect1"><a id="idm9551"></a><h2>Description</h2><p>Send changes from your working copy to the repository. If you do not supply a log message with your commit by using either the <code class="option">--file</code> (<code class="option">-F</code>) or <code class="option">--message</code> (<code class="option">-m</code>) option, <span class="command"><strong>svn</strong></span> will launch your editor for you to compose a commit message. See the <code class="literal">editor-cmd</code> list entry in <a class="xref" href="#svn.advanced.confarea.opts.config" title="Config">the section called “Config”</a>.</p><p><span class="command"><strong>svn commit</strong></span> will send any lock tokens that it finds and will release locks on all <em class="replaceable"><code>PATH</code></em>s committed (recursively) unless <code class="option">--no-unlock</code> is passed.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>If you begin a commit and Subversion launches your editor to compose the commit message, you can still abort without committing your changes. If you want to cancel your commit, just quit your editor without saving your commit message and Subversion will prompt you to either abort the commit, continue with no message, or edit the message again.</p></td></tr></table></div></div><div class="refsect1"><a id="idm9567"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.changelist"><code class="option">--changelist</code> (<code class="option">--cl</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.editor_cmd"><code class="option">--editor-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.encoding"><code class="option">--encoding</code> <em class="replaceable"><code>ENC</code></em></a> <a class="xref" href="#svn.ref.svn.sw.file"><code class="option">--file</code> (<code class="option">-F</code>) <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force_log"><code class="option">--force-log</code></a> <a class="xref" href="#svn.ref.svn.sw.keep_changelists"><code class="option">--keep-changelists</code></a> <a class="xref" href="#svn.ref.svn.sw.message"><code class="option">--message</code> (<code class="option">-m</code>) <em class="replaceable"><code>MESSAGE</code></em></a> <a class="xref" href="#svn.ref.svn.sw.no_unlock"><code class="option">--no-unlock</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.with_revprop"><code class="option">--with-revprop</code> <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm9583"></a><h2>Examples</h2><p>Commit a simple modification to a file with the commit message on the command line and an implicit target of your current directory (<span class="quote">“<span class="quote"><code class="filename">.</code></span>”</span>):</p><div class="informalexample"><pre class="screen"> $ svn commit -m "added howto section." Sending a Transmitting file data . Committed revision 3. </pre></div><p>Commit a modification to the file <code class="filename">foo.c</code> (explicitly specified on the command line) with the commit message in a file named <code class="filename">msg</code>:</p><div class="informalexample"><pre class="screen"> $ svn commit -F msg foo.c Sending foo.c Transmitting file data . Committed revision 5. </pre></div><p>If you want to use a file that's under version control for your commit message with <code class="option">--file</code> (<code class="option">-F</code>), you need to pass the <code class="option">--force-log</code> option:</p><div class="informalexample"><pre class="screen"> $ svn commit -F file_under_vc.txt foo.c svn: E205004: Log message file is a versioned file; use '--force-log' to override $ svn commit --force-log -F file_under_vc.txt foo.c Sending foo.c Transmitting file data . Committed revision 6. </pre></div><p>To commit a file scheduled for deletion:</p><div class="informalexample"><pre class="screen"> $ svn commit -m "removed file 'c'." Deleting c Committed revision 7. </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.copy"></a><div class="titlepage"></div><a id="idm9605" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn copy (cp) — Copy a file or directory in a working copy or in the repository.</p></div><div class="refsect1"><a id="idm9612"></a><h2>Synopsis</h2><p><code class="literal">svn copy SRC[@REV]... DST</code></p></div><div class="refsect1"><a id="idm9616"></a><h2>Description</h2><p>Copy one or more files in a working copy or in the repository. <em class="replaceable"><code>SRC</code></em> and <em class="replaceable"><code>DST</code></em> can each be either a working copy (WC) path or URL. When copying multiple sources, add the copies as immediate children of <em class="replaceable"><code>DST</code></em> (which, of course, must be a directory).</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">WC → WC</span></dt><dd><p>Copy and schedule an item for addition (with history).</p></dd><dt><span class="term">WC → URL</span></dt><dd><p>Immediately commit a copy of WC to URL.</p></dd><dt><span class="term">URL → WC</span></dt><dd><p>Check out URL into WC and schedule it for addition.</p></dd><dt><span class="term">URL → URL</span></dt><dd><p>Complete server-side copy. This is usually used to branch and tag.</p></dd></dl></div><p>If no peg revision (i.e., <em class="replaceable"><code>@REV</code></em>) is supplied, by default the <code class="literal">BASE</code> revision will be used for files copied from the working copy, while the <code class="literal">HEAD</code> revision will be used for files copied from a URL.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>You can only copy files within a single repository. Subversion does not support cross-repository copying.</p></td></tr></table></div></div><div class="refsect1"><a id="idm9645"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.editor_cmd"><code class="option">--editor-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.encoding"><code class="option">--encoding</code> <em class="replaceable"><code>ENC</code></em></a> <a class="xref" href="#svn.ref.svn.sw.file"><code class="option">--file</code> (<code class="option">-F</code>) <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force_log"><code class="option">--force-log</code></a> <a class="xref" href="#svn.ref.svn.sw.ignore_externals"><code class="option">--ignore-externals</code></a> <a class="xref" href="#svn.ref.svn.sw.message"><code class="option">--message</code> (<code class="option">-m</code>) <em class="replaceable"><code>MESSAGE</code></em></a> <a class="xref" href="#svn.ref.svn.sw.parents"><code class="option">--parents</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.with_revprop"><code class="option">--with-revprop</code> <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm9659"></a><h2>Examples</h2><p>Copy an item within your working copy (this schedules the copy—nothing goes into the repository until you commit):</p><div class="informalexample"><pre class="screen"> $ svn copy foo.txt bar.txt A bar.txt $ svn status A + bar.txt </pre></div><p>Copy several files in a working copy into a subdirectory:</p><div class="informalexample"><pre class="screen"> $ svn copy bat.c baz.c qux.c src A src/bat.c A src/baz.c A src/qux.c </pre></div><p>Copy revision 8 of <code class="filename">bat.c</code> into your working copy under a different name:</p><div class="informalexample"><pre class="screen"> $ svn copy -r 8 bat.c ya-old-bat.c A ya-old-bat.c </pre></div><p>Copy an item in your working copy to a URL in the repository (this is an immediate commit, so you must supply a commit message):</p><div class="informalexample"><pre class="screen"> $ svn copy near.txt file:///var/svn/repos/test/far-away.txt -m "Remote copy." Committed revision 8. </pre></div><p>Copy an item from the repository to your working copy (this just schedules the copy—nothing goes into the repository until you commit):</p><div class="informalexample"><pre class="screen"> $ svn copy file:///var/svn/repos/test/far-away -r 6 near-here A near-here </pre></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>This is the recommended way to resurrect a dead file in your repository!</p></td></tr></table></div><p>And finally, copy between two URLs:</p><div class="informalexample"><pre class="screen"> $ svn copy file:///var/svn/repos/test/far-away \ file:///var/svn/repos/test/over-there -m "remote copy." Committed revision 9. </pre></div><div class="informalexample"><pre class="screen"> $ svn copy file:///var/svn/repos/test/trunk \ file:///var/svn/repos/test/tags/0.6.32-prerelease -m "tag tree" Committed revision 12. </pre></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>This is the easiest way to <span class="quote">“<span class="quote">tag</span>”</span> a revision in your repository—just <span class="command"><strong>svn copy</strong></span> that revision (usually <code class="literal">HEAD</code>) into your <code class="filename">tags</code> directory.</p></td></tr></table></div><p>And don't worry if you forgot to tag—you can always specify an older revision and tag anytime:</p><div class="informalexample"><pre class="screen"> $ svn copy -r 11 file:///var/svn/repos/test/trunk \ file:///var/svn/repos/test/tags/0.6.32-prerelease \ -m "Forgot to tag at rev 11" Committed revision 13. </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.delete"></a><div class="titlepage"></div><a id="idm9694" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn delete (del, remove, rm) — Delete an item from a working copy or the repository.</p></div><div class="refsect1"><a id="idm9701"></a><h2>Synopsis</h2><p><code class="literal">svn delete PATH...</code></p><p><code class="literal">svn delete URL...</code></p></div><div class="refsect1"><a id="idm9707"></a><h2>Description</h2><p>Items specified by <em class="replaceable"><code>PATH</code></em> are scheduled for deletion upon the next commit. Files (and directories that have not been committed) are immediately removed from the working copy unless the <code class="option">--keep-local</code> option is given. The command will not remove any unversioned or modified items; use the <code class="option">--force</code> option to override this behavior.</p><p>Items specified by URL are deleted from the repository via an immediate commit. Multiple URLs are committed atomically.</p></div><div class="refsect1"><a id="idm9714"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.editor_cmd"><code class="option">--editor-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.encoding"><code class="option">--encoding</code> <em class="replaceable"><code>ENC</code></em></a> <a class="xref" href="#svn.ref.svn.sw.file"><code class="option">--file</code> (<code class="option">-F</code>) <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.force_log"><code class="option">--force-log</code></a> <a class="xref" href="#svn.ref.svn.sw.keep_local"><code class="option">--keep-local</code></a> <a class="xref" href="#svn.ref.svn.sw.message"><code class="option">--message</code> (<code class="option">-m</code>) <em class="replaceable"><code>MESSAGE</code></em></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.with_revprop"><code class="option">--with-revprop</code> <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm9728"></a><h2>Examples</h2><p>Using <span class="command"><strong>svn</strong></span> to delete a file from your working copy deletes your local copy of the file, but it merely schedules the file to be deleted from the repository. When you commit, the file is deleted in the repository.</p><div class="informalexample"><pre class="screen"> $ svn delete myfile D myfile $ svn commit -m "Deleted file 'myfile'." Deleting myfile Transmitting file data . Committed revision 14. </pre></div><p>Deleting a URL, however, is immediate, so you have to supply a log message:</p><div class="informalexample"><pre class="screen"> $ svn delete -m "Deleting file 'yourfile'" \ file:///var/svn/repos/test/yourfile Committed revision 15. </pre></div><p>Here's an example of how to force deletion of a file that has local mods:</p><div class="informalexample"><pre class="screen"> $ svn delete over-there svn: E195006: Use --force to override this restriction (local modifications m\ ay be lost) svn: E195006: '/home/sally/project/over-there' has local modifications -- com\ mit or revert them first $ svn delete --force over-there D over-there $ </pre></div><p>Use the <code class="option">--keep-local</code> option to override the default <span class="command"><strong>svn delete</strong></span> behavior of also removing the target file that was scheduled for versioned deletion. This is helpful when you realize that you've accidentally committed the addition of a file that you need to keep around in your working copy, but which shouldn't have been added to version control.</p><div class="informalexample"><pre class="screen"> $ svn delete --keep-local conf/program.conf D conf/program.conf $ svn commit -m "Remove accidentally-added configuration file." Deleting conf/program.conf Transmitting file data . Committed revision 21. $ svn status ? conf/program.conf $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.diff"></a><div class="titlepage"></div><a id="idm9746" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn diff (di) — This displays the differences between two revisions or paths.</p></div><div class="refsect1"><a id="idm9753"></a><h2>Synopsis</h2><p><code class="literal">diff [-c M | -r N[:M]] [TARGET[@REV]...]</code></p><p><code class="literal">diff [-r N[:M]] --old=OLD-TGT[@OLDREV] [--new=NEW-TGT[@NEWREV]] [PATH...]</code></p><p><code class="literal">diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]</code></p></div><div class="refsect1"><a id="idm9761"></a><h2>Description</h2><p>Display the differences between two paths. You can use <span class="command"><strong>svn diff</strong></span> in the following ways:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Use just <span class="command"><strong>svn diff</strong></span> to display local modifications in a working copy.</p></li><li class="listitem"><p>Display the changes made to <em class="replaceable"><code>TARGET</code></em>s as they are seen in <em class="replaceable"><code>REV</code></em> between two revisions. <em class="replaceable"><code>TARGET</code></em>s may be all working copy paths or all <em class="replaceable"><code>URL</code></em>s. If <em class="replaceable"><code>TARGET</code></em>s are working copy paths, <em class="replaceable"><code>N</code></em> defaults to <code class="literal">BASE</code> and <em class="replaceable"><code>M</code></em> to the working copy; if <em class="replaceable"><code>TARGET</code></em>s are <em class="replaceable"><code>URL</code></em>s, <em class="replaceable"><code>N</code></em> must be specified and <em class="replaceable"><code>M</code></em> defaults to <code class="literal">HEAD</code>. The <code class="literal">-c M</code> option is equivalent to <code class="literal">-r N:M</code> where <code class="literal">N = M-1</code>. Using <code class="literal">-c -M</code> does the reverse: <code class="literal">-r M:N</code> where <code class="literal">N = M-1</code>.</p></li><li class="listitem"><p>Display the differences between <em class="replaceable"><code>OLD-TGT</code></em> as it was seen in <em class="replaceable"><code>OLDREV</code></em> and <em class="replaceable"><code>NEW-TGT</code></em> as it was seen in <em class="replaceable"><code>NEWREV</code></em>. <em class="replaceable"><code>PATH</code></em>s, if given, are relative to <em class="replaceable"><code>OLD-TGT</code></em> and <em class="replaceable"><code>NEW-TGT</code></em> and restrict the output to differences for those paths. <em class="replaceable"><code>OLD-TGT</code></em> and <em class="replaceable"><code>NEW-TGT</code></em> may be working copy paths or <em class="replaceable"><code>URL[@REV]</code></em>. <em class="replaceable"><code>NEW-TGT</code></em> defaults to <em class="replaceable"><code>OLD-TGT</code></em> if not specified. <code class="literal">-r N</code> makes <em class="replaceable"><code>OLDREV</code></em> default to <code class="literal">N</code>; <code class="literal">-r N:M</code> makes <em class="replaceable"><code>OLDREV</code></em> default to <em class="replaceable"><code>N</code></em> and <em class="replaceable"><code>NEWREV</code></em> default to <em class="replaceable"><code>M</code></em>.</p></li></ul></div><p><strong class="userinput"><code>svn diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]</code></strong> is shorthand for <strong class="userinput"><code>svn diff --old=OLD-URL[@OLDREV] --new=NEW-URL[@NEWREV].</code></strong></p><p><strong class="userinput"><code>svn diff -r N:M URL</code></strong> is shorthand for <strong class="userinput"><code>svn diff -r N:M --old=URL --new=URL</code></strong>.</p><p><strong class="userinput"><code>svn diff [-r N[:M]] URL1[@N] URL2[@M]</code></strong> is shorthand for <strong class="userinput"><code>svn diff [-r N[:M]] --old=URL1 --new=URL2</code></strong>.</p><p>If <em class="replaceable"><code>TARGET</code></em> is a URL, then revs <code class="literal">N</code> and <code class="literal">M</code> can be given either via the <code class="option">--revision</code> (<code class="option">-r</code>) option or by using the <span class="quote">“<span class="quote">@</span>”</span> notation as described earlier.</p><p>If <em class="replaceable"><code>TARGET</code></em> is a working copy path, the default behavior (when no <code class="option">--revision</code> (<code class="option">-r</code>) option is provided) is to display the differences between the base and working copies of <em class="replaceable"><code>TARGET</code></em>. If a <code class="option">--revision</code> (<code class="option">-r</code>) option is specified in this scenario, though, it means:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--revision N:M</code></span></dt><dd><p>The server compares <em class="replaceable"><code>TARGET@N</code></em> and <em class="replaceable"><code>TARGET@M</code></em>.</p></dd><dt><span class="term"><code class="option">--revision N</code></span></dt><dd><p>The client compares <em class="replaceable"><code>TARGET@N</code></em> against the working copy.</p></dd></dl></div><p>If the alternate syntax is used, the server compares <em class="replaceable"><code>URL1</code></em> and <em class="replaceable"><code>URL2</code></em> at revisions <em class="replaceable"><code>N</code></em> and <em class="replaceable"><code>M</code></em>, respectively. If either <em class="replaceable"><code>N</code></em> or <em class="replaceable"><code>M</code></em> is omitted, a value of <code class="literal">HEAD</code> is assumed.</p><p>By default, <span class="command"><strong>svn diff</strong></span> ignores the ancestry of files and merely compares the contents of the two files being compared. If you use <code class="option">--notice-ancestry</code>, the ancestry of the paths in question will be taken into consideration when comparing revisions (i.e., if you run <span class="command"><strong>svn diff</strong></span> on two files with identical contents but different ancestry, you will see the entire contents of the file as having been removed and added again).</p></div><div class="refsect1"><a id="idm9861"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.change"><code class="option">--change</code> (<code class="option">-c</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.changelist"><code class="option">--changelist</code> (<code class="option">--cl</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.diff_cmd"><code class="option">--diff-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.extensions"><code class="option">--extensions</code> (<code class="option">-x</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.git"><code class="option">--git</code></a> <a class="xref" href="#svn.ref.svn.sw.internal_diff"><code class="option">--internal-diff</code></a> <a class="xref" href="#svn.ref.svn.sw.new"><code class="option">--new</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.no_diff_deleted"><code class="option">--no-diff-deleted</code></a> <a class="xref" href="#svn.ref.svn.sw.notice_ancestry"><code class="option">--notice-ancestry</code></a> <a class="xref" href="#svn.ref.svn.sw.old"><code class="option">--old</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.show_copies_as_adds"><code class="option">--show-copies-as-adds</code></a> <a class="xref" href="#svn.ref.svn.sw.summarize"><code class="option">--summarize</code></a> <a class="xref" href="#svn.ref.svn.sw.xml"><code class="option">--xml</code></a> </pre></div></div><div class="refsect1"><a id="idm9881"></a><h2>Examples</h2><p>Compare <code class="literal">BASE</code> and your working copy (one of the most popular uses of <span class="command"><strong>svn diff</strong></span>):</p><div class="informalexample"><pre class="screen"> $ svn diff COMMITTERS Index: COMMITTERS =================================================================== --- COMMITTERS (revision 4404) +++ COMMITTERS (working copy) … </pre></div><p>See what changed in the file <code class="filename">COMMITTERS</code> revision 9115:</p><div class="informalexample"><pre class="screen"> $ svn diff -c 9115 COMMITTERS Index: COMMITTERS =================================================================== --- COMMITTERS (revision 3900) +++ COMMITTERS (working copy) … </pre></div><p>See how your working copy's modifications compare against an older revision:</p><div class="informalexample"><pre class="screen"> $ svn diff -r 3900 COMMITTERS Index: COMMITTERS =================================================================== --- COMMITTERS (revision 3900) +++ COMMITTERS (working copy) … </pre></div><p>Compare revision 3000 to revision 3500 using <span class="quote">“<span class="quote">@</span>”</span> syntax:</p><div class="informalexample"><pre class="screen"> $ svn diff http://svn.collab.net/repos/svn/trunk/COMMITTERS@3000 \ http://svn.collab.net/repos/svn/trunk/COMMITTERS@3500 Index: COMMITTERS =================================================================== --- COMMITTERS (revision 3000) +++ COMMITTERS (revision 3500) … </pre></div><p>Compare revision 3000 to revision 3500 using range notation (pass only the one URL in this case):</p><div class="informalexample"><pre class="screen"> $ svn diff -r 3000:3500 http://svn.collab.net/repos/svn/trunk/COMMITTERS Index: COMMITTERS =================================================================== --- COMMITTERS (revision 3000) +++ COMMITTERS (revision 3500) … </pre></div><p>Compare revision 3000 to revision 3500 of all the files in <code class="filename">trunk</code> using range notation:</p><div class="informalexample"><pre class="screen"> $ svn diff -r 3000:3500 http://svn.collab.net/repos/svn/trunk </pre></div><p>Compare revision 3000 to revision 3500 of only three files in <code class="filename">trunk</code> using range notation:</p><div class="informalexample"><pre class="screen"> $ svn diff -r 3000:3500 --old http://svn.collab.net/repos/svn/trunk \ COMMITTERS README HACKING </pre></div><p>If you have a working copy, you can obtain the differences without typing in the long URLs:</p><div class="informalexample"><pre class="screen"> $ svn diff -r 3000:3500 COMMITTERS Index: COMMITTERS =================================================================== --- COMMITTERS (revision 3000) +++ COMMITTERS (revision 3500) … </pre></div><p>Use <code class="option">--diff-cmd</code> <em class="replaceable"><code>CMD</code></em> <code class="option">--extensions</code> (<code class="option">-x</code>) to pass arguments directly to the external diff program:</p><div class="informalexample"><pre class="screen"> $ svn diff --diff-cmd /usr/bin/diff -x "-i -b" COMMITTERS Index: COMMITTERS =================================================================== 0a1,2 &gt; This is a test &gt; $ </pre></div><p>Lastly, you can use the <code class="option">--xml</code> option along with the <code class="option">--summarize</code> option to view XML describing the changes that occurred between revisions, but not the contents of the diff itself:</p><div class="informalexample"><pre class="screen"> $ svn diff --summarize --xml http://svn.red-bean.com/repos/test@r2 \ http://svn.red-bean.com/repos/test &lt;?xml version="1.0"?&gt; &lt;diff&gt; &lt;paths&gt; &lt;path props="none" kind="file" item="modified"&gt;http://svn.red-bean.com/repos/test/sandwich.txt&lt;/path&gt; &lt;path props="none" kind="file" item="deleted"&gt;http://svn.red-bean.com/repos/test/burrito.txt&lt;/path&gt; &lt;path props="none" kind="dir" item="added"&gt;http://svn.red-bean.com/repos/test/snacks&lt;/path&gt; &lt;/paths&gt; &lt;/diff&gt; </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.export"></a><div class="titlepage"></div><a id="idm9926" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn export — Export a clean directory tree.</p></div><div class="refsect1"><a id="idm9933"></a><h2>Synopsis</h2><p><code class="literal">svn export [-r REV] URL[@PEGREV] [PATH]</code></p><p><code class="literal">svn export [-r REV] PATH1[@PEGREV] [PATH2]</code></p></div><div class="refsect1"><a id="idm9939"></a><h2>Description</h2><p>The first form exports a clean directory tree from the repository specified by <em class="replaceable"><code>URL</code></em>—at revision <em class="replaceable"><code>REV</code></em> if it is given; otherwise, at <code class="literal">HEAD</code>, into <em class="replaceable"><code>PATH</code></em>. If <em class="replaceable"><code>PATH</code></em> is omitted, the last component of the <em class="replaceable"><code>URL</code></em> is used for the local directory name.</p><p>The second form exports a clean directory tree from the working copy specified by <em class="replaceable"><code>PATH1</code></em> into <em class="replaceable"><code>PATH2</code></em>. All local changes will be preserved, but files not under version control will not be copied.</p></div><div class="refsect1"><a id="idm9951"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.ignore_externals"><code class="option">--ignore-externals</code></a> <a class="xref" href="#svn.ref.svn.sw.ignore_keywords"><code class="option">--ignore-keywords</code></a> <a class="xref" href="#svn.ref.svn.sw.native_eol"><code class="option">--native-eol</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> </pre></div></div><div class="refsect1"><a id="idm9962"></a><h2>Examples</h2><p>Export from your working copy (doesn't print every file and directory):</p><div class="informalexample"><pre class="screen"> $ svn export a-wc my-export Export complete. </pre></div><p>Export directly from the repository (prints every file and directory):</p><div class="informalexample"><pre class="screen"> $ svn export file:///var/svn/repos my-export A my-export/test A my-export/quiz … Exported revision 15. </pre></div><p>When rolling operating-system-specific release packages, it can be useful to export a tree that uses a specific EOL character for line endings. The <code class="option">--native-eol</code> option will do this, but it affects only files that have <code class="literal">svn:eol-style = native</code> properties attached to them. For example, to export a tree with all CRLF line endings (possibly for a Windows <code class="filename">.zip</code> file distribution):</p><div class="informalexample"><pre class="screen"> $ svn export file:///var/svn/repos my-export --native-eol CRLF A my-export/test A my-export/quiz … Exported revision 15. </pre></div><p>You can specify <code class="literal">LR</code>, <code class="literal">CR</code>, or <code class="literal">CRLF</code> as a line-ending type with the <code class="option">--native-eol</code> option.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.help"></a><div class="titlepage"></div><a id="idm9982" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn help (h, ?) — Help!</p></div><div class="refsect1"><a id="idm9989"></a><h2>Synopsis</h2><p><code class="literal">svn help [SUBCOMMAND...]</code></p></div><div class="refsect1"><a id="idm9993"></a><h2>Description</h2><p>This is your best friend when you're using Subversion and this book isn't within reach!</p></div><div class="refsect1"><a id="idm9996"></a><h2>Options</h2><p>None</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.import"></a><div class="titlepage"></div><a id="idm10000" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn import — Commit an unversioned file or tree into the repository.</p></div><div class="refsect1"><a id="idm10007"></a><h2>Synopsis</h2><p><code class="literal">svn import [PATH] URL</code></p></div><div class="refsect1"><a id="idm10011"></a><h2>Description</h2><p>Recursively commit a copy of <em class="replaceable"><code>PATH</code></em> to <em class="replaceable"><code>URL</code></em>. If <em class="replaceable"><code>PATH</code></em> is omitted, <span class="quote">“<span class="quote"><code class="filename">.</code></span>”</span> is assumed. Parent directories are created in the repository as necessary. Unversionable items such as device files and pipes are ignored even if <code class="option">--force</code> is specified.</p></div><div class="refsect1"><a id="idm10020"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.auto_props"><code class="option">--auto-props</code></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.editor_cmd"><code class="option">--editor-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.encoding"><code class="option">--encoding</code> <em class="replaceable"><code>ENC</code></em></a> <a class="xref" href="#svn.ref.svn.sw.file"><code class="option">--file</code> (<code class="option">-F</code>) <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.force_log"><code class="option">--force-log</code></a> <a class="xref" href="#svn.ref.svn.sw.message"><code class="option">--message</code> (<code class="option">-m</code>) <em class="replaceable"><code>MESSAGE</code></em></a> <a class="xref" href="#svn.ref.svn.sw.no_auto_props"><code class="option">--no-auto-props</code></a> <a class="xref" href="#svn.ref.svn.sw.no_ignore"><code class="option">--no-ignore</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.with_revprop"><code class="option">--with-revprop</code> <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm10036"></a><h2>Examples</h2><p>This imports the local directory <code class="filename">myproj</code> into <code class="filename">trunk/misc</code> in your repository. The directory <code class="filename">trunk/misc</code> need not exist before you import into it—<span class="command"><strong>svn import</strong></span> will recursively create directories for you.</p><div class="informalexample"><pre class="screen"> $ svn import -m "New import" myproj \ http://svn.red-bean.com/repos/trunk/misc Adding myproj/sample.txt … Transmitting file data ......... Committed revision 16. </pre></div><p>Be aware that this will <span class="emphasis"><em>not</em></span> create a directory named <code class="filename">myproj</code> in the repository. If that's what you want, simply add <code class="filename">myproj</code> to the end of the URL:</p><div class="informalexample"><pre class="screen"> $ svn import -m "New import" myproj \ http://svn.red-bean.com/repos/trunk/misc/myproj Adding myproj/sample.txt … Transmitting file data ......... Committed revision 16. </pre></div><p>After importing data, note that the original tree is <span class="emphasis"><em>not</em></span> under version control. To start working, you still need to <span class="command"><strong>svn checkout</strong></span> a fresh working copy of the tree.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.info"></a><div class="titlepage"></div><a id="idm10055" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn info — Display information about a local or remote item.</p></div><div class="refsect1"><a id="idm10062"></a><h2>Synopsis</h2><p><code class="literal">svn info [TARGET[@REV]...]</code></p></div><div class="refsect1"><a id="idm10066"></a><h2>Description</h2><p>Print information about the working copy paths or URLs specified. The information displayed for each path may include (as pertinent to the object at that path):</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>information about the repository in which the object is versioned</p></li><li class="listitem"><p>the most recent commit made to the specified version of the object</p></li><li class="listitem"><p>any user-level locks held on the object</p></li><li class="listitem"><p>local scheduling information (added, deleted, copied, etc.)</p></li><li class="listitem"><p>local conflict information</p></li></ul></div></div><div class="refsect1"><a id="idm10080"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.changelist"><code class="option">--changelist</code> (<code class="option">--cl</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.incremental"><code class="option">--incremental</code></a> <a class="xref" href="#svn.ref.svn.sw.recursive"><code class="option">--recursive</code> (<code class="option">-R</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.xml"><code class="option">--xml</code></a> </pre></div></div><div class="refsect1"><a id="idm10091"></a><h2>Examples</h2><p><span class="command"><strong>svn info</strong></span> will show you all the useful information that it has for items in your working copy. It will show information for files:</p><div class="informalexample"><pre class="screen"> $ svn info foo.c Path: foo.c Name: foo.c Working Copy Root Path: /home/sally/projects/test URL: http://svn.red-bean.com/repos/test/foo.c Repository Root: http://svn.red-bean.com/repos/test Repository UUID: 5e7d134a-54fb-0310-bd04-b611643e5c25 Revision: 4417 Node Kind: file Schedule: normal Last Changed Author: sally Last Changed Rev: 20 Last Changed Date: 2003-01-13 16:43:13 -0600 (Mon, 13 Jan 2003) Text Last Updated: 2003-01-16 21:18:16 -0600 (Thu, 16 Jan 2003) Properties Last Updated: 2003-01-13 21:50:19 -0600 (Mon, 13 Jan 2003) Checksum: d6aeb60b0662ccceb6bce4bac344cb66 </pre></div><p>It will also show information for directories:</p><div class="informalexample"><pre class="screen"> $ svn info vendors Path: vendors Working Copy Root Path: /home/sally/projects/test URL: http://svn.red-bean.com/repos/test/vendors Repository Root: http://svn.red-bean.com/repos/test Repository UUID: 5e7d134a-54fb-0310-bd04-b611643e5c25 Revision: 19 Node Kind: directory Schedule: normal Last Changed Author: harry Last Changed Rev: 19 Last Changed Date: 2003-01-16 23:21:19 -0600 (Thu, 16 Jan 2003) Properties Last Updated: 2003-01-16 23:39:02 -0600 (Thu, 16 Jan 2003) </pre></div><p><span class="command"><strong>svn info</strong></span> also acts on URLs (also note that the file <code class="filename">readme.doc</code> in this example is locked, so lock information is also provided):</p><div class="informalexample"><pre class="screen"> $ svn info http://svn.red-bean.com/repos/test/readme.doc Path: readme.doc Name: readme.doc URL: http://svn.red-bean.com/repos/test/readme.doc Repository Root: http://svn.red-bean.com/repos/test Repository UUID: 5e7d134a-54fb-0310-bd04-b611643e5c25 Revision: 1 Node Kind: file Schedule: normal Last Changed Author: sally Last Changed Rev: 42 Last Changed Date: 2003-01-14 23:21:19 -0600 (Tue, 14 Jan 2003) Lock Token: opaquelocktoken:14011d4b-54fb-0310-8541-dbd16bd471b2 Lock Owner: harry Lock Created: 2003-01-15 17:35:12 -0600 (Wed, 15 Jan 2003) Lock Comment (1 line): My test lock comment </pre></div><p>Lastly, <span class="command"><strong>svn info</strong></span> output is available in XML format by passing the <code class="option">--xml</code> option:</p><div class="informalexample"><pre class="screen"> $ svn info --xml http://svn.red-bean.com/repos/test &lt;?xml version="1.0"?&gt; &lt;info&gt; &lt;entry kind="dir" path="." revision="1"&gt; &lt;url&gt;http://svn.red-bean.com/repos/test&lt;/url&gt; &lt;repository&gt; &lt;root&gt;http://svn.red-bean.com/repos/test&lt;/root&gt; &lt;uuid&gt;5e7d134a-54fb-0310-bd04-b611643e5c25&lt;/uuid&gt; &lt;/repository&gt; &lt;wc-info&gt; &lt;schedule&gt;normal&lt;/schedule&gt; &lt;depth&gt;infinity&lt;/depth&gt; &lt;/wc-info&gt; &lt;commit revision="1"&gt; &lt;author&gt;sally&lt;/author&gt; &lt;date&gt;2003-01-15T23:35:12.847647Z&lt;/date&gt; &lt;/commit&gt; &lt;/entry&gt; &lt;/info&gt; </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.list"></a><div class="titlepage"></div><a id="idm10111" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn list (ls) — List directory entries in the repository.</p></div><div class="refsect1"><a id="idm10118"></a><h2>Synopsis</h2><p><code class="literal">svn list [TARGET[@REV]...]</code></p></div><div class="refsect1"><a id="idm10122"></a><h2>Description</h2><p>List each <em class="replaceable"><code>TARGET</code></em> file and the contents of each <em class="replaceable"><code>TARGET</code></em> directory as they exist in the repository. If <em class="replaceable"><code>TARGET</code></em> is a working copy path, the corresponding repository URL will be used.</p><p>The default <em class="replaceable"><code>TARGET</code></em> is <span class="quote">“<span class="quote"><code class="filename">.</code></span>”</span>, meaning the repository URL of the current working copy directory.</p><p>With <code class="option">--verbose</code> (<code class="option">-v</code>), <span class="command"><strong>svn list</strong></span> shows the following fields for each item:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Revision number of the last commit</p></li><li class="listitem"><p>Author of the last commit</p></li><li class="listitem"><p>If locked, the letter <span class="quote">“<span class="quote">O</span>”</span> (see the preceding section on <a class="xref" href="#svn.ref.svn.c.info" title="svn info">svn info</a> for details).</p></li><li class="listitem"><p>Size (in bytes)</p></li><li class="listitem"><p>Date and time of the last commit</p></li></ul></div><p>With <code class="option">--xml</code>, output is in XML format (with a header and an enclosing document element unless <code class="option">--incremental</code> is also specified). All of the information is present; the <code class="option">--verbose</code> (<code class="option">-v</code>) option is not accepted.</p></div><div class="refsect1"><a id="idm10154"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.incremental"><code class="option">--incremental</code></a> <a class="xref" href="#svn.ref.svn.sw.recursive"><code class="option">--recursive</code> (<code class="option">-R</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.verbose"><code class="option">--verbose</code> (<code class="option">-v</code>)</a> <a class="xref" href="#svn.ref.svn.sw.xml"><code class="option">--xml</code></a> </pre></div></div><div class="refsect1"><a id="idm10164"></a><h2>Examples</h2><p><span class="command"><strong>svn list</strong></span> is most useful if you want to see what files a repository has without downloading a working copy:</p><div class="informalexample"><pre class="screen"> $ svn list http://svn.red-bean.com/repos/test/support README.txt INSTALL examples/ … </pre></div><p>You can pass the <code class="option">--verbose</code> (<code class="option">-v</code>) option for additional information, rather like the Unix command <span class="command"><strong>ls -l</strong></span>:</p><div class="informalexample"><pre class="screen"> $ svn list -v file:///var/svn/repos 16 sally 28361 Jan 16 23:18 README.txt 27 sally 0 Jan 18 15:27 INSTALL 24 harry Jan 18 11:27 examples/ </pre></div><p>You can also get <span class="command"><strong>svn list</strong></span> output in XML format with the <code class="option">--xml</code> option:</p><div class="informalexample"><pre class="screen"> $ svn list --xml http://svn.red-bean.com/repos/test &lt;?xml version="1.0"?&gt; &lt;lists&gt; &lt;list path="http://svn.red-bean.com/repos/test"&gt; &lt;entry kind="dir"&gt; &lt;name&gt;examples&lt;/name&gt; &lt;size&gt;0&lt;/size&gt; &lt;commit revision="24"&gt; &lt;author&gt;harry&lt;/author&gt; &lt;date&gt;2008-01-18T06:35:53.048870Z&lt;/date&gt; &lt;/commit&gt; &lt;/entry&gt; ... &lt;/list&gt; &lt;/lists&gt; </pre></div><p>For further details, see the earlier section <a class="xref" href="#svn.tour.history.browsing.list" title="Listing versioned directories">the section called “Listing versioned directories”</a>.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.lock"></a><div class="titlepage"></div><a id="idm10184" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn lock — Lock working copy paths or URLs in the repository so that no other user can commit changes to them.</p></div><div class="refsect1"><a id="idm10191"></a><h2>Synopsis</h2><p><code class="literal">svn lock TARGET...</code></p></div><div class="refsect1"><a id="idm10195"></a><h2>Description</h2><p>Lock each <em class="replaceable"><code>TARGET</code></em>. If any <em class="replaceable"><code>TARGET</code></em> is already locked by another user, print a warning and continue locking the rest of the <em class="replaceable"><code>TARGET</code></em>s. Use <code class="option">--force</code> to steal a lock from another user or working copy.</p></div><div class="refsect1"><a id="idm10202"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.encoding"><code class="option">--encoding</code> <em class="replaceable"><code>ENC</code></em></a> <a class="xref" href="#svn.ref.svn.sw.file"><code class="option">--file</code> (<code class="option">-F</code>) <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.force_log"><code class="option">--force-log</code></a> <a class="xref" href="#svn.ref.svn.sw.message"><code class="option">--message</code> (<code class="option">-m</code>) <em class="replaceable"><code>MESSAGE</code></em></a> <a class="xref" href="#svn.ref.svn.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> </pre></div></div><div class="refsect1"><a id="idm10212"></a><h2>Examples</h2><p>Lock two files in your working copy:</p><div class="informalexample"><pre class="screen"> $ svn lock tree.jpg house.jpg 'tree.jpg' locked by user 'harry'. 'house.jpg' locked by user 'harry'. </pre></div><p>Lock a file in your working copy that is currently locked by another user:</p><div class="informalexample"><pre class="screen"> $ svn lock tree.jpg svn: warning: W160035: Path '/tree.jpg is already locked by user 'sally' in fi lesystem '/var/svn/repos/db' $ svn lock --force tree.jpg 'tree.jpg' locked by user 'harry'. </pre></div><p>Lock a file without a working copy:</p><div class="informalexample"><pre class="screen"> $ svn lock http://svn.red-bean.com/repos/test/tree.jpg 'tree.jpg' locked by user 'harry'. </pre></div><p>For further details, see <a class="xref" href="#svn.advanced.locking" title="Locking">the section called “Locking”</a>.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.log"></a><div class="titlepage"></div><a id="idm10226" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn log — Display commit log messages.</p></div><div class="refsect1"><a id="idm10233"></a><h2>Synopsis</h2><p><code class="literal">svn log [PATH]</code></p><p><code class="literal">svn log URL[@REV] [PATH...]</code></p></div><div class="refsect1"><a id="idm10239"></a><h2>Description</h2><p>Shows log messages from the repository. If no arguments are supplied, <span class="command"><strong>svn log</strong></span> shows the log messages for all files and directories inside (and including) the current working directory of your working copy. You can refine the results by specifying a path, one or more revisions, or any combination of the two. The default revision range for a local path is <code class="literal">BASE:1</code>.</p><p>If you specify a URL alone, it prints log messages for everything the URL contains. If you add paths past the URL, only messages for those paths under that URL will be printed. The default revision range for a URL is <code class="literal">HEAD:1</code>.</p><p>With <code class="option">--verbose</code> (<code class="option">-v</code>), <span class="command"><strong>svn log</strong></span> will also print all affected paths with each log message. With <code class="option">--quiet</code> (<code class="option">-q</code>), <span class="command"><strong>svn log</strong></span> will not print the log message body itself, this is compatible with <code class="option">--verbose</code> (<code class="option">-v</code>).</p><p>Each log message is printed just once, even if more than one of the affected paths for that revision were explicitly requested. Logs follow copy history by default. Use <code class="option">--stop-on-copy</code> to disable this behavior, which can be useful for determining branch points.</p></div><div class="refsect1"><a id="idm10257"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.change"><code class="option">--change</code> (<code class="option">-c</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.diff"><code class="option">--diff</code></a> <a class="xref" href="#svn.ref.svn.sw.diff_cmd"><code class="option">--diff-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.extensions"><code class="option">--extensions</code> (<code class="option">-x</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.incremental"><code class="option">--incremental</code></a> <a class="xref" href="#svn.ref.svn.sw.internal_diff"><code class="option">--internal-diff</code></a> <a class="xref" href="#svn.ref.svn.sw.limit"><code class="option">--limit</code> (<code class="option">-l</code>) <em class="replaceable"><code>NUM</code></em></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.stop_on_copy"><code class="option">--stop-on-copy</code></a> <a class="xref" href="#svn.ref.svn.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.use_merge_history"><code class="option">--use-merge-history</code> (<code class="option">-g</code>)</a> <a class="xref" href="#svn.ref.svn.sw.verbose"><code class="option">--verbose</code> (<code class="option">-v</code>)</a> <a class="xref" href="#svn.ref.svn.sw.with_all_revprops"><code class="option">--with-all-revprops</code></a> <a class="xref" href="#svn.ref.svn.sw.with_no_revprops"><code class="option">--with-no-revprops</code></a> <a class="xref" href="#svn.ref.svn.sw.with_revprop"><code class="option">--with-revprop</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.xml"><code class="option">--xml</code></a> </pre></div></div><div class="refsect1"><a id="idm10279"></a><h2>Examples</h2><p>You can see the log messages for all the paths that changed in your working copy by running <strong class="userinput"><code>svn log</code></strong> from the top:</p><div class="informalexample"><pre class="screen"> $ svn log ------------------------------------------------------------------------ r20 | harry | 2003-01-17 22:56:19 -0600 (Fri, 17 Jan 2003) | 1 line Tweak. ------------------------------------------------------------------------ r17 | sally | 2003-01-16 23:21:19 -0600 (Thu, 16 Jan 2003) | 2 lines … </pre></div><p>Examine all log messages for a particular file in your working copy:</p><div class="informalexample"><pre class="screen"> $ svn log foo.c ------------------------------------------------------------------------ r32 | sally | 2003-01-13 00:43:13 -0600 (Mon, 13 Jan 2003) | 1 line Added defines. ------------------------------------------------------------------------ r28 | sally | 2003-01-07 21:48:33 -0600 (Tue, 07 Jan 2003) | 3 lines … </pre></div><p>If you don't have a working copy handy, you can log a URL:</p><div class="informalexample"><pre class="screen"> $ svn log http://svn.red-bean.com/repos/test/foo.c ------------------------------------------------------------------------ r32 | sally | 2003-01-13 00:43:13 -0600 (Mon, 13 Jan 2003) | 1 line Added defines. ------------------------------------------------------------------------ r28 | sally | 2003-01-07 21:48:33 -0600 (Tue, 07 Jan 2003) | 3 lines … </pre></div><p>If you want several distinct paths underneath the same URL, you can use the <code class="literal">URL [PATH...]</code> syntax:</p><div class="informalexample"><pre class="screen"> $ svn log http://svn.red-bean.com/repos/test/ foo.c bar.c ------------------------------------------------------------------------ r32 | sally | 2003-01-13 00:43:13 -0600 (Mon, 13 Jan 2003) | 1 line Added defines. ------------------------------------------------------------------------ r31 | harry | 2003-01-10 12:25:08 -0600 (Fri, 10 Jan 2003) | 1 line Added new file bar.c ------------------------------------------------------------------------ r28 | sally | 2003-01-07 21:48:33 -0600 (Tue, 07 Jan 2003) | 3 lines … </pre></div><p>The <code class="option">--verbose</code> (<code class="option">-v</code>) option causes <span class="command"><strong>svn log</strong></span> to include information about the paths that were changed in each displayed revision. These paths appear, one path per line of output, with action codes that indicate what type of change was made to the path.</p><div class="informalexample"><pre class="screen"> $ svn log -v http://svn.red-bean.com/repos/test/ foo.c bar.c ------------------------------------------------------------------------ r32 | sally | 2003-01-13 00:43:13 -0600 (Mon, 13 Jan 2003) | 1 line Changed paths: M /foo.c Added defines. ------------------------------------------------------------------------ r31 | harry | 2003-01-10 12:25:08 -0600 (Fri, 10 Jan 2003) | 1 line Changed paths: A /bar.c Added new file bar.c ------------------------------------------------------------------------ r28 | sally | 2003-01-07 21:48:33 -0600 (Tue, 07 Jan 2003) | 3 lines … </pre></div><p><span class="command"><strong>svn log</strong></span> uses just a handful of action codes, and they are similar to the ones the <span class="command"><strong>svn update</strong></span> command uses:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">A</code></span></dt><dd><p>The item was added.</p></dd><dt><span class="term"><code class="literal">D</code></span></dt><dd><p>The item was deleted.</p></dd><dt><span class="term"><code class="literal">M</code></span></dt><dd><p>Properties or textual contents on the item were changed.</p></dd><dt><span class="term"><code class="literal">R</code></span></dt><dd><p>The item was replaced by a different one at the same location.</p></dd></dl></div><p>In addition to the action codes which precede the changed paths, <span class="command"><strong>svn log</strong></span> with the <code class="option">--verbose</code> (<code class="option">-v</code>) option will note whether a path was added or replaced as the result of a copy operation. It does so by printing <code class="literal">(from <em class="replaceable"><code>COPY-FROM-PATH</code></em>:<em class="replaceable"><code>COPY-FROM-REV</code></em>)</code> after such paths.</p><p>When you're concatenating the results of multiple calls to the log command, you may want to use the <code class="option">--incremental</code> option. <span class="command"><strong>svn log</strong></span> normally prints out a dashed line at the beginning of a log message, after each subsequent log message, and following the final log message. If you ran <span class="command"><strong>svn log</strong></span> on a range of two revisions, you would get this:</p><div class="informalexample"><pre class="screen"> $ svn log -r 14:15 ------------------------------------------------------------------------ r14 | … ------------------------------------------------------------------------ r15 | … ------------------------------------------------------------------------ </pre></div><p>However, if you wanted to gather two nonsequential log messages into a file, you might do something like this:</p><div class="informalexample"><pre class="screen"> $ svn log -r 14 &gt; mylog $ svn log -r 19 &gt;&gt; mylog $ svn log -r 27 &gt;&gt; mylog $ cat mylog ------------------------------------------------------------------------ r14 | … ------------------------------------------------------------------------ ------------------------------------------------------------------------ r19 | … ------------------------------------------------------------------------ ------------------------------------------------------------------------ r27 | … ------------------------------------------------------------------------ </pre></div><p>You can avoid the clutter of the double dashed lines in your output by using the <code class="option">--incremental</code> option:</p><div class="informalexample"><pre class="screen"> $ svn log --incremental -r 14 &gt; mylog $ svn log --incremental -r 19 &gt;&gt; mylog $ svn log --incremental -r 27 &gt;&gt; mylog $ cat mylog ------------------------------------------------------------------------ r14 | … ------------------------------------------------------------------------ r19 | … ------------------------------------------------------------------------ r27 | … </pre></div><p>The <code class="option">--incremental</code> option provides similar output control when using the <code class="option">--xml</code> option:</p><div class="informalexample"><pre class="screen"> $ svn log --xml --incremental -r 1 sandwich.txt &lt;logentry revision="1"&gt; &lt;author&gt;harry&lt;/author&gt; &lt;date&gt;2008-06-03T06:35:53.048870Z&lt;/date&gt; &lt;msg&gt;Initial Import.&lt;/msg&gt; &lt;/logentry&gt; </pre></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Sometimes when you run <span class="command"><strong>svn log</strong></span> on a specific path and a specific revision, you see no log information output at all, as in the following:</p><div class="informalexample"><pre class="screen"> $ svn log -r 20 http://svn.red-bean.com/untouched.txt ------------------------------------------------------------------------ </pre></div><p>That just means the path wasn't modified in that revision. To get log information for that revision, either run the log operation against the repository's root URL, or specify a path that you happen to know was changed in that revision:</p><div class="informalexample"><pre class="screen"> $ svn log -r 20 touched.txt ------------------------------------------------------------------------ r20 | sally | 2003-01-17 22:56:19 -0600 (Fri, 17 Jan 2003) | 1 line Made a change. ------------------------------------------------------------------------ </pre></div></td></tr></table></div><p>Beginning with Subversion 1.7, users can take advantage of a special output mode which combines the information from <span class="command"><strong>svn log</strong></span> with what you would see when running <span class="command"><strong>svn diff</strong></span> on the same targets for each revision of the log. Simply invoke <span class="command"><strong>svn log</strong></span> with the <code class="option">--diff</code> option to trigger this output mode.</p><div class="informalexample"><pre class="screen"> $ svn log -r 20 touched.txt --diff ------------------------------------------------------------------------ r20 | sally | 2003-01-17 22:56:19 -0600 (Fri, 17 Jan 2003) | 1 line Made a change. Index: touched.txt =================================================================== --- touched.txt (revision 19) +++ touched.txt (revision 20) @@ -1 +1,2 @@ This is the file 'touched.txt'. +We add such exciting text to files around here! ------------------------------------------------------------------------ $ </pre></div><p>As with <span class="command"><strong>svn diff</strong></span>, you may also make use of many of the various options which control the way the difference is generated, including <code class="option">--depth</code>, <code class="option">--diff-cmd</code>, and <code class="option">--extensions</code> (<code class="option">-x</code>).</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.merge"></a><div class="titlepage"></div><a id="idm10372" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn merge — Apply the differences between two sources to a working copy path.</p></div><div class="refsect1"><a id="idm10379"></a><h2>Synopsis</h2><p><code class="literal">svn merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]</code></p><p><code class="literal">svn merge --reintegrate SOURCE[@REV] [TARGET_WCPATH]</code></p><p><code class="literal">svn merge SOURCE1[@N] SOURCE2[@M] [TARGET_WCPATH]</code></p></div><div class="refsect1"><a id="idm10387"></a><h2>Description</h2><p>In all three forms <em class="replaceable"><code>TARGET_WCPATH</code></em> is the working copy path that will receive the differences. If <em class="replaceable"><code>TARGET_WCPATH</code></em> is omitted, the changes are applied to the current working directory, unless the sources have identical basenames that match a file within the current working directory. In this case, the differences will be applied to that file.</p><p>In the first two forms, <em class="replaceable"><code>SOURCE</code></em> can be either a URL or a working copy path (in which case its corresponding URL is used). If the peg revision <em class="replaceable"><code>REV</code></em> is not specified, then <code class="literal">HEAD</code> is assumed. In the third form the same rules apply for <em class="replaceable"><code>SOURCE1</code></em>, <em class="replaceable"><code>SOURCE2</code></em>, <em class="replaceable"><code>M</code></em>, and <em class="replaceable"><code>N</code></em> with the only difference being that if either source is a working copy path, then the peg revisions <span class="emphasis"><em>must</em></span> be explicitly stated.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Sync and Cherrypick Merges</p><p>The first form, when used without either the <code class="option">-c</code> or <code class="option">-r</code> options, is called a <span class="quote">“<span class="quote">sync</span>”</span> merge and <code class="literal">-r 1:REV</code> is implied. This variant is used to merge all eligible changes to a branch from its immediate ancestor branch, see <a class="xref" href="#svn.branchemerge.basicmerging.stayinsync" title="Keeping a Branch in Sync">the section called “Keeping a Branch in Sync”</a>. </p><p>When the first form is used with the <code class="option">-c</code> or <code class="option">-r</code> options, this is called a <span class="quote">“<span class="quote">cherrypick</span>”</span> merge and is used to merge an explicitly defined set of changes from one branch to another, see <a class="xref" href="#svn.branchmerge.cherrypicking" title="Cherrypicking">the section called “Cherrypicking”</a></p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Multiple <code class="literal">-c</code> and/or <code class="literal">-r</code> instances may be specified, and mixing of forward and reverse ranges is allowed— the ranges are internally compacted to their minimum representation before merging begins (which may result in a no-op merge or conflicts that cause the merge to stop before merging all of the requested revisions).</p></td></tr></table></div><p>In both variants of the first form, <em class="replaceable"><code>SOURCE</code></em> in revision <em class="replaceable"><code>REV</code></em> is compared as it existed between revisions <em class="replaceable"><code>N</code></em> and <em class="replaceable"><code>M</code></em> for each revision range provided.</p></li><li class="listitem"><p>Reintegrate Merges</p><p>The second form is called a <span class="quote">“<span class="quote">reintegrate merge</span>”</span> and is used to bring changes from a feature branch (<em class="replaceable"><code>SOURCE</code></em>) back into the feature branch's immediate ancestor branch (<em class="replaceable"><code>TARGET_WCPATH</code></em>).</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Reintegrate merges support only this specialized use case and as such have a number of special requirements and limitations that the other two merge forms do not posses. See <a class="xref" href="#svn.branchemerge.basicmerging.stayinsync" title="Keeping a Branch in Sync">the section called “Keeping a Branch in Sync”</a>, <a class="xref" href="#svn.branchemerge.basicmerging.reintegrate" title="Reintegrating a Branch">the section called “Reintegrating a Branch”</a>, <a class="xref" href="#svn.branchmerge.advanced.reintegratetwice" title="Keeping a Reintegrated Branch Alive">the section called “Keeping a Reintegrated Branch Alive”</a>, and <a class="xref" href="#svn.branchmerge.commonpatterns.feature" title="Feature Branches">the section called “Feature Branches”</a>. </p></td></tr></table></div></li><li class="listitem"><p>2-URL Merges</p><p>In the third form, called a <span class="quote">“<span class="quote">2-URL Merge</span>”</span>, the difference between <em class="replaceable"><code>SOURCE1</code></em> at revision <em class="replaceable"><code>N</code></em> and <em class="replaceable"><code>SOURCE2</code></em> at revision <em class="replaceable"><code>M</code></em> is generated and applied to <em class="replaceable"><code>TARGET_WCPATH</code></em>. The revisions default to <code class="literal">HEAD</code> if omitted.</p></li></ul></div><p>If <a class="xref" href="#svn.branchmerge.basicmerging.mergetracking" title="Merge Tracking">Merge Tracking</a> is active, then Subversion will internally track metadata (i.e. the <code class="literal">svn:mergeinfo</code> property) about merge operations when the two merge sources are ancestrally related—if the first source is an ancestor of the second or vice versa—this is guaranteed to be the case when using the first two forms. Subversion will also take preexisting merge metadata on the working copy target into account when determining what revisions to merge and in an effort to avoid repeat merges and needless conflicts it may only merge a subset of the requested ranges.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p><a class="xref" href="#svn.branchmerge.basicmerging.mergetracking" title="Merge Tracking">Merge Tracking</a> can be disabled by using the <code class="option">--ignore-ancestry</code> option.</p></td></tr></table></div><p>Unlike <span class="command"><strong>svn diff</strong></span>, the merge command takes the ancestry of a file into consideration when performing a merge operation. This is very important when you're merging changes from one branch into another and you've renamed a file on one branch but not the other.</p></div><div class="refsect1"><a id="idm10455"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.accept"><code class="option">--accept</code> <em class="replaceable"><code>ACTION</code></em></a> <a class="xref" href="#svn.ref.svn.sw.allow_mixed_revisions"><code class="option">--allow-mixed-revisions</code></a> <a class="xref" href="#svn.ref.svn.sw.change"><code class="option">--change</code> (<code class="option">-c</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.diff3_cmd"><code class="option">--diff3-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.dry_run"><code class="option">--dry-run</code></a> <a class="xref" href="#svn.ref.svn.sw.extensions"><code class="option">--extensions</code> (<code class="option">-x</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.ignore_ancestry"><code class="option">--ignore-ancestry</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.record_only"><code class="option">--record-only</code></a> <a class="xref" href="#svn.ref.svn.sw.reintegrate"><code class="option">--reintegrate</code></a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> </pre></div></div><div class="refsect1"><a id="idm10472"></a><h2>Examples</h2><p>Merge a branch back into the trunk (assuming that you have an up-to-date working copy of the trunk):</p><div class="informalexample"><pre class="screen"> $ svn merge --reintegrate \ http://svn.example.com/repos/calc/branches/my-calc-branch --- Merging differences between repository URLs into '.': U button.c U integer.c U Makefile U . --- Recording mergeinfo for merge between repository URLs into '.': U . $ # build, test, verify, ... $ svn commit -m "Merge my-calc-branch back into trunk!" Sending . Sending button.c Sending integer.c Sending Makefile Transmitting file data .. Committed revision 391. </pre></div><p>To merge changes to a single file:</p><div class="informalexample"><pre class="screen"> $ svn merge -c 31 ^/trunk/thhgttg.txt thhgttg.txt --- Merging r31 into 'thhgttg.txt': U thhgttg.txt --- Recording mergeinfo for merge of r31 into 'thhgttg.txt': U thhgttg.txt </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.mergeinfo"></a><div class="titlepage"></div><a id="idm10481" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn mergeinfo — Query merge-related information. See <a class="xref" href="#svn.branchmerge.basicmerging.mergeinfo" title="Mergeinfo and Previews">the section called “Mergeinfo and Previews”</a> for details.</p></div><div class="refsect1"><a id="idm10489"></a><h2>Synopsis</h2><p><code class="literal">svn mergeinfo SOURCE_URL[@REV] [TARGET[@REV]]</code></p></div><div class="refsect1"><a id="idm10493"></a><h2>Description</h2><p>Query information related to merges (or potential merges) between <em class="replaceable"><code>SOURCE-URL</code></em> and <em class="replaceable"><code>TARGET</code></em>. If the <code class="option">--show-revs</code> option is not provided, display revisions which have been merged from <em class="replaceable"><code>SOURCE-URL</code></em> to <em class="replaceable"><code>TARGET</code></em>. Otherwise, display either <code class="literal">merged</code> or <code class="literal">eligible</code> revisions as specified by the <code class="option">--show-revs</code> option.</p></div><div class="refsect1"><a id="idm10504"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.recursive"><code class="option">--recursive</code> (<code class="option">-R</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.show_revs"><code class="option">--show-revs</code> <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm10512"></a><h2>Examples</h2><p>Find out which changesets your have been merged from your trunk directory into your test branch:</p><div class="informalexample"><pre class="screen"> $ svn propget svn:mergeinfo ^/branches/test /branches/other:3-4 /trunk:11-13,14,16 $ svn mergeinfo --show-revs merged ^/trunk ^/branches/test r11 r12 r13 r14 r16 $ </pre></div><p>Note that the default output from the <span class="command"><strong>svn mergeinfo</strong></span> command is to display merged revisions, so the <code class="option">--show-revs</code> option shown in the command line of the previous example is not strictly required.</p><p>Find out which changesets from your trunk directory have not yet been merged into your test branch:</p><div class="informalexample"><pre class="screen"> $ svn mergeinfo --show-revs eligible ^/trunk ^/branches/test r15 r17 r20 r21 r22 $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.mkdir"></a><div class="titlepage"></div><a id="idm10524" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn mkdir — Create a new directory under version control.</p></div><div class="refsect1"><a id="idm10531"></a><h2>Synopsis</h2><p><code class="literal">svn mkdir PATH...</code></p><p><code class="literal">svn mkdir URL...</code></p></div><div class="refsect1"><a id="idm10537"></a><h2>Description</h2><p>Create a directory with a name given by the final component of the <em class="replaceable"><code>PATH</code></em> or <em class="replaceable"><code>URL</code></em>. A directory specified by a working copy <em class="replaceable"><code>PATH</code></em> is scheduled for addition in the working copy. A directory specified by a URL is created in the repository via an immediate commit. Multiple directory URLs are committed atomically. In both cases, all the intermediate directories must already exist unless the <code class="option">--parents</code> option is used.</p></div><div class="refsect1"><a id="idm10544"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.editor_cmd"><code class="option">--editor-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.encoding"><code class="option">--encoding</code> <em class="replaceable"><code>ENC</code></em></a> <a class="xref" href="#svn.ref.svn.sw.file"><code class="option">--file</code> (<code class="option">-F</code>) <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force_log"><code class="option">--force-log</code></a> <a class="xref" href="#svn.ref.svn.sw.message"><code class="option">--message</code> (<code class="option">-m</code>) <em class="replaceable"><code>MESSAGE</code></em></a> <a class="xref" href="#svn.ref.svn.sw.parents"><code class="option">--parents</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.with_revprop"><code class="option">--with-revprop</code> <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm10556"></a><h2>Examples</h2><p>Create a directory in your working copy:</p><div class="informalexample"><pre class="screen"> $ svn mkdir newdir A newdir </pre></div><p>Create one in the repository (this is an instant commit, so a log message is required):</p><div class="informalexample"><pre class="screen"> $ svn mkdir -m "Making a new dir." http://svn.red-bean.com/repos/newdir Committed revision 26. </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.move"></a><div class="titlepage"></div><a id="idm10565" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn move (mv) — Move a file or directory.</p></div><div class="refsect1"><a id="idm10572"></a><h2>Synopsis</h2><p><code class="literal">svn move SRC... DST</code></p></div><div class="refsect1"><a id="idm10576"></a><h2>Description</h2><p>This command moves files or directories in your working copy or in the repository.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>This command is equivalent to an <span class="command"><strong>svn copy</strong></span> followed by <span class="command"><strong>svn delete</strong></span>.</p></td></tr></table></div><p>When moving multiple sources, they will be added as children of <em class="replaceable"><code>DST</code></em>, which must be a directory.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Subversion does not support moving between working copies and URLs. In addition, you can only move files within a single repository—Subversion does not support cross-repository moving. Subversion supports the following types of moves within a single repository:</p></td></tr></table></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">WC → WC</span></dt><dd><p>Move and schedule a file or directory for addition (with history).</p></dd><dt><span class="term">URL → URL</span></dt><dd><p>Complete server-side rename.</p></dd></dl></div></div><div class="refsect1"><a id="idm10596"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.editor_cmd"><code class="option">--editor-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.encoding"><code class="option">--encoding</code> <em class="replaceable"><code>ENC</code></em></a> <a class="xref" href="#svn.ref.svn.sw.file"><code class="option">--file</code> (<code class="option">-F</code>) <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.force_log"><code class="option">--force-log</code></a> <a class="xref" href="#svn.ref.svn.sw.message"><code class="option">--message</code> (<code class="option">-m</code>) <em class="replaceable"><code>MESSAGE</code></em></a> <a class="xref" href="#svn.ref.svn.sw.parents"><code class="option">--parents</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.with_revprop"><code class="option">--with-revprop</code> <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm10610"></a><h2>Examples</h2><p>Move a file in your working copy:</p><div class="informalexample"><pre class="screen"> $ svn move foo.c bar.c A bar.c D foo.c </pre></div><p>Move several files in your working copy into a subdirectory:</p><div class="informalexample"><pre class="screen"> $ svn move baz.c bat.c qux.c src A src/baz.c D baz.c A src/bat.c D bat.c A src/qux.c D qux.c </pre></div><p>Move a file in the repository (this is an immediate commit, so it requires a commit message):</p><div class="informalexample"><pre class="screen"> $ svn move -m "Move a file" http://svn.red-bean.com/repos/foo.c \ http://svn.red-bean.com/repos/bar.c Committed revision 27. </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.patch"></a><div class="titlepage"></div><a id="idm10622" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn patch — Apply changes represented in a unidiff patch to the working copy.</p></div><div class="refsect1"><a id="idm10629"></a><h2>Synopsis</h2><p><code class="literal">svn patch PATCHFILE [WCPATH]</code></p></div><div class="refsect1"><a id="idm10633"></a><h2>Description</h2><p>This subcommand will apply changes described a unidiff-formatted patch file <em class="replaceable"><code>PATCHFILE</code></em> to the working copy <em class="replaceable"><code>WCPATH</code></em>. As with most other working copy subcommands, if <em class="replaceable"><code>WCPATH</code></em> is omitted, the changes are applied to the current working directory. A unidiff patch suitable for application to a working copy can be produced with the <span class="command"><strong>svn diff</strong></span> command or third-party differencing tools. Any non-unidiff content found in the patch file is ignored.</p><p>Changes listed in the patch file will either be applied or rejected. If a change does not match at its exact line offset, it may be applied earlier or later in the file if a match is found elsewhere for the surrounding lines of context provided by the patch. A change may also be applied with <em class="firstterm">fuzz</em>—meaning, one or more lines of context are ignored when attempting to match the change location. If no matching context can be found for a change, the change conflicts and will be written to a reject file which bears the extension <code class="filename">.svnpatch.rej</code>.</p><p><span class="command"><strong>svn patch</strong></span> reports a status line for patched file or directory using letter codes, very similar to the way that <span class="command"><strong>svn update</strong></span> provides notification. The letter codes have the following meanings:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">A</code></span></dt><dd><p>Added</p></dd><dt><span class="term"><code class="literal">D</code></span></dt><dd><p>Deleted</p></dd><dt><span class="term"><code class="literal">C</code></span></dt><dd><p>Conflicted</p></dd><dt><span class="term"><code class="literal">G</code></span></dt><dd><p>Merged</p></dd><dt><span class="term"><code class="literal">U</code></span></dt><dd><p>Updated</p></dd></dl></div><p>Changes applied with an offset or fuzz are reported on lines starting with the '<code class="literal">&gt;</code>' symbol. You should review such changes carefully.</p><p>If the patch removes all content from a file, that file is automatically scheduled for deletion. Likewise, if the patch creates a new file, that file is automatically scheduled for addition. Use <span class="command"><strong>svn revert</strong></span> to undo undesired deletions and additions.</p></div><div class="refsect1"><a id="idm10676"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.dry_run"><code class="option">--dry-run</code></a> <a class="xref" href="#svn.ref.svn.sw.ignore_whitespace"><code class="option">--ignore-whitespace</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.reverse_diff"><code class="option">--reverse-diff</code></a> <a class="xref" href="#svn.ref.svn.sw.strip"><code class="option">--strip</code> <em class="replaceable"><code>NUM</code></em></a> </pre></div></div><div class="refsect1"><a id="idm10685"></a><h2>Examples</h2><p>Apply a simple patch file generated by the <span class="command"><strong>svn diff</strong></span> command. Our patch file will create a new file, delete another file, and modify a third's contents and properties. Here's the patch file itself (which we'll assume is creatively named <code class="filename">PATCH</code>):</p><div class="informalexample"><pre class="programlisting"> Index: deleted-file =================================================================== --- deleted-file (revision 3) +++ deleted-file (working copy) @@ -1 +0,0 @@ -This file will be deleted. Index: changed-file =================================================================== --- changed-file (revision 4) +++ changed-file (working copy) @@ -1,6 +1,6 @@ The letters in a line of text Could make your day much better. But expanded into paragraphs, -I'd tell of kangaroos and calves +I'd tell of monkeys and giraffes Until you were all smiles and laughs From my letter made of letters. Property changes on: changed-file ___________________________________________________________________ Added: propname ## -0,0 +1 ## +propvalue Index: added-file =================================================================== --- added-file (revision 0) +++ added-file (working copy) @@ -0,0 +1 @@ +This is an added file. </pre></div><p>We can apply the previous patch file to another working copy from our repository using <span class="command"><strong>svn patch</strong></span>, and verify that it did the right thing by using <span class="command"><strong>svn diff</strong></span>:</p><div class="informalexample"><pre class="screen"> $ cd /some/other/workingcopy $ svn patch /path/to/PATCH D deleted-file UU changed-file A added-file $ svn diff Index: deleted-file =================================================================== --- deleted-file (revision 3) +++ deleted-file (working copy) @@ -1 +0,0 @@ -This file will be deleted. Index: changed-file =================================================================== --- changed-file (revision 4) +++ changed-file (working copy) @@ -1,6 +1,6 @@ The letters in a line of text Could make your day much better. But expanded into paragraphs, -I'd tell of kangaroos and calves +I'd tell of monkeys and giraffes Until you were all smiles and laughs From my letter made of letters. Property changes on: changed-file ___________________________________________________________________ Added: propname ## -0,0 +1 ## +propvalue Index: added-file =================================================================== --- added-file (revision 0) +++ added-file (working copy) @@ -0,0 +1 @@ +This is an added file. $ </pre></div><p>Sometimes you might need Subversion to interpret a patch <span class="quote">“<span class="quote">in reverse</span>”</span>—where added things get treated as removed things, and vice-versa. Use the <code class="option">--reverse-diff</code> option for this purpose. In the following example, we'll squirrel away a patch file which describes the changes in our working copy, and then use a reverse patch operation to undo those changes.</p><div class="informalexample"><pre class="screen"> $ svn status M foo.c $ svn diff &gt; PATCH $ cat PATCH Index: foo.c =================================================================== --- foo.c (revision 128) +++ foo.c (working copy) @@ -1003,7 +1003,7 @@ return ERROR_ON_THE_G_STRING; /* Do something in a loop. */ - for (i = 0; i &lt; txns-&gt;nelts; i++) + for (i = 0; i &lt; txns-&gt;nelts; i--) { status = do_something(i); if (status) $ svn patch --reverse-diff PATCH U foo.c $ svn status $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.propdel"></a><div class="titlepage"></div><a id="idm10703" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn propdel (pdel, pd) — Remove a property from an item.</p></div><div class="refsect1"><a id="idm10710"></a><h2>Synopsis</h2><p><code class="literal">svn propdel PROPNAME [PATH...]</code></p><p><code class="literal">svn propdel PROPNAME --revprop -r REV [TARGET]</code></p></div><div class="refsect1"><a id="idm10716"></a><h2>Description</h2><p>This removes properties from files, directories, or revisions. The first form removes versioned properties in your working copy, and the second removes unversioned remote properties on a repository revision (<em class="replaceable"><code>TARGET</code></em> determines only which repository to access).</p></div><div class="refsect1"><a id="idm10720"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.changelist"><code class="option">--changelist</code> (<code class="option">--cl</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.recursive"><code class="option">--recursive</code> (<code class="option">-R</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.revprop"><code class="option">--revprop</code></a> </pre></div></div><div class="refsect1"><a id="idm10730"></a><h2>Examples</h2><p>Delete a property from a file in your working copy:</p><div class="informalexample"><pre class="screen"> $ svn propdel svn:mime-type some-script property 'svn:mime-type' deleted from 'some-script'. </pre></div><p>Delete a revision property:</p><div class="informalexample"><pre class="screen"> $ svn propdel --revprop -r 26 release-date property 'release-date' deleted from repository revision '26' </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.propedit"></a><div class="titlepage"></div><a id="idm10739" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn propedit (pedit, pe) — Edit the property of one or more items under version control. See <a class="xref" href="#svn.ref.svn.c.propset" title="svn propset (pset, ps)">svn propset (pset, ps)</a> later in this chapter.</p></div><div class="refsect1"><a id="idm10747"></a><h2>Synopsis</h2><p><code class="literal">svn propedit PROPNAME TARGET...</code></p><p><code class="literal">svn propedit PROPNAME --revprop -r REV [TARGET]</code></p></div><div class="refsect1"><a id="idm10753"></a><h2>Description</h2><p>Edit one or more properties using your favorite editor. The first form edits versioned properties in your working copy, and the second edits unversioned remote properties on a repository revision (<em class="replaceable"><code>TARGET</code></em> determines only which repository to access).</p></div><div class="refsect1"><a id="idm10757"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.editor_cmd"><code class="option">--editor-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.encoding"><code class="option">--encoding</code> <em class="replaceable"><code>ENC</code></em></a> <a class="xref" href="#svn.ref.svn.sw.file"><code class="option">--file</code> (<code class="option">-F</code>) <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.force_log"><code class="option">--force-log</code></a> <a class="xref" href="#svn.ref.svn.sw.message"><code class="option">--message</code> (<code class="option">-m</code>) <em class="replaceable"><code>MESSAGE</code></em></a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.revprop"><code class="option">--revprop</code></a> <a class="xref" href="#svn.ref.svn.sw.with_revprop"><code class="option">--with-revprop</code> <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm10770"></a><h2>Examples</h2><p><span class="command"><strong>svn propedit</strong></span> makes it easy to modify properties that have multiple values:</p><div class="informalexample"><pre class="screen"> $ svn propedit svn:keywords foo.c # svn will open in your favorite text editor a temporary file # containing the current contents of the svn:keywords property. You # can add multiple values to a property easily here by entering one # value per line. When you save the temporary file and exit, # Subversion will re-read the temporary file and use its updated # contents as the new value of the property. Set new value for property 'svn:keywords' on 'foo.c' $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.propget"></a><div class="titlepage"></div><a id="idm10777" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn propget (pget, pg) — Print the value of a property.</p></div><div class="refsect1"><a id="idm10784"></a><h2>Synopsis</h2><p><code class="literal">svn propget PROPNAME [TARGET[@REV]...]</code></p><p><code class="literal">svn propget PROPNAME --revprop -r REV [URL]</code></p></div><div class="refsect1"><a id="idm10790"></a><h2>Description</h2><p>Print the value of a property on files, directories, or revisions. The first form prints the versioned property of an item or items in your working copy, and the second prints unversioned remote properties on a repository revision. See <a class="xref" href="#svn.advanced.props" title="Properties">the section called “Properties”</a> for more information on properties.</p></div><div class="refsect1"><a id="idm10794"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.changelist"><code class="option">--changelist</code> (<code class="option">--cl</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.recursive"><code class="option">--recursive</code> (<code class="option">-R</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.revprop"><code class="option">--revprop</code></a> <a class="xref" href="#svn.ref.svn.sw.strict"><code class="option">--strict</code></a> <a class="xref" href="#svn.ref.svn.sw.verbose"><code class="option">--verbose</code> (<code class="option">-v</code>)</a> <a class="xref" href="#svn.ref.svn.sw.xml"><code class="option">--xml</code></a> </pre></div></div><div class="refsect1"><a id="idm10806"></a><h2>Examples</h2><p>Examine a property of a file in your working copy:</p><div class="informalexample"><pre class="screen"> $ svn propget svn:keywords foo.c Author Date Rev </pre></div><p>The same goes for a revision property:</p><div class="informalexample"><pre class="screen"> $ svn propget svn:log --revprop -r 20 Began journal. </pre></div><p>For a more structured display of properties, use the <code class="option">--verbose</code> (<code class="option">-v</code>) option:</p><div class="informalexample"><pre class="screen"> $ svn propget svn:keywords foo.c --verbose Properties on 'foo.c': svn:keywords Author Date Rev </pre></div><p>By default, <span class="command"><strong>svn propget</strong></span> will append a trailing end-of-line sequence to the property value it prints. Most of the time, this is a desirable feature that has a positive effect on the printed output. But there are times when you might wish to capture the precise property value, perhaps because that value is not textual in nature, but of some binary format (such as a JPEG thumbnail stored as a property value, for example). To disable pretty-printing of property values, use the <code class="option">--strict</code> option.</p><p>Lastly, you can get <span class="command"><strong>svn propget</strong></span> output in XML format with the <code class="option">--xml</code> option:</p><div class="informalexample"><pre class="screen"> $ svn propget --xml svn:ignore . &lt;?xml version="1.0"?&gt; &lt;properties&gt; &lt;target path=""&gt; &lt;property name="svn:ignore"&gt;*.o &lt;/property&gt; &lt;/target&gt; &lt;/properties&gt; </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.proplist"></a><div class="titlepage"></div><a id="idm10828" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn proplist (plist, pl) — List all properties.</p></div><div class="refsect1"><a id="idm10835"></a><h2>Synopsis</h2><p><code class="literal">svn proplist [TARGET[@REV]...]</code></p><p><code class="literal">svn proplist --revprop -r REV [TARGET]</code></p></div><div class="refsect1"><a id="idm10841"></a><h2>Description</h2><p>List all properties on files, directories, or revisions. The first form lists versioned properties in your working copy, and the second lists unversioned remote properties on a repository revision (<em class="replaceable"><code>TARGET</code></em> determines only which repository to access).</p></div><div class="refsect1"><a id="idm10845"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.changelist"><code class="option">--changelist</code> (<code class="option">--cl</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.recursive"><code class="option">--recursive</code> (<code class="option">-R</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.revprop"><code class="option">--revprop</code></a> <a class="xref" href="#svn.ref.svn.sw.verbose"><code class="option">--verbose</code> (<code class="option">-v</code>)</a> <a class="xref" href="#svn.ref.svn.sw.xml"><code class="option">--xml</code></a> </pre></div></div><div class="refsect1"><a id="idm10857"></a><h2>Examples</h2><p>You can use <span class="command"><strong>proplist</strong></span> to see the properties on an item in your working copy:</p><div class="informalexample"><pre class="screen"> $ svn proplist foo.c Properties on 'foo.c': svn:mime-type svn:keywords owner </pre></div><p>But with the <code class="option">--verbose</code> (<code class="option">-v</code>) flag, <span class="command"><strong>svn proplist</strong></span> is extremely handy as it also shows you the values for the properties:</p><div class="informalexample"><pre class="screen"> $ svn proplist -v foo.c Properties on 'foo.c': svn:mime-type text/plain svn:keywords Author Date Rev owner sally </pre></div><p>Lastly, you can get <span class="command"><strong>svn proplist</strong></span> output in xml format with the <code class="option">--xml</code> option:</p><div class="informalexample"><pre class="screen"> $ svn proplist --xml &lt;?xml version="1.0"?&gt; &lt;properties&gt; &lt;target path="."&gt; &lt;property name="svn:ignore"/&gt; &lt;/target&gt; &lt;/properties&gt; </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.propset"></a><div class="titlepage"></div><a id="idm10875" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn propset (pset, ps) — Set <em class="replaceable"><code>PROPNAME</code></em> to <em class="replaceable"><code>PROPVAL</code></em> on files, directories, or revisions.</p></div><div class="refsect1"><a id="idm10884"></a><h2>Synopsis</h2><p><code class="literal">svn propset PROPNAME [PROPVAL | -F VALFILE] PATH...</code></p><p><code class="literal">svn propset PROPNAME --revprop -r REV [PROPVAL | -F VALFILE] [TARGET]</code></p></div><div class="refsect1"><a id="idm10890"></a><h2>Description</h2><p>Set <em class="replaceable"><code>PROPNAME</code></em> to <em class="replaceable"><code>PROPVAL</code></em> on files, directories, or revisions. The first example creates a versioned, local property change in the working copy, and the second creates an unversioned, remote property change on a repository revision (<em class="replaceable"><code>TARGET</code></em> determines only which repository to access).</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Subversion has a number of <span class="quote">“<span class="quote">special</span>”</span> properties that affect its behavior. See <a class="xref" href="#svn.ref.properties" title="Subversion Properties">the section called “Subversion Properties”</a> later in this chapter for more on these properties.</p></td></tr></table></div></div><div class="refsect1"><a id="idm10900"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.changelist"><code class="option">--changelist</code> (<code class="option">--cl</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.encoding"><code class="option">--encoding</code> <em class="replaceable"><code>ENC</code></em></a> <a class="xref" href="#svn.ref.svn.sw.file"><code class="option">--file</code> (<code class="option">-F</code>) <em class="replaceable"><code>FILENAME</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.recursive"><code class="option">--recursive</code> (<code class="option">-R</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.revprop"><code class="option">--revprop</code></a> <a class="xref" href="#svn.ref.svn.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> </pre></div></div><div class="refsect1"><a id="idm10914"></a><h2>Examples</h2><p>Set the MIME type for a file:</p><div class="informalexample"><pre class="screen"> $ svn propset svn:mime-type image/jpeg foo.jpg property 'svn:mime-type' set on 'foo.jpg' </pre></div><p>On a Unix system, if you want a file to have the executable permission set:</p><div class="informalexample"><pre class="screen"> $ svn propset svn:executable ON somescript property 'svn:executable' set on 'somescript' </pre></div><p>Perhaps you have an internal policy to set certain properties for the benefit of your coworkers:</p><div class="informalexample"><pre class="screen"> $ svn propset owner sally foo.c property 'owner' set on 'foo.c' </pre></div><p>If you made a mistake in a log message for a particular revision and want to change it, use <code class="option">--revprop</code> and set <code class="literal">svn:log</code> to the new log message:</p><div class="informalexample"><pre class="screen"> $ svn propset --revprop -r 25 svn:log "Journaled about trip to New York." property 'svn:log' set on repository revision '25' </pre></div><p>Or, if you don't have a working copy, you can provide a URL:</p><div class="informalexample"><pre class="screen"> $ svn propset --revprop -r 26 svn:log "Document nap." \ http://svn.red-bean.com/repos property 'svn:log' set on repository revision '25' </pre></div><p>Lastly, you can tell <span class="command"><strong>propset</strong></span> to take its input from a file. You could even use this to set the contents of a property to something binary:</p><div class="informalexample"><pre class="screen"> $ svn propset owner-pic -F sally.jpg moo.c property 'owner-pic' set on 'moo.c' </pre></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>By default, you cannot modify revision properties in a Subversion repository. Your repository administrator must explicitly enable revision property modifications by creating a hook named <code class="literal">pre-revprop-change</code>. See <a class="xref" href="#svn.reposadmin.create.hooks" title="Implementing Repository Hooks">the section called “Implementing Repository Hooks”</a> for more information on hook scripts.</p></td></tr></table></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.relocate"></a><div class="titlepage"></div><a id="idm10942" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn relocate — Relocate the working copy to point to a different repository root URL.</p></div><div class="refsect1"><a id="idm10949"></a><h2>Synopsis</h2><p><code class="literal">svn relocate FROM-PREFIX TO-PREFIX [PATH...]</code></p><p><code class="literal">svn relocate TO-URL [PATH]</code></p></div><div class="refsect1"><a id="idm10955"></a><h2>Description</h2><p>Sometimes an administrator might change the location (or apparent location, from the client's perspective) of a repository. The content of the repository doesn't change, but the repository's root URL does. The hostname may change because the repository is now being served from a different computer. Or, perhaps the URL scheme changes because the repository is now being served via SSL (using <code class="literal">https://</code>) instead of over plain HTTP. There are many different reasons for these types of repository relocations. But ideally, a <span class="quote">“<span class="quote">change of address</span>”</span> for a repository shouldn't suddently cause all the working copies which point to that repository to become forever unusable. And fortunately, that's not the case. Rather than force users to check out a new working copy when a repository is relocated, Subversion provides the <span class="command"><strong>svn relocate</strong></span> command, which <span class="quote">“<span class="quote">rewrites</span>”</span> the working copy's administrative metadata to refer to the new repository location.</p><p>The first <span class="command"><strong>svn relocate</strong></span> syntax allows you to update one or more working copies by what essentially amounts to a find-and-replace within the repository root URLs recorded in those working copies. Subversion will replace the initial substring <em class="replaceable"><code>FROM-PREFIX</code></em> with the string <em class="replaceable"><code>TO-PREFIX</code></em> in those URLs. These initial URL substrings can be as long or as short as is necessary to differentiate between them. Obviously, to use this syntax form, you need to know both the current root URL of the repository to which the working copy is pointing, and the new URL of that repository. (You can use <span class="command"><strong>svn info</strong></span> to determine the former.)</p><p>The second syntax does not require that you know the current repository root URL with which the working copy is associated at all—only the new repository URL (<em class="replaceable"><code>TO-URL</code></em>) to which it should be pointing. In this syntax form, only one working copy may be relocated at a time.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Users often get confused about the difference between <span class="command"><strong>svn switch</strong></span> and <span class="command"><strong>svn relocate</strong></span>. Here's the rule of thumb:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>If the working copy needs to reflect a new directory <span class="emphasis"><em>within</em></span> the repository, use <span class="command"><strong>svn switch</strong></span>.</p></li><li class="listitem"><p>If the working copy still reflects the same repository directory, but the location of the repository itself has changed, use <span class="command"><strong>svn relocate</strong></span>.</p></li></ul></div></td></tr></table></div></div><div class="refsect1"><a id="idm10981"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.ignore_externals"><code class="option">--ignore-externals</code></a> </pre></div></div><div class="refsect1"><a id="idm10986"></a><h2>Examples</h2><p>Let's start with a working copy that reflects a local repository URL:</p><div class="informalexample"><pre class="screen"> $ svn info | grep URL: URL: file:///var/svn/repos/trunk $ </pre></div><p>One day the administrator decides to rename the on-disk repository directory. We missed the memo, so we see an error the next time we try to update our working copy.</p><div class="informalexample"><pre class="screen"> $ svn up Updating '.': svn: E180001: Unable to connect to a repository at URL 'file:///var/svn/repos/trunk' </pre></div><p>After cornering the administrator over by the vending machines, we learn about the repository being moved and are told the new URL. Rather than checkout a new working copy, though, we simply ask Subversion to rewrite the working copy metadata to point to the new repository location.</p><div class="informalexample"><pre class="screen"> $ svn relocate file:///var/svn/new-repos/trunk $ </pre></div><p>Subversion doesn't tell us much about what it did, but hey—error-free operation is really all we need, right? Our working copy is functional for online operations again.</p><div class="informalexample"><pre class="screen"> $ svn up Updating '.': A lib/new.c M src/code.h M src/headers.h … </pre></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Once again, this type of relocation affects <span class="emphasis"><em>working copy metadata only</em></span>. It will not change your versioned or unversioned file contents, perform any version control operations (such as commits or updates), and so on.</p></td></tr></table></div><p>A few months later, we're told that the company is moving development to separate machines and that we'll be using HTTP to access the repository. So we relocate our working copy again.</p><div class="informalexample"><pre class="screen"> $ svn relocate http://svn.company.com/repos/trunk $ </pre></div><p>Now, each time we perform a relocation of this sort, Subversion contacts the repository—at its new URL, of course—to verify a few things.</p><p>First, it wants to compare the UUID of the repository against what is stored in the working copy. If these UUIDs don't match, the working copy relocation is disallowed. Maybe this isn't the same repository (just in a new location) after all?</p><p>Secondly, Subversion wants to ensure that the updated working copy metadata jives with respect to the directory location <span class="emphasis"><em>inside</em></span> the repository. Subversion won't let you accidentally relocate a working copy of a branch in your repository to the URL of a different branch in the same repository. (That's what <span class="command"><strong>svn switch</strong></span>, described in <a class="xref" href="#svn.ref.svn.c.switch" title="svn switch (sw)">svn switch (sw)</a>, is for.)</p><p>Also, Subversion will not allow you to relocate a subtree of the working copy. If you're going to relocate the working copy at all, you must relocate the whole thing. This is to protect the integrity of the working copy metadata and behavior as a whole. (And really, you'd be hard pressed to come up with a compelling reason to relocate only a piece of your working copy anyway.)</p><p>Let's look at one final relocation opportunity. After using HTTP access for some time, the company moves to SSL-only access. Now, the only change to the repository URL is that the scheme goes from being <code class="literal">http://</code> to being <code class="literal">https://</code>. There are two different ways that we could make our working copy reflect ths change. The first is to do exactly as we've done before and relocate to the new repository URL.</p><div class="informalexample"><pre class="screen"> $ svn relocate https://svn.company.com/repos/trunk $ </pre></div><p>But we have another option here, too. We could simply ask Subversion to swap out the changed prefixes of the URL.</p><div class="informalexample"><pre class="screen"> $ svn relocate http https $ </pre></div><p>Either approach leaves us a working copy whose metadata has been updated to point to the right repository location.</p><p>By default, <span class="command"><strong>svn relocate</strong></span> will traverse any external working copies nested within your working copy and attempt relocation of those working copies, too. Use the <code class="option">--ignore-externals</code> option to disable this behavior.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.resolve"></a><div class="titlepage"></div><a id="idm11026" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn resolve — Resolve conflicts on working copy files or directories.</p></div><div class="refsect1"><a id="idm11033"></a><h2>Synopsis</h2><p><code class="literal">svn resolve PATH...</code></p></div><div class="refsect1"><a id="idm11037"></a><h2>Description</h2><p>Resolve <span class="quote">“<span class="quote">conflicted</span>”</span> state on working copy files or directories. This routine does not semantically resolve conflict markers; however, it replaces <em class="replaceable"><code>PATH</code></em> with the version specified by the <code class="option">--accept</code> argument and then removes conflict-related artifact files. This allows <em class="replaceable"><code>PATH</code></em> to be committed again—that is, it tells Subversion that the conflicts have been <span class="quote">“<span class="quote">resolved.</span>”</span></p><p>See <a class="xref" href="#svn.tour.cycle.resolve" title="Resolve Any Conflicts">the section called “Resolve Any Conflicts”</a> for an in-depth look at resolving conflicts.</p></div><div class="refsect1"><a id="idm11047"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.accept"><code class="option">--accept</code> <em class="replaceable"><code>ACTION</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.recursive"><code class="option">--recursive</code> (<code class="option">-R</code>)</a> <a class="xref" href="#svn.ref.svn.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> </pre></div></div><div class="refsect1"><a id="idm11056"></a><h2>Examples</h2><p>Here's an example where, after a postponed conflict resolution during update, <span class="command"><strong>svn resolve</strong></span> replaces the all conflicts in file <code class="filename">foo.c</code> with your edits:</p><div class="informalexample"><pre class="screen"> $ svn update Updating '.': Conflict discovered in 'foo.c'. Select: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options: p C foo.c Updated to revision 5. Summary of conflicts: Text conflicts: 1 $ svn resolve --accept mine-full foo.c Resolved conflicted state of 'foo.c' $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.resolved"></a><div class="titlepage"></div><a id="idm11064" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn resolved — <span class="emphasis"><em>Deprecated</em></span>. Remove <span class="quote">“<span class="quote">conflicted</span>”</span> state on working copy files or directories.</p></div><div class="refsect1"><a id="idm11073"></a><h2>Synopsis</h2><p><code class="literal">svn resolved PATH...</code></p></div><div class="refsect1"><a id="idm11077"></a><h2>Description</h2><p>This command has been deprecated in favor of running <strong class="userinput"><code>svn resolve --accept working <em class="replaceable"><code>PATH</code></em></code></strong>. See <a class="xref" href="#svn.ref.svn.c.resolve" title="svn resolve">svn resolve</a> in the preceding section for details.</p><p>Remove <span class="quote">“<span class="quote">conflicted</span>”</span> state on working copy files or directories. This routine does not semantically resolve conflict markers; it merely removes conflict-related artifact files and allows <em class="replaceable"><code>PATH</code></em> to be committed again; that is, it tells Subversion that the conflicts have been <span class="quote">“<span class="quote">resolved.</span>”</span> See <a class="xref" href="#svn.tour.cycle.resolve" title="Resolve Any Conflicts">the section called “Resolve Any Conflicts”</a> for an in-depth look at resolving conflicts.</p></div><div class="refsect1"><a id="idm11088"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.recursive"><code class="option">--recursive</code> (<code class="option">-R</code>)</a> <a class="xref" href="#svn.ref.svn.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> </pre></div></div><div class="refsect1"><a id="idm11096"></a><h2>Examples</h2><p>If you get a conflict on an update, your working copy will sprout three new files:</p><div class="informalexample"><pre class="screen"> $ svn update Updating '.': C foo.c Updated to revision 31. Summary of conflicts: Text conflicts: 1 $ ls foo.c* foo.c foo.c.mine foo.c.r30 foo.c.r31 $ </pre></div><p>Once you've resolved the conflict and <code class="filename">foo.c</code> is ready to be committed, run <span class="command"><strong>svn resolved</strong></span> to let your working copy know you've taken care of everything.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>You <span class="emphasis"><em>can</em></span> just remove the conflict files and commit, but <span class="command"><strong>svn resolved</strong></span> fixes up some bookkeeping data in the working copy administrative area in addition to removing the conflict files, so we recommend that you use this command.</p></td></tr></table></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.revert"></a><div class="titlepage"></div><a id="idm11109" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn revert — Undo all local edits.</p></div><div class="refsect1"><a id="idm11116"></a><h2>Synopsis</h2><p><code class="literal">svn revert PATH...</code></p></div><div class="refsect1"><a id="idm11120"></a><h2>Description</h2><p>Reverts any local changes to a file or directory and resolves any conflicted states. <span class="command"><strong>svn revert</strong></span> will revert not only the contents of an item in your working copy, but also any property changes. Finally, you can use it to undo any scheduling operations that you may have performed (e.g., files scheduled for addition or deletion can be <span class="quote">“<span class="quote">unscheduled</span>”</span>).</p></div><div class="refsect1"><a id="idm11125"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.changelist"><code class="option">--changelist</code> (<code class="option">--cl</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.recursive"><code class="option">--recursive</code> (<code class="option">-R</code>)</a> <a class="xref" href="#svn.ref.svn.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> </pre></div></div><div class="refsect1"><a id="idm11134"></a><h2>Examples</h2><p>Discard changes to a file:</p><div class="informalexample"><pre class="screen"> $ svn revert foo.c Reverted foo.c </pre></div><p>If you want to revert a whole directory of files, use the <code class="option">--depth=infinity</code> option:</p><div class="informalexample"><pre class="screen"> $ svn revert --depth=infinity . Reverted newdir/afile Reverted foo.c Reverted bar.txt </pre></div><p>Lastly, you can undo any scheduling operations:</p><div class="informalexample"><pre class="screen"> $ svn add mistake.txt whoops A mistake.txt A whoops A whoops/oopsie.c $ svn revert mistake.txt whoops Reverted mistake.txt Reverted whoops $ svn status ? mistake.txt ? whoops </pre></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p><span class="command"><strong>svn revert</strong></span> is inherently dangerous, since its entire purpose is to throw away data—namely, your uncommitted changes. Once you've reverted, Subversion provides <span class="emphasis"><em>no way</em></span> to get back those uncommitted changes.</p><p>If you provide no targets to <span class="command"><strong>svn revert</strong></span>, it will do nothing. To protect you from accidentally losing changes in your working copy, <span class="command"><strong>svn revert</strong></span> requires you to explicitly provide at least one target.</p></td></tr></table></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.status"></a><div class="titlepage"></div><a id="idm11154" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn status (stat, st) — Print the status of working copy files and directories.</p></div><div class="refsect1"><a id="idm11161"></a><h2>Synopsis</h2><p><code class="literal">svn status [PATH...]</code></p></div><div class="refsect1"><a id="idm11165"></a><h2>Description</h2><p>Print the status of working copy files and directories. With no arguments, it prints only locally modified items (no repository access). With <code class="option">--show-updates</code> (<code class="option">-u</code>), it adds working revision and server out-of-date information. With <code class="option">--verbose</code> (<code class="option">-v</code>), it prints full revision information on every item. With <code class="option">--quiet</code> (<code class="option">-q</code>), it prints only summary information about locally modified items.</p><p>The first seven columns in the output are each one character wide, and each column gives you information about a different aspect of each working copy item.</p><p>The first column indicates that an item was added, deleted, or otherwise changed:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">' '</code></span></dt><dd><p>No modifications.</p></dd><dt><span class="term"><code class="literal">'A'</code></span></dt><dd><p>Item is scheduled for addition.</p></dd><dt><span class="term"><code class="literal">'D'</code></span></dt><dd><p>Item is scheduled for deletion.</p></dd><dt><span class="term"><code class="literal">'M'</code></span></dt><dd><p>Item has been modified.</p></dd><dt><span class="term"><code class="literal">'R'</code></span></dt><dd><p>Item has been replaced in your working copy. This means the file was scheduled for deletion, and then a new file with the same name was scheduled for addition in its place.</p></dd><dt><span class="term"><code class="literal">'C'</code></span></dt><dd><p>The contents (as opposed to the properties) of the item conflict with updates received from the repository.</p></dd><dt><span class="term"><code class="literal">'X'</code></span></dt><dd><p>Item is present because of an externals definition.</p></dd><dt><span class="term"><code class="literal">'I'</code></span></dt><dd><p>Item is being ignored (e.g., with the <code class="literal">svn:ignore</code> property).</p></dd><dt><span class="term"><code class="literal">'?'</code></span></dt><dd><p>Item is not under version control.</p></dd><dt><span class="term"><code class="literal">'!'</code></span></dt><dd><p>Item is missing (e.g., you moved or deleted it without using <span class="command"><strong>svn</strong></span>). This also indicates that a directory is incomplete (a checkout or update was interrupted).</p></dd><dt><span class="term"><code class="literal">'~'</code></span></dt><dd><p>Item is versioned as one kind of object (file, directory, link), but has been replaced by a different kind of object.</p></dd></dl></div><p>The second column tells the status of a file's or directory's properties:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">' '</code></span></dt><dd><p>No modifications.</p></dd><dt><span class="term"><code class="literal">'M'</code></span></dt><dd><p>Properties for this item have been modified.</p></dd><dt><span class="term"><code class="literal">'C'</code></span></dt><dd><p>Properties for this item are in conflict with property updates received from the repository.</p></dd></dl></div><p>The third column is populated only if the working copy directory is locked (see <a class="xref" href="#svn.tour.cleanup" title="Sometimes You Just Need to Clean Up">the section called “Sometimes You Just Need to Clean Up”</a>):</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">' '</code></span></dt><dd><p>Item is not locked.</p></dd><dt><span class="term"><code class="literal">'L'</code></span></dt><dd><p>Item is locked.</p></dd></dl></div><p>The fourth column is populated only if the item is scheduled for addition-with-history:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">' '</code></span></dt><dd><p>No history scheduled with commit.</p></dd><dt><span class="term"><code class="literal">'+'</code></span></dt><dd><p>History scheduled with commit.</p></dd></dl></div><p>The fifth column is populated only if the item is switched relative to its parent (see <a class="xref" href="#svn.branchmerge.switchwc" title="Traversing Branches">the section called “Traversing Branches”</a>):</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">' '</code></span></dt><dd><p>Item is a child of its parent directory.</p></dd><dt><span class="term"><code class="literal">'S'</code></span></dt><dd><p>Item is switched.</p></dd></dl></div><p>The sixth column is populated with lock information:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">' '</code></span></dt><dd><p>When <code class="option">--show-updates</code> (<code class="option">-u</code>) is used, this means the file is not locked. If <code class="option">--show-updates</code> (<code class="option">-u</code>) is <span class="emphasis"><em>not</em></span> used, this merely means that the file is not locked in this working copy.</p></dd><dt><span class="term"><code class="literal">'K'</code></span></dt><dd><p>File is locked in this working copy.</p></dd><dt><span class="term"><code class="literal">'O'</code></span></dt><dd><p>File is locked either by another user or in another working copy. This appears only when <code class="option">--show-updates</code> (<code class="option">-u</code>) is used.</p></dd><dt><span class="term"><code class="literal">'T'</code></span></dt><dd><p>File was locked in this working copy, but the lock has been <span class="quote">“<span class="quote">stolen</span>”</span> and is invalid. The file is currently locked in the repository. This appears only when <code class="option">--show-updates</code> (<code class="option">-u</code>) is used.</p></dd><dt><span class="term"><code class="literal">'B'</code></span></dt><dd><p>File was locked in this working copy, but the lock has been <span class="quote">“<span class="quote">broken</span>”</span> and is invalid. The file is no longer locked. This appears only when <code class="option">--show-updates</code> (<code class="option">-u</code>) is used.</p></dd></dl></div><p>The seventh column is populated only if the item is the victim of a tree conflict:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">' '</code></span></dt><dd><p>Item is not the victim of a tree conflict.</p></dd><dt><span class="term"><code class="literal">'C'</code></span></dt><dd><p>Item is the victim of a tree conflict.</p></dd></dl></div><p>The eighth column is always blank.</p><p>The out-of-date information appears in the ninth column (only if you pass the <code class="option">--show-updates</code> (<code class="option">-u</code>) option):</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">' '</code></span></dt><dd><p>The item in your working copy is up to date.</p></dd><dt><span class="term"><code class="literal">'*'</code></span></dt><dd><p>A newer revision of the item exists on the server.</p></dd></dl></div><p>The remaining fields are variable width and delimited by spaces. The working revision is the next field if the <code class="option">--show-updates</code> (<code class="option">-u</code>) or <code class="option">--verbose</code> (<code class="option">-v</code>) option is passed.</p><p>If the <code class="option">--verbose</code> (<code class="option">-v</code>) option is passed, the last committed revision and last committed author are displayed next.</p><p>The working copy path is always the final field, so it can include spaces.</p></div><div class="refsect1"><a id="idm11365"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.changelist"><code class="option">--changelist</code> (<code class="option">--cl</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.ignore_externals"><code class="option">--ignore-externals</code></a> <a class="xref" href="#svn.ref.svn.sw.incremental"><code class="option">--incremental</code></a> <a class="xref" href="#svn.ref.svn.sw.no_ignore"><code class="option">--no-ignore</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.show_updates"><code class="option">--show-updates</code> (<code class="option">-u</code>)</a> <a class="xref" href="#svn.ref.svn.sw.verbose"><code class="option">--verbose</code> (<code class="option">-v</code>)</a> <a class="xref" href="#svn.ref.svn.sw.xml"><code class="option">--xml</code></a> </pre></div></div><div class="refsect1"><a id="idm11378"></a><h2>Examples</h2><p>This is the easiest way to find out what changes you have made to your working copy:</p><div class="informalexample"><pre class="screen"> $ svn status wc M wc/bar.c A + wc/qax.c </pre></div><p>If you want to find out what files in your working copy are out of date, pass the <code class="option">--show-updates</code> (<code class="option">-u</code>) option (this will <span class="emphasis"><em>not</em></span> make any changes to your working copy). Here you can see that <code class="filename">wc/foo.c</code> has changed in the repository since we last updated our working copy:</p><div class="informalexample"><pre class="screen"> $ svn status -u wc M 965 wc/bar.c * 965 wc/foo.c A + 965 wc/qax.c Status against revision: 981 </pre></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p><code class="option">--show-updates</code> (<code class="option">-u</code>) <span class="emphasis"><em>only</em></span> places an asterisk next to items that are out of date (i.e., items that will be updated from the repository if you later use <span class="command"><strong>svn update</strong></span>). <code class="option">--show-updates</code> (<code class="option">-u</code>) does <span class="emphasis"><em>not</em></span> cause the status listing to reflect the repository's version of the item (although you can see the revision number in the repository by passing the <code class="option">--verbose</code> (<code class="option">-v</code>) option).</p></td></tr></table></div><p>The most information you can get out of the status subcommand is as follows:</p><div class="informalexample"><pre class="screen"> $ svn status -u -v wc M 965 938 sally wc/bar.c * 965 922 harry wc/foo.c A + 965 687 harry wc/qax.c 965 687 harry wc/zig.c Status against revision: 981 </pre></div><p>Lastly, you can get <span class="command"><strong>svn status</strong></span> output in XML format with the <code class="option">--xml</code> option:</p><div class="informalexample"><pre class="screen"> $ svn status --xml wc &lt;?xml version="1.0"?&gt; &lt;status&gt; &lt;target path="wc"&gt; &lt;entry path="qax.c"&gt; &lt;wc-status props="none" item="added" revision="0"&gt; &lt;/wc-status&gt; &lt;/entry&gt; &lt;entry path="bar.c"&gt; &lt;wc-status props="normal" item="modified" revision="965"&gt; &lt;commit revision="965"&gt; &lt;author&gt;sally&lt;/author&gt; &lt;date&gt;2008-05-28T06:35:53.048870Z&lt;/date&gt; &lt;/commit&gt; &lt;/wc-status&gt; &lt;/entry&gt; &lt;/target&gt; &lt;/status&gt; </pre></div><p>For many more examples of <span class="command"><strong>svn status</strong></span>, see <a class="xref" href="#svn.tour.cycle.examine.status" title="See an overview of your changes">the section called “See an overview of your changes”</a>.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.switch"></a><div class="titlepage"></div><a id="idm11413" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn switch (sw) — Update working copy to a different URL.</p></div><div class="refsect1"><a id="idm11420"></a><h2>Synopsis</h2><p><code class="literal">svn switch URL[@PEGREV] [PATH]</code></p><p><code class="literal">switch --relocate FROM TO [PATH...]</code></p></div><div class="refsect1"><a id="idm11426"></a><h2>Description</h2><p>The first variant of this subcommand (without the <code class="option">--relocate</code> option) updates your working copy to point to a new URL. This is the Subversion way to make a working copy begin tracking a new branch. If specified, <em class="replaceable"><code>PEGREV</code></em> determines in which revision the target is first looked up. See <a class="xref" href="#svn.branchmerge.switchwc" title="Traversing Branches">the section called “Traversing Branches”</a> for an in-depth look at switching.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Beginning with Subversion 1.7, the <span class="command"><strong>svn switch</strong></span> command will demand by default that the URL to which you are switching your working copy shares a common ancestry with item that the working copy currently reflects. You can override this behavior by specifying the <code class="option">--ignore-ancestry</code> option.</p></td></tr></table></div><p>If <code class="option">--force</code> is used, unversioned obstructing paths in the working copy do not automatically cause a failure if the switch attempts to add the same path. If the obstructing path is the same type (file or directory) as the corresponding path in the repository, it becomes versioned but its contents are left untouched in the working copy. This means that an obstructing directory's unversioned children may also obstruct and become versioned. For files, any content differences between the obstruction and the repository are treated like a local modification to the working copy. All properties from the repository are applied to the obstructing path.</p><p>As with most subcommands, you can limit the scope of the switch operation to a particular tree depth using the <code class="option">--depth</code> option. Alternatively, you can use the <code class="option">--set-depth</code> option to set a new <span class="quote">“<span class="quote">sticky</span>”</span> working copy depth on the switch target.</p><p>The <code class="option">--relocate</code> option is deprecated as of Subversion 1.7. Use <span class="command"><strong>svn relocate</strong></span> (described in <a class="xref" href="#svn.ref.svn.c.relocate" title="svn relocate">svn relocate</a>) to perform working copy relocation instead.</p></div><div class="refsect1"><a id="idm11446"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.accept"><code class="option">--accept</code> <em class="replaceable"><code>ACTION</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.diff3_cmd"><code class="option">--diff3-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.ignore_ancestry"><code class="option">--ignore-ancestry</code></a> <a class="xref" href="#svn.ref.svn.sw.ignore_externals"><code class="option">--ignore-externals</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.relocate"><code class="option">--relocate</code></a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.set_depth"><code class="option">--set-depth</code> <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm11460"></a><h2>Examples</h2><p>If you're currently inside the directory <code class="filename">vendors</code>, which was branched to <code class="filename">vendors-with-fix</code>, and you'd like to switch your working copy to that branch:</p><div class="informalexample"><pre class="screen"> $ svn switch http://svn.red-bean.com/repos/branches/vendors-with-fix . U myproj/foo.txt U myproj/bar.txt U myproj/baz.c U myproj/qux.c Updated to revision 31. </pre></div><p>To switch back, just provide the URL to the location in the repository from which you originally checked out your working copy:</p><div class="informalexample"><pre class="screen"> $ svn switch http://svn.red-bean.com/repos/trunk/vendors . U myproj/foo.txt U myproj/bar.txt U myproj/baz.c U myproj/qux.c Updated to revision 31. </pre></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>You <span class="emphasis"><em>can</em></span> switch just part of your working copy to a branch if you don't want to switch your entire working copy, but this is not generally recommended. It's too easy to forget that you've done this and wind up accidentally making and committing changes both to the switched and unswitched portions of your tree.</p></td></tr></table></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.unlock"></a><div class="titlepage"></div><a id="idm11474" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn unlock — Unlock working copy paths or URLs.</p></div><div class="refsect1"><a id="idm11481"></a><h2>Synopsis</h2><p><code class="literal">svn unlock TARGET...</code></p></div><div class="refsect1"><a id="idm11485"></a><h2>Description</h2><p>Unlock each <em class="replaceable"><code>TARGET</code></em>. If any <em class="replaceable"><code>TARGET</code></em> is locked by another user or no valid lock token exists in the working copy, print a warning and continue unlocking the rest of the <em class="replaceable"><code>TARGET</code></em>s. Use <code class="option">--force</code> to break a lock belonging to another user or working copy.</p></div><div class="refsect1"><a id="idm11492"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> </pre></div></div><div class="refsect1"><a id="idm11498"></a><h2>Examples</h2><p>Unlock two files in your working copy:</p><div class="informalexample"><pre class="screen"> $ svn unlock tree.jpg house.jpg 'tree.jpg' unlocked. 'house.jpg' unlocked. </pre></div><p>Unlock a file in your working copy that is currently locked by another user:</p><div class="informalexample"><pre class="screen"> $ svn unlock tree.jpg svn: E195013: 'tree.jpg' is not locked in this working copy $ svn unlock --force tree.jpg 'tree.jpg' unlocked. </pre></div><p>Unlock a file without a working copy:</p><div class="informalexample"><pre class="screen"> $ svn unlock http://svn.red-bean.com/repos/test/tree.jpg 'tree.jpg unlocked. </pre></div><p>For further details, see <a class="xref" href="#svn.advanced.locking" title="Locking">the section called “Locking”</a>.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.update"></a><div class="titlepage"></div><a id="idm11512" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn update (up) — Update your working copy.</p></div><div class="refsect1"><a id="idm11519"></a><h2>Synopsis</h2><p><code class="literal">svn update [PATH...]</code></p></div><div class="refsect1"><a id="idm11523"></a><h2>Description</h2><p><span class="command"><strong>svn update</strong></span> brings changes from the repository into your working copy. If no revision is given, it brings your working copy up to date with the <code class="literal">HEAD</code> revision. Otherwise, it synchronizes the working copy to the revision given by the <code class="option">--revision</code> (<code class="option">-r</code>) option. As part of the synchronization, <span class="command"><strong>svn update</strong></span> also removes any stale locks (see <a class="xref" href="#svn.tour.cleanup" title="Sometimes You Just Need to Clean Up">the section called “Sometimes You Just Need to Clean Up”</a>) found in the working copy.</p><p>For each updated item, it prints a line that starts with a character reporting the action taken. These characters have the following meaning:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">A</code></span></dt><dd><p>Added</p></dd><dt><span class="term"><code class="literal">B</code></span></dt><dd><p>Broken lock (third column only)</p></dd><dt><span class="term"><code class="literal">D</code></span></dt><dd><p>Deleted</p></dd><dt><span class="term"><code class="literal">U</code></span></dt><dd><p>Updated</p></dd><dt><span class="term"><code class="literal">C</code></span></dt><dd><p>Conflicted</p></dd><dt><span class="term"><code class="literal">G</code></span></dt><dd><p>Merged</p></dd><dt><span class="term"><code class="literal">E</code></span></dt><dd><p>Existed</p></dd></dl></div><p>A character in the first column signifies an update to the actual file, whereas updates to the file's properties are shown in the second column. Lock information is printed in the third column.</p><p>As with most subcommands, you can limit the scope of the update operation to a particular tree depth using the <code class="option">--depth</code> option. Alternatively, you can use the <code class="option">--set-depth</code> option to set a new <span class="quote">“<span class="quote">sticky</span>”</span> working copy depth on the update target.</p></div><div class="refsect1"><a id="idm11574"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.accept"><code class="option">--accept</code> <em class="replaceable"><code>ACTION</code></em></a> <a class="xref" href="#svn.ref.svn.sw.changelist"><code class="option">--changelist</code> (<code class="option">--cl</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svn.sw.diff3_cmd"><code class="option">--diff3-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.editor_cmd"><code class="option">--editor-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="#svn.ref.svn.sw.ignore_externals"><code class="option">--ignore-externals</code></a> <a class="xref" href="#svn.ref.svn.sw.parents"><code class="option">--parents</code></a> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svn.sw.set_depth"><code class="option">--set-depth</code> <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm11589"></a><h2>Examples</h2><p>Pick up repository changes that have happened since your last update:</p><div class="informalexample"><pre class="screen"> $ svn update Updating '.': A newdir/toggle.c A newdir/disclose.c A newdir/launch.c D newdir/README Updated to revision 32. </pre></div><p>You can also <span class="quote">“<span class="quote">update</span>”</span> your working copy to an older revision (Subversion doesn't have the concept of <span class="quote">“<span class="quote">sticky</span>”</span> files like CVS does; see <a class="xref" href="#svn.forcvs" title="Appendix B. Subversion for CVS Users">Appendix B, <em>Subversion for CVS Users</em></a>):</p><div class="informalexample"><pre class="screen"> $ svn update -r30 Updating '.': A newdir/README D newdir/toggle.c D newdir/disclose.c D newdir/launch.c U foo.c Updated to revision 30. </pre></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></img></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>If you want to examine an older revision of a single file, you may want to use <span class="command"><strong>svn cat</strong></span> instead—it won't change your working copy.</p></td></tr></table></div><p><span class="command"><strong>svn update</strong></span> is also the primary mechanism used to configure sparse working copies. When used with the <code class="option">--set-depth</code>, the update operation will omit or reenlist individual working copy members by modifying their recorded ambient depth to the depth you specify (fetching information from the repository as necessary). See <a class="xref" href="#svn.advanced.sparsedirs" title="Sparse Directories">the section called “Sparse Directories”</a> for more about sparse directories.</p><p>You can update multiple targets with a single invocation, and Subversion will not only gracefully skip any unversioned targets you provide it, but as of Subversion 1.7 will also include a post-update summary of all the updates it performed:</p><div class="informalexample"><pre class="screen"> $ cd my-projects $ svn update * Updating 'calc': U button.c U integer.c Updated to revision 394. Skipped 'tempfile.tmp' Updating 'paint': A palettes.c U brushes.c Updated to revision 60. Updating 'ziptastic': At revision 43. Summary of updates: Updated 'calc' to r394. Updated 'paint' to r60. Updated 'ziptastic' to r43. Summary of conflicts: Skipped paths: 1 $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svn.c.upgrade"></a><div class="titlepage"></div><a id="idm11611" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svn upgrade — Upgrade the metadata storage format for a working copy.</p></div><div class="refsect1"><a id="idm11618"></a><h2>Synopsis</h2><p><code class="literal">svn upgrade [PATH...]</code></p></div><div class="refsect1"><a id="idm11622"></a><h2>Description</h2><p>As new versions of Subversion are released, the format used for the working copy metadata changes to accomodate new features or fix bugs. Older versions of Subversion would automatically upgrade working copies to the new format the first time the working copy was used by the new version of the software. Beginning with Subversion 1.7, working copy upgrades must be explicitly performed at the user's request. <span class="command"><strong>svn upgrade</strong></span> is the subcommand used to trigger that upgrade process.</p></div><div class="refsect1"><a id="idm11626"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> </pre></div></div><div class="refsect1"><a id="idm11631"></a><h2>Examples</h2><p>If you attempt to use Subversion 1.7 on a working copy created with an older version of Subversion, you will see an error:</p><div class="informalexample"><pre class="screen"> $ svn status svn: E155036: Please see the 'svn upgrade' command svn: E155036: Working copy '/home/sally/project' is too old (format 10, create d by Subversion 1.6) $ </pre></div><p>Use the <span class="command"><strong>svn upgrade</strong></span> command to upgrade the working copy to the most recent metadata format supported by your version of Subversion.</p><div class="informalexample"><pre class="screen"> $ svn upgrade Upgraded '.' Upgraded 'A' Upgraded 'A/B' Upgraded 'A/B/E' Upgraded 'A/B/F' Upgraded 'A/C' Upgraded 'A/D' Upgraded 'A/D/G' Upgraded 'A/D/H' $ svn status D A/B/E/alpha M A/D/gamma A A/newfile $ </pre></div><p>Notice that <span class="command"><strong>svn upgrade</strong></span> preserved the local modifications present in the working copy at the time of the upgrade, which were introduced by the version of Subversion previously used to manipulate this working copy.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>As was the case with automatically upgraded working copies in the past, explicitly upgraded working copies will be unusable by older versions of Subversion, too.</p></td></tr></table></div></div></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.ref.svnadmin"></a>svnadmin—Subversion Repository Administration</h2></div></div></div><p><span class="command"><strong>svnadmin</strong></span> is the administrative tool for monitoring and repairing your Subversion repository. For detailed information on repository administration, see the maintenance section for <a class="xref" href="#svn.reposadmin.maint.tk.svnadmin" title="svnadmin">the section called “svnadmin”</a>.</p><p>Since <span class="command"><strong>svnadmin</strong></span> works via direct repository access (and thus can only be used on the machine that holds the repository), it refers to the repository with a path, not a URL.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svnadmin.sw"></a>svnadmin Options</h3></div></div></div><p>Options in <span class="command"><strong>svnadmin</strong></span> are global, just as they are in <span class="command"><strong>svn</strong></span>:</p><div class="variablelist"><dl class="variablelist"><dt><a id="svn.ref.svnadmin.sw.bdb_log_keep"></a><span class="term"><code class="option">--bdb-log-keep</code></span></dt><dd><p>(Berkeley DB-specific.) Disable automatic log removal of database logfiles. Having these logfiles around can be convenient if you need to restore from a catastrophic repository failure.</p></dd><dt><a id="svn.ref.svnadmin.sw.bdb_txn_nosync"></a><span class="term"><code class="option">--bdb-txn-nosync</code></span></dt><dd><p>(Berkeley DB-specific.) Disables fsync when committing database transactions. Used with the <span class="command"><strong>svnadmin create</strong></span> command to create a Berkeley DB-backed repository with <code class="literal">DB_TXN_NOSYNC</code> enabled (which improves speed but has some risks associated with it).</p></dd><dt><a id="svn.ref.svnadmin.sw.bypass_hooks"></a><span class="term"><code class="option">--bypass-hooks</code></span></dt><dd><p>Bypass the repository hook system.</p></dd><dt><a id="svn.ref.svnadmin.sw.bypass_prop_validation"></a><span class="term"><code class="option">--bypass-prop-validation</code></span></dt><dd><p>When loading a dump file, disable the logic which validates property values.</p></dd><dt><a id="svn.ref.svnadmin.sw.clean_logs"></a><span class="term"><code class="option">--clean-logs</code></span></dt><dd><p>Remove unused Berkeley DB logs.</p></dd><dt><a id="svn.ref.svnadmin.sw.config_dir"></a><span class="term"><code class="option">--config-dir</code> <em class="replaceable"><code>DIR</code></em></span></dt><dd><p>Instructs Subversion to read configuration information from the specified directory instead of the default location (<code class="filename">.subversion</code> in the user's home directory).</p></dd><dt><a id="svn.ref.svnadmin.sw.deltas"></a><span class="term"><code class="option">--deltas</code></span></dt><dd><p>When creating a repository dump file, specify changes in versioned properties and file contents as deltas against their previous state.</p></dd><dt><a id="svn.ref.svnadmin.sw.fs_type"></a><span class="term"><code class="option">--fs-type</code> <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>When creating a repository, use <em class="replaceable"><code>ARG</code></em> as the requested filesyste type. <em class="replaceable"><code>ARG</code></em> may be either <code class="literal">bdb</code> or <code class="literal">fsfs</code>.</p></dd><dt><a id="svn.ref.svnadmin.sw.force_uuid"></a><span class="term"><code class="option">--force-uuid</code></span></dt><dd><p>By default, when loading data into a repository that already contains revisions, <span class="command"><strong>svnadmin</strong></span> will ignore the UUID from the dump stream. This option will cause the repository's UUID to be set to the UUID from the stream.</p></dd><dt><a id="svn.ref.svnadmin.sw.ignore_uuid"></a><span class="term"><code class="option">--ignore-uuid</code></span></dt><dd><p>By default, when loading data into an empty repository, <span class="command"><strong>svnadmin</strong></span> will set the repository's UUID to the UUID from the dump stream. This option will cause the UUID from the stream to be ignored.</p></dd><dt><a id="svn.ref.svnadmin.sw.incremental"></a><span class="term"><code class="option">--incremental</code></span></dt><dd><p>Dump a revision only as a diff against the previous revision, instead of the usual fulltext.</p></dd><dt><a id="svn.ref.svnadmin.sw.memory_cache_size"></a><span class="term"><code class="option">--memory-cache-size</code> (<code class="option">-M</code>) <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Configures the size (in Megabytes) of the extra in-memory cache used to minimize redundant operations. The default value is <code class="literal">16</code>. (This cache is used for FSFS-backed repositories only.)</p></dd><dt><a id="svn.ref.svnadmin.sw.parent_dir"></a><span class="term"><code class="option">--parent-dir</code> <em class="replaceable"><code>DIR</code></em></span></dt><dd><p>When loading a dump file, root paths at <em class="replaceable"><code>DIR</code></em> instead of <code class="filename">/</code>.</p></dd><dt><a id="svn.ref.svnadmin.sw.pre_1.4_compatible"></a><span class="term"><code class="option">--pre-1.4-compatible</code></span></dt><dd><p>When creating a new repository, use a format that is compatible with versions of Subversion earlier than Subversion 1.4.</p></dd><dt><a id="svn.ref.svnadmin.sw.pre_1.5_compatible"></a><span class="term"><code class="option">--pre-1.5-compatible</code></span></dt><dd><p>When creating a new repository, use a format that is compatible with versions of Subversion earlier than Subversion 1.5.</p></dd><dt><a id="svn.ref.svnadmin.sw.pre_1.6_compatible"></a><span class="term"><code class="option">--pre-1.6-compatible</code></span></dt><dd><p>When creating a new repository, use a format that is compatible with versions of Subversion earlier than Subversion 1.6.</p></dd><dt><a id="svn.ref.svnadmin.sw.revision"></a><span class="term"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Specify a particular revision to operate on.</p></dd><dt><a id="svn.ref.svnadmin.sw.quiet"></a><span class="term"><code class="option">--quiet</code> (<code class="option">-q</code>)</span></dt><dd><p>Do not show normal progress—show only errors.</p></dd><dt><a id="svn.ref.svnadmin.sw.use_post_commit_hook"></a><span class="term"><code class="option">--use-post-commit-hook</code></span></dt><dd><p>When loading a dump file, runs the repository's <code class="literal">post-commit</code> hook after finalizing each newly loaded revision.</p></dd><dt><a id="svn.ref.svnadmin.sw.use_post_revprop_change_hook"></a><span class="term"><code class="option">--use-post-revprop-change-hook</code></span></dt><dd><p>When changing a revision property, runs the repository's <code class="literal">post-revprop-change</code> hook after changing the revision property.</p></dd><dt><a id="svn.ref.svnadmin.sw.use_pre_commit_hook"></a><span class="term"><code class="option">--use-pre-commit-hook</code></span></dt><dd><p>When loading a dump file, runs the repository's <code class="literal">pre-commit</code> hook before finalizing each newly loaded revision. If the hook fails, aborts the commit and terminates the load process.</p></dd><dt><a id="svn.ref.svnadmin.sw.use_pre_revprop_change_hook"></a><span class="term"><code class="option">--use-pre-revprop-change-hook</code></span></dt><dd><p>When changing a revision property, runs the repository's <code class="literal">pre-revprop-change</code> hook before changing the revision property. If the hook fails, aborts the modification and terminates.</p></dd><dt><a id="svn.ref.svnadmin.sw.wait"></a><span class="term"><code class="option">--wait</code></span></dt><dd><p>For operations which require exclusive repository access, wait until the requisite repository lock has been obtained instead of immediately erroring out when it cannot be.</p></dd></dl></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svnadmin.c"></a>svnadmin Subcommands</h3></div></div></div><p>Here are the various subcommands for the <span class="command"><strong>svnadmin</strong></span> program.</p><div class="refentry"><a id="svn.ref.svnadmin.c.crashtest"></a><div class="titlepage"></div><a id="idm11801" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin crashtest — Simulate a process that crashes.</p></div><div class="refsect1"><a id="idm11808"></a><h2>Synopsis</h2><p><code class="literal">svnadmin crashtest REPOS_PATH</code></p></div><div class="refsect1"><a id="idm11812"></a><h2>Description</h2><p>Open the repository at <em class="replaceable"><code>REPOS_PATH</code></em>, then abort, thus simulating a process that crashes while holding an open repository handle. This is used for testing automatic repository recovery (a new feature in Berkeley DB 4.4). It's unlikely that you'll need to run this command.</p></div><div class="refsect1"><a id="idm11816"></a><h2>Options</h2><p>None</p></div><div class="refsect1"><a id="idm11819"></a><h2>Examples</h2><div class="informalexample"><pre class="screen"> $ svnadmin crashtest /var/svn/repos Aborted </pre></div><p>Exciting, isn't it?</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.create"></a><div class="titlepage"></div><a id="idm11825" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin create — Create a new, empty repository.</p></div><div class="refsect1"><a id="idm11832"></a><h2>Synopsis</h2><p><code class="literal">svnadmin create REPOS_PATH</code></p></div><div class="refsect1"><a id="idm11836"></a><h2>Description</h2><p>Create a new, empty repository at the path provided. If the provided directory does not exist, it will be created for you.<a href="#ftn.idm11839" class="footnote" id="idm11839"><sup class="footnote">[72]</sup></a> As of Subversion 1.2, <span class="command"><strong>svnadmin</strong></span> creates new repositories with the <code class="literal">FSFS</code> filesystem backend by default.</p><p>While <span class="command"><strong>svnadmin create</strong></span> will create the base directory for a new repository, it will not create intermediate directories. For example, if you have an empty directory named <code class="filename">/var/svn</code>, creating <code class="filename">/var/svn/repos</code> will work, while attempting to create <code class="filename">/var/svn/subdirectory/repos</code> will fail with an error. Also, keep in mind that, depending on where on your system you are creating your repository, you might need to run <span class="command"><strong>svnadmin create</strong></span> as a user with elevated privileges (such as the <code class="literal">root</code> user).</p></div><div class="refsect1"><a id="idm11853"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnadmin.sw.bdb_log_keep"><code class="option">--bdb-log-keep</code></a> <a class="xref" href="#svn.ref.svnadmin.sw.bdb_txn_nosync"><code class="option">--bdb-txn-nosync</code></a> <a class="xref" href="#svn.ref.svnadmin.sw.config_dir"><code class="option">--config-dir</code> <em class="replaceable"><code>DIR</code></em></a> <a class="xref" href="#svn.ref.svnadmin.sw.fs_type"><code class="option">--fs-type</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svnadmin.sw.pre_1.4_compatible"><code class="option">--pre-1.4-compatible</code></a> <a class="xref" href="#svn.ref.svnadmin.sw.pre_1.5_compatible"><code class="option">--pre-1.5-compatible</code></a> <a class="xref" href="#svn.ref.svnadmin.sw.pre_1.6_compatible"><code class="option">--pre-1.6-compatible</code></a> </pre></div></div><div class="refsect1"><a id="idm11864"></a><h2>Examples</h2><p>Creating a new repository is this easy:</p><div class="informalexample"><pre class="screen"> $ cd /var/svn $ svnadmin create repos $ </pre></div><p>In Subversion 1.0, a Berkeley DB repository is always created. In Subversion 1.1, a Berkeley DB repository is the default repository type, but an FSFS repository can be created using the <code class="option">--fs-type</code> option:</p><div class="informalexample"><pre class="screen"> $ cd /var/svn $ svnadmin create repos --fs-type fsfs $ </pre></div></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm11839" class="footnote"><p><a href="#idm11839" class="para"><sup class="para">[72] </sup></a>Remember, <span class="command"><strong>svnadmin</strong></span> works only with local <span class="emphasis"><em>paths</em></span>, not <span class="emphasis"><em>URLs</em></span>.</p></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.deltify"></a><div class="titlepage"></div><a id="idm11874" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin deltify — Deltify changed paths in a revision range.</p></div><div class="refsect1"><a id="idm11881"></a><h2>Synopsis</h2><p><code class="literal">svnadmin deltify [-r LOWER[:UPPER]] REPOS_PATH</code></p></div><div class="refsect1"><a id="idm11885"></a><h2>Description</h2><p><span class="command"><strong>svnadmin deltify</strong></span> exists in current versions of Subversion only for historical reasons. This command is deprecated and no longer needed.</p><p>It dates from a time when Subversion offered administrators greater control over compression strategies in the repository. This turned out to be a lot of complexity for <span class="emphasis"><em>very</em></span> little gain, and this <span class="quote">“<span class="quote">feature</span>”</span> was deprecated.</p></div><div class="refsect1"><a id="idm11892"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnadmin.sw.memory_cache_size"><code class="option">--memory-cache-size</code> (<code class="option">-M</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svnadmin.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svnadmin.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>ARG</code></em></a> </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.dump"></a><div class="titlepage"></div><a id="idm11900" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin dump — Dump the contents of the filesystem to <code class="filename">stdout</code>.</p></div><div class="refsect1"><a id="idm11908"></a><h2>Synopsis</h2><p><code class="literal">svnadmin dump REPOS_PATH [-r LOWER[:UPPER]] [--incremental] [--deltas]</code></p></div><div class="refsect1"><a id="idm11912"></a><h2>Description</h2><p>Dump the contents of the filesystem to <code class="filename">stdout</code> in a <span class="quote">“<span class="quote">dump file</span>”</span> portable format, sending feedback to <code class="filename">stderr</code>. Dump revisions <em class="replaceable"><code>LOWER</code></em> rev through <em class="replaceable"><code>UPPER</code></em> rev. If no revisions are given, dump all revision trees. If only <em class="replaceable"><code>LOWER</code></em> is given, dump that one revision tree. See <a class="xref" href="#svn.reposadmin.maint.migrate" title="Migrating Repository Data Elsewhere">the section called “Migrating Repository Data Elsewhere”</a> for a practical use.</p><p>By default, the Subversion dump stream contains a single revision (the first revision in the requested revision range) in which every file and directory in the repository in that revision is presented as though that whole tree was added at once, followed by other revisions (the remainder of the revisions in the requested range), which contain only the files and directories that were modified in those revisions. For a modified file, the complete full-text representation of its contents, as well as all of its properties, are presented in the dump file; for a directory, all of its properties are presented.</p><p>Two useful options modify the dump file generator's behavior. The first is the <code class="option">--incremental</code> option, which simply causes that first revision in the dump stream to contain only the files and directories modified in that revision, instead of being presented as the addition of a new tree, and in exactly the same way that every other revision in the dump file is presented. This is useful for generating a relatively small dump file to be loaded into another repository that already has the files and directories that exist in the original repository.</p><p>The second useful option is <code class="option">--deltas</code>. This option causes <span class="command"><strong>svnadmin dump</strong></span> to, instead of emitting full-text representations of file contents and property lists, emit only deltas of those items against their previous versions. This reduces (in some cases, drastically) the size of the dump file that <span class="command"><strong>svnadmin dump</strong></span> creates. There are, however, disadvantages to using this option—deltified dump files are more CPU-intensive to create, cannot be operated on by <span class="command"><strong>svndumpfilter</strong></span>, and tend not to compress as well as their nondeltified counterparts when using third-party tools such as <span class="command"><strong>gzip</strong></span> and <span class="command"><strong>bzip2</strong></span>.</p></div><div class="refsect1"><a id="idm11932"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnadmin.sw.deltas"><code class="option">--deltas</code></a> <a class="xref" href="#svn.ref.svnadmin.sw.incremental"><code class="option">--incremental</code></a> <a class="xref" href="#svn.ref.svnadmin.sw.memory_cache_size"><code class="option">--memory-cache-size</code> (<code class="option">-M</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svnadmin.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svnadmin.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm11941"></a><h2>Examples</h2><p>Dump your whole repository:</p><div class="informalexample"><pre class="screen"> $ svnadmin dump /var/svn/repos &gt; full.dump * Dumped revision 0. * Dumped revision 1. * Dumped revision 2. … </pre></div><p>Incrementally dump a single transaction from your repository:</p><div class="informalexample"><pre class="screen"> $ svnadmin dump /var/svn/repos -r 21 --incremental &gt; incr.dump * Dumped revision 21. </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.help"></a><div class="titlepage"></div><a id="idm11950" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin help (h, ?) — Help!</p></div><div class="refsect1"><a id="idm11957"></a><h2>Synopsis</h2><p><code class="literal">svnadmin help [SUBCOMMAND...]</code></p></div><div class="refsect1"><a id="idm11961"></a><h2>Description</h2><p>This subcommand is useful when you're trapped on a desert island with neither a Net connection nor a copy of this book.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.hotcopy"></a><div class="titlepage"></div><a id="idm11965" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin hotcopy — Make a hot copy of a repository.</p></div><div class="refsect1"><a id="idm11972"></a><h2>Synopsis</h2><p><code class="literal">svnadmin hotcopy REPOS_PATH NEW_REPOS_PATH</code></p></div><div class="refsect1"><a id="idm11976"></a><h2>Description</h2><p>This subcommand makes a full <span class="quote">“<span class="quote">hot</span>”</span> backup of your repository, including all hooks, configuration files, and, of course, database files. If you pass the <code class="option">--clean-logs</code> option, <span class="command"><strong>svnadmin</strong></span> will perform a hot copy of your repository, and then remove unused Berkeley DB logs from the original repository. You can run this command at any time and make a safe copy of the repository, regardless of whether other processes are using the repository.</p></div><div class="refsect1"><a id="idm11982"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnadmin.sw.clean_logs"><code class="option">--clean-logs</code></a> </pre></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>As described in <a class="xref" href="#svn.reposadmin.basics.backends.bdb" title="Berkeley DB">the section called “Berkeley DB”</a>, hot-copied Berkeley DB repositories are <span class="emphasis"><em>not</em></span> portable across operating systems, nor will they work on machines with a different <span class="quote">“<span class="quote">endianness</span>”</span> than the machine where they were created.</p></td></tr></table></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.list-dblogs"></a><div class="titlepage"></div><a id="idm11993" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin list-dblogs — Ask Berkeley DB which logfiles exist for a given Subversion repository (applies only to repositories using the <code class="literal">bdb</code> backend).</p></div><div class="refsect1"><a id="idm12001"></a><h2>Synopsis</h2><p><code class="literal">svnadmin list-dblogs REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12005"></a><h2>Description</h2><p>Berkeley DB creates logs of all changes to the repository, which allow it to recover in the face of catastrophe. Unless you enable <code class="literal">DB_LOG_AUTOREMOVE</code>, the logfiles accumulate, although most are no longer used and can be deleted to reclaim disk space. See <a class="xref" href="#svn.reposadmin.maint.diskspace" title="Managing Disk Space">the section called “Managing Disk Space”</a> for more information.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.list-unused-dblogs"></a><div class="titlepage"></div><a id="idm12011" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin list-unused-dblogs — Ask Berkeley DB which logfiles can be safely deleted (applies only to repositories using the <code class="literal">bdb</code> backend).</p></div><div class="refsect1"><a id="idm12019"></a><h2>Synopsis</h2><p><code class="literal">svnadmin list-unused-dblogs REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12023"></a><h2>Description</h2><p>Berkeley DB creates logs of all changes to the repository, which allow it to recover in the face of catastrophe. Unless you enable <code class="literal">DB_LOG_AUTOREMOVE</code>, the logfiles accumulate, although most are no longer used and can be deleted to reclaim disk space. See <a class="xref" href="#svn.reposadmin.maint.diskspace" title="Managing Disk Space">the section called “Managing Disk Space”</a> for more information.</p></div><div class="refsect1"><a id="idm12028"></a><h2>Examples</h2><p>Remove all unused logfiles from the repository:</p><div class="informalexample"><pre class="screen"> $ svnadmin list-unused-dblogs /var/svn/repos /var/svn/repos/log.0000000031 /var/svn/repos/log.0000000032 /var/svn/repos/log.0000000033 $ svnadmin list-unused-dblogs /var/svn/repos | xargs rm ## disk space reclaimed! </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.load"></a><div class="titlepage"></div><a id="idm12034" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin load — Read a repository dump stream from <code class="filename">stdin</code>.</p></div><div class="refsect1"><a id="idm12042"></a><h2>Synopsis</h2><p><code class="literal">svnadmin load REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12046"></a><h2>Description</h2><p>Read a repository dump stream from <code class="filename">stdin</code>, committing new revisions into the repository's filesystem. Send progress feedback to <code class="filename">stdout</code>.</p></div><div class="refsect1"><a id="idm12051"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnadmin.sw.bypass_prop_validation"><code class="option">--bypass-prop-validation</code></a> <a class="xref" href="#svn.ref.svnadmin.sw.force_uuid"><code class="option">--force-uuid</code></a> <a class="xref" href="#svn.ref.svnadmin.sw.ignore_uuid"><code class="option">--ignore-uuid</code></a> <a class="xref" href="#svn.ref.svnadmin.sw.memory_cache_size"><code class="option">--memory-cache-size</code> (<code class="option">-M</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svnadmin.sw.parent_dir"><code class="option">--parent-dir</code> <em class="replaceable"><code>DIR</code></em></a> <a class="xref" href="#svn.ref.svnadmin.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svnadmin.sw.use_post_commit_hook"><code class="option">--use-post-commit-hook</code></a> <a class="xref" href="#svn.ref.svnadmin.sw.use_pre_commit_hook"><code class="option">--use-pre-commit-hook</code></a> </pre></div></div><div class="refsect1"><a id="idm12063"></a><h2>Examples</h2><p>This shows the beginning of loading a repository from a backup file (made, of course, with <span class="command"><strong>svnadmin dump</strong></span>):</p><div class="informalexample"><pre class="screen"> $ svnadmin load /var/svn/restored &lt; repos-backup &lt;&lt;&lt; Started new txn, based on original revision 1 * adding path : test ... done. * adding path : test/a ... done. … </pre></div><p>Or if you want to load into a subdirectory:</p><div class="informalexample"><pre class="screen"> $ svnadmin load --parent-dir new/subdir/for/project \ /var/svn/restored &lt; repos-backup &lt;&lt;&lt; Started new txn, based on original revision 1 * adding path : test ... done. * adding path : test/a ... done. … </pre></div><p>Newer versions of Subversion have grown more strict regarding the format of the values of Subversion's own built-in properties. Of course, properties created with older versions of Subversion wouldn't have benefitted from that strictness, and as such might be improperly formatted. Dump streams carry property values as-is, so using Subversion 1.7 to load dump streams created from repositories with ill-formatted property values will, by default, trigger a validation error. There are several workaround for this problem. First, you can manually repair the problematic property values in the source repository and recreate the dump stream. Or, you can manually tweak the dump stream itself to fix those property values. Finally, if you'd rather not deal with the problem right now, use the <code class="option">--bypass-prop-validation</code> option with <span class="command"><strong>svnadmin load</strong></span>.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.lslocks"></a><div class="titlepage"></div><a id="idm12076" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin lslocks — Print descriptions of all locks.</p></div><div class="refsect1"><a id="idm12083"></a><h2>Synopsis</h2><p><code class="literal">svnadmin lslocks REPOS_PATH [PATH-IN-REPOS]</code></p></div><div class="refsect1"><a id="idm12087"></a><h2>Description</h2><p>Print descriptions of all locks in repository <em class="replaceable"><code>REPOS_PATH</code></em> underneath the path <em class="replaceable"><code>PATH-IN-REPOS</code></em>. If <em class="replaceable"><code>PATH-IN-REPOS</code></em> is not provided, it defaults to the root directory of the repository.</p></div><div class="refsect1"><a id="idm12093"></a><h2>Options</h2><p>None</p></div><div class="refsect1"><a id="idm12096"></a><h2>Examples</h2><p>This lists the one locked file in the repository at <code class="filename">/var/svn/repos</code>:</p><div class="informalexample"><pre class="screen"> $ svnadmin lslocks /var/svn/repos Path: /tree.jpg UUID Token: opaquelocktoken:ab00ddf0-6afb-0310-9cd0-dda813329753 Owner: harry Created: 2005-07-08 17:27:36 -0500 (Fri, 08 Jul 2005) Expires: Comment (1 line): Rework the uppermost branches on the bald cypress in the foreground. </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.lstxns"></a><div class="titlepage"></div><a id="idm12103" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin lstxns — Print the names of all uncommitted transactions.</p></div><div class="refsect1"><a id="idm12110"></a><h2>Synopsis</h2><p><code class="literal">svnadmin lstxns REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12114"></a><h2>Description</h2><p>Print the names of all uncommitted transactions. See <a class="xref" href="#svn.reposadmin.maint.diskspace.deadtxns" title="Removing dead transactions">the section called “Removing dead transactions”</a> for information on how uncommitted transactions are created and what you should do with them.</p></div><div class="refsect1"><a id="idm12118"></a><h2>Examples</h2><p>List all outstanding transactions in a repository:</p><div class="informalexample"><pre class="screen"> $ svnadmin lstxns /var/svn/repos/ 1w 1x </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.pack"></a><div class="titlepage"></div><a id="idm12124" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin pack — Possibly compact the repository into a more efficient storage model.</p></div><div class="refsect1"><a id="idm12131"></a><h2>Synopsis</h2><p><code class="literal">svnadmin pack REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12135"></a><h2>Description</h2><p>See <a class="xref" href="#svn.reposadmin.maint.diskspace.fsfspacking" title="Packing FSFS filesystems">the section called “Packing FSFS filesystems”</a> for more information.</p></div><div class="refsect1"><a id="idm12139"></a><h2>Options</h2><p>None</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.recover"></a><div class="titlepage"></div><a id="idm12143" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin recover — Bring a repository database back into a consistent state (applies only to repositories using the <code class="literal">bdb</code> backend). In addition, if <code class="filename">repos/conf/passwd</code> does not exist, it will create a default passwordfile .</p></div><div class="refsect1"><a id="idm12152"></a><h2>Synopsis</h2><p><code class="literal">svnadmin recover REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12156"></a><h2>Description</h2><p>Run this command if you get an error indicating that your repository needs to be recovered.</p></div><div class="refsect1"><a id="idm12159"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnadmin.sw.wait"><code class="option">--wait</code></a> </pre></div></div><div class="refsect1"><a id="idm12164"></a><h2>Examples</h2><p>Recover a hung repository:</p><div class="informalexample"><pre class="screen"> $ svnadmin recover /var/svn/repos/ Repository lock acquired. Please wait; recovering the repository may take some time... Recovery completed. The latest repos revision is 34. </pre></div><p>Recovering the database requires an exclusive lock on the repository. (This is a <span class="quote">“<span class="quote">database lock</span>”</span>; see the sidebar <a class="xref" href="#svn.advanced.locking.meanings" title="The Three Meanings of “Lock”">The Three Meanings of <span class="quote">“<span class="quote">Lock</span>”</span></a>.) If another process is accessing the repository, then <span class="command"><strong>svnadmin recover</strong></span> will error:</p><div class="informalexample"><pre class="screen"> $ svnadmin recover /var/svn/repos svn: E165000: Failed to get exclusive repository access; perhaps another proce ss such as httpd, svnserve or svn has it open? $ </pre></div><p>The <code class="option">--wait</code> option, however, will cause <span class="command"><strong>svnadmin recover</strong></span> to wait indefinitely for other processes to disconnect:</p><div class="informalexample"><pre class="screen"> $ svnadmin recover /var/svn/repos --wait Waiting on repository lock; perhaps another process has it open? ### time goes by… Repository lock acquired. Please wait; recovering the repository may take some time... Recovery completed. The latest repos revision is 34. </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.rmlocks"></a><div class="titlepage"></div><a id="idm12181" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin rmlocks — Unconditionally remove one or more locks from a repository.</p></div><div class="refsect1"><a id="idm12188"></a><h2>Synopsis</h2><p><code class="literal">svnadmin rmlocks REPOS_PATH LOCKED_PATH...</code></p></div><div class="refsect1"><a id="idm12192"></a><h2>Description</h2><p>Remove one or more locks from each <em class="replaceable"><code>LOCKED_PATH</code></em>.</p></div><div class="refsect1"><a id="idm12196"></a><h2>Options</h2><p>None</p></div><div class="refsect1"><a id="idm12199"></a><h2>Examples</h2><p>This deletes the locks on <code class="filename">tree.jpg</code> and <code class="filename">house.jpg</code> in the repository at <code class="filename">/var/svn/repos</code>:</p><div class="informalexample"><pre class="screen"> $ svnadmin rmlocks /var/svn/repos tree.jpg house.jpg Removed lock on '/tree.jpg. Removed lock on '/house.jpg. </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.rmtxns"></a><div class="titlepage"></div><a id="idm12208" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin rmtxns — Delete transactions from a repository.</p></div><div class="refsect1"><a id="idm12215"></a><h2>Synopsis</h2><p><code class="literal">svnadmin rmtxns REPOS_PATH TXN_NAME...</code></p></div><div class="refsect1"><a id="idm12219"></a><h2>Description</h2><p>Delete outstanding transactions from a repository. This is covered in detail in <a class="xref" href="#svn.reposadmin.maint.diskspace.deadtxns" title="Removing dead transactions">the section called “Removing dead transactions”</a>.</p></div><div class="refsect1"><a id="idm12223"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnadmin.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> </pre></div></div><div class="refsect1"><a id="idm12228"></a><h2>Examples</h2><p>Remove named transactions:</p><div class="informalexample"><pre class="screen"> $ svnadmin rmtxns /var/svn/repos/ 1w 1x </pre></div><p>Fortunately, the output of <span class="command"><strong>lstxns</strong></span> works great as the input for <span class="command"><strong>rmtxns</strong></span>:</p><div class="informalexample"><pre class="screen"> $ svnadmin rmtxns /var/svn/repos/ `svnadmin lstxns /var/svn/repos/` </pre></div><p>This removes all uncommitted transactions from your repository.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.setlog"></a><div class="titlepage"></div><a id="idm12240" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin setlog — Set the log message on a revision.</p></div><div class="refsect1"><a id="idm12247"></a><h2>Synopsis</h2><p><code class="literal">svnadmin setlog REPOS_PATH -r REVISION FILE</code></p></div><div class="refsect1"><a id="idm12251"></a><h2>Description</h2><p>Set the log message on revision <em class="replaceable"><code>REVISION</code></em> to the contents of <em class="replaceable"><code>FILE</code></em>.</p><p>This is similar to using <span class="command"><strong>svn propset</strong></span> with the <code class="option">--revprop</code> option to set the <code class="literal">svn:log</code> property on a revision, except that you can also use the option <code class="option">--bypass-hooks</code> to avoid running any pre- or post-commit hooks, which is useful if the modification of revision properties has not been enabled in the <code class="literal">pre-revprop-change</code> hook.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Revision properties are not under version control, so this command will permanently overwrite the previous log message.</p></td></tr></table></div></div><div class="refsect1"><a id="idm12264"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnadmin.sw.bypass_hooks"><code class="option">--bypass-hooks</code></a> <a class="xref" href="#svn.ref.svnadmin.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm12270"></a><h2>Examples</h2><p>Set the log message for revision 19 to the contents of the file <code class="filename">msg</code>:</p><div class="informalexample"><pre class="screen"> $ svnadmin setlog /var/svn/repos/ -r 19 msg </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.setrevprop"></a><div class="titlepage"></div><a id="idm12277" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin setrevprop — Set a property on a revision.</p></div><div class="refsect1"><a id="idm12284"></a><h2>Synopsis</h2><p><code class="literal">svnadmin setrevprop REPOS_PATH -r REVISION NAME FILE</code></p></div><div class="refsect1"><a id="idm12288"></a><h2>Description</h2><p>Set the property <em class="replaceable"><code>NAME</code></em> on revision <em class="replaceable"><code>REVISION</code></em> to the contents of <em class="replaceable"><code>FILE</code></em>. Use <code class="option">--use-pre-revprop-change-hook</code> or <code class="option">--use-post-revprop-change-hook</code> to trigger the revision property-related hooks (e.g., if you want an email notification sent from your <code class="literal">post-revprop-change-hook</code>).</p></div><div class="refsect1"><a id="idm12297"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnadmin.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svnadmin.sw.use_post_revprop_change_hook"><code class="option">--use-post-revprop-change-hook</code></a> <a class="xref" href="#svn.ref.svnadmin.sw.use_pre_revprop_change_hook"><code class="option">--use-pre-revprop-change-hook</code></a> </pre></div></div><div class="refsect1"><a id="idm12304"></a><h2>Examples</h2><p>The following sets the revision property <code class="literal">repository-photo</code> to the contents of the file <code class="filename">sandwich.png</code>:</p><div class="informalexample"><pre class="screen"> $ svnadmin setrevprop /var/svn/repos -r 0 repository-photo sandwich.png </pre></div><p>As you can see, <span class="command"><strong>svnadmin setrevprop</strong></span> has no output upon success.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.setuuid"></a><div class="titlepage"></div><a id="idm12314" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin setuuid — Reset the repository UUID.</p></div><div class="refsect1"><a id="idm12321"></a><h2>Synopsis</h2><p><code class="literal">svnadmin setuuid REPOS_PATH [NEW_UUID]</code></p></div><div class="refsect1"><a id="idm12325"></a><h2>Description</h2><p>Reset the repository UUID for the repository located at <em class="replaceable"><code>REPOS_PATH</code></em>. If <em class="replaceable"><code>NEW_UUID</code></em> is provided, use that as the new repository UUID; otherwise, generate a brand-new UUID for the repository.</p></div><div class="refsect1"><a id="idm12330"></a><h2>Options</h2><p>None</p></div><div class="refsect1"><a id="idm12333"></a><h2>Examples</h2><p>If you've <span class="command"><strong>svnsync</strong></span>ed <code class="filename">/var/svn/repos</code> to <code class="filename">/var/svn/repos-new</code> and intend to use <code class="filename">repos-new</code> as your canonical repository, you may want to change the UUID for <code class="filename">repos-new</code> to the UUID of <code class="filename">repos</code> so that your users don't have to check out a new working copy to accommodate the change:</p><div class="informalexample"><pre class="screen"> $ svnadmin setuuid /var/svn/repos-new 2109a8dd-854f-0410-ad31-d604008985ab </pre></div><p>As you can see, <span class="command"><strong>svnadmin setuuid</strong></span> has no output upon success.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.upgrade"></a><div class="titlepage"></div><a id="idm12347" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin upgrade — Upgrade a repository to the latest supported schema version.</p></div><div class="refsect1"><a id="idm12354"></a><h2>Synopsis</h2><p><code class="literal">svnadmin upgrade REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12358"></a><h2>Description</h2><p>Upgrade the repository located at <em class="replaceable"><code>REPOS_PATH</code></em> to the latest supported schema version.</p><p>This functionality is provided as a convenience for repository administrators who wish to make use of new Subversion functionality without having to undertake a potentially costly full repository dump and load operation. As such, the upgrade performs only the minimum amount of work needed to accomplish this while still maintaining the integrity of the repository. While a dump and subsequent load guarantee the most optimized repository state, <span class="command"><strong>svnadmin upgrade</strong></span> does not.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>You should <span class="emphasis"><em>always</em></span> back up your repository before upgrading.</p></td></tr></table></div></div><div class="refsect1"><a id="idm12367"></a><h2>Options</h2><p>None</p></div><div class="refsect1"><a id="idm12370"></a><h2>Examples</h2><p>Upgrade the repository at path <code class="filename">/var/repos/svn</code>:</p><div class="informalexample"><pre class="screen"> $ svnadmin upgrade /var/repos/svn Repository lock acquired. Please wait; upgrading the repository may take some time... Upgrade completed. </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnadmin.c.verify"></a><div class="titlepage"></div><a id="idm12377" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnadmin verify — Verify the data stored in the repository.</p></div><div class="refsect1"><a id="idm12384"></a><h2>Synopsis</h2><p><code class="literal">svnadmin verify REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12388"></a><h2>Description</h2><p>Run this command if you wish to verify the integrity of your repository. This basically iterates through all revisions in the repository by internally dumping all revisions and discarding the output—it's a good idea to run this on a regular basis to guard against latent hard disk failures and <span class="quote">“<span class="quote">bitrot.</span>”</span> If this command fails—which it will do at the first sign of a problem—that means your repository has at least one corrupted revision, and you should restore the corrupted revision from a backup (you did make a backup, didn't you?).</p></div><div class="refsect1"><a id="idm12392"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnadmin.sw.memory_cache_size"><code class="option">--memory-cache-size</code> (<code class="option">-M</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svnadmin.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svnadmin.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm12399"></a><h2>Examples</h2><p>Verify a hung repository:</p><div class="informalexample"><pre class="screen"> $ svnadmin verify /var/svn/repos/ * Verified revision 1729. </pre></div></div></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.ref.svnlook"></a>svnlook—Subversion Repository Examination</h2></div></div></div><p><span class="command"><strong>svnlook</strong></span> is a command-line utility for examining different aspects of a Subversion repository. It does not make any changes to the repository—it's just used for <span class="quote">“<span class="quote">peeking.</span>”</span> <span class="command"><strong>svnlook</strong></span> is typically used by the repository hooks, but a repository administrator might find it useful for diagnostic purposes.</p><p>Since <span class="command"><strong>svnlook</strong></span> works via direct repository access (and thus can be used only on the machine that holds the repository), it refers to the repository with a path, not a URL.</p><p>If no revision or transaction is specified, <span class="command"><strong>svnlook</strong></span> defaults to the youngest (most recent) revision of the repository.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svnlook.sw"></a>svnlook Options</h3></div></div></div><p>Options in <span class="command"><strong>svnlook</strong></span> are global, just as they are in <span class="command"><strong>svn</strong></span> and <span class="command"><strong>svnadmin</strong></span>; however, most options apply to only one subcommand since the functionality of <span class="command"><strong>svnlook</strong></span> is (intentionally) limited in scope:</p><div class="variablelist"><dl class="variablelist"><dt><a id="svn.ref.svnlook.sw.copy_info"></a><span class="term"><code class="option">--copy-info</code></span></dt><dd><p>Causes <span class="command"><strong>svnlook changed</strong></span> to show detailed copy source information.</p></dd><dt><a id="svn.ref.svnlook.sw.diff_copy_from"></a><span class="term"><code class="option">--diff-copy-from</code></span></dt><dd><p>Print differences for copied items against the copy source.</p></dd><dt><a id="svn.ref.svnlook.sw.extensions"></a><span class="term"><code class="option">--extensions</code> (<code class="option">-x</code>) <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Specifies customizations which Subversion should make when performing difference calculations. Valid extensions include:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--ignore-space-change</code> (<code class="option">-b</code>)</span></dt><dd><p>Ignore changes in the amount of white space.</p></dd><dt><span class="term"><code class="option">--ignore-all-space</code> (<code class="option">-w</code>)</span></dt><dd><p>Ignore all white space.</p></dd><dt><span class="term"><code class="option">--ignore-eol-style</code></span></dt><dd><p>Ignore changes in EOL (end-of-line) style.</p></dd><dt><span class="term"><code class="option">--show-c-function</code> (<code class="option">-p</code>)</span></dt><dd><p>Show C function names in the diff output.</p></dd><dt><span class="term"><code class="option">--unified</code> (<code class="option">-u</code>)</span></dt><dd><p>Show three lines of unified diff context.</p></dd></dl></div><p>The default value is <code class="literal">-u</code>.</p><p>Note that when Subversion is configured to invoke an external diff command, the value of the <code class="option">--extension</code> (<code class="option">-x</code>) option isn't restricted to the previously mentioned options, but may be <span class="emphasis"><em>any</em></span> additional arguments which Subversion should pass to that command. If you wish to pass multiple arguments, you must enclose all of them in quotes.</p></dd><dt><a id="svn.ref.svnlook.sw.full_paths"></a><span class="term"><code class="option">--full-paths</code></span></dt><dd><p>Causes <span class="command"><strong>svnlook tree</strong></span> to display full paths instead of hierarchical, indented path components.</p></dd><dt><a id="svn.ref.svnlook.sw.limit"></a><span class="term"><code class="option">--limit</code> (<code class="option">-l</code>) <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Limit output to a maximum number of <em class="replaceable"><code>ARG</code></em> items.</p></dd><dt><a id="svn.ref.svnlook.sw.no_diff_deleted"></a><span class="term"><code class="option">--no-diff-deleted</code></span></dt><dd><p>Prevents <span class="command"><strong>svnlook diff</strong></span> from printing differences for deleted files. The default behavior when a file is deleted in a transaction/revision is to print the same differences that you would see if you had left the file but removed all the content.</p></dd><dt><a id="svn.ref.svnlook.sw.no_diff_added"></a><span class="term"><code class="option">--no-diff-added</code></span></dt><dd><p>Prevents <span class="command"><strong>svnlook diff</strong></span> from printing differences for added files. The default behavior when you add a file is to print the same differences that you would see if you had added the entire contents of an existing (empty) file.</p></dd><dt><a id="svn.ref.svnlook.sw.non_recursive"></a><span class="term"><code class="option">--non-recursive</code> (<code class="option">-N</code>)</span></dt><dd><p>Operate on a single directory only.</p></dd><dt><a id="svn.ref.svnlook.sw.revision"></a><span class="term"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></span></dt><dd><p>Specifies a particular revision number that you wish to examine.</p></dd><dt><a id="svn.ref.svnlook.sw.revprop"></a><span class="term"><code class="option">--revprop</code></span></dt><dd><p>Operates on a revision property instead of a property specific to a file or directory. This option requires that you also pass a revision with the <code class="option">--revision</code> (<code class="option">-r</code>) option.</p></dd><dt><a id="svn.ref.svnlook.sw.transaction"></a><span class="term"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></span></dt><dd><p>Specifies a particular transaction ID that you wish to examine.</p></dd><dt><a id="svn.ref.svnlook.sw.show_ids"></a><span class="term"><code class="option">--show-ids</code></span></dt><dd><p>Shows the filesystem node revision IDs for each path in the filesystem tree.</p></dd><dt><a id="svn.ref.svnlook.sw.verbose"></a><span class="term"><code class="option">--verbose</code> (<code class="option">-v</code>)</span></dt><dd><p>Be verbose. When used with <span class="command"><strong>svnlook proplist</strong></span>, for example, this causes Subversion to display not just the list of properties, but their values also.</p></dd><dt><a id="svn.ref.svnlook.sw.xml"></a><span class="term"><code class="option">--xml</code></span></dt><dd><p>Prints output in XML format.</p></dd></dl></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svnlook.c"></a>svnlook Subcommands</h3></div></div></div><p>Here are the various subcommands for the <span class="command"><strong>svnlook</strong></span> program.</p><div class="refentry"><a id="svn.ref.svnlook.c.author"></a><div class="titlepage"></div><a id="idm12551" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook author — Print the author.</p></div><div class="refsect1"><a id="idm12558"></a><h2>Synopsis</h2><p><code class="literal">svnlook author REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12562"></a><h2>Description</h2><p>Print the author of a revision or transaction in the repository.</p></div><div class="refsect1"><a id="idm12565"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.transaction"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></a> </pre></div></div><div class="refsect1"><a id="idm12571"></a><h2>Examples</h2><p><span class="command"><strong>svnlook author</strong></span> is handy, but not very exciting:</p><div class="informalexample"><pre class="screen"> $ svnlook author -r 40 /var/svn/repos sally </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.cat"></a><div class="titlepage"></div><a id="idm12578" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook cat — Print the contents of a file.</p></div><div class="refsect1"><a id="idm12585"></a><h2>Synopsis</h2><p><code class="literal">svnlook cat REPOS_PATH PATH_IN_REPOS</code></p></div><div class="refsect1"><a id="idm12589"></a><h2>Description</h2><p>Print the contents of a file.</p></div><div class="refsect1"><a id="idm12592"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.transaction"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></a> </pre></div></div><div class="refsect1"><a id="idm12598"></a><h2>Examples</h2><p>This shows the contents of a file in transaction <code class="literal">ax8</code>, located at <code class="filename">/trunk/README</code>:</p><div class="informalexample"><pre class="screen"> $ svnlook cat -t ax8 /var/svn/repos /trunk/README Subversion, a version control system. ===================================== $LastChangedDate: 2003-07-17 10:45:25 -0500 (Thu, 17 Jul 2003) $ Contents: I. A FEW POINTERS II. DOCUMENTATION III. PARTICIPATING IN THE SUBVERSION COMMUNITY … </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.changed"></a><div class="titlepage"></div><a id="idm12606" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook changed — Print the paths that were changed.</p></div><div class="refsect1"><a id="idm12613"></a><h2>Synopsis</h2><p><code class="literal">svnlook changed REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12617"></a><h2>Description</h2><p>Print the paths that were changed in a particular revision or transaction, as well as <span class="quote">“<span class="quote">svn update-style</span>”</span> status letters in the first two columns:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">'A '</code></span></dt><dd><p>Item added to repository</p></dd><dt><span class="term"><code class="literal">'D '</code></span></dt><dd><p>Item deleted from repository</p></dd><dt><span class="term"><code class="literal">'U '</code></span></dt><dd><p>File contents changed</p></dd><dt><span class="term"><code class="literal">'_U'</code></span></dt><dd><p>Properties of item changed; note the leading underscore</p></dd><dt><span class="term"><code class="literal">'UU'</code></span></dt><dd><p>File contents and properties changed</p></dd></dl></div><p>Files and directories can be distinguished, as directory paths are displayed with a trailing <span class="quote">“<span class="quote"><code class="literal">/</code></span>”</span> character.</p></div><div class="refsect1"><a id="idm12650"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.copy_info"><code class="option">--copy-info</code></a> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.transaction"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></a> </pre></div></div><div class="refsect1"><a id="idm12657"></a><h2>Examples</h2><p>This shows a list of all the changed files and directories in revision 39 of a test repository. Note that the first changed item is a directory, as evidenced by the trailing <code class="literal">/</code>:</p><div class="informalexample"><pre class="screen"> $ svnlook changed -r 39 /var/svn/repos A trunk/vendors/deli/ A trunk/vendors/deli/chips.txt A trunk/vendors/deli/sandwich.txt A trunk/vendors/deli/pickle.txt U trunk/vendors/baker/bagel.txt _U trunk/vendors/baker/croissant.txt UU trunk/vendors/baker/pretzel.txt D trunk/vendors/baker/baguette.txt </pre></div><p>Here's an example that shows a revision in which a file was renamed:</p><div class="informalexample"><pre class="screen"> $ svnlook changed -r 64 /var/svn/repos A trunk/vendors/baker/toast.txt D trunk/vendors/baker/bread.txt </pre></div><p>Unfortunately, nothing in the preceding output reveals the connection between the deleted and added files. Use the <code class="option">--copy-info</code> option to make this relationship more apparent:</p><div class="informalexample"><pre class="screen"> $ svnlook changed -r 64 --copy-info /var/svn/repos A + trunk/vendors/baker/toast.txt (from trunk/vendors/baker/bread.txt:r63) D trunk/vendors/baker/bread.txt </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.date"></a><div class="titlepage"></div><a id="idm12671" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook date — Print the datestamp.</p></div><div class="refsect1"><a id="idm12678"></a><h2>Synopsis</h2><p><code class="literal">svnlook date REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12682"></a><h2>Description</h2><p>Print the datestamp of a revision or transaction in a repository.</p></div><div class="refsect1"><a id="idm12685"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.transaction"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></a> </pre></div></div><div class="refsect1"><a id="idm12691"></a><h2>Examples</h2><p>This shows the date of revision 40 of a test repository:</p><div class="informalexample"><pre class="screen"> $ svnlook date -r 40 /var/svn/repos/ 2003-02-22 17:44:49 -0600 (Sat, 22 Feb 2003) </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.diff"></a><div class="titlepage"></div><a id="idm12697" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook diff — Print differences of changed files and properties.</p></div><div class="refsect1"><a id="idm12704"></a><h2>Synopsis</h2><p><code class="literal">svnlook diff REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12708"></a><h2>Description</h2><p>Print GNU-style differences of changed files and properties in a repository.</p></div><div class="refsect1"><a id="idm12711"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.diff_copy_from"><code class="option">--diff-copy-from</code></a> <a class="xref" href="#svn.ref.svnlook.sw.no_diff_added"><code class="option">--no-diff-added</code></a> <a class="xref" href="#svn.ref.svnlook.sw.no_diff_deleted"><code class="option">--no-diff-deleted</code></a> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.transaction"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.extensions"><code class="option">--extensions</code> (<code class="option">-x</code>) <em class="replaceable"><code>ARG</code></em></a> </pre></div></div><div class="refsect1"><a id="idm12721"></a><h2>Examples</h2><p>This shows a newly added (empty) file, a modified binary file, and a renamed (that is, copied and deleted) file with modifications:</p><div class="informalexample"><pre class="screen"> $ svnlook diff -r 40 /var/svn/repos Copied: trunk/relish.txt (from rev 39, trunk/vendors/deli/pickle.txt) =================================================================== --- trunk/relish.txt (rev 0) +++ trunk/relish.txt 2013-01-29 20:39:17 UTC (rev 40) @@ -0,0 +1 @@ +Pickle relish is mostly made from cucumbers. Deleted: trunk/vendors/deli/pickle.txt =================================================================== --- trunk/vendors/deli/pickle.txt (rev 39) +++ trunk/vendors/deli/pickle.txt 2013-01-29 20:39:17 UTC (rev 49) @@ -1 +0,0 @@ -Pickles are mostly made from cucumbers. Modified: trunk/vendors/deli/logo.jpg =================================================================== (Binary files differ) Added: trunk/vendors/deli/soda.txt =================================================================== $ </pre></div><p>By default, <span class="command"><strong>svnlook diff</strong></span> will treat copied files very much like any other added file, displaying in their entirety the contents of the new file and merely using a different label to draw the copy/add distinction. However, you can use the <code class="option">--diff-copy-from</code> option to cause <span class="command"><strong>svnlook diff</strong></span> to consider a copied file as worthy of mention only if it differs from the file from which it was copied, and to actually describe those differences.</p><div class="informalexample"><pre class="screen"> $ svnlook diff -r 40 /var/svn/repos --diff-copy-from Copied: trunk/relish.txt (from rev 39, trunk/vendors/deli/pickle.txt) =================================================================== --- trunk/vendors/deli/pickle.txt 2013-01-29 20:39:17 UTC (rev 39) +++ trunk/relish.txt 2013-01-29 20:47:40 UTC (rev 3) @@ -1 +1 @@ -Pickles are mostly made from cucumbers. +Pickle relish is mostly made from cucumbers. Deleted: trunk/vendors/deli/pickle.txt =================================================================== --- trunk/vendors/deli/pickle.txt (rev 39) +++ trunk/vendors/deli/pickle.txt 2013-01-29 20:39:17 UTC (rev 40) @@ -1 +0,0 @@ -Pickles are mostly made from cucumbers. Modified: trunk/vendors/deli/logo.jpg =================================================================== (Binary files differ) Added: trunk/vendors/deli/soda.txt ============================================================================== $ </pre></div><p>Use the <code class="option">--no-diff-deleted</code> option to silence output regarding deleted files.</p><div class="informalexample"><pre class="screen"> $ svnlook diff -r 40 /var/svn/repos --no-diff-deleted Copied: trunk/relish.txt (from rev 39, trunk/vendors/deli/pickle.txt) =================================================================== --- trunk/relish.txt (rev 0) +++ trunk/relish.txt 2013-01-29 20:39:17 UTC (rev 40) @@ -0,0 +1 @@ +Pickle relish is mostly made from cucumbers. Modified: trunk/vendors/deli/logo.jpg =================================================================== (Binary files differ) Added: trunk/vendors/deli/soda.txt ============================================================================== $ </pre></div><p>Note that in each of the previous examples, when a file has a nontextual <code class="literal">svn:mime-type</code> property, the differences are not explicitly shown.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.dirs-changed"></a><div class="titlepage"></div><a id="idm12739" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook dirs-changed — Print the directories that were themselves changed.</p></div><div class="refsect1"><a id="idm12746"></a><h2>Synopsis</h2><p><code class="literal">svnlook dirs-changed REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12750"></a><h2>Description</h2><p>Print the directories that were themselves changed (property edits) or whose file children were changed.</p></div><div class="refsect1"><a id="idm12753"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.transaction"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></a> </pre></div></div><div class="refsect1"><a id="idm12759"></a><h2>Examples</h2><p>This shows the directories that changed in revision 40 in our sample repository:</p><div class="informalexample"><pre class="screen"> $ svnlook dirs-changed -r 40 /var/svn/repos trunk/vendors/deli/ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.filesize"></a><div class="titlepage"></div><a id="idm12765" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook filesize — Print the size (in bytes) of a versioned file.</p></div><div class="refsect1"><a id="idm12772"></a><h2>Synopsis</h2><p><code class="literal">svnlook filesize REPOS_PATH PATH_IN_REPOS</code></p></div><div class="refsect1"><a id="idm12776"></a><h2>Description</h2><p>Print the file size (in bytes) of the file located at <em class="replaceable"><code>PATH_IN_REPOS</code></em> in the HEAD revision of the repository identified by <em class="replaceable"><code>REPOS_PATH</code></em> as a base-10 integer followed by an end-of-line character. Use the <code class="option">--revision</code> (<code class="option">-r</code>) and <code class="option">--transaction</code> (<code class="option">-t</code>) options to specify a version of the file other than HEAD whose file size you wish to display.</p></div><div class="refsect1"><a id="idm12785"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.transaction"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></a> </pre></div></div><div class="refsect1"><a id="idm12791"></a><h2>Examples</h2><p>The following demonstrates how to display the size of the <code class="filename">trunk/vendors/deli/soda.txt</code> file as it appeared in revision 40 of our sample repository:</p><div class="informalexample"><pre class="screen"> $ svnlook filesize -r 40 /var/svn/repos trunk/vendors/deli/soda.txt 23 $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.help"></a><div class="titlepage"></div><a id="idm12798" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook help (h, ?) — Help!</p></div><div class="refsect1"><a id="idm12805"></a><h2>Synopsis</h2><p><code class="literal">Also svnlook -h and svnlook -?.</code></p></div><div class="refsect1"><a id="idm12809"></a><h2>Description</h2><p>Displays the help message for <span class="command"><strong>svnlook</strong></span>. This command, like its brother, <span class="command"><strong>svn help</strong></span>, is also your friend, even though you never call it anymore and forgot to invite it to your last party.</p></div><div class="refsect1"><a id="idm12814"></a><h2>Options</h2><p>None</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.history"></a><div class="titlepage"></div><a id="idm12818" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook history — Print information about the history of a path in the repository (or the root directory if no path is supplied).</p></div><div class="refsect1"><a id="idm12825"></a><h2>Synopsis</h2><p><code class="literal">svnlook history REPOS_PATH [PATH_IN_REPOS]</code></p></div><div class="refsect1"><a id="idm12829"></a><h2>Description</h2><p>Print information about the history of a path in the repository (or the root directory if no path is supplied).</p></div><div class="refsect1"><a id="idm12832"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.limit"><code class="option">--limit</code> (<code class="option">-l</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.show_ids"><code class="option">--show-ids</code></a> </pre></div></div><div class="refsect1"><a id="idm12839"></a><h2>Examples</h2><p>This shows the history output for the path <code class="filename">/branches/bookstore</code> as of revision 13 in our sample repository:</p><div class="informalexample"><pre class="screen"> $ svnlook history -r 13 /var/svn/repos /branches/bookstore --show-ids REVISION PATH &lt;ID&gt; -------- --------- 13 /branches/bookstore &lt;1.1.r13/390&gt; 12 /branches/bookstore &lt;1.1.r12/413&gt; 11 /branches/bookstore &lt;1.1.r11/0&gt; 9 /trunk &lt;1.0.r9/551&gt; 8 /trunk &lt;1.0.r8/131357096&gt; 7 /trunk &lt;1.0.r7/294&gt; 6 /trunk &lt;1.0.r6/353&gt; 5 /trunk &lt;1.0.r5/349&gt; 4 /trunk &lt;1.0.r4/332&gt; 3 /trunk &lt;1.0.r3/335&gt; 2 /trunk &lt;1.0.r2/295&gt; 1 /trunk &lt;1.0.r1/532&gt; </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.info"></a><div class="titlepage"></div><a id="idm12846" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook info — Print the author, datestamp, log message size, and log message.</p></div><div class="refsect1"><a id="idm12853"></a><h2>Synopsis</h2><p><code class="literal">svnlook info REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12857"></a><h2>Description</h2><p>Print the author, datestamp, log message size (in bytes), and log message, followed by a newline character.</p></div><div class="refsect1"><a id="idm12860"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.transaction"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></a> </pre></div></div><div class="refsect1"><a id="idm12866"></a><h2>Examples</h2><p>This shows the info output for revision 40 in our sample repository:</p><div class="informalexample"><pre class="screen"> $ svnlook info -r 40 /var/svn/repos sally 2003-02-22 17:44:49 -0600 (Sat, 22 Feb 2003) 16 Rearrange lunch. </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.lock"></a><div class="titlepage"></div><a id="idm12872" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook lock — If a lock exists on a path in the repository, describe it.</p></div><div class="refsect1"><a id="idm12879"></a><h2>Synopsis</h2><p><code class="literal">svnlook lock REPOS_PATH PATH_IN_REPOS</code></p></div><div class="refsect1"><a id="idm12883"></a><h2>Description</h2><p>Print all information available for the lock at <em class="replaceable"><code>PATH_IN_REPOS</code></em>. If <em class="replaceable"><code>PATH_IN_REPOS</code></em> is not locked, print nothing.</p></div><div class="refsect1"><a id="idm12888"></a><h2>Options</h2><p>None</p></div><div class="refsect1"><a id="idm12891"></a><h2>Examples</h2><p>This describes the lock on the file <code class="filename">tree.jpg</code>:</p><div class="informalexample"><pre class="screen"> $ svnlook lock /var/svn/repos tree.jpg UUID Token: opaquelocktoken:ab00ddf0-6afb-0310-9cd0-dda813329753 Owner: harry Created: 2005-07-08 17:27:36 -0500 (Fri, 08 Jul 2005) Expires: Comment (1 line): Rework the uppermost branches on the bald cypress in the foreground. </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.log"></a><div class="titlepage"></div><a id="idm12898" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook log — Print the log message, followed by a newline character.</p></div><div class="refsect1"><a id="idm12905"></a><h2>Synopsis</h2><p><code class="literal">svnlook log REPOS_PATH</code></p></div><div class="refsect1"><a id="idm12909"></a><h2>Description</h2><p>Print the log message.</p></div><div class="refsect1"><a id="idm12912"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.transaction"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></a> </pre></div></div><div class="refsect1"><a id="idm12918"></a><h2>Examples</h2><p>This shows the log output for revision 40 in our sample repository:</p><div class="informalexample"><pre class="screen"> $ svnlook log /var/svn/repos/ Rearrange lunch. </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.propget"></a><div class="titlepage"></div><a id="idm12924" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook propget (pget, pg) — Print the raw value of a property on a path in the repository.</p></div><div class="refsect1"><a id="idm12931"></a><h2>Synopsis</h2><p><code class="literal">svnlook propget REPOS_PATH PROPNAME [PATH_IN_REPOS]</code></p></div><div class="refsect1"><a id="idm12935"></a><h2>Description</h2><p>List the value of a property on a path in the repository.</p></div><div class="refsect1"><a id="idm12938"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.revprop"><code class="option">--revprop</code></a> <a class="xref" href="#svn.ref.svnlook.sw.transaction"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></a> </pre></div></div><div class="refsect1"><a id="idm12945"></a><h2>Examples</h2><p>This shows the value of the <span class="quote">“<span class="quote">seasonings</span>”</span> property on the file <code class="filename">/trunk/sandwich</code> in the <code class="literal">HEAD</code> revision:</p><div class="informalexample"><pre class="screen"> $ svnlook pg /var/svn/repos seasonings /trunk/sandwich mustard </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.proplist"></a><div class="titlepage"></div><a id="idm12954" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook proplist (plist, pl) — Print the names and values of versioned file and directory properties.</p></div><div class="refsect1"><a id="idm12961"></a><h2>Synopsis</h2><p><code class="literal">svnlook proplist REPOS_PATH [PATH_IN_REPOS]</code></p></div><div class="refsect1"><a id="idm12965"></a><h2>Description</h2><p>List the properties of a path in the repository. With <code class="option">--verbose</code> (<code class="option">-v</code>), show the property values too.</p></div><div class="refsect1"><a id="idm12970"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.revprop"><code class="option">--revprop</code></a> <a class="xref" href="#svn.ref.svnlook.sw.transaction"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.verbose"><code class="option">--verbose</code> (<code class="option">-v</code>)</a> <a class="xref" href="#svn.ref.svnlook.sw.xml"><code class="option">--xml</code></a> </pre></div></div><div class="refsect1"><a id="idm12979"></a><h2>Examples</h2><p>This shows the names of properties set on the file <code class="filename">/trunk/README</code> in the <code class="literal">HEAD</code> revision:</p><div class="informalexample"><pre class="screen"> $ svnlook proplist /var/svn/repos /trunk/README original-author svn:mime-type </pre></div><p>This is the same command as in the preceding example, but this time showing the property values as well:</p><div class="informalexample"><pre class="screen"> $ svnlook -v proplist /var/svn/repos /trunk/README original-author : harry svn:mime-type : text/plain </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.tree"></a><div class="titlepage"></div><a id="idm12990" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook tree — Print the tree.</p></div><div class="refsect1"><a id="idm12997"></a><h2>Synopsis</h2><p><code class="literal">svnlook tree REPOS_PATH [PATH_IN_REPOS]</code></p></div><div class="refsect1"><a id="idm13001"></a><h2>Description</h2><p>Print the tree, starting at <em class="replaceable"><code>PATH_IN_REPOS</code></em> (if supplied; at the root of the tree otherwise), optionally showing node revision IDs.</p></div><div class="refsect1"><a id="idm13005"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnlook.sw.full_paths"><code class="option">--full-paths</code></a> <a class="xref" href="#svn.ref.svnlook.sw.non_recursive"><code class="option">--non-recursive</code> (<code class="option">-N</code>)</a> <a class="xref" href="#svn.ref.svnlook.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="#svn.ref.svnlook.sw.show_ids"><code class="option">--show-ids</code></a> <a class="xref" href="#svn.ref.svnlook.sw.transaction"><code class="option">--transaction</code> (<code class="option">-t</code>) <em class="replaceable"><code>ID</code></em></a> </pre></div></div><div class="refsect1"><a id="idm13014"></a><h2>Example</h2><p>This shows the tree output for revision 13 in our sample repository:</p><div class="informalexample"><pre class="screen"> $ svnlook tree -r 13 /var/svn/repos / trunk/ button.c Makefile integer.c branches/ bookstore/ button.c Makefile integer.c … </pre></div><p>Use the <code class="option">--show-ids</code> option to include node revision IDs (unique internal identifiers for specific nodes in Subversion's versioned filesystem implementation):</p><div class="informalexample"><pre class="screen"> $ svnlook tree -r 13 /var/svn/repos --show-ids / &lt;0.0.r13/811&gt; trunk/ &lt;1.0.r9/551&gt; button.c &lt;2.0.r9/238&gt; Makefile &lt;3.0.r7/41&gt; integer.c &lt;4.0.r6/98&gt; branches/ &lt;5.0.r13/593&gt; bookstore/ &lt;1.1.r13/390&gt; button.c &lt;2.1.r12/85&gt; Makefile &lt;3.0.r7/41&gt; integer.c &lt;4.1.r13/109&gt; … </pre></div><p>For output which lends itself more readily to being parsed by scripts, use the <code class="option">--full-paths</code> option, which causes <span class="command"><strong>svnlook</strong></span> to print the full repository path of each tree item and to not use indentation to indicate hierarchy:</p><div class="informalexample"><pre class="screen"> $ svnlook tree -r 13 /var/svn/repos --show-ids --full-paths / &lt;0.0.r13/811&gt; trunk/ &lt;1.0.r9/551&gt; trunk/button.c &lt;2.0.r9/238&gt; trunk/Makefile &lt;3.0.r7/41&gt; trunk/integer.c &lt;4.0.r6/98&gt; branches/ &lt;5.0.r13/593&gt; branches/bookstore/ &lt;1.1.r13/390&gt; branches/bookstore/button.c &lt;2.1.r12/85&gt; branches/bookstore/Makefile &lt;3.0.r7/41&gt; branches/bookstore/integer.c &lt;4.1.r13/109&gt; … </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.uuid"></a><div class="titlepage"></div><a id="idm13029" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook uuid — Print the repository's <code class="literal">UUID</code>.</p></div><div class="refsect1"><a id="idm13037"></a><h2>Synopsis</h2><p><code class="literal">svnlook uuid REPOS_PATH</code></p></div><div class="refsect1"><a id="idm13041"></a><h2>Description</h2><p>Print the <code class="literal">UUID</code> for the repository. The <code class="literal">UUID</code> is the repository's <span class="emphasis"><em>u</em></span>niversal <span class="emphasis"><em>u</em></span>nique <span class="emphasis"><em>id</em></span>entifier. The Subversion client uses this identifier to differentiate between one repository and another.</p></div><div class="refsect1"><a id="idm13049"></a><h2>Options</h2><p>None</p></div><div class="refsect1"><a id="idm13052"></a><h2>Examples</h2><div class="informalexample"><pre class="screen"> $ svnlook uuid /var/svn/repos e7fe1b91-8cd5-0310-98dd-2f12e793c5e8 </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnlook.c.youngest"></a><div class="titlepage"></div><a id="idm13057" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnlook youngest — Print the youngest revision number.</p></div><div class="refsect1"><a id="idm13064"></a><h2>Synopsis</h2><p><code class="literal">svnlook youngest REPOS_PATH</code></p></div><div class="refsect1"><a id="idm13068"></a><h2>Description</h2><p>Print the youngest revision number of a repository.</p></div><div class="refsect1"><a id="idm13071"></a><h2>Options</h2><p>None</p></div><div class="refsect1"><a id="idm13074"></a><h2>Examples</h2><p>This shows the youngest revision of our sample repository:</p><div class="informalexample"><pre class="screen"> $ svnlook youngest /var/svn/repos/ 42 </pre></div></div></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.ref.svnsync"></a>svnsync—Subversion Repository Mirroring</h2></div></div></div><p><span class="command"><strong>svnsync</strong></span> is the Subversion remote repository mirroring tool. Put simply, it allows you to replay the revisions of one repository into another one.</p><p>In any mirroring scenario, there are two repositories: the source repository, and the mirror (or <span class="quote">“<span class="quote">sink</span>”</span>) repository. The source repository is the repository from which <span class="command"><strong>svnsync</strong></span> pulls revisions. The mirror repository is the destination for the revisions pulled from the source repository. Each of the repositories may be local or remote—they are only ever addressed by their URLs.</p><p>The <span class="command"><strong>svnsync</strong></span> process requires only read access to the source repository; it never attempts to modify it. But obviously, <span class="command"><strong>svnsync</strong></span> requires both read and write access to the mirror repository.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p><span class="command"><strong>svnsync</strong></span> is very sensitive to changes made in the mirror repository that weren't made as part of a mirroring operation. To prevent this from happening, it's best if the <span class="command"><strong>svnsync</strong></span> process is the only process permitted to modify the mirror repository.</p></td></tr></table></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svnsync.sw"></a>svnsync Options</h3></div></div></div><p>Options in <span class="command"><strong>svnsync</strong></span> are global, just as they are in <span class="command"><strong>svn</strong></span> and <span class="command"><strong>svnadmin</strong></span>:</p><div class="variablelist"><dl class="variablelist"><dt><a id="svn.ref.svnsync.sw.allow_non_empty"></a><span class="term"><code class="option">--allow-non-empty</code></span></dt><dd><p>Disables the verification (which <span class="command"><strong>svnsync initialize</strong></span> performs by default) that the repository being initialized is empty of history version.</p></dd><dt><a id="svn.ref.svnsync.sw.config_dir"></a><span class="term"><code class="option">--config-dir</code> <em class="replaceable"><code>DIR</code></em></span></dt><dd><p>Instructs Subversion to read configuration information from the specified directory instead of the default location (<code class="filename">.subversion</code> in the user's home directory).</p></dd><dt><a id="svn.ref.svnsync.sw.config_option"></a><span class="term"><code class="option">--config-option</code> <em class="replaceable"><code>CONFSPEC</code></em></span></dt><dd><p>Sets, for the duration of the command, the value of a runtime configuration option. <em class="replaceable"><code>CONFSPEC</code></em> is a string which specifies the configuration option namespace, name and value that you'd like to assign, formatted as <em class="replaceable"><code>FILE</code></em>:<em class="replaceable"><code>SECTION</code></em>:<em class="replaceable"><code>OPTION</code></em>=[<em class="replaceable"><code>VALUE</code></em>]. In this syntax, <em class="replaceable"><code>FILE</code></em> and <em class="replaceable"><code>SECTION</code></em> are the runtime configuration file (either <code class="literal">config</code> or <code class="literal">servers</code>) and the section thereof, respectively, which contain the option whose value you wish to change. <em class="replaceable"><code>OPTION</code></em> is, of course, the option itself, and <em class="replaceable"><code>VALUE</code></em> the value (if any) you wish to assign to the option. For example, to temporarily disable the use of the compression in the HTTP protocol, use <code class="option">--config-option=servers:global:http-compression=no</code>. You can use this option multiple times to change multiple option values simultaneously.</p></dd><dt><a id="svn.ref.svnsync.sw.disable_locking"></a><span class="term"><code class="option">--disable-locking</code></span></dt><dd><p>Causes <span class="command"><strong>svnsync</strong></span> to bypass its own exclusive access mechanisms and operate on the assumption that its exclusive access to the mirror repository is being guaranteed through some other, out-of-band mechanism.</p></dd><dt><a id="svn.ref.svnsync.sw.no_auth_cache"></a><span class="term"><code class="option">--no-auth-cache</code></span></dt><dd><p>Prevents caching of authentication information (e.g., username and password) in the Subversion runtime configuration directories.</p></dd><dt><a id="svn.ref.svnsync.sw.non_interactive"></a><span class="term"><code class="option">--non-interactive</code></span></dt><dd><p>In the case of an authentication failure or insufficient credentials, prevents prompting for credentials (e.g., username or password). This is useful if you're running Subversion inside an automated script and it's more appropriate to have Subversion fail than to prompt for more information.</p></dd><dt><a id="svn.ref.svnsync.sw.quiet"></a><span class="term"><code class="option">--quiet</code> (<code class="option">-q</code>)</span></dt><dd><p>Requests that the client print only essential information while performing an operation.</p></dd><dt><a id="svn.ref.svnsync.sw.revision"></a><span class="term"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Used by <span class="command"><strong>svnsync copy-revprops</strong></span> to specify a particular revision or revision range on which to operate.</p></dd><dt><a id="svn.ref.svnsync.sw.source_password"></a><span class="term"><code class="option">--source-password</code> <em class="replaceable"><code>PASSWD</code></em></span></dt><dd><p>Specifies the password for the Subversion server from which you are syncing. If not provided, or if incorrect, Subversion will prompt you for this information as needed.</p></dd><dt><a id="svn.ref.svnsync.sw.source_prop_encoding"></a><span class="term"><code class="option">--source-prop-encoding <em class="replaceable"><code>ARG</code></em></code></span></dt><dd><p>Instructs <span class="command"><strong>svnsync</strong></span> to assume that translatable Subversion revision properties found in the source repository are stored using the character encoding <em class="replaceable"><code>ARG</code></em> and to transcode those into UTF-8 when copying them into the mirror repository.</p></dd><dt><a id="svn.ref.svnsync.sw.source_username"></a><span class="term"><code class="option">--source-username</code> <em class="replaceable"><code>NAME</code></em></span></dt><dd><p>Specifies the username for the Subversion server from which you are syncing. If not provided, or if incorrect, Subversion will prompt you for this information as needed.</p></dd><dt><a id="svn.ref.svnsync.sw.steal_lock"></a><span class="term"><code class="option">--steal-lock</code></span></dt><dd><p>Causes <span class="command"><strong>svnsync</strong></span> to steal, as necessary, the lock which it uses on the mirror repository to ensure exclusive repository access. (This option should only be used when a lock exists in the mirror repository and is known to be stale—that is, when you are certain that there are no other <span class="command"><strong>svnsync</strong></span> processes accessing that repository.)</p></dd><dt><a id="svn.ref.svnsync.sw.sync_password"></a><span class="term"><code class="option">--sync-password</code> <em class="replaceable"><code>PASSWD</code></em></span></dt><dd><p>Specifies the password for the Subversion server to which you are syncing. If not provided, or if incorrect, Subversion will prompt you for this information as needed.</p></dd><dt><a id="svn.ref.svnsync.sw.sync_username"></a><span class="term"><code class="option">--sync-username</code> <em class="replaceable"><code>NAME</code></em></span></dt><dd><p>Specifies the username for the Subversion server to which you are syncing. If not provided, or if incorrect, Subversion will prompt you for this information as needed.</p></dd><dt><a id="svn.ref.svnsync.sw.trust_server_cert"></a><span class="term"><code class="option">--trust-server-cert</code></span></dt><dd><p>Used with <code class="option">--non-interactive</code> to accept any unknown SSL server certificates without prompting.</p></dd></dl></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svnsync.c"></a>svnsync Subcommands</h3></div></div></div><p>Here are the various subcommands for the <span class="command"><strong>svnsync</strong></span> program.</p><div class="refentry"><a id="svn.ref.svnsync.c.copy-revprops"></a><div class="titlepage"></div><a id="idm13211" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnsync copy-revprops — Copy all revision properties for a particular revision (or range of revisions) from the source repository to the mirror repository.</p></div><div class="refsect1"><a id="idm13218"></a><h2>Synopsis</h2><p><code class="literal">svnsync copy-revprops DEST_URL [SOURCE_URL]</code></p><p><code class="literal">svnsync copy-revprops DEST_URL REV[:REV2]</code></p></div><div class="refsect1"><a id="idm13224"></a><h2>Description</h2><p>Because Subversion revision properties can be changed at any time, it's possible that the properties for some revision might be changed after that revision has already been synchronized to another repository. Because the <span class="command"><strong>svnsync synchronize</strong></span> command operates only on the range of revisions that have not yet been synchronized, it won't notice a revision property change outside that range. Left as is, this causes a deviation in the values of that revision's properties between the source and mirror repositories. <span class="command"><strong>svnsync copy-revprops</strong></span> is the answer to this problem. Use it to resynchronize the revision properties for a particular revision or range of revisions.</p><p>When <em class="replaceable"><code>SOURCE_URL</code></em> is provided, <span class="command"><strong>svnsync</strong></span> will use it as the repository URL which the destination repository is mirroring. Generally, <em class="replaceable"><code>SOURCE_URL</code></em> will be exactly the same source URL as was used with the <span class="command"><strong>svnsync initialize</strong></span> command when the mirror was first set up. You may choose, however, to omit <em class="replaceable"><code>SOURCE_URL</code></em>, in which case <span class="command"><strong>svnsync</strong></span> will consult the mirror repository's records to determine the source URL which should be used.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>We strongly recommend that you specify the source URL on the command-line, especially when untrusted users have write access to the revision 0 properties which <span class="command"><strong>svnsync</strong></span> uses to coordinate its efforts.</p></td></tr></table></div></div><div class="refsect1"><a id="idm13239"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnsync.sw.config_dir"><code class="option">--config-dir</code> <em class="replaceable"><code>DIR</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.config_option"><code class="option">--config-option</code> <em class="replaceable"><code>CONFSPEC</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.disable_locking"><code class="option">--disable-locking</code></a> <a class="xref" href="#svn.ref.svnsync.sw.no_auth_cache"><code class="option">--no-auth-cache</code></a> <a class="xref" href="#svn.ref.svnsync.sw.non_interactive"><code class="option">--non-interactive</code></a> <a class="xref" href="#svn.ref.svnsync.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svnsync.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.source_password"><code class="option">--source-password</code> <em class="replaceable"><code>PASSWD</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.source_prop_encoding"><code class="option">--source-prop-encoding <em class="replaceable"><code>ARG</code></em></code></a> <a class="xref" href="#svn.ref.svnsync.sw.source_username"><code class="option">--source-username</code> <em class="replaceable"><code>NAME</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.steal_lock"><code class="option">--steal-lock</code></a> <a class="xref" href="#svn.ref.svnsync.sw.sync_password"><code class="option">--sync-password</code> <em class="replaceable"><code>PASSWD</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.sync_username"><code class="option">--sync-username</code> <em class="replaceable"><code>NAME</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.trust_server_cert"><code class="option">--trust-server-cert</code></a> </pre></div></div><div class="refsect1"><a id="idm13257"></a><h2>Examples</h2><p>Resynchronize the revision properties associated with a single revision (r6):</p><div class="informalexample"><pre class="screen"> $ svnsync copy-revprops -r 6 file:///var/svn/repos-mirror \ http://svn.example.com/repos Copied properties for revision 6. $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnsync.c.help"></a><div class="titlepage"></div><a id="idm13263" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnsync help — Help!</p></div><div class="refsect1"><a id="idm13270"></a><h2>Synopsis</h2><p><code class="literal">svnsync help</code></p></div><div class="refsect1"><a id="idm13274"></a><h2>Description</h2><p>This subcommand is useful when you're trapped in a foreign prison with neither a Net connection nor a copy of this book, but you do have a local Wi-Fi network running and you'd like to sync a copy of your repository over to the backup server that Ira The Knife is running over in cell block D.</p></div><div class="refsect1"><a id="idm13277"></a><h2>Options</h2><p>None</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnsync.c.info"></a><div class="titlepage"></div><a id="idm13281" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnsync info — Print information about the synchronization of a destination repository.</p></div><div class="refsect1"><a id="idm13288"></a><h2>Synopsis</h2><p><code class="literal">svnsync info DEST_URL</code></p></div><div class="refsect1"><a id="idm13292"></a><h2>Description</h2><p>Print the synchronization source URL, source repository UUID and the last revision merged from the source to the destination repository at <em class="replaceable"><code>DEST_URL</code></em>.</p></div><div class="refsect1"><a id="idm13296"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnsync.sw.config_dir"><code class="option">--config-dir</code> <em class="replaceable"><code>DIR</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.config_option"><code class="option">--config-option</code> <em class="replaceable"><code>CONFSPEC</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.no_auth_cache"><code class="option">--no-auth-cache</code></a> <a class="xref" href="#svn.ref.svnsync.sw.non_interactive"><code class="option">--non-interactive</code></a> <a class="xref" href="#svn.ref.svnsync.sw.source_password"><code class="option">--source-password</code> <em class="replaceable"><code>PASSWD</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.source_username"><code class="option">--source-username</code> <em class="replaceable"><code>NAME</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.sync_password"><code class="option">--sync-password</code> <em class="replaceable"><code>PASSWD</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.sync_username"><code class="option">--sync-username</code> <em class="replaceable"><code>NAME</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.trust_server_cert"><code class="option">--trust-server-cert</code></a> </pre></div></div><div class="refsect1"><a id="idm13309"></a><h2>Examples</h2><p>Print the synchronization information of a mirror repository:</p><div class="informalexample"><pre class="screen"> $ svnsync info file:///var/svn/repos-mirror Source URL: http://svn.example.com/repos Source Repository UUID: e7fe1b91-8cd5-0310-98dd-2f12e793c5e8 Last Merged Revision: 47 $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnsync.c.init"></a><div class="titlepage"></div><a id="idm13315" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnsync initialize (init) — Initialize a mirror repository for synchronization from the source repository.</p></div><div class="refsect1"><a id="idm13322"></a><h2>Synopsis</h2><p><code class="literal">svnsync initialize MIRROR_URL SOURCE_URL</code></p></div><div class="refsect1"><a id="idm13326"></a><h2>Description</h2><p><span class="command"><strong>svnsync initialize</strong></span> verifies that a repository meets the basic requirements of a new mirror repository and records the initial administrative information that associates the mirror repository with the source repository (specified by <em class="replaceable"><code>SOURCE_URL</code></em>). This is the first <span class="command"><strong>svnsync</strong></span> operation you run on a would-be mirror repository.</p><p>Ordinarily, <em class="replaceable"><code>SOURCE_URL</code></em> is the URL of the root directory of the Subversion repository you wish to mirror. Subversion 1.5 and newer allow you to use <span class="command"><strong>svnsync</strong></span> for partial repository mirroring, though — simply specify the URL of the source repository subdirectory you wish to mirror as <em class="replaceable"><code>SOURCE_URL</code></em>.</p><p>By default, the aforementioned basic requirements of a mirror are that it allows revision property modifications and that it contains no version history. However, as of Subversion 1.7, you may now optionally disable the verification that the target repository is empty using the <code class="option">--allow-non-empty</code> option. While the use of this option should not become habitual (as it bypasses a valuable safeguard mechanism), it does aid in one very common use-case: initializing a copy of a repository as a mirror of the original. This is especially handy when setting up new mirrors of repositories which contain a large amount of version history. Rather than initialize a brand new repository as a mirror and then syncronize all of the history into it, administrators will find it <span class="emphasis"><em>significantly</em></span> faster to first make a copy of the mature repository (perhaps using <span class="command"><strong>svnadmin hotcopy</strong></span>) and then use <span class="command"><strong>svnsync initialize --allow-non-empty</strong></span> to initialize that copy as a mirror which is now already up-to-date with the original.</p></div><div class="refsect1"><a id="idm13341"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnsync.sw.allow_non_empty"><code class="option">--allow-non-empty</code></a> <a class="xref" href="#svn.ref.svnsync.sw.config_dir"><code class="option">--config-dir</code> <em class="replaceable"><code>DIR</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.config_option"><code class="option">--config-option</code> <em class="replaceable"><code>CONFSPEC</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.disable_locking"><code class="option">--disable-locking</code></a> <a class="xref" href="#svn.ref.svnsync.sw.no_auth_cache"><code class="option">--no-auth-cache</code></a> <a class="xref" href="#svn.ref.svnsync.sw.non_interactive"><code class="option">--non-interactive</code></a> <a class="xref" href="#svn.ref.svnsync.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svnsync.sw.source_password"><code class="option">--source-password</code> <em class="replaceable"><code>PASSWD</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.source_prop_encoding"><code class="option">--source-prop-encoding <em class="replaceable"><code>ARG</code></em></code></a> <a class="xref" href="#svn.ref.svnsync.sw.source_username"><code class="option">--source-username</code> <em class="replaceable"><code>NAME</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.steal_lock"><code class="option">--steal-lock</code></a> <a class="xref" href="#svn.ref.svnsync.sw.sync_password"><code class="option">--sync-password</code> <em class="replaceable"><code>PASSWD</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.sync_username"><code class="option">--sync-username</code> <em class="replaceable"><code>NAME</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.trust_server_cert"><code class="option">--trust-server-cert</code></a> </pre></div></div><div class="refsect1"><a id="idm13359"></a><h2>Examples</h2><p>Fail to initialize a mirror repository due to inability to modify revision properties:</p><div class="informalexample"><pre class="screen"> $ svnsync initialize file:///var/svn/repos-mirror \ http://svn.example.com/repos svnsync: Repository has not been enabled to accept revision propchanges; ask the administrator to create a pre-revprop-change hook $ </pre></div><p>Initialize a repository as a mirror, having already created a <code class="literal">pre-revprop-change</code> hook that permits all revision property changes:</p><div class="informalexample"><pre class="screen"> $ svnsync initialize file:///var/svn/repos-mirror \ http://svn.example.com/repos Copied properties for revision 0. $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnsync.c.sync"></a><div class="titlepage"></div><a id="idm13369" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnsync synchronize (sync) — Transfer all pending revisions from the source repository to the mirror repository.</p></div><div class="refsect1"><a id="idm13376"></a><h2>Synopsis</h2><p><code class="literal">svnsync synchronize DEST_URL [SOURCE_URL]</code></p></div><div class="refsect1"><a id="idm13380"></a><h2>Description</h2><p>The <span class="command"><strong>svnsync synchronize</strong></span> command does all the heavy lifting of a repository mirroring operation. After consulting with the mirror repository to see which revisions have already been copied into it, it then begins to copy any not-yet-mirrored revisions from the source repository.</p><p><span class="command"><strong>svnsync synchronize</strong></span> can be gracefully canceled and restarted.</p><p>When <em class="replaceable"><code>SOURCE_URL</code></em> is provided, <span class="command"><strong>svnsync</strong></span> will use it as the repository URL which the destination repository is mirroring. Generally, <em class="replaceable"><code>SOURCE_URL</code></em> will be exactly the same source URL as was used with the <span class="command"><strong>svnsync initialize</strong></span> command when the mirror was first set up. You may choose, however, to omit <em class="replaceable"><code>SOURCE_URL</code></em>, in which case <span class="command"><strong>svnsync</strong></span> will consult the mirror repository's records to determine the source URL which should be used.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>We strongly recommend that you specify the source URL on the command-line, especially when untrusted users have write access to the revision 0 properties which <span class="command"><strong>svnsync</strong></span> uses to coordinate its efforts.</p></td></tr></table></div></div><div class="refsect1"><a id="idm13396"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnsync.sw.config_dir"><code class="option">--config-dir</code> <em class="replaceable"><code>DIR</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.config_option"><code class="option">--config-option</code> <em class="replaceable"><code>CONFSPEC</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.disable_locking"><code class="option">--disable-locking</code></a> <a class="xref" href="#svn.ref.svnsync.sw.no_auth_cache"><code class="option">--no-auth-cache</code></a> <a class="xref" href="#svn.ref.svnsync.sw.non_interactive"><code class="option">--non-interactive</code></a> <a class="xref" href="#svn.ref.svnsync.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svnsync.sw.source_password"><code class="option">--source-password</code> <em class="replaceable"><code>PASSWD</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.source_prop_encoding"><code class="option">--source-prop-encoding <em class="replaceable"><code>ARG</code></em></code></a> <a class="xref" href="#svn.ref.svnsync.sw.source_username"><code class="option">--source-username</code> <em class="replaceable"><code>NAME</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.steal_lock"><code class="option">--steal-lock</code></a> <a class="xref" href="#svn.ref.svnsync.sw.sync_password"><code class="option">--sync-password</code> <em class="replaceable"><code>PASSWD</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.sync_username"><code class="option">--sync-username</code> <em class="replaceable"><code>NAME</code></em></a> <a class="xref" href="#svn.ref.svnsync.sw.trust_server_cert"><code class="option">--trust-server-cert</code></a> </pre></div></div><div class="refsect1"><a id="idm13413"></a><h2>Examples</h2><p>Copy unsynchronized revisions from the source repository to the mirror repository:</p><div class="informalexample"><pre class="screen"> $ svnsync synchronize file:///var/svn/repos-mirror \ http://svn.example.com/repos Committed revision 1. Copied properties for revision 1. Committed revision 2. Copied properties for revision 2. Committed revision 3. Copied properties for revision 3. … Committed revision 45. Copied properties for revision 45. Committed revision 46. Copied properties for revision 46. Committed revision 47. Copied properties for revision 47. $ </pre></div></div></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.ref.svnrdump"></a>svnrdump—Remote Subversion Repository Data Migration</h2></div></div></div><p><span class="command"><strong>svnrdump</strong></span> joined the Subversion tool chain in the Subversion 1.7 release. It is best described as a network-aware version of the <span class="command"><strong>svnadmin dump</strong></span> and <span class="command"><strong>svnadmin load</strong></span> commands, paired together and released as a separate standalone program. We discuss the process of dumping and loading repository data—using both <span class="command"><strong>svnadmin</strong></span> and <span class="command"><strong>svnrdump</strong></span>— in <a class="xref" href="#svn.reposadmin.maint.migrate" title="Migrating Repository Data Elsewhere">the section called “Migrating Repository Data Elsewhere”</a>.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svnrdump.sw"></a>svnrdump Options</h3></div></div></div><p>Options in <span class="command"><strong>svnrdump</strong></span> are global, just as they are in <span class="command"><strong>svn</strong></span> and <span class="command"><strong>svnadmin</strong></span>:</p><div class="variablelist"><dl class="variablelist"><dt><a id="svn.ref.svnrdump.sw.config_dir"></a><span class="term"><code class="option">--config-dir</code> <em class="replaceable"><code>DIR</code></em></span></dt><dd><p>Instructs Subversion to read configuration information from the specified directory instead of the default location (<code class="filename">.subversion</code> in the user's home directory).</p></dd><dt><a id="svn.ref.svnrdump.sw.config_option"></a><span class="term"><code class="option">--config-option</code> <em class="replaceable"><code>FILE</code></em>:<em class="replaceable"><code>SECTION</code></em>:<em class="replaceable"><code>OPTION</code></em>=[<em class="replaceable"><code>VALUE</code></em>]</span></dt><dd><p>Sets, for the duration of the command, the value of a runtime configuration option. <em class="replaceable"><code>FILE</code></em> and <em class="replaceable"><code>SECTION</code></em> are the runtime configuration file (either <code class="literal">config</code> or <code class="literal">servers</code>) and the section thereof, respectively, which contain the option whose value you wish to change. <em class="replaceable"><code>OPTION</code></em> is, of course, the option itself, and <em class="replaceable"><code>VALUE</code></em> the value (if any) you wish to assign to the option. For example, to temporarily disable the use of the compression in the HTTP protocol, use <code class="option">--config-option=servers:global:http-compression=no</code>. You can use this option multiple times to change multiple option values simultaneously.</p></dd><dt><a id="svn.ref.svnrdump.sw.incremental"></a><span class="term"><code class="option">--incremental</code></span></dt><dd><p>Dump a revision or revision range only as a diff against the previous revision, instead of the default, which is begin a dumped revision range with a complete expansion of all contents of the repository as of that revision.</p></dd><dt><a id="svn.ref.svnrdump.sw.no_auth_cache"></a><span class="term"><code class="option">--no-auth-cache</code></span></dt><dd><p>Prevents caching of authentication information (e.g., username and password) in the Subversion runtime configuration directories.</p></dd><dt><a id="svn.ref.svnrdump.sw.non_interactive"></a><span class="term"><code class="option">--non-interactive</code></span></dt><dd><p>In the case of an authentication failure or insufficient credentials, prevents prompting for credentials (e.g., username or password). This is useful if you're running Subversion inside an automated script and it's more appropriate to have Subversion fail than to prompt for more information.</p></dd><dt><a id="svn.ref.svnrdump.sw.password"></a><span class="term"><code class="option">--password</code> <em class="replaceable"><code>PASSWD</code></em></span></dt><dd><p>Specifies the password to use when authenticating against a Subversion server. If not provided, or if incorrect, Subversion will prompt you for this information as needed.</p></dd><dt><a id="svn.ref.svnrdump.sw.quiet"></a><span class="term"><code class="option">--quiet</code> (<code class="option">-q</code>)</span></dt><dd><p>Requests that the client print only essential information while performing an operation.</p></dd><dt><a id="svn.ref.svnrdump.sw.revision"></a><span class="term"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Specifies a particular revision or revision range on which to operate.</p></dd><dt><a id="svn.ref.svnrdump.sw.trust_server_cert"></a><span class="term"><code class="option">--trust-server-cert</code></span></dt><dd><p>Used with <code class="option">--non-interactive</code> to accept any unknown SSL server certificates without prompting.</p></dd><dt><a id="svn.ref.svnrdump.sw.username"></a><span class="term"><code class="option">--username</code> <em class="replaceable"><code>NAME</code></em></span></dt><dd><p>Specifies the username to use when authenticating against a Subversion server. If not provided, or if incorrect, Subversion will prompt you for this information as needed.</p></dd></dl></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svnrdump.c"></a>svnrdump Subcommands</h3></div></div></div><p>Here are the various subcommands for the <span class="command"><strong>svnrdump</strong></span> program.</p><div class="refentry"><a id="svn.ref.svnrdump.c.dump"></a><div class="titlepage"></div><a id="idm13508" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnrdump dump</p></div><div class="refsect1"><a id="idm13515"></a><h2>Synopsis</h2><p><code class="literal">svnrdump dump SOURCE_URL</code></p></div><div class="refsect1"><a id="idm13519"></a><h2>Description</h2><p>Dump—that is, generate a repository dump stream of—revisions of the repository item located at <em class="replaceable"><code>SOURCE_URL</code></em>, printing the information to standard output. By default, the entire history will be included in the dump stream, but the scope of the operation can be limited via the use of the <code class="option">--revision</code> (<code class="option">-r</code>) option.</p></div><div class="refsect1"><a id="idm13525"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnrdump.sw.config_dir"><code class="option">--config-dir</code> <em class="replaceable"><code>DIR</code></em></a> <a class="xref" href="#svn.ref.svnrdump.sw.config_option"><code class="option">--config-option</code> <em class="replaceable"><code>FILE</code></em>:<em class="replaceable"><code>SECTION</code></em>:<em class="replaceable"><code>OPTION</code></em>=[<em class="replaceable"><code>VALUE</code></em>]</a> <a class="xref" href="#svn.ref.svnrdump.sw.incremental"><code class="option">--incremental</code></a> <a class="xref" href="#svn.ref.svnrdump.sw.no_auth_cache"><code class="option">--no-auth-cache</code></a> <a class="xref" href="#svn.ref.svnrdump.sw.non_interactive"><code class="option">--non-interactive</code></a> <a class="xref" href="#svn.ref.svnrdump.sw.password"><code class="option">--password</code> <em class="replaceable"><code>PASSWD</code></em></a> <a class="xref" href="#svn.ref.svnrdump.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svnrdump.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="#svn.ref.svnrdump.sw.trust_server_cert"><code class="option">--trust-server-cert</code></a> <a class="xref" href="#svn.ref.svnrdump.sw.username"><code class="option">--username</code> <em class="replaceable"><code>NAME</code></em></a> </pre></div></div><div class="refsect1"><a id="idm13539"></a><h2>Examples</h2><p>Generate a dump stream of the full history of a remote repository (assuming that the user as who this runs has authorization to read all paths in the repository).</p><div class="informalexample"><pre class="screen"> $ svnrdump dump http://svn.example.com/repos/calc &gt; full.dump * Dumped revision 0. * Dumped revision 1. * Dumped revision 2. … </pre></div><p>Incrementally dump a single revision from that same repository:</p><div class="informalexample"><pre class="screen"> $ svnrdump dump http://svn.example.com/repos/calc \ -r 21 --incremental &gt; inc.dump * Dumped revision 21. $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnrdump.c.help"></a><div class="titlepage"></div><a id="idm13548" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnrdump help — Help!</p></div><div class="refsect1"><a id="idm13555"></a><h2>Synopsis</h2><p><code class="literal">svnrdump help</code></p></div><div class="refsect1"><a id="idm13559"></a><h2>Description</h2><p>Use this to get help. Well, certain kinds of help. Need white lab coat and straightjackets kind of help? There's a whole different protocol for that sort of thing.</p></div><div class="refsect1"><a id="idm13562"></a><h2>Options</h2><p>None</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svnrdump.c.load"></a><div class="titlepage"></div><a id="idm13566" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnrdump load</p></div><div class="refsect1"><a id="idm13573"></a><h2>Synopsis</h2><p><code class="literal">svnrdump load DEST_URL</code></p></div><div class="refsect1"><a id="idm13577"></a><h2>Description</h2><p>Read from standard input revision information described in a Subversion repository dump stream, and load that information into the repository located at <em class="replaceable"><code>DEST_URL</code></em>.</p></div><div class="refsect1"><a id="idm13581"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svnrdump.sw.config_dir"><code class="option">--config-dir</code> <em class="replaceable"><code>DIR</code></em></a> <a class="xref" href="#svn.ref.svnrdump.sw.config_option"><code class="option">--config-option</code> <em class="replaceable"><code>FILE</code></em>:<em class="replaceable"><code>SECTION</code></em>:<em class="replaceable"><code>OPTION</code></em>=[<em class="replaceable"><code>VALUE</code></em>]</a> <a class="xref" href="#svn.ref.svnrdump.sw.no_auth_cache"><code class="option">--no-auth-cache</code></a> <a class="xref" href="#svn.ref.svnrdump.sw.non_interactive"><code class="option">--non-interactive</code></a> <a class="xref" href="#svn.ref.svnrdump.sw.password"><code class="option">--password</code> <em class="replaceable"><code>PASSWD</code></em></a> <a class="xref" href="#svn.ref.svnrdump.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="#svn.ref.svnrdump.sw.trust_server_cert"><code class="option">--trust-server-cert</code></a> <a class="xref" href="#svn.ref.svnrdump.sw.username"><code class="option">--username</code> <em class="replaceable"><code>NAME</code></em></a> </pre></div></div><div class="refsect1"><a id="idm13593"></a><h2>Examples</h2><p>Dump the contents of a local repository, and use <span class="command"><strong>svnrdump load</strong></span> to transfer that revision information into an existing remote repository:</p><div class="informalexample"><pre class="screen"> $ svnadmin dump -q /var/svn/repos/new-project | \ svnrdump load http://svn.example.com/repos/new-project * Loaded revision 0 * Loaded revision 1. * Loaded revision 2. … </pre></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>To operate properly <span class="command"><strong>svnrdump load</strong></span> requires that the target repository have revision property modification enabled via the pre-revprop-change hook. For details about that hook, see <a class="xref" href="#svn.ref.reposhooks.pre-revprop-change" title="pre-revprop-change">pre-revprop-change</a>.</p></td></tr></table></div></div></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.ref.svnserve"></a>svnserve—Custom Subversion Server</h2></div></div></div><p><span class="command"><strong>svnserve</strong></span> allows access to Subversion repositories using Subversion's custom network protocol.</p><p>You can run <span class="command"><strong>svnserve</strong></span> as a standalone server process (for clients that are using the <code class="literal">svn://</code> access method); you can have a daemon such as <span class="command"><strong>inetd</strong></span> or <span class="command"><strong>xinetd</strong></span> launch it for you on demand (also for <code class="literal">svn://</code>), or you can have <span class="command"><strong>sshd</strong></span> launch it on demand for the <code class="literal">svn+ssh://</code> access method.</p><p>Regardless of the access method, once the client has selected a repository by transmitting its URL, <span class="command"><strong>svnserve</strong></span> reads a file named <code class="filename">conf/svnserve.conf</code> in the repository directory to determine repository-specific settings such as what authentication database to use and what authorization policies to apply. See <a class="xref" href="#svn.serverconfig.svnserve" title="svnserve, a Custom Server">the section called “svnserve, a Custom Server”</a> for details of the <code class="filename">svnserve.conf</code> file.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svnserve.sw"></a>svnserve Options</h3></div></div></div><p>Unlike the previous commands we've described, <span class="command"><strong>svnserve</strong></span> has no subcommands—it is controlled exclusively by options.</p><div class="variablelist"><dl class="variablelist"><dt><a id="svn.ref.svnserve.sw.cache_fulltexts"></a><span class="term"><code class="option">--cache-fulltexts</code> <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Toggles support for fulltext file content caching (in FSFS repositories only).</p></dd><dt><a id="svn.ref.svnserve.sw.cache_txdeltas"></a><span class="term"><code class="option">--cache-txdeltas</code> <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Toggles support for file content delta caching (in FSFS repositories only).</p></dd><dt><a id="svn.ref.svnserve.sw.compression"></a><span class="term"><code class="option">--compression</code> <em class="replaceable"><code>LEVEL</code></em></span></dt><dd><p>Specifies the level of compression used for wire transmissions as an integer beween 0 and 9, inclusive. A value of <code class="literal">9</code> offers the best compression, <code class="literal">5</code> is the default value, and <code class="literal">0</code> disables compression altogether.</p></dd><dt><a id="svn.ref.svnserve.sw.daemon"></a><span class="term"><code class="option">--daemon</code> (<code class="option">-d</code>)</span></dt><dd><p>Causes <span class="command"><strong>svnserve</strong></span> to run in daemon mode. <span class="command"><strong>svnserve</strong></span> backgrounds itself and accepts and serves TCP/IP connections on the <code class="literal">svn</code> port (3690, by default).</p></dd><dt><a id="svn.ref.svnserve.sw.foreground"></a><span class="term"><code class="option">--foreground</code></span></dt><dd><p>When used together with <code class="option">-d</code>, causes <span class="command"><strong>svnserve</strong></span> to stay in the foreground. This is mainly useful for debugging.</p></dd><dt><a id="svn.ref.svnserve.sw.inetd"></a><span class="term"><code class="option">--inetd</code> (<code class="option">-i</code>)</span></dt><dd><p>Causes <span class="command"><strong>svnserve</strong></span> to use the <code class="filename">stdin</code> and <code class="filename">stdout</code> file descriptors, as is appropriate for a daemon running out of <span class="command"><strong>inetd</strong></span>.</p></dd><dt><a id="svn.ref.svnserve.sw.help"></a><span class="term"><code class="option">--help</code> (<code class="option">-h</code>)</span></dt><dd><p>Displays a usage summary and exits.</p></dd><dt><a id="svn.ref.svnserve.sw.listen_host"></a><span class="term"><code class="option">--listen-host</code> <em class="replaceable"><code>HOST</code></em></span></dt><dd><p>Causes <span class="command"><strong>svnserve</strong></span> to listen on the interface specified by <em class="replaceable"><code>HOST</code></em>, which may be either a hostname or an IP address.</p></dd><dt><a id="svn.ref.svnserve.sw.listen_once"></a><span class="term"><code class="option">--listen-once</code> (<code class="option">-X</code>)</span></dt><dd><p>Causes <span class="command"><strong>svnserve</strong></span> to accept one connection on the <code class="literal">svn</code> port, serve it, and exit. This option is mainly useful for debugging.</p></dd><dt><a id="svn.ref.svnserve.sw.listen_port"></a><span class="term"><code class="option">--listen-port</code> <em class="replaceable"><code>PORT</code></em></span></dt><dd><p>Causes <span class="command"><strong>svnserve</strong></span> to listen on <em class="replaceable"><code>PORT</code></em> when run in daemon mode. (FreeBSD daemons listen only on tcp6 by default—this option tells them to also listen on tcp4.)</p></dd><dt><a id="svn.ref.svnserve.sw.log_file"></a><span class="term"><code class="option">--log-file</code> <em class="replaceable"><code>FILENAME</code></em></span></dt><dd><p>Instructs <span class="command"><strong>svnserve</strong></span> to create (if necessary) and use the file located at <em class="replaceable"><code>FILENAME</code></em> for Subversion operational log output of the same sort that <span class="command"><strong>mod_dav_svn</strong></span> generates. See <a class="xref" href="#svn.serverconfig.operational-logging" title="High-level Logging">the section called “High-level Logging”</a> for details.</p></dd><dt><a id="svn.ref.svnserve.sw.memory_cache_size"></a><span class="term"><code class="option">--memory-cache-size</code> (<code class="option">-M</code>) <em class="replaceable"><code>ARG</code></em></span></dt><dd><p>Configures the size (in Megabytes) of the extra in-memory cache used to minimize redundant operations. The default value is <code class="literal">16</code>. (This cache is used for FSFS-backed repositories only.)</p></dd><dt><a id="svn.ref.svnserve.sw.pid_file"></a><span class="term"><code class="option">--pid-file</code> <em class="replaceable"><code>FILENAME</code></em></span></dt><dd><p>Causes <span class="command"><strong>svnserve</strong></span> to write its process ID to <em class="replaceable"><code>FILENAME</code></em>, which must be writable by the user under which <span class="command"><strong>svnserve</strong></span> is running.</p></dd><dt><a id="svn.ref.svnserve.sw.prefer_ipv6"></a><span class="term"><code class="option">--prefer-ipv6</code> (<code class="option">-6</code>)</span></dt><dd><p>When resolving the listen hostname, prever an IPv6 answer over an IPv4 one. IPv4 is preferred by default.</p></dd><dt><a id="svn.ref.svnserve.sw.quiet"></a><span class="term"><code class="option">--quiet</code></span></dt><dd><p>Disables progress notifications. Error output will still be printed.</p></dd><dt><a id="svn.ref.svnserve.sw.root"></a><span class="term"><code class="option">--root</code> (<code class="option">-r</code>) <em class="replaceable"><code>ROOT</code></em></span></dt><dd><p>Sets the virtual root for repositories served by <span class="command"><strong>svnserve</strong></span>. The pathname in URLs provided by the client will be interpreted relative to this root and will not be allowed to escape this root.</p></dd><dt><a id="svn.ref.svnserve.sw.threads"></a><span class="term"><code class="option">--threads</code> (<code class="option">-T</code>)</span></dt><dd><p>When running in daemon mode, causes <span class="command"><strong>svnserve</strong></span> to spawn a thread instead of a process for each connection (e.g., for when running on Windows). The <span class="command"><strong>svnserve</strong></span> process still backgrounds itself at startup time.</p></dd><dt><a id="svn.ref.svnserve.sw.tunnel"></a><span class="term"><code class="option">--tunnel</code> (<code class="option">-t</code>)</span></dt><dd><p>Causes <span class="command"><strong>svnserve</strong></span> to run in tunnel mode, which is just like the <span class="command"><strong>inetd</strong></span> mode of operation (both modes serve one connection over <code class="filename">stdin</code>/<code class="filename">stdout</code>, and then exit), except that the connection is considered to be preauthenticated with the username of the current UID. This flag is automatically passed for you by the client when running over a tunnel agent such as <span class="command"><strong>ssh</strong></span>. That means there's rarely any need for <span class="emphasis"><em>you</em></span> to pass this option to <span class="command"><strong>svnserve</strong></span>. So, if you find yourself typing <code class="literal">svnserve --tunnel</code> on the command line and wondering what to do next, see <a class="xref" href="#svn.serverconfig.svnserve.sshauth" title="Tunneling over SSH">the section called “Tunneling over SSH”</a>.</p></dd><dt><a id="svn.ref.svnserve.sw.tunnel_user"></a><span class="term"><code class="option">--tunnel-user</code> <em class="replaceable"><code>NAME</code></em></span></dt><dd><p>Used in conjunction with the <code class="option">--tunnel</code> option, tells <span class="command"><strong>svnserve</strong></span> to assume that <em class="replaceable"><code>NAME</code></em> is the authenticated user, rather than the UID of the <span class="command"><strong>svnserve</strong></span> process. This is useful for users wishing to share a single system account over SSH, but to maintain separate commit identities.</p></dd><dt><a id="svn.ref.svnserve.sw.version"></a><span class="term"><code class="option">--version</code></span></dt><dd><p>Displays version information and a list of repository backend modules available, and then exits.</p></dd></dl></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.ref.svndumpfilter"></a>svndumpfilter—Subversion History Filtering</h2></div></div></div><p><span class="command"><strong>svndumpfilter</strong></span> is a command-line utility for removing history from a Subversion dump file by either excluding or including paths beginning with one or more named prefixes. For details, see <a class="xref" href="#svn.reposadmin.maint.tk.svndumpfilter" title="svndumpfilter">the section called “svndumpfilter”</a>.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svndumpfilter.options"></a>svndumpfilter Options</h3></div></div></div><p>Options in <span class="command"><strong>svndumpfilter</strong></span> are global, just as they are in <span class="command"><strong>svn</strong></span> and <span class="command"><strong>svnadmin</strong></span>:</p><div class="variablelist"><dl class="variablelist"><dt><a id="svn.ref.svndumpfilter.sw.drop_empty_revs"></a><span class="term"><code class="option">--drop-empty-revs</code></span></dt><dd><p>If filtering causes any revision to be empty (i.e., causes no change to the repository), removes these revisions from the final dump file.</p></dd><dt><a id="svn.ref.svndumpfilter.sw.pattern"></a><span class="term"><code class="option">--pattern</code></span></dt><dd><p>Treat the path prefixes provided to the filtering commands as file glob patterns rather than explicit path substrings.</p></dd><dt><a id="svn.ref.svndumpfilter.sw.renumber_revs"></a><span class="term"><code class="option">--renumber-revs</code></span></dt><dd><p>Renumbers revisions that remain after filtering.</p></dd><dt><a id="svn.ref.svndumpfilter.sw.skip_missing_merge_sources"></a><span class="term"><code class="option">--skip-missing-merge-sources</code></span></dt><dd><p>Skips merge sources that have been removed as part of the filtering. Without this option, <span class="command"><strong>svndumpfilter</strong></span> will exit with an error if the merge source for a retained path is removed by filtering.</p></dd><dt><a id="svn.ref.svndumpfilter.sw.preserve_revprops"></a><span class="term"><code class="option">--preserve-revprops</code></span></dt><dd><p>If all nodes in a revision are removed by filtering and <code class="option">--drop-empty-revs</code> is not passed, the default behavior of <span class="command"><strong>svndumpfilter</strong></span> is to remove all revision properties except for the date and the log message (which will merely indicate that the revision is empty). Passing this option will preserve existing revision properties (which may or may not make sense since the related content is no longer present in the dump file).</p></dd><dt><a id="svn.ref.svndumpfilter.sw.targets"></a><span class="term"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></span></dt><dd><p>Instructs <span class="command"><strong>svndumpfilter</strong></span> to read additional path prefixes—one per line—from the file located at <em class="replaceable"><code>FILENAME</code></em>. This is especially useful for complex filtering operations which require more prefixes than the operating system allows to be specified on a single command line.</p></dd><dt><a id="svn.ref.svndumpfilter.sw.quiet"></a><span class="term"><code class="option">--quiet</code></span></dt><dd><p>Does not display filtering statistics.</p></dd></dl></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.svndumpfilter.c"></a>svndumpfilter Subcommands</h3></div></div></div><p>Here are the various subcommands for the <span class="command"><strong>svndumpfilter</strong></span> program.</p><div class="refentry"><a id="svn.ref.svndumpfilter.commands.c.exclude"></a><div class="titlepage"></div><a id="idm13844" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svndumpfilter exclude — Filter out nodes with given prefixes from the dump stream.</p></div><div class="refsect1"><a id="idm13851"></a><h2>Synopsis</h2><p><code class="literal">svndumpfilter exclude PATH_PREFIX...</code></p></div><div class="refsect1"><a id="idm13855"></a><h2>Description</h2><p>This can be used to exclude nodes that begin with one or more <em class="replaceable"><code>PATH_PREFIX</code></em>es from a filtered dump file.</p></div><div class="refsect1"><a id="idm13859"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svndumpfilter.sw.drop_empty_revs"><code class="option">--drop-empty-revs</code></a> <a class="xref" href="#svn.ref.svndumpfilter.sw.pattern"><code class="option">--pattern</code></a> <a class="xref" href="#svn.ref.svndumpfilter.sw.preserve_revprops"><code class="option">--preserve-revprops</code></a> <a class="xref" href="#svn.ref.svndumpfilter.sw.quiet"><code class="option">--quiet</code></a> <a class="xref" href="#svn.ref.svndumpfilter.sw.renumber_revs"><code class="option">--renumber-revs</code></a> <a class="xref" href="#svn.ref.svndumpfilter.sw.skip_missing_merge_sources"><code class="option">--skip-missing-merge-sources</code></a> <a class="xref" href="#svn.ref.svndumpfilter.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> </pre></div></div><div class="refsect1"><a id="idm13870"></a><h2>Examples</h2><p>If we have a dump file from a repository with a number of different picnic-related directories in it, but we want to keep everything <span class="emphasis"><em>except</em></span> the <code class="filename">sandwiches</code> part of the repository, we'll exclude only that path:</p><div class="informalexample"><pre class="screen"> $ svndumpfilter exclude sandwiches &lt; dumpfile &gt; filtered-dumpfile Excluding prefixes: '/sandwiches' Revision 0 committed as 0. Revision 1 committed as 1. Revision 2 committed as 2. Revision 3 committed as 3. Revision 4 committed as 4. Dropped 1 node(s): '/sandwiches' $ </pre></div><p>Beginning in Subversion 1.7, <span class="command"><strong>svndumpfilter</strong></span> can optionally treat the <em class="replaceable"><code>PATH_PREFIX</code></em>s not merely as explicit substrings, but as file patterns instead. So, for example, if you wished to filter out paths which ended with <code class="filename">.OLD</code>, you would do the following:</p><div class="informalexample"><pre class="screen"> $ svndumpfilter exclude --pattern "*.OLD" &lt; dumpfile &gt; filtered-dumpfile Excluding prefix patterns: '/*.OLD' Revision 0 committed as 0. Revision 1 committed as 1. Revision 2 committed as 2. Revision 3 committed as 3. Revision 4 committed as 4. Dropped 3 node(s): '/condiments/salt.OLD' '/condiments/pepper.OLD' '/toppings/cheese.OLD' $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svndumpfilter.commands.c.include"></a><div class="titlepage"></div><a id="idm13884" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svndumpfilter include — Filter out nodes without given prefixes from dump stream.</p></div><div class="refsect1"><a id="idm13891"></a><h2>Synopsis</h2><p><code class="literal">svndumpfilter include PATH_PREFIX...</code></p></div><div class="refsect1"><a id="idm13895"></a><h2>Description</h2><p>Can be used to include nodes that begin with one or more <em class="replaceable"><code>PATH_PREFIX</code></em>es in a filtered dump file (thus excluding all other paths).</p></div><div class="refsect1"><a id="idm13899"></a><h2>Options</h2><div class="informalexample"><pre class="screen"> <a class="xref" href="#svn.ref.svndumpfilter.sw.drop_empty_revs"><code class="option">--drop-empty-revs</code></a> <a class="xref" href="#svn.ref.svndumpfilter.sw.pattern"><code class="option">--pattern</code></a> <a class="xref" href="#svn.ref.svndumpfilter.sw.preserve_revprops"><code class="option">--preserve-revprops</code></a> <a class="xref" href="#svn.ref.svndumpfilter.sw.quiet"><code class="option">--quiet</code></a> <a class="xref" href="#svn.ref.svndumpfilter.sw.renumber_revs"><code class="option">--renumber-revs</code></a> <a class="xref" href="#svn.ref.svndumpfilter.sw.skip_missing_merge_sources"><code class="option">--skip-missing-merge-sources</code></a> <a class="xref" href="#svn.ref.svndumpfilter.sw.targets"><code class="option">--targets</code> <em class="replaceable"><code>FILENAME</code></em></a> </pre></div></div><div class="refsect1"><a id="idm13910"></a><h2>Example</h2><p>If we have a dump file from a repository with a number of different picnic-related directories in it, but want to keep only the <code class="filename">sandwiches</code> part of the repository, we'll include only that path:</p><div class="informalexample"><pre class="screen"> $ svndumpfilter include sandwiches &lt; dumpfile &gt; filtered-dumpfile Including prefixes: '/sandwiches' Revision 0 committed as 0. Revision 1 committed as 1. Revision 2 committed as 2. Revision 3 committed as 3. Revision 4 committed as 4. Dropped 12 node(s): '/condiments' '/condiments/pepper' '/condiments/pepper.OLD' '/condiments/salt' '/condiments/salt.OLD' '/drinks' '/snacks' '/supplies' '/toppings' '/toppings/cheese' '/toppings/cheese.OLD' '/toppings/lettuce' $ </pre></div><p>Beginning in Subversion 1.7, <span class="command"><strong>svndumpfilter</strong></span> can optionally treat the <em class="replaceable"><code>PATH_PREFIX</code></em>s not merely as explicit substrings, but as file patterns instead. So, for example, if you wished to include only paths which ended with <code class="filename">ks</code>, you would do the following:</p><div class="informalexample"><pre class="screen"> $ svndumpfilter include --pattern "*ks" &lt; dumpfile &gt; filtered-dumpfile Including prefix patterns: '/*ks' Revision 0 committed as 0. Revision 1 committed as 1. Revision 2 committed as 2. Revision 3 committed as 3. Revision 4 committed as 4. Dropped 11 node(s): '/condiments' '/condiments/pepper' '/condiments/pepper.OLD' '/condiments/salt' '/condiments/salt.OLD' '/sandwiches' '/supplies' '/toppings' '/toppings/cheese' '/toppings/cheese.OLD' '/toppings/lettuce' $ </pre></div></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.svndumpfilter.commands.c.help"></a><div class="titlepage"></div><a id="idm13923" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svndumpfilter help — Help!</p></div><div class="refsect1"><a id="idm13930"></a><h2>Synopsis</h2><p><code class="literal">svndumpfilter help [SUBCOMMAND...]</code></p></div><div class="refsect1"><a id="idm13934"></a><h2>Description</h2><p>Displays the help message for <span class="command"><strong>svndumpfilter</strong></span>. Unlike other help commands documented in this chapter, there is no witty commentary for this help command. The authors of this book deeply regret the omission.</p></div><div class="refsect1"><a id="idm13938"></a><h2>Options</h2><p>None</p></div></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.ref.svnversion"></a>svnversion—Subversion Working Copy Version Info</h2></div></div></div><div class="refentry"><a id="svn.ref.svnversion.re"></a><div class="titlepage"></div><a id="idm13944" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>svnversion — Summarize the local revision(s) of a working copy.</p></div><div class="refsect1"><a id="svn.ref.svnversion.re.syn"></a><h2>Synopsis</h2><p><code class="literal">svnversion [OPTIONS] [WC_PATH [TRAIL_URL]]</code></p></div><div class="refsect1"><a id="svn.ref.svnversion.re.desc"></a><h2>Description</h2><p><span class="command"><strong>svnversion</strong></span> is a program for summarizing the revision mixture of a working copy. The resultant revision number, or revision range, is written to standard output.</p><p>It's common to use this output in your build process when defining the version number of your program.</p><p><em class="replaceable"><code>TRAIL_URL</code></em>, if present, is the trailing portion of the URL used to determine whether <em class="replaceable"><code>WC_PATH</code></em> itself is switched (detection of switches within <em class="replaceable"><code>WC_PATH</code></em> does not rely on <em class="replaceable"><code>TRAIL_URL</code></em>).</p><p>When <em class="replaceable"><code>WC_PATH</code></em> is not defined, the current directory will be used as the working copy path. <em class="replaceable"><code>TRAIL_URL</code></em> cannot be defined if <em class="replaceable"><code>WC_PATH</code></em> is not explicitly given.</p></div><div class="refsect1"><a id="svn.ref.svnversion.re.sw"></a><h2>Options</h2><p>Like <span class="command"><strong>svnserve</strong></span>, <span class="command"><strong>svnversion</strong></span> has no subcommands—only options:</p><div class="variablelist"><dl class="variablelist"><dt><a id="svn.ref.svnversion.sw.no_newline"></a><span class="term"><code class="option">--no-newline</code> (<code class="option">-n</code>)</span></dt><dd><p>Omits the usual trailing newline from the output.</p></dd><dt><a id="svn.ref.svnversion.sw.committed"></a><span class="term"><code class="option">--committed</code> (<code class="option">-c</code>)</span></dt><dd><p>Uses the last-changed revisions rather than the current (i.e., highest locally available) revisions.</p></dd><dt><a id="svn.ref.svnversion.sw.help"></a><span class="term"><code class="option">--help</code> (<code class="option">-h</code>)</span></dt><dd><p>Prints a help summary.</p></dd><dt><a id="svn.ref.svnversion.sw.quiet"></a><span class="term"><code class="option">--quiet</code> (<code class="option">-q</code>)</span></dt><dd><p>Requests that the program print only essential information while performing an operation.</p></dd><dt><a id="svn.ref.svnversion.sw.version"></a><span class="term"><code class="option">--version</code></span></dt><dd><p>Prints the version of <span class="command"><strong>svnversion</strong></span> and exit with no error.</p></dd></dl></div></div><div class="refsect1"><a id="svn.ref.svnversion.re.examples"></a><h2>Examples</h2><p>If the working copy is all at the same revision (e.g., immediately after an update), then that revision is printed out:</p><div class="informalexample"><pre class="screen"> $ svnversion 4168 </pre></div><p>You can add <em class="replaceable"><code>TRAIL_URL</code></em> to make sure the working copy is not switched from what you expect. Note that the <em class="replaceable"><code>WC_PATH</code></em> is required in this command:</p><div class="informalexample"><pre class="screen"> $ svnversion . /var/svn/trunk 4168 </pre></div><p>For a mixed-revision working copy, the range of revisions present is printed:</p><div class="informalexample"><pre class="screen"> $ svnversion 4123:4168 </pre></div><p>If the working copy contains modifications, a trailing '<code class="literal">M</code>' is added:</p><div class="informalexample"><pre class="screen"> $ svnversion 4168M </pre></div><p>If the working copy is switched, a trailing '<code class="literal">S</code>' is added:</p><div class="informalexample"><pre class="screen"> $ svnversion 4168S </pre></div><p><span class="command"><strong>svnversion</strong></span> will also inform you if the target working copy is sparsely populated (see <a class="xref" href="#svn.advanced.sparsedirs" title="Sparse Directories">the section called “Sparse Directories”</a>) by attaching the '<code class="literal">P</code>' code to its output:</p><div class="informalexample"><pre class="screen"> $ svnversion 4168P </pre></div><p>Thus, here is a mixed-revision, sparsely populated and switched working copy containing some local modifications:</p><div class="informalexample"><pre class="screen"> $ svnversion 4123:4168MSP </pre></div></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.ref.mod_dav_svn"></a>mod_dav_svn—Subversion Apache HTTP Server Module</h2></div></div></div><div class="refentry"><a id="svn.ref.mod_dav_svn.conf"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>mod_dav_svn Configuration Directives — Apache configuration directives for serving Subversion repositories through the Apache HTTP Server.</p></div><div class="refsect1"><a id="svn.ref.mod_dav_svn.conf.desc"></a><h2>Description</h2><p>This section briefly describes each Subversion Apache configuration directive. For an in-depth description of configuring Apache with Subversion, see <a class="xref" href="#svn.serverconfig.httpd" title="httpd, the Apache HTTP Server">the section called “httpd, the Apache HTTP Server”</a>.</p></div><div class="refsect1"><a id="svn.ref.mod_dav_svn.conf.directives"></a><h2>Directives</h2><p>These are the <code class="filename">httpd.conf</code> directives that apply to <span class="command"><strong>mod_dav_svn</strong></span>:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">DAV svn</code></span></dt><dd><p>Must be included in any <code class="literal">Directory</code> or <code class="literal">Location</code> block for a Subversion repository. It tells <span class="command"><strong>httpd</strong></span> to use the Subversion backend for <code class="literal">mod_dav</code> to handle all requests.</p></dd><dt><span class="term"><code class="literal">SVNActivitiesDB <em class="replaceable"><code>directory-path</code></em></code></span></dt><dd><p>Specifies the location in the filesystem where the activities database should be stored. By default, <span class="command"><strong>mod_dav_svn</strong></span> creates and uses a directory in the repository called <code class="filename">dav/activities.d</code>. The path specified with this option must be an absolute path.</p><p>If specified for an <code class="literal">SVNParentPath</code> area, <span class="command"><strong>mod_dav_svn</strong></span> appends the basename of the repository to the path specified here. For example:</p><div class="informalexample"><pre class="screen"> &lt;Location /svn&gt; DAV svn # any "/svn/foo" URL will map to a repository in # /net/svn.nfs/repositories/foo SVNParentPath "/net/svn.nfs/repositories" # any "/svn/foo" URL will map to an activities db in # /var/db/svn/activities/foo SVNActivitiesDB "/var/db/svn/activities" &lt;/Location&gt; </pre></div></dd><dt><span class="term"><code class="literal">SVNAdvertiseV2Protocol On|Off</code></span></dt><dd><p>New to Subversion 1.7, this toggles whether <span class="command"><strong>mod_dav_svn</strong></span> advertises its support for the new version of its HTTP protocol also introduced in that version. Most admins will not wish to use this directive (which is <code class="literal">On</code> by default), choosing instead to enjoy the performance benefits that the new protocol offers. However, whena configuring a server as a write-through proxy to another server which does not support the new protocol, set this directive's value to <code class="literal">Off</code>.</p></dd><dt><span class="term"><code class="literal">SVNAllowBulkUpdates On|Off</code></span></dt><dd><p>Toggles support for all-inclusive responses to update-style <code class="literal">REPORT</code> requests. Subversion clients use <code class="literal">REPORT</code> requests to get information about directory tree checkouts and updates from <span class="command"><strong>mod_dav_svn</strong></span>. They can ask the server to send that information in one of two ways: with the entirety of the tree's information in one massive response, or with a <em class="firstterm">skelta</em> (a skeletal representation of a tree delta) which contains just enough information for the client to know what <span class="emphasis"><em>additional</em></span> data to request from the server. When this directive is included with a value of <code class="literal">Off</code>, <span class="command"><strong>mod_dav_svn</strong></span> will only ever respond to these <code class="literal">REPORT</code> requests with skelta responses, regardless of the type of responses requested by the client.</p><p>Most folks won't need to use this directive at all. It primarily exists for administrators who wish—for security or auditing reasons—to force Subversion clients to fetch individually all the files and directories needed for updates and checkouts, thus leaving an audit trail of <code class="literal">GET</code> and <code class="literal">PROPFIND</code> requests in Apache's logs. The default value of this directive is <code class="literal">On</code>.</p></dd><dt><span class="term"><code class="literal">SVNAutoversioning On|Off</code></span></dt><dd><p>When its value is <code class="literal">On</code>, allows write requests from WebDAV clients to result in automatic commits. A generic log message is auto-generated and attached to each revision. If you enable autoversioning, you'll likely want to set <code class="literal">ModMimeUsePathInfo On</code> so that <code class="literal">mod_mime</code> can set <code class="literal">svn:mime-type</code> to the correct MIME type automatically (as best as <code class="literal">mod_mime</code> is able to, of course). For more information, see <a class="xref" href="#svn.webdav" title="Appendix C. WebDAV and Autoversioning">Appendix C, <em>WebDAV and Autoversioning</em></a>. The default value of this directive is <code class="literal">Off</code>.</p></dd><dt><span class="term"><code class="literal">SVNCacheFullTexts On|Off</code></span></dt><dd><p>When set to <code class="literal">On</code>, this tells Subversion to cache content fulltexts if sufficient in-memory cache is available, which could offer a significant performance benefit to the server. (See also the <code class="literal">SVNInMemoryCacheSize</code> directive.) The default value of this directive is <code class="literal">Off</code>.</p></dd><dt><span class="term"><code class="literal">SVNCacheTextDeltas On|Off</code></span></dt><dd><p>When set to <code class="literal">On</code>, this tells Subversion to cache content deltas if sufficient in-memory cache is available, which could offer a significant performance benefit to the server. (See also the <code class="literal">SVNInMemoryCacheSize</code> directive.) The default value of this directive is <code class="literal">Off</code>.</p></dd><dt><span class="term"><code class="literal">SVNCompressionLevel <em class="replaceable"><code>level</code></em></code></span></dt><dd><p>Specifies the compression level used when sending file content over the network. A value of <code class="literal">0</code> disables compression altogether, and <code class="literal">9</code> is the maximum value. <code class="literal">5</code> is the default value.</p></dd><dt><span class="term"><code class="literal">SVNIndexXSLT <em class="replaceable"><code>directory-path</code></em></code></span></dt><dd><p>Specifies the URI of an XSL transformation for directory indexes. This directive is optional.</p></dd><dt><span class="term"><code class="literal">SVNInMemoryCacheSize <em class="replaceable"><code>size</code></em></code></span></dt><dd><p>Specifies the maximum size (in kbytes) per process of Subversion's in-memory object cache. The default value is <code class="literal">16384</code>; use a value of <code class="literal">0</code> to deactivate this cache altogether.</p></dd><dt><span class="term"><code class="literal">SVNListParentPath On|Off</code></span></dt><dd><p>When set to <code class="literal">On</code>, allows a <code class="literal">GET</code> of <code class="literal">SVNParentPath</code>, which results in a listing of all repositories under that path. The default setting is <code class="literal">Off</code>.</p></dd><dt><span class="term"><code class="literal">SVNMasterURI <em class="replaceable"><code>url</code></em></code></span></dt><dd><p>Specifies a URI to the master Subversion repository (used for a write-through proxy).</p></dd><dt><span class="term"><code class="literal">SVNParentPath <em class="replaceable"><code>directory-path</code></em></code></span></dt><dd><p>Specifies the location in the filesystem of a parent directory whose child directories are Subversion repositories. In a configuration block for a Subversion repository, either this directive or <code class="literal">SVNPath</code> must be present, but not both.</p></dd><dt><span class="term"><code class="literal">SVNPath <em class="replaceable"><code>directory-path</code></em></code></span></dt><dd><p>Specifies the location in the filesystem for a Subversion repository's files. In a configuration block for a Subversion repository, either this directive or <code class="literal">SVNParentPath</code> must be present, but not both.</p></dd><dt><span class="term"><code class="literal">SVNPathAuthz On|Off|short_circuit</code></span></dt><dd><p>Controls path-based authorization by enabling subrequests (<code class="literal">On</code>), disabling subrequests (<code class="literal">Off</code>; see <a class="xref" href="#svn.serverconfig.httpd.authz.pathauthzoff" title="Disabling path-based checks">the section called “Disabling path-based checks”</a>), or querying <span class="command"><strong>mod_authz_svn</strong></span> directly (<code class="literal">short_circuit</code>). The default value of this directive is <code class="literal">On</code>.</p></dd><dt><span class="term"><code class="literal">SVNReposName <em class="replaceable"><code>name</code></em></code></span></dt><dd><p>Specifies the name of a Subversion repository for use in <code class="literal">HTTP GET</code> responses. This value will be prepended to the title of all directory listings (which are served when you navigate to a Subversion repository with a web browser). This directive is optional.</p></dd><dt><span class="term"><code class="literal">SVNSpecialURI <em class="replaceable"><code>component</code></em></code></span></dt><dd><p>Specifies the URI component (namespace) for special Subversion resources. The default is <code class="literal">!svn</code>, and most administrators will never use this directive. Set this only if there is a pressing need to have a file named <code class="filename">!svn</code> in your repository. If you change this on a server already in use, it will break all of the outstanding working copies, and your users will hunt you down with pitchforks and flaming torches.</p></dd></dl></div></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.ref.mod_authz_svn"></a>mod_authz_svn—Subversion Apache HTTP Authorization Module</h2></div></div></div><div class="refentry"><a id="svn.ref.mod_authz_svn.conf"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>mod_authz_svn Configuration Directives — Apache configuration directives for configuring path-based authorization for Subversion repositories served through the Apache HTTP Server.</p></div><div class="refsect1"><a id="svn.ref.mod_authz_svn.conf.desc"></a><h2>Description</h2><p>This section briefly describes each Apache configuration directive offered by <span class="command"><strong>mod_authz_svn</strong></span>. For an in-depth description of using path-based authorization in Subversion, see <a class="xref" href="#svn.serverconfig.pathbasedauthz" title="Path-Based Authorization">the section called “Path-Based Authorization”</a>.</p></div><div class="refsect1"><a id="svn.ref.mod_authz_svn.conf.directives"></a><h2>Directives</h2><p>These are the <code class="filename">httpd.conf</code> directives that apply to <span class="command"><strong>mod_authz_svn</strong></span>:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">AuthzForceUsernameCase Upper|Lower</code></span></dt><dd><p>Set to <code class="literal">Upper</code> or <code class="literal">Lower</code> to perform case conversion of the specified sort on the authenticated username before checking it for authorization. While usernames are compared in a case-sensitive fashion against those referenced in the authorization rules file, this directive can at least normalize variably-cased usernames into something consistent.</p></dd><dt><span class="term"><code class="literal">AuthzSVNAccessFile <em class="replaceable"><code>file-path</code></em></code></span></dt><dd><p>Consult <em class="replaceable"><code>file-path</code></em> for access rules describing the permissions for paths in Subversion repository.</p></dd><dt><span class="term"><code class="literal">AuthzSVNAnonymous On|Off</code></span></dt><dd><p>Set to <code class="literal">Off</code> to disable two special-case behaviours of this module: interaction with the <code class="literal">Satisfy Any</code> directive and enforcement of the authorization policy even when no <code class="literal">Require</code> directives are present. The default value of this directive is <code class="literal">On</code>.</p></dd><dt><span class="term"><code class="literal">AuthzSVNAuthoritative On|Off</code></span></dt><dd><p>Set to <code class="literal">Off</code> to allow access control to be passed along to lower modules. The default value of this directive is <code class="literal">On</code>.</p></dd><dt><span class="term"><code class="literal">AuthzSVNNoAuthWhenAnonymousAllowed On|Off</code></span></dt><dd><p>Set to <code class="literal">On</code> to suppress authentication and authorization for requests which anonymous users are allowed to perform. The default value of this directive is <code class="literal">On</code>.</p></dd></dl></div></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.ref.properties"></a>Subversion Properties</h2></div></div></div><p>Subversion allows users to invent arbitrarily named versioned properties on files and directories, as well as unversioned properties on revisions. The only restriction is on properties whose names begin with <code class="literal">svn:</code> (those are reserved for Subversion's own use). While these properties may be set by users to control Subversion's behavior, users may not invent new <code class="literal">svn:</code> properties.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.properties.versioned-props"></a>Versioned Properties</h3></div></div></div><p>These are the versioned properties that Subversion reserves for its own use:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">svn:executable</code></span></dt><dd><p>If present on a file, the client will make the file executable in Unix-hosted working copies. See <a class="xref" href="#svn.advanced.props.special.executable" title="File Executability">the section called “File Executability”</a>.</p></dd><dt><span class="term"><code class="literal">svn:mime-type</code></span></dt><dd><p>If present on a file, the value indicates the file's MIME type. This allows the client to decide whether line-based contextual merging is safe to perform during updates, and can also affect how the file behaves when fetched via a web browser. See <a class="xref" href="#svn.advanced.props.special.mime-type" title="File Content Type">the section called “File Content Type”</a>.</p></dd><dt><span class="term"><code class="literal">svn:ignore</code></span></dt><dd><p>If present on a directory, the value is a list of <span class="emphasis"><em>unversioned</em></span> file patterns to be ignored by <span class="command"><strong>svn status</strong></span> and other subcommands. See <a class="xref" href="#svn.advanced.props.special.ignore" title="Ignoring Unversioned Items">the section called “Ignoring Unversioned Items”</a>.</p></dd><dt><span class="term"><code class="literal">svn:keywords</code></span></dt><dd><p>If present on a file, the value tells the client how to expand particular keywords within the file. See <a class="xref" href="#svn.advanced.props.special.keywords" title="Keyword Substitution">the section called “Keyword Substitution”</a>.</p></dd><dt><span class="term"><code class="literal">svn:eol-style</code></span></dt><dd><p>If present on a file, the value tells the client how to manipulate the file's line-endings in the working copy and in exported trees. See <a class="xref" href="#svn.advanced.props.special.eol-style" title="End-of-Line Character Sequences">the section called “End-of-Line Character Sequences”</a> and <a class="xref" href="#svn.ref.svn.c.export" title="svn export">svn export</a> earlier in this chapter.</p></dd><dt><span class="term"><code class="literal">svn:externals</code></span></dt><dd><p>If present on a directory, the value is a multiline list of other paths and URLs the client should check out. See <a class="xref" href="#svn.advanced.externals" title="Externals Definitions">the section called “Externals Definitions”</a>.</p></dd><dt><span class="term"><code class="literal">svn:special</code></span></dt><dd><p>If present on a file, indicates that the file is not an ordinary file, but a symbolic link or other special object.<a href="#ftn.idm14309" class="footnote" id="idm14309"><sup class="footnote">[73]</sup></a></p></dd><dt><span class="term"><code class="literal">svn:needs-lock</code></span></dt><dd><p>If present on a file, tells the client to make the file read-only in the working copy, as a reminder that the file should be locked before editing begins. See <a class="xref" href="#svn.advanced.locking.lock-communication" title="Lock Communication">the section called “Lock Communication”</a>.</p></dd><dt><span class="term"><code class="literal">svn:mergeinfo</code></span></dt><dd><p>Used by Subversion to track merge data. See <a class="xref" href="#svn.branchmerge.basicmerging.mergeinfo" title="Mergeinfo and Previews">the section called “Mergeinfo and Previews”</a> for details, but you should never edit this property unless you <span class="emphasis"><em>really</em></span> know what you're doing.</p></dd></dl></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.ref.properties.unversioned-props"></a>Unversioned Properties</h3></div></div></div><p>These are the unversioned properties that Subversion reserves for its own use:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">svn:author</code></span></dt><dd><p>If present, contains the authenticated username of the person who created the revision. (If not present, the revision was committed anonymously.)</p></dd><dt><span class="term"><code class="literal">svn:autoversioned</code></span></dt><dd><p>If present, the revision was created via the autoversioning feature. See <a class="xref" href="#svn.webdav.autoversioning" title="Autoversioning">the section called “Autoversioning”</a>.</p></dd><dt><span class="term"><code class="literal">svn:date</code></span></dt><dd><p>Contains the UTC time the revision was created, in ISO 8601 format. The value comes from the <span class="emphasis"><em>server</em></span> machine's clock, not the client's.</p></dd><dt><span class="term"><code class="literal">svn:log</code></span></dt><dd><p>Contains the log message describing the revision.</p></dd><dt><span class="term"><code class="literal">svn:rdump-lock</code></span></dt><dd><p>Used to temporarily enforce mutually exclusive access to the repository by <span class="command"><strong>svnrdump load</strong></span>. This property is generally only observed when such an operation is active—or when an <span class="command"><strong>svnrdump</strong></span> command failed to cleanly disconnect from the repository. (This property is only relevant when it appears on revision 0.)</p></dd><dt><span class="term"><code class="literal">svn:sync-currently-copying</code></span></dt><dd><p>Contains the revision number from the source repository which is currently being mirrored to this one by the <span class="command"><strong>svnsync</strong></span> tool. (This property is only relevant when it appears on revision 0.)</p></dd><dt><span class="term"><code class="literal">svn:sync-from-uuid</code></span></dt><dd><p>Contains the UUID of the repository of which this repository has been initialized as a mirror by the <span class="command"><strong>svnsync</strong></span> tool. (This property is only relevant when it appears on revision 0.)</p></dd><dt><span class="term"><code class="literal">svn:sync-from-url</code></span></dt><dd><p>Contains the URL of the repository directory of which this repository has been initialized as a mirror by the <span class="command"><strong>svnsync</strong></span> tool. (This property is only relevant when it appears on revision 0.)</p></dd><dt><span class="term"><code class="literal">svn:sync-last-merged-rev</code></span></dt><dd><p>Contains the revision of the source repository which was most recently and successfully mirrored to this one. (This property is only relevant when it appears on revision 0.)</p></dd><dt><span class="term"><code class="literal">svn:sync-lock</code></span></dt><dd><p>Used to temporarily enforce mutually exclusive access to the repository by <span class="command"><strong>svnsync</strong></span> mirroring operations. This property is generally only observed when such an operation is active—or when an <span class="command"><strong>svnsync</strong></span> command failed to cleanly disconnect from the repository. (This property is only relevant when it appears on revision 0.)</p></dd></dl></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.ref.reposhooks"></a>Repository Hooks</h2></div></div></div><p>These are the repository hooks that Subversion provides:</p><div class="refentry"><a id="svn.ref.reposhooks.start-commit"></a><div class="titlepage"></div><a id="idm14392" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>start-commit — Notification of the beginning of a commit.</p></div><div class="refsect1"><a id="idm14399"></a><h2>Description</h2><p>The start-commit hook is run before the commit transaction is even created. It is typically used to decide whether the user has commit privileges at all.</p><p>If the start-commit hook program returns a nonzero exit value, the commit is stopped before the commit transaction is even created, and anything printed to <code class="filename">stderr</code> is marshalled back to the client.</p></div><div class="refsect1"><a id="idm14404"></a><h2>Input Parameter(s)</h2><p>The command-line arguments passed to the hook program, in order, are:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Repository path</p></li><li class="listitem"><p>Authenticated username attempting the commit</p></li><li class="listitem"><p>Colon-separated list of capabilities that a client passes to the server, including <code class="literal">depth</code>, <code class="literal">mergeinfo</code>, and <code class="literal">log-revprops</code> (new in Subversion 1.5).</p></li></ol></div></div><div class="refsect1"><a id="idm14417"></a><h2>Common uses</h2><p>Access control (e.g., temporarily lock out commits for some reason).</p><p>A means to allow access only from clients that have certain capabilities.</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.reposhooks.pre-commit"></a><div class="titlepage"></div><a id="idm14422" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>pre-commit — Notification just prior to commit completion.</p></div><div class="refsect1"><a id="idm14429"></a><h2>Description</h2><p>The <code class="literal">pre-commit</code> hook is run just before a commit transaction is promoted to a new revision. Typically, this hook is used to protect against commits that are disallowed due to content or location (e.g., your site might require that all commits to a certain branch include a ticket number from the bug tracker, or that the incoming log message is nonempty).</p><p>If the <code class="literal">pre-commit</code> hook program returns a nonzero exit value, the commit is aborted, the commit transaction is removed, and anything printed to <code class="filename">stderr</code> is marshalled back to the client.</p></div><div class="refsect1"><a id="idm14436"></a><h2>Input parameter(s)</h2><p>The command-line arguments passed to the hook program, in order, are:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Repository path</p></li><li class="listitem"><p>Commit transaction name</p></li></ol></div><p>Additionally, Subversion passes any lock tokens provided by the committing client to the hook script via standard input. When present, these are formatted as a single line containing the string <code class="literal">LOCK-TOKENS:</code>, followed by additional lines—one per lock token—which contain the lock token information. Each lock token information line consists of the URI-escaped repository filesystem path associated with the lock, followed by the pipe (<code class="literal">|</code>) separator character, and finally the lock token string.</p></div><div class="refsect1"><a id="idm14447"></a><h2>Common uses</h2><p>Change validation and control</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.reposhooks.post-commit"></a><div class="titlepage"></div><a id="idm14451" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>post-commit — Notification of a successful commit.</p></div><div class="refsect1"><a id="idm14458"></a><h2>Description</h2><p>The <code class="literal">post-commit</code> hook is run after the transaction is committed and a new revision is created. Most people use this hook to send out descriptive emails about the commit or to notify some other tool (such as an issue tracker) that a commit has happened. Some configurations also use this hook to trigger backup processes.</p><p>If the <code class="literal">post-commit</code> hook returns a nonzero exit status, the commit <span class="emphasis"><em>will not</em></span> be aborted since it has already completed. However, anything that the hook printed to <code class="filename">stderr</code> will be marshalled back to the client, making it easier to diagnose hook failures.</p></div><div class="refsect1"><a id="idm14466"></a><h2>Input parameter(s)</h2><p>The command-line arguments passed to the hook program, in order, are:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Repository path</p></li><li class="listitem"><p>Revision number created by the commit</p></li></ol></div></div><div class="refsect1"><a id="idm14474"></a><h2>Common uses</h2><p>Commit notification; tool integration</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.reposhooks.pre-revprop-change"></a><div class="titlepage"></div><a id="idm14478" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>pre-revprop-change — Notification of a revision property change attempt.</p></div><div class="refsect1"><a id="idm14485"></a><h2>Description</h2><p>The <code class="literal">pre-revprop-change</code> hook is run immediately prior to the modification of a revision property when performed outside the scope of a normal commit. Unlike the other hooks, the default state of this one is to deny the proposed action. The hook must actually exist and return a zero exit value before a revision property modification can happen.</p><p>If the <code class="literal">pre-revprop-change</code> hook doesn't exist, isn't executable, or returns a nonzero exit value, no change to the property will be made, and anything printed to <code class="filename">stderr</code> is marshalled back to the client.</p></div><div class="refsect1"><a id="idm14492"></a><h2>Input parameter(s)</h2><p>The command-line arguments passed to the hook program, in order, are:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Repository path</p></li><li class="listitem"><p>Revision whose property is about to be modified</p></li><li class="listitem"><p>Authenticated username attempting the property change</p></li><li class="listitem"><p>Name of the property changed</p></li><li class="listitem"><p>Change description: <code class="literal">A</code> (added), <code class="literal">D</code> (deleted), or <code class="literal">M</code> (modified)</p></li></ol></div><p>Additionally, Subversion passes the intended new value of the property to the hook program via standard input.</p></div><div class="refsect1"><a id="idm14510"></a><h2>Common uses</h2><p>Access control; change validation and control</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.reposhooks.post-revprop-change"></a><div class="titlepage"></div><a id="idm14514" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>post-revprop-change — Notification of a successful revision property change.</p></div><div class="refsect1"><a id="idm14521"></a><h2>Description</h2><p>The <code class="literal">post-revprop-change</code> hook is run immediately after the modification of a revision property when performed outside the scope of a normal commit. As you can derive from the description of its counterpart, the <code class="literal">pre-revprop-change</code> hook, this hook will not run at all unless the <code class="literal">pre-revprop-change</code> hook is implemented. It is typically used to send email notification of the property change.</p><p>If the <code class="literal">post-revprop-change</code> hook returns a nonzero exit status, the change <span class="emphasis"><em>will not</em></span> be aborted since it has already completed. However, anything that the hook printed to <code class="filename">stderr</code> will be marshalled back to the client, making it easier to diagnose hook failures.</p></div><div class="refsect1"><a id="idm14531"></a><h2>Input parameter(s)</h2><p>The command-line arguments passed to the hook program, in order, are:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Repository path</p></li><li class="listitem"><p>Revision whose property was modified</p></li><li class="listitem"><p>Authenticated username of the person making the change</p></li><li class="listitem"><p>Name of the property changed</p></li><li class="listitem"><p>Change description: <code class="literal">A</code> (added), <code class="literal">D</code> (deleted), or <code class="literal">M</code> (modified)</p></li></ol></div><p>Additionally, Subversion passes to the hook program, via standard input, the previous value of the property.</p></div><div class="refsect1"><a id="idm14549"></a><h2>Common uses</h2><p>Property change notification</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.reposhooks.pre-lock"></a><div class="titlepage"></div><a id="idm14553" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>pre-lock — Notification of a path lock attempt.</p></div><div class="refsect1"><a id="idm14560"></a><h2>Description</h2><p>The <code class="literal">pre-lock</code> hook runs whenever someone attempts to lock a path. It can be used to prevent locks altogether or to create a more complex policy specifying exactly which users are allowed to lock particular paths. If the hook notices a preexisting lock, it can also decide whether a user is allowed to <span class="quote">“<span class="quote">steal</span>”</span> the existing lock.</p><p>If the <code class="literal">pre-lock</code> hook program returns a nonzero exit value, the lock action is aborted and anything printed to <code class="filename">stderr</code> is marshalled back to the client.</p><p>The hook program may optionally dictate the lock token which will be assigned to the lock by printing the desired lock token to standard output. Because of this, implementations of this hook should carefully avoid unexpected output sent to standard output.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>If the <code class="literal">pre-lock</code> script takes advantage of lock token dictation feature, the responsibility of generating a <span class="emphasis"><em>unique</em></span> lock token falls to the script itself. Failure to generate unique lock tokens may result in undefined—and very likely, undesired—behavior.</p></td></tr></table></div></div><div class="refsect1"><a id="idm14573"></a><h2>Input parameter(s)</h2><p>The command-line arguments passed to the hook program, in order, are:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Repository path</p></li><li class="listitem"><p>Versioned path that is to be locked</p></li><li class="listitem"><p>Authenticated username of the person attempting the lock</p></li><li class="listitem"><p>Comment provided when the lock was created</p></li><li class="listitem"><p><code class="literal">1</code> if the user is attempting to steal an existing lock; <code class="literal">0</code> otherwise</p></li></ol></div></div><div class="refsect1"><a id="idm14589"></a><h2>Common uses</h2><p>Access control</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.reposhooks.post-lock"></a><div class="titlepage"></div><a id="idm14593" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>post-lock — Notification of a successful path lock.</p></div><div class="refsect1"><a id="idm14600"></a><h2>Description</h2><p>The <code class="literal">post-lock</code> hook runs after one or more paths have been locked. It is typically used to send email notification of the lock event.</p><p>If the <code class="literal">post-lock</code> hook returns a nonzero exit status, the lock <span class="emphasis"><em>will not</em></span> be aborted since it has already completed. However, anything that the hook printed to <code class="filename">stderr</code> will be marshalled back to the client, making it easier to diagnose hook failures.</p></div><div class="refsect1"><a id="idm14608"></a><h2>Input parameter(s)</h2><p>The command-line arguments passed to the hook program, in order, are:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Repository path</p></li><li class="listitem"><p>Authenticated username of the person who locked the paths</p></li></ol></div><p>Additionally, the list of paths locked is passed to the hook program via standard input, one path per line.</p></div><div class="refsect1"><a id="idm14617"></a><h2>Common uses</h2><p>Lock notification</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.reposhooks.pre-unlock"></a><div class="titlepage"></div><a id="idm14621" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>pre-unlock — Notification of a path unlock attempt.</p></div><div class="refsect1"><a id="idm14628"></a><h2>Description</h2><p>The <code class="literal">pre-unlock</code> hook runs whenever someone attempts to remove a lock on a file. It can be used to create policies that specify which users are allowed to unlock particular paths. It's particularly important for determining policies about lock breakage. If user A locks a file, is user B allowed to break the lock? What if the lock is more than a week old? These sorts of things can be decided and enforced by the hook.</p><p>If the <code class="literal">pre-unlock</code> hook program returns a nonzero exit value, the unlock action is aborted and anything printed to <code class="filename">stderr</code> is marshalled back to the client.</p></div><div class="refsect1"><a id="idm14635"></a><h2>Input parameter(s)</h2><p>The command-line arguments passed to the hook program, in order, are:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Repository path</p></li><li class="listitem"><p>Versioned path which is to be unlocked</p></li><li class="listitem"><p>Authenticated username of the person attempting the unlock</p></li><li class="listitem"><p>Lock token associated with the lock which is to be removed</p></li><li class="listitem"><p><code class="literal">1</code> if the user is attempting to break the lock; <code class="literal">0</code> otherwise</p></li></ol></div></div><div class="refsect1"><a id="idm14651"></a><h2>Common uses</h2><p>Access control</p></div></div><div class="refentry"><div class="refentry.separator"><hr></hr></div><a id="svn.ref.reposhooks.post-unlock"></a><div class="titlepage"></div><a id="idm14655" class="indexterm"></a><div class="refnamediv"><h2>Name</h2><p>post-unlock — Notification of a successful path unlock.</p></div><div class="refsect1"><a id="idm14662"></a><h2>Description</h2><p>The <code class="literal">post-unlock</code> hook runs after one or more paths have been unlocked. It is typically used to send email notification of the unlock event.</p><p>If the <code class="literal">post-unlock</code> hook returns a nonzero exit status, the unlock <span class="emphasis"><em>will not</em></span> be aborted since it has already completed. However, anything that the hook printed to <code class="filename">stderr</code> will be marshalled back to the client, making it easier to diagnose hook failures.</p></div><div class="refsect1"><a id="idm14670"></a><h2>Input parameter(s)</h2><p>The command-line arguments passed to the hook program, in order, are:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Repository path</p></li><li class="listitem"><p>Authenticated username of the person who unlocked the paths</p></li></ol></div><p>Additionally, the list of paths unlocked is passed to the hook program via standard input, one path per line.</p></div><div class="refsect1"><a id="idm14679"></a><h2>Common uses</h2><p>Unlock notification</p></div></div></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm11839" class="footnote"><p><a href="#idm11839" class="para"><sup class="para">[72] </sup></a>Remember, <span class="command"><strong>svnadmin</strong></span> works only with local <span class="emphasis"><em>paths</em></span>, not <span class="emphasis"><em>URLs</em></span>.</p></div><div id="ftn.idm14309" class="footnote"><p><a href="#idm14309" class="para"><sup class="para">[73] </sup></a>As of this writing, symbolic links are indeed the only <span class="quote">“<span class="quote">special</span>”</span> objects. But there might be more in future releases of Subversion.</p></div></div></div><div class="appendix"><div class="titlepage"><div><div><h1 class="title"><a id="svn.intro"></a>Appendix A. Subversion Quick-Start Guide</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.intro.install">Installing Subversion</a></span></dt><dt><span class="sect1"><a href="#svn.intro.quickstart">High-Speed Tutorial</a></span></dt></dl></div><p>If you're eager to get Subversion up and running (and you enjoy learning by experimentation), this appendix will show you how to create a repository, import code, and then check it back out again as a working copy. Along the way, we give links to the relevant chapters of this book.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>If you're new to the entire concept of version control or to the <span class="quote">“<span class="quote">copy-modify-merge</span>”</span> model used by both CVS and Subversion, you should read <a class="xref" href="#svn.basic" title="Chapter 1. Fundamental Concepts">Chapter 1, <em>Fundamental Concepts</em></a> before going any further.</p></td></tr></table></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.intro.install"></a>Installing Subversion</h2></div></div></div><p>Subversion is built on a portability layer called APR—the Apache Portable Runtime library. The APR library provides all the interfaces that Subversion needs to function on different operating systems: disk access, network access, memory management, and so on. While Subversion is able to use Apache HTTP Server (or, <span class="command"><strong>httpd</strong></span>) as one of its network server programs, its dependence on APR <span class="emphasis"><em>does not</em></span> mean that <span class="command"><strong>httpd</strong></span> is a required component. APR is a standalone library usable by any application. It does mean, however, that Subversion clients and servers run on any operating system that <span class="command"><strong>httpd</strong></span> runs on: Windows, Linux, all flavors of BSD, Mac OS X, NetWare, and others.</p><p>The easiest way to get Subversion is to download a binary package built for your operating system. Subversion's web site (<a class="ulink" href="http://subversion.apache.org" target="_top">http://subversion.apache.org</a>) often has these packages available for download, posted by volunteers. The site usually contains graphical installer packages for users of Microsoft operating systems. If you run a Unix-like operating system, you can use your system's native package distribution system (RPMs, DEBs, the ports tree, etc.) to get Subversion.</p><p>Alternatively, you can build Subversion directly from source code, though it's not always an easy task. (If you're not experienced at building open source software packages, you're probably better off downloading a binary distribution instead!) From the Subversion web site, download the latest source code release. After unpacking it, follow the instructions in the <code class="filename">INSTALL</code> file to build it.</p><p>If you're one of those folks that likes to use bleeding-edge software, you can also get the Subversion source code from the Subversion repository in which it lives. Obviously, you'll need to already have a Subversion client on hand to do this. But once you do, you can check out a working copy from <a class="ulink" href="http://svn.apache.org/repos/asf/subversion" target="_top">http://svn.apache.org/repos/asf/subversion</a><a href="#ftn.idm14702" class="footnote" id="idm14702"><sup class="footnote">[74]</sup></a>:</p><div class="informalexample"><pre class="screen"> $ svn checkout http://svn.apache.org/repos/asf/subversion/trunk subversion A subversion/HACKING A subversion/INSTALL A subversion/README A subversion/autogen.sh A subversion/build.conf … </pre></div><p>The preceding command will create a working copy of the latest (unreleased) Subversion source code into a subdirectory named <code class="filename">subversion</code> in your current working directory. You can adjust that last argument as you see fit. Regardless of what you call the new working copy directory, though, after this operation completes, you will now have the Subversion source code. Of course, you will still need to fetch a few helper libraries (apr, apr-util, etc.)—see the <code class="filename">INSTALL</code> file in the top level of the working copy for details.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.intro.quickstart"></a>High-Speed Tutorial</h2></div></div></div><div class="blockquote"><blockquote class="blockquote"><p><span class="quote">“<span class="quote">Please make sure your seat backs are in their full, upright position and that your tray tables are stored. Flight attendants, prepare for take-off….</span>”</span></p></blockquote></div><p>What follows is a quick tutorial that walks you through some basic Subversion configuration and operation. When you finish it, you should have a general understanding of Subversion's typical usage.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></img></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The examples used in this appendix assume that you have <span class="command"><strong>svn</strong></span>, the Subversion command-line client, and <span class="command"><strong>svnadmin</strong></span>, the administrative tool, ready to go on a Unix-like operating system. (This tutorial also works at the Windows command-line prompt, assuming you make some obvious tweaks.) We also assume you are using Subversion 1.2 or later (run <strong class="userinput"><code>svn --version</code></strong> to check).</p></td></tr></table></div><p>Subversion stores all versioned data in a central repository. To begin, create a new repository:</p><div class="informalexample"><pre class="screen"> $ cd /var/svn $ svnadmin create repos $ ls repos conf/ dav/ db/ format hooks/ locks/ README.txt $ </pre></div><p>This command creates a Subversion repository in the directory <code class="filename">/var/svn/repos</code>, creating the <code class="filename">repos</code> directory itself if it doesn't already exist. This directory contains (among other things) a collection of database files. You won't see your versioned files if you peek inside. For more information about repository creation and maintenance, see <a class="xref" href="#svn.reposadmin" title="Chapter 5. Repository Administration">Chapter 5, <em>Repository Administration</em></a>.</p><p>Subversion has no concept of a <span class="quote">“<span class="quote">project.</span>”</span> The repository is just a virtual versioned filesystem, a large tree that can hold anything you wish. Some administrators prefer to store only one project in a repository, and others prefer to store multiple projects in a repository by placing them into separate directories. We discuss the merits of each approach in <a class="xref" href="#svn.reposadmin.projects.chooselayout" title="Planning Your Repository Organization">the section called “Planning Your Repository Organization”</a>. Either way, the repository manages only files and directories, so it's up to humans to interpret particular directories as <span class="quote">“<span class="quote">projects.</span>”</span> So while you might see references to projects throughout this book, keep in mind that we're only ever talking about some directory (or collection of directories) in the repository.</p><p>In this example, we assume you already have some sort of project (a collection of files and directories) that you wish to import into your newly created Subversion repository. Begin by organizing your data into a single directory called <code class="filename">myproject</code> (or whatever you wish). For reasons explained in <a class="xref" href="#svn.branchmerge" title="Chapter 4. Branching and Merging">Chapter 4, <em>Branching and Merging</em></a>, your project's tree structure should contain three top-level directories named <code class="filename">branches</code>, <code class="filename">tags</code>, and <code class="filename">trunk</code>. The <code class="filename">trunk</code> directory should contain all of your data, and the <code class="filename">branches</code> and <code class="filename">tags</code> directories should be empty:</p><div class="informalexample"><div class="literallayout"><p><br></br> /tmp/<br></br>    myproject/<br></br>       branches/<br></br>       tags/<br></br>       trunk/<br></br>          foo.c<br></br>          bar.c<br></br>          Makefile<br></br>          …<br></br> </p></div></div><p>The <code class="filename">branches</code>, <code class="filename">tags</code>, and <code class="filename">trunk</code> subdirectories aren't actually required by Subversion. They're merely a popular convention that you'll most likely want to use later on.</p><p>Once you have your tree of data ready to go, import it into the repository with the <span class="command"><strong>svn import</strong></span> command (see <a class="xref" href="#svn.tour.importing" title="Getting Data into Your Repository">the section called “Getting Data into Your Repository”</a>):</p><div class="informalexample"><pre class="screen"> $ svn import /tmp/myproject file:///var/svn/repos/myproject \ -m "initial import" Adding /tmp/myproject/branches Adding /tmp/myproject/tags Adding /tmp/myproject/trunk Adding /tmp/myproject/trunk/foo.c Adding /tmp/myproject/trunk/bar.c Adding /tmp/myproject/trunk/Makefile … Committed revision 1. $ </pre></div><p>Now the repository contains this tree of data. As mentioned earlier, you won't see your files by directly peeking into the repository; they're all stored within a database. But the repository's imaginary filesystem now contains a top-level directory named <code class="filename">myproject</code>, which in turn contains your data.</p><p>Note that the original <code class="filename">/tmp/myproject</code> directory is unchanged; Subversion is unaware of it. (In fact, you can even delete that directory if you wish.) To start manipulating repository data, you need to create a new <span class="quote">“<span class="quote">working copy</span>”</span> of the data, a sort of private workspace. Ask Subversion to <span class="quote">“<span class="quote">check out</span>”</span> a working copy of the <code class="filename">myproject/trunk</code> directory in the repository:</p><div class="informalexample"><pre class="screen"> $ svn checkout file:///var/svn/repos/myproject/trunk myproject A myproject/foo.c A myproject/bar.c A myproject/Makefile … Checked out revision 1. $ </pre></div><p>Now you have a personal copy of part of the repository in a new directory named <code class="filename">myproject</code>. You can edit the files in your working copy and then commit those changes back into the repository.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Enter your working copy and edit a file's contents.</p></li><li class="listitem"><p>Run <strong class="userinput"><code>svn diff</code></strong> to see unified diff output of your changes.</p></li><li class="listitem"><p>Run <strong class="userinput"><code>svn commit</code></strong> to commit the new version of your file to the repository.</p></li><li class="listitem"><p>Run <strong class="userinput"><code>svn update</code></strong> to bring your working copy <span class="quote">“<span class="quote">up to date</span>”</span> with the repository.</p></li></ul></div><p>For a full tour of all the things you can do with your working copy, read <a class="xref" href="#svn.tour" title="Chapter 2. Basic Usage">Chapter 2, <em>Basic Usage</em></a>.</p><p>At this point, you have the option of making your repository available to others over a network. See <a class="xref" href="#svn.serverconfig" title="Chapter 6. Server Configuration">Chapter 6, <em>Server Configuration</em></a> to learn about the different sorts of server processes available and how to configure them.</p></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm14702" class="footnote"><p><a href="#idm14702" class="para"><sup class="para">[74] </sup></a>Note that the URL checked out in the example ends not with <code class="literal">subversion</code>, but with a subdirectory thereof called <code class="literal">trunk</code>. See our discussion of Subversion's branching and tagging model for the reasoning behind this.</p></div></div></div><div class="appendix"><div class="titlepage"><div><div><h1 class="title"><a id="svn.forcvs"></a>Appendix B. Subversion for CVS Users</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.forcvs.revnums">Revision Numbers Are Different Now</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.directories">Directory Versions</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.disconnected">More Disconnected Operations</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.status-vs-update">Distinction Between Status and Update</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.forcvs.status-vs-update.status">Status</a></span></dt><dt><span class="sect2"><a href="#svn.forcvs.status-vs-update.update">Update</a></span></dt></dl></dd><dt><span class="sect1"><a href="#svn.forcvs.branches-and-tags">Branches and Tags</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.properties">Metadata Properties</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.conflicts">Conflict Resolution</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.binary-and-trans">Binary Files and Translation</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.modules">Versioned Modules</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.auth">Authentication</a></span></dt><dt><span class="sect1"><a href="#svn.forcvs.convert">Converting a Repository from CVS to Subversion</a></span></dt></dl></div><p>This appendix is a guide for CVS users new to Subversion. It's essentially a list of differences between the two systems as <span class="quote">“<span class="quote">viewed from 10,000 feet.</span>”</span> For each section, we provide references to relevant chapters when possible.</p><p>Although the goal of Subversion is to take over the current and future CVS user base, some new features and design changes were required to fix certain <span class="quote">“<span class="quote">broken</span>”</span> behaviors that CVS had. This means that, as a CVS user, you may need to break habits—ones that you forgot were odd to begin with.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.forcvs.revnums"></a>Revision Numbers Are Different Now</h2></div></div></div><p>In CVS, revision numbers are per file. This is because CVS stores its data in RCS files; each file has a corresponding RCS file in the repository, and the repository is roughly laid out according to the structure of your project tree.</p><p>In Subversion, the repository looks like a single filesystem. Each commit results in an entirely new filesystem tree; in essence, the repository is an array of trees. Each of these trees is labeled with a single revision number. When someone talks about <span class="quote">“<span class="quote">revision 54</span>”</span>, he's talking about a particular tree (and indirectly, the way the filesystem looked after the 54th commit).</p><p>Technically, it's not valid to talk about <span class="quote">“<span class="quote">revision 5 of <code class="filename">foo.c</code>.</span>”</span> Instead, one would say <span class="quote">“<span class="quote"><code class="filename">foo.c</code> as it appears in revision 5.</span>”</span> Also, be careful when making assumptions about the evolution of a file. In CVS, revisions 5 and 6 of <code class="filename">foo.c</code> are always different. In Subversion, it's most likely that <code class="filename">foo.c</code> did <span class="emphasis"><em>not</em></span> change between revisions 5 and 6.</p><p>Similarly, in CVS, a tag or branch is an annotation on the file or on the version information for that individual file, whereas in Subversion, a tag or branch is a copy of an entire tree (by convention, into the <code class="filename">/branches</code> or <code class="filename">/tags</code> directories that appear at the top level of the repository, beside <code class="filename">/trunk</code>). In the repository as a whole, many versions of each file may be visible: the latest version on each branch, every tagged version, and of course the latest version on the trunk itself. So, to refine the terms even further, one would often say <span class="quote">“<span class="quote"><code class="filename">foo.c</code> as it appears in <code class="filename">/branches/REL1</code> in revision 5.</span>”</span></p><p>For more details on this topic, see <a class="xref" href="#svn.basic.in-action.revs" title="Revisions">the section called “Revisions”</a>.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.forcvs.directories"></a>Directory Versions</h2></div></div></div><p>Subversion tracks tree structures, not just file contents. It's one of the biggest reasons Subversion was written to replace CVS.</p><p>Here's what this means to you, as a former CVS user:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>The <span class="command"><strong>svn add</strong></span> and <span class="command"><strong>svn delete</strong></span> commands work on directories now, just as they work on files. So do <span class="command"><strong>svn copy</strong></span> and <span class="command"><strong>svn move</strong></span>. However, these commands do <span class="emphasis"><em>not</em></span> cause any kind of immediate change in the repository. Instead, the working items are simply <span class="quote">“<span class="quote">scheduled</span>”</span> for addition or deletion. No repository changes happen until you run <strong class="userinput"><code>svn commit</code></strong>.</p></li><li class="listitem"><p>Directories aren't dumb containers anymore; they have revision numbers like files. (Or more properly, it's correct to talk about <span class="quote">“<span class="quote">directory <code class="filename">foo/</code> in revision 5.</span>”</span>)</p></li></ul></div><p>Let's talk more about that last point. Directory versioning is a hard problem; because we want to allow mixed-revision working copies, there are some limitations on how far we can abuse this model.</p><p>From a theoretical point of view, we define <span class="quote">“<span class="quote">revision 5 of directory <code class="filename">foo</code></span>”</span> to mean a specific collection of directory entries and properties. Now suppose we start adding and removing files from <code class="filename">foo</code>, and then commit. It would be a lie to say that we still have revision 5 of <code class="filename">foo</code>. However, if we bumped <code class="filename">foo</code>'s revision number after the commit, that would be a lie too; there may be other changes to <code class="filename">foo</code> we haven't yet received, because we haven't updated yet.</p><p>Subversion deals with this problem by quietly tracking committed adds and deletes in the <code class="filename">.svn</code> area. When you eventually run <strong class="userinput"><code>svn update</code></strong>, all accounts are settled with the repository, and the directory's new revision number is set correctly. <span class="emphasis"><em>Therefore, only after an update is it truly safe to say that you have a <span class="quote">“<span class="quote">perfect</span>”</span> revision of a directory.</em></span> Most of the time, your working copy will contain <span class="quote">“<span class="quote">imperfect</span>”</span> directory revisions.</p><p>Similarly, a problem arises if you attempt to commit property changes on a directory. Normally, the commit would bump the working directory's local revision number. But again, that would be a lie, as there may be adds or deletes that the directory doesn't yet have, because no update has happened. <span class="emphasis"><em>Therefore, you are not allowed to commit property changes on a directory unless the directory is up to date.</em></span></p><p>For more discussion about the limitations of directory versioning, see <a class="xref" href="#svn.basic.in-action.mixedrevs" title="Mixed-revision working copies">the section called “Mixed-revision working copies”</a>.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.forcvs.disconnected"></a>More Disconnected Operations</h2></div></div></div><p>In recent years, disk space has become outrageously cheap and abundant, but network bandwidth has not. Therefore, the Subversion working copy has been optimized around the scarcer resource.</p><p>The <code class="filename">.svn</code> administrative directory serves the same purpose as the <code class="filename">CVS</code> directory, except that it also stores read-only, <span class="quote">“<span class="quote">pristine</span>”</span> copies of your files. This allows you to do many things offline:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="command"><strong>svn status</strong></span></span></dt><dd><p>Shows you any local changes you've made (see <a class="xref" href="#svn.tour.cycle.examine.status" title="See an overview of your changes">the section called “See an overview of your changes”</a>)</p></dd><dt><span class="term"><span class="command"><strong>svn diff</strong></span></span></dt><dd><p>Shows you the details of your changes (see <a class="xref" href="#svn.tour.cycle.examine.diff" title="Examine the details of your local modifications">the section called “Examine the details of your local modifications”</a>)</p></dd><dt><span class="term"><span class="command"><strong>svn revert</strong></span></span></dt><dd><p>Removes your local changes (see <a class="xref" href="#svn.tour.cycle.revert" title="Fix Your Mistakes">the section called “Fix Your Mistakes”</a>)</p></dd></dl></div><p>Also, the cached pristine files allow the Subversion client to send differences when committing, which CVS cannot do.</p><p>The last subcommand in the list—<span class="command"><strong>svn revert</strong></span>—is new. It will not only remove local changes, but also unschedule operations such as adds and deletes. Although deleting the file and then running <strong class="userinput"><code>svn update</code></strong> will still work, doing so distorts the true purpose of updating. And, while we're on this subject…</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.forcvs.status-vs-update"></a>Distinction Between Status and Update</h2></div></div></div><p>Subversion attempts to erase a lot of the confusion between the <span class="command"><strong>cvs status</strong></span> and <span class="command"><strong>cvs update</strong></span> commands.</p><p>The <span class="command"><strong>cvs status</strong></span> command has two purposes: first, to show the user any local modifications in the working copy, and second, to show the user which files are out of date. Unfortunately, because of CVS's hard-to-read status output, many CVS users don't take advantage of this command at all. Instead, they've developed a habit of running <strong class="userinput"><code>cvs update</code></strong> or <strong class="userinput"><code>cvs -n update</code></strong> to quickly see their changes. If users forget to use the <code class="option">-n</code> option, this has the side effect of merging repository changes they may not be ready to deal with.</p><p>Subversion removes this muddle by making the output of <span class="command"><strong>svn status</strong></span> easy to read for both humans and parsers. Also, <span class="command"><strong>svn update</strong></span> prints only information about files that are updated, <span class="emphasis"><em>not</em></span> local modifications.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.forcvs.status-vs-update.status"></a>Status</h3></div></div></div><p><span class="command"><strong>svn status</strong></span> prints all files that have local modifications. By default, the repository is not contacted. While this subcommand accepts a fair number of options, the following are the most commonly used ones:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-u</code></span></dt><dd><p>Contact the repository to determine, and then display, out-of-dateness information.</p></dd><dt><span class="term"><code class="option">-v</code></span></dt><dd><p>Show <span class="emphasis"><em>all</em></span> entries under version control.</p></dd><dt><span class="term"><code class="option">-N</code></span></dt><dd><p>Run nonrecursively (do not descend into subdirectories).</p></dd></dl></div><p>The <span class="command"><strong>svn status</strong></span> command has two output formats. In the default <span class="quote">“<span class="quote">short</span>”</span> format, local modifications look like this:</p><div class="informalexample"><pre class="screen"> $ svn status M foo.c M bar/baz.c </pre></div><p>If you specify the <code class="option">--show-updates</code> (<code class="option">-u</code>) option, a longer output format is used:</p><div class="informalexample"><pre class="screen"> $ svn status -u M 1047 foo.c * 1045 faces.html * bloo.png M 1050 bar/baz.c Status against revision: 1066 </pre></div><p>In this case, two new columns appear. The second column contains an asterisk if the file or directory is out of date. The third column shows the working copy's revision number of the item. In the previous example, the asterisk indicates that <code class="filename">faces.html</code> would be patched if we updated, and that <code class="filename">bloo.png</code> is a newly added file in the repository. (The absence of any revision number next to <code class="filename">bloo.png</code> means that it doesn't yet exist in the working copy.)</p><p>For a more detailed discussion of <span class="command"><strong>svn status</strong></span>, including an explanation of the status codes shown in the previous example, see <a class="xref" href="#svn.tour.cycle.examine.status" title="See an overview of your changes">the section called “See an overview of your changes”</a>.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.forcvs.status-vs-update.update"></a>Update</h3></div></div></div><p><span class="command"><strong>svn update</strong></span> updates your working copy, and prints only information about files that it updates.</p><p>Subversion has combined CVS's <code class="literal">P</code> and <code class="literal">U</code> codes into just <code class="literal">U</code>. When a merge or conflict occurs, Subversion simply prints <code class="literal">G</code> or <code class="literal">C</code>, rather than a whole sentence about it.</p><p>For a more detailed discussion of <span class="command"><strong>svn update</strong></span>, see <a class="xref" href="#svn.tour.cycle.update" title="Update Your Working Copy">the section called “Update Your Working Copy”</a>.</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.forcvs.branches-and-tags"></a>Branches and Tags</h2></div></div></div><p>Subversion doesn't distinguish between filesystem space and <span class="quote">“<span class="quote">branch</span>”</span> space; branches and tags are ordinary directories within the filesystem. This is probably the single biggest mental hurdle that a CVS user will need to cross. Read all about it in <a class="xref" href="#svn.branchmerge" title="Chapter 4. Branching and Merging">Chapter 4, <em>Branching and Merging</em></a>.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></img></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Since Subversion treats branches and tags as ordinary directories, your project's various lines of development probably live in subdirectories of the main project directory. So remember to check out using the URL of the subdirectory that contains the particular line of development you want, not the project's root URL. If you make the mistake of checking out the root of the project, you may very well wind up with a working copy that contains a complete copy of your project's content for each and every one of its branches and tags. <a href="#ftn.idm14947" class="footnote" id="idm14947"><sup class="footnote">[75]</sup></a></p></td></tr></table></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.forcvs.properties"></a>Metadata Properties</h2></div></div></div><p>A new feature of Subversion is that you can attach arbitrary metadata (or <span class="quote">“<span class="quote">properties</span>”</span>) to files and directories. Properties are arbitrary name/value pairs associated with files and directories in your working copy.</p><p>To set or get a property name, use the <span class="command"><strong>svn propset</strong></span> and <span class="command"><strong>svn propget</strong></span> subcommands. To list all properties on an object, use <span class="command"><strong>svn proplist</strong></span>.</p><p>For more information, see <a class="xref" href="#svn.advanced.props" title="Properties">the section called “Properties”</a>.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.forcvs.conflicts"></a>Conflict Resolution</h2></div></div></div><p>CVS marks conflicts with inline <span class="quote">“<span class="quote">conflict markers,</span>”</span> and then prints a <code class="literal">C</code> during an update or merge operation. Historically, this has caused problems, because CVS isn't doing enough. Many users forget about (or don't see) the <code class="literal">C</code> after it whizzes by on their terminal. They often forget that the conflict markers are even present, and then accidentally commit files containing those conflict markers.</p><p>Subversion solves this problem in a pair of ways. First, when a conflict occurs in a file, Subversion records the fact that the file is in a state of conflict, and won't allow you to commit changes to that file until you explicitly resolve the conflict. Second, Subversion provides interactive conflict resolution, which allows you to resolve conflicts as they happen instead of having to go back and do so after the update or merge operation completes. See <a class="xref" href="#svn.tour.cycle.resolve" title="Resolve Any Conflicts">the section called “Resolve Any Conflicts”</a> for more about conflict resolution in Subversion.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.forcvs.binary-and-trans"></a>Binary Files and Translation</h2></div></div></div><p>In the most general sense, Subversion handles binary files more gracefully than CVS does. Because CVS uses RCS, it can only store successive full copies of a changing binary file. Subversion, however, expresses differences between files using a binary differencing algorithm, regardless of whether they contain textual or binary data. That means all files are stored differentially (compressed) in the repository.</p><p>CVS users have to mark binary files with <code class="option">-kb</code> flags to prevent data from being garbled (due to keyword expansion and line-ending translations). They sometimes forget to do this.</p><p>Subversion takes the more paranoid route. First, it never performs any kind of keyword or line-ending translation unless you explicitly ask it to do so (see <a class="xref" href="#svn.advanced.props.special.keywords" title="Keyword Substitution">the section called “Keyword Substitution”</a> and <a class="xref" href="#svn.advanced.props.special.eol-style" title="End-of-Line Character Sequences">the section called “End-of-Line Character Sequences”</a> for more details). By default, Subversion treats all file data as literal byte strings, and files are always stored in the repository in an untranslated state.</p><p>Second, Subversion maintains an internal notion of whether a file is <span class="quote">“<span class="quote">text</span>”</span> or <span class="quote">“<span class="quote">binary</span>”</span> data, but this notion is <span class="emphasis"><em>only</em></span> extant in the working copy. During an <span class="command"><strong>svn update</strong></span>, Subversion will perform contextual merges on locally modified text files, but will not attempt to do so for binary files.</p><p>To determine whether a contextual merge is possible, Subversion examines the <code class="literal">svn:mime-type</code> property. If the file has no <code class="literal">svn:mime-type</code> property, or has a MIME type that is textual (e.g., <code class="literal">text/*</code>), Subversion assumes it is text. Otherwise, Subversion assumes the file is binary. Subversion also helps users by running a binary-detection algorithm in the <span class="command"><strong>svn import</strong></span> and <span class="command"><strong>svn add</strong></span> commands. These commands will make a good guess and then (possibly) set a binary <code class="literal">svn:mime-type</code> property on the file being added. (If Subversion guesses wrong, the user can always remove or hand-edit the property.)</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.forcvs.modules"></a>Versioned Modules</h2></div></div></div><p>Unlike CVS, a Subversion working copy is aware that it has checked out a module. That means if somebody changes the definition of a module (e.g., adds or removes components), a call to <span class="command"><strong>svn update</strong></span> will update the working copy appropriately, adding and removing components.</p><p>Subversion defines modules as a list of directories within a directory property; see <a class="xref" href="#svn.advanced.externals" title="Externals Definitions">the section called “Externals Definitions”</a>.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.forcvs.auth"></a>Authentication</h2></div></div></div><p>With CVS's pserver, you are required to log in to the server (using the <span class="command"><strong>cvs login</strong></span> command) before performing any read or write operation—you sometimes even have to log in for anonymous operations. With a Subversion repository using Apache <span class="command"><strong>httpd</strong></span> or <span class="command"><strong>svnserve</strong></span> as the server, you don't provide any authentication credentials at the outset—if an operation that you perform requires authentication, the server will challenge you for your credentials (whether those credentials are username and password, a client certificate, or even both). So if your repository is world-readable, you will not be required to authenticate at all for read operations.</p><p>As with CVS, Subversion still caches your credentials on disk (in your <code class="filename">~/.subversion/auth/</code> directory) unless you tell it not to by using the <code class="option">--no-auth-cache</code> option.</p><p>The exception to this behavior, however, is in the case of accessing an <span class="command"><strong>svnserve</strong></span> server over an SSH tunnel, using the <code class="literal">svn+ssh://</code> URL scheme. In that case, the <span class="command"><strong>ssh</strong></span> program unconditionally demands authentication just to start the tunnel.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.forcvs.convert"></a>Converting a Repository from CVS to Subversion</h2></div></div></div><p>Perhaps the most important way to familiarize CVS users with Subversion is to let them continue to work on their projects using the new system. And while that can be somewhat accomplished using a flat import into a Subversion repository of an exported CVS repository, the more thorough solution involves transferring not just the latest snapshot of their data, but all the history behind it as well, from one system to another. This is an extremely difficult problem to solve; it involves deducing changesets in the absence of atomicity and translating between the systems' completely orthogonal branching policies, among other complications. Still, a handful of tools claim to at least partially support the ability to convert existing CVS repositories into Subversion ones.</p><p>The most popular (and mature) conversion tool is cvs2svn (<a class="ulink" href="http://cvs2svn.tigris.org/" target="_top">http://cvs2svn.tigris.org/</a>), a Python program originally created by members of Subversion's own development community. This tool is meant to run exactly once: it scans your CVS repository multiple times and attempts to deduce commits, branches, and tags as best it can. When it finishes, the result is either a Subversion repository or a portable Subversion dump file representing your code's history. See the web site for detailed instructions and caveats.</p></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm14947" class="footnote"><p><a href="#idm14947" class="para"><sup class="para">[75] </sup></a>That is, providing you don't run out of disk space before your checkout finishes.</p></div></div></div><div class="appendix"><div class="titlepage"><div><div><h1 class="title"><a id="svn.webdav"></a>Appendix C. WebDAV and Autoversioning</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="#svn.webdav.basic">What Is WebDAV?</a></span></dt><dt><span class="sect1"><a href="#svn.webdav.autoversioning">Autoversioning</a></span></dt><dt><span class="sect1"><a href="#svn.webdav.clients">Client Interoperability</a></span></dt><dd><dl><dt><span class="sect2"><a href="#svn.webdav.clients.standalone">Standalone WebDAV Applications</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.webdav.clients.standalone.windows">Microsoft Office, Dreamweaver, Photoshop</a></span></dt><dt><span class="sect3"><a href="#svn.webdav.clients.standalone.free">cadaver, DAV Explorer</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.webdav.clients.file-explorer-extensions">File-Explorer WebDAV Extensions</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.webdav.clients.file-explorer-extensions.windows">Microsoft Web Folders</a></span></dt><dt><span class="sect3"><a href="#svn.webdav.clients.file-explorer-extensions.linux-de">Nautilus, Konqueror</a></span></dt></dl></dd><dt><span class="sect2"><a href="#svn.webdav.clients.fs-impl">WebDAV Filesystem Implementation</a></span></dt><dd><dl><dt><span class="sect3"><a href="#svn.webdav.clients.fs-impl.windows">WebDrive, NetDrive</a></span></dt><dt><span class="sect3"><a href="#svn.webdav.clients.fs-impl.macosx">Mac OS X</a></span></dt><dt><span class="sect3"><a href="#svn.webdav.clients.fs-impl.linux">Linux davfs2</a></span></dt></dl></dd></dl></dd></dl></div><p>WebDAV is an extension to HTTP, and it is growing more and more popular as a standard for file sharing. Today's operating systems are becoming extremely web-aware, and many now have built-in support for mounting <span class="quote">“<span class="quote">shares</span>”</span> exported by WebDAV servers.</p><p>If you use Apache as your Subversion network server, to some extent you are also running a WebDAV server. This appendix gives some background on the nature of this protocol, how Subversion uses it, and how well Subversion interoperates with other software that is WebDAV-aware.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.webdav.basic"></a>What Is WebDAV?</h2></div></div></div><p><em class="firstterm">DAV</em> stands for <span class="quote">“<span class="quote">Distributed Authoring and Versioning.</span>”</span> RFC 2518 defines a set of concepts and accompanying extension methods to HTTP 1.1 that make the Web a more universal read/write medium. The basic idea is that a WebDAV-compliant web server can act like a generic file server; clients can <span class="quote">“<span class="quote">mount</span>”</span> shared folders over HTTP that behave much like other network filesystems (such as NFS or SMB).</p><p>The tragedy, though, is that despite the acronym, the RFC specification doesn't actually describe any sort of version control. Basic WebDAV clients and servers assume that only one version of each file or directory exists, and that it can be repeatedly overwritten.</p><p>Because RFC 2518 left out versioning concepts, another committee was left with the responsibility of writing RFC 3253 a few years later. The new RFC adds versioning concepts to WebDAV, placing the <span class="quote">“<span class="quote">V</span>”</span> back in <span class="quote">“<span class="quote">DAV</span>”</span>—hence the term <span class="quote">“<span class="quote">DeltaV.</span>”</span> WebDAV/DeltaV clients and servers are often called just <span class="quote">“<span class="quote">DeltaV</span>”</span> programs, since DeltaV implies the existence of basic WebDAV.</p><p>The original WebDAV standard has been widely successful. Every modern computer operating system has a general WebDAV client built in (details to follow), and a number of popular standalone applications are also able to speak WebDAV—Microsoft Office, Dreamweaver, and Photoshop, to name a few. On the server end, Apache HTTP Server has been able to provide WebDAV services since 1998 and is considered the de facto open source standard. Several other commercial WebDAV servers are available, including Microsoft's own IIS.</p><p>DeltaV, unfortunately, has not been so successful. It's very difficult to find any DeltaV clients or servers. The few that do exist are relatively unknown commercial products, and thus it's very difficult to test interoperability. It's not entirely clear as to why DeltaV has remained stagnant. Some opine that the specification is just too complex. Others argue that while WebDAV's features have mass appeal (even the least technical users appreciate network file sharing), its version control features just aren't interesting or necessary for most users. Finally, some believe that DeltaV remains unpopular because there's still no open source server product that implements it well.</p><p>When Subversion was still in its design phase, it seemed like a great idea to use Apache as a network server. It already had a module to provide WebDAV services. DeltaV was a relatively new specification. The hope was that the Subversion server module (<span class="command"><strong>mod_dav_svn</strong></span>) would eventually evolve into an open source DeltaV reference implementation. Unfortunately, DeltaV has a very specific versioning model that doesn't quite line up with Subversion's model. Some concepts were mappable; others were not.</p><p>What does this mean, then?</p><p>First, the Subversion client is not a fully implemented DeltaV client. It needs certain types of things from the server that DeltaV itself cannot provide, and thus is largely dependent on a number of Subversion-specific HTTP <code class="literal">REPORT</code> requests that only <span class="command"><strong>mod_dav_svn</strong></span> understands.</p><p>Second, <span class="command"><strong>mod_dav_svn</strong></span> is not a fully realized DeltaV server. Many portions of the DeltaV specification were irrelevant to Subversion, and thus were left unimplemented.</p><p>A long-held debate in the Subversion developer community about whether it was worthfile to remedy either of these situations eventually reached closure, with the Subversion developers officially deciding to abandon plans to fully support DeltaV. As of Subversion 1.7, Subversion clients and servers introduce numerous non-standard simplifications of the DeltaV standards<a href="#ftn.idm15039" class="footnote" id="idm15039"><sup class="footnote">[76]</sup></a>, with more customizations of this sort likely to come. Those versions of Subversion will, of course, continue to provide the same DeltaV feature support already present in older releases, but no new work will be done to increase coverage of the specification—Subversion is intentionally moving away from strict DeltaV as its primary HTTP-based protocol.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.webdav.autoversioning"></a>Autoversioning</h2></div></div></div><p>While the Subversion client is not a full DeltaV client, and the Subversion server is not a full DeltaV server, there's still a glimmer of WebDAV interoperability to be happy about: <em class="firstterm">autoversioning</em>.</p><p>Autoversioning is an optional feature defined in the DeltaV standard. A typical DeltaV server will reject an ignorant WebDAV client attempting to do a <code class="literal">PUT</code> to a file that's under version control. To change a version-controlled file, the server expects a series of proper versioning requests: something like <code class="literal">MKACTIVITY</code>, <code class="literal">CHECKOUT</code>, <code class="literal">PUT</code>, <code class="literal">CHECKIN</code>. But if the DeltaV server supports autoversioning, write requests from basic WebDAV clients are accepted. The server behaves as though the client <span class="emphasis"><em>had</em></span> issued the proper series of versioning requests, performing a commit under the hood. In other words, it allows a DeltaV server to interoperate with ordinary WebDAV clients that don't understand versioning.</p><p>Because so many operating systems already have integrated WebDAV clients, the use case for this feature can be incredibly appealing to administrators working with non-technical users. Imagine an office of ordinary users running Microsoft Windows or Mac OS. Each user <span class="quote">“<span class="quote">mounts</span>”</span> the Subversion repository, which appears to be an ordinary network folder. They use the shared folder as they always do: open files, edit them, and save them. Meanwhile, the server is automatically versioning everything. Any administrator (or knowledgeable user) can still use a Subversion client to search history and retrieve older versions of data.</p><p>This scenario isn't fiction—it's real and it works. To activate autoversioning in <span class="command"><strong>mod_dav_svn</strong></span>, use the <code class="literal">SVNAutoversioning</code> directive within the <code class="filename">httpd.conf</code> <code class="literal">Location</code> block, like so:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /repos&gt; DAV svn SVNPath /var/svn/repository SVNAutoversioning on &lt;/Location&gt; </pre></div><p>When Subversion autoversioning is active, write requests from WebDAV clients result in automatic commits. A generic log message is automatically generated and attached to each revision.</p><p>Before activating this feature, however, understand what you're getting into. WebDAV clients tend to do <span class="emphasis"><em>many</em></span> write requests, resulting in a huge number of automatically committed revisions. For example, when saving data, many clients will do a <code class="literal">PUT</code> of a 0-byte file (as a way of reserving a name) followed by another <code class="literal">PUT</code> with the real file data. The single file-write results in two separate commits. Also consider that many applications auto-save every few minutes, resulting in even more commits.</p><p>If you have a post-commit hook program that sends email, you may want to disable email generation either altogether or on certain sections of the repository; it depends on whether you think the influx of emails will still prove to be valuable notifications or not. Also, a smart post-commit hook program can distinguish between a transaction created via autoversioning and one created through a normal Subversion commit operation. The trick is to look for a revision property named <code class="literal">svn:autoversioned</code>. If present, the commit was made by a generic WebDAV client.</p><p>Another feature that may be a useful complement for Subversion's autoversioning comes from Apache's <span class="command"><strong>mod_mime</strong></span> module. If a WebDAV client adds a new file to the repository, there's no opportunity for the user to set the the <code class="literal">svn:mime-type</code> property. This might cause the file to appear as a generic icon when viewed within a WebDAV shared folder, not having an association with any application. One remedy is to have a sysadmin (or other Subversion-knowledgeable person) check out a working copy and manually set the <code class="literal">svn:mime-type</code> property on necessary files. But there's potentially no end to such cleanup tasks. Instead, you can use the <code class="literal">ModMimeUsePathInfo</code> directive in your Subversion <code class="literal">&lt;Location&gt;</code> block:</p><div class="informalexample"><pre class="programlisting"> &lt;Location /repos&gt; DAV svn SVNPath /var/svn/repository SVNAutoversioning on ModMimeUsePathInfo on &lt;/Location&gt; </pre></div><p>This directive allows <span class="command"><strong>mod_mime</strong></span> to attempt automatic deduction of the MIME type on new files that enter the repository via autoversioning. The module looks at the file's named extension and possibly the contents as well; if the file matches some common patterns, the file's <code class="literal">svn:mime-type</code> property will be set automatically.</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.webdav.clients"></a>Client Interoperability</h2></div></div></div><p>All WebDAV clients fall into one of three categories—standalone applications, file-explorer extensions, or filesystem implementations. These categories broadly define the types of WebDAV functionality available to users. <a class="xref" href="#svn.webdav.clients.tbl-1" title="Table C.1. Common WebDAV clients">Table C.1, “Common WebDAV clients”</a> gives our categorization as well as a quick description of some common pieces of WebDAV-enabled software. You can find more details about these software offerings, as well as their general category, in the sections that follow.</p><div class="table"><a id="svn.webdav.clients.tbl-1"></a><p class="title"><strong>Table C.1. Common WebDAV clients</strong></p><div class="table-contents"><table class="table" summary="Common WebDAV clients" border="1"><colgroup><col></col><col></col><col></col><col></col><col></col><col></col></colgroup><thead><tr><th>Software</th><th>Type</th><th>Windows</th><th>Mac</th><th>Linux</th><th>Description</th></tr></thead><tbody><tr><td>Adobe Photoshop</td><td>Standalone WebDAV application</td><td>X</td><td> </td><td> </td><td>Image editing software, allowing direct opening from, and writing to, WebDAV URLs</td></tr><tr><td>cadaver</td><td>Standalone WebDAV application</td><td> </td><td>X</td><td>X</td><td>Command-line WebDAV client supporting file transfer, tree, and locking operations</td></tr><tr><td>DAV Explorer</td><td>Standalone WebDAV application</td><td>X</td><td>X</td><td>X</td><td>Java GUI tool for exploring WebDAV shares</td></tr><tr><td>Adobe Dreamweaver</td><td>Standalone WebDAV application</td><td>X</td><td> </td><td> </td><td>Web production software able to directly read from and write to WebDAV URLs</td></tr><tr><td>Microsoft Office</td><td>Standalone WebDAV application</td><td>X</td><td> </td><td> </td><td>Office productivity suite with several components able to directly read from and write to WebDAV URLs</td></tr><tr><td>Microsoft Web Folders</td><td>File-explorer WebDAV extension</td><td>X</td><td> </td><td> </td><td>GUI file explorer program able to perform tree operations on a WebDAV share</td></tr><tr><td>GNOME Nautilus</td><td>File-explorer WebDAV extension</td><td> </td><td> </td><td>X</td><td>GUI file explorer able to perform tree operations on a WebDAV share</td></tr><tr><td>KDE Konqueror</td><td>File-explorer WebDAV extension</td><td> </td><td> </td><td>X</td><td>GUI file explorer able to perform tree operations on a WebDAV share</td></tr><tr><td>Mac OS X</td><td>WebDAV filesystem implementation</td><td> </td><td>X</td><td> </td><td>Operating system that has built-in support for mounting WebDAV shares.</td></tr><tr><td>Novell NetDrive</td><td>WebDAV filesystem implementation</td><td>X</td><td> </td><td> </td><td>Drive-mapping program for assigning Windows drive letters to a mounted remote WebDAV share</td></tr><tr><td>SRT WebDrive</td><td>WebDAV filesystem implementation</td><td>X</td><td> </td><td> </td><td>File transfer software, which, among other things, allows the assignment of Windows drive letters to a mounted remote WebDAV share</td></tr><tr><td>davfs2</td><td>WebDAV filesystem implementation</td><td> </td><td> </td><td>X</td><td>Linux filesystem driver that allows you to mount a WebDAV share</td></tr></tbody></table></div></div><br class="table-break"></br><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.webdav.clients.standalone"></a>Standalone WebDAV Applications</h3></div></div></div><p>A WebDAV application is a program that speaks WebDAV protocols with a WebDAV server. We'll cover some of the most popular programs with this kind of WebDAV support.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.webdav.clients.standalone.windows"></a>Microsoft Office, Dreamweaver, Photoshop</h4></div></div></div><p>On Windows, several well-known applications contain integrated WebDAV client functionality, such as Microsoft's Office,<a href="#ftn.idm15186" class="footnote" id="idm15186"><sup class="footnote">[77]</sup></a> Adobe's Photoshop and Dreamweaver programs. They're able to directly open and save to URLs, and tend to make heavy use of WebDAV locks when editing a file.</p><p>Note that while many of these programs also exist for Mac OS X, they do not appear to support WebDAV directly on that platform. In fact, on Mac OS X, the <span class="guimenu">File→Open</span> dialog box doesn't allow one to type a path or URL at all. It's likely that the WebDAV features were deliberately left out of Macintosh versions of these programs, since OS X already provides such excellent low-level filesystem support for WebDAV.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.webdav.clients.standalone.free"></a>cadaver, DAV Explorer</h4></div></div></div><p>cadaver is a bare-bones Unix command-line program for browsing and changing WebDAV shares. Like the Subversion client, it uses the neon HTTP library—not surprisingly, since both neon and cadaver are written by the same author. cadaver is free software (GPL license) and is available at <a class="ulink" href="https://notroj.github.io/cadaver/" target="_top">https://notroj.github.io/cadaver/</a>.</p><p>Using cadaver is similar to using a command-line FTP program, and thus it's extremely useful for basic WebDAV debugging. It can be used to upload or download files in a pinch, to examine properties, and to copy, move, lock, or unlock files:</p><div class="informalexample"><pre class="screen"> $ cadaver http://host/repos dav:/repos/&gt; ls Listing collection `/repos/': succeeded. Coll: &gt; foobar 0 May 10 16:19 &gt; playwright.el 2864 May 4 16:18 &gt; proofbypoem.txt 1461 May 5 15:09 &gt; westcoast.jpg 66737 May 5 15:09 dav:/repos/&gt; put README Uploading README to `/repos/README': Progress: [=============================&gt;] 100.0% of 357 bytes succeeded. dav:/repos/&gt; get proofbypoem.txt Downloading `/repos/proofbypoem.txt' to proofbypoem.txt: Progress: [=============================&gt;] 100.0% of 1461 bytes succeeded. </pre></div><p>DAV Explorer is another standalone WebDAV client, written in Java. It's under a free Apache-like license and is available at <a class="ulink" href="http://www.ics.uci.edu/~webdav/" target="_top">http://www.ics.uci.edu/~webdav/</a>. It does everything cadaver does, but has the advantages of being portable and being a more user-friendly GUI application. It's also one of the first clients to support the new WebDAV Access Control Protocol (RFC 3744).</p><p>Of course, DAV Explorer's ACL support is useless in this case, since <span class="command"><strong>mod_dav_svn</strong></span> doesn't support it. The fact that both cadaver and DAV Explorer support some limited DeltaV commands isn't particularly useful either, since they don't allow <code class="literal">MKACTIVITY</code> requests. But it's not relevant anyway; we're assuming all of these clients are operating against an autoversioning repository.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.webdav.clients.file-explorer-extensions"></a>File-Explorer WebDAV Extensions</h3></div></div></div><p>Some popular file explorer GUI programs support WebDAV extensions that allow a user to browse a DAV share as though it was just another directory on the local computer, and to perform basic tree editing operations on the items in that share. For example, Windows Explorer is able to browse a WebDAV server as a <span class="quote">“<span class="quote">network place.</span>”</span> Users can drag files to and from the desktop, or can rename, copy, or delete files in the usual way. But because it's only a feature of the file explorer, the DAV share isn't visible to ordinary applications. All DAV interaction must happen through the explorer interface.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.webdav.clients.file-explorer-extensions.windows"></a>Microsoft Web Folders</h4></div></div></div><p>Microsoft was one of the original backers of the WebDAV specification, and first started shipping a client in Windows 98, which was known as Web Folders. This client was also shipped in Windows NT 4.0 and Windows 2000.</p><p>The original Web Folders client was an extension to Explorer, the main GUI program used to browse filesystems. It works well enough. In Windows 98, the feature might need to be explicitly installed if Web Folders aren't already visible inside My Computer. In Windows 2000, simply add a new <span class="quote">“<span class="quote">network place,</span>”</span> enter the URL, and the WebDAV share will pop up for browsing.</p><p>With the release of Windows XP, Microsoft started shipping a new implementation of Web Folders, known as the WebDAV Mini-Redirector. The new implementation is a filesystem-level client, allowing WebDAV shares to be mounted as drive letters. Unfortunately, this implementation is incredibly buggy. The client usually tries to convert HTTP URLs (<code class="literal">http://host/repos</code>) into UNC share notation (<code class="literal">\\host\repos</code>); it also often tries to use Windows Domain authentication to respond to basic-auth HTTP challenges, sending usernames as <code class="literal">HOST\username</code>. These interoperability problems are severe and are documented in numerous places around the Web, to the frustration of many users. Even Greg Stein, the original author of Apache's WebDAV module, bluntly states that XP Web Folders simply can't operate against an Apache server.</p><p>Windows Vista's initial implementation of Web Folders seems to be almost the same as XP's, so it has the same sort of problems. With luck, Microsoft will remedy these issues in a Vista Service Pack.</p><p>However, there seem to be workarounds for both XP and Vista that allow Web Folders to work against Apache. Users have mostly reported success with these techniques, so we'll relay them here.</p><p>On Windows XP, you have two options. First, search Microsoft's web site for update KB907306, <span class="quote">“<span class="quote">Software Update for Web Folders.</span>”</span> This may fix all your problems. If it doesn't, it seems that the original pre-XP Web Folders implementation is still buried within the system. You can unearth it by going to Network Places and adding a new network place. When prompted, enter the URL of the repository, but <span class="emphasis"><em>include a port number</em></span> in the URL. For example, you should enter <strong class="userinput"><code>http://host/repos</code></strong> as <strong class="userinput"><code>http://host:80/repos</code></strong> instead. Respond to any authentication prompts with your Subversion credentials.</p><p>On Windows Vista, the same KB907306 update may clear everything up. But there may still be other issues. Some users have reported that Vista considers all <code class="literal">http://</code> connections insecure, and thus will always fail any authentication challenges from Apache unless the connection happens over <code class="literal">https://</code>. If you're unable to connect to the Subversion repository via SSL, you can tweak the system registry to turn off this behavior. Just change the value of the <code class="literal">HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters\BasicAuthLevel</code> key from <strong class="userinput"><code>1</code></strong> to <strong class="userinput"><code>2</code></strong>. A final warning: be sure to set up the Web Folder to point to the repository's root directory (<code class="filename">/</code>), rather than some subdirectory such as <code class="filename">/trunk</code>. Vista Web Folders seems to work only against repository roots.</p><p>In general, while these workarounds may function for you, you might get a better overall experience using a third-party WebDAV client such as WebDrive or NetDrive.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.webdav.clients.file-explorer-extensions.linux-de"></a>Nautilus, Konqueror</h4></div></div></div><p>Nautilus is the official file manager/browser for the GNOME desktop (<a class="ulink" href="http://www.gnome.org" target="_top">http://www.gnome.org</a>), and Konqueror is the manager/browser for the KDE desktop (<a class="ulink" href="http://www.kde.org" target="_top">http://www.kde.org</a>). Both of these applications have an explorer-level WebDAV client built in, and they operate just fine against an autoversioning repository.</p><p>In GNOME's Nautilus, select the <span class="guimenuitem">File→Open location</span> menu item and enter the URL in the dialog box presented. The repository should then be displayed like any other filesystem.</p><p>In KDE's Konqueror, you need to use the <code class="literal">webdav://</code> scheme when entering the URL in the location bar. If you enter an <code class="literal">http://</code> URL, Konqueror will behave like an ordinary web browser. You'll likely see the generic HTML directory listing produced by <span class="command"><strong>mod_dav_svn</strong></span>. When you enter <strong class="userinput"><code>webdav://host/repos</code></strong> instead of <strong class="userinput"><code>http://host/repos</code></strong>, Konqueror becomes a WebDAV client and displays the repository as a filesystem.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="svn.webdav.clients.fs-impl"></a>WebDAV Filesystem Implementation</h3></div></div></div><p>The WebDAV filesystem implementation is arguably the best sort of WebDAV client. It's implemented as a low-level filesystem module, typically within the operating system's kernel. This means that the DAV share is mounted like any other network filesystem, similar to mounting an NFS share on Unix or attaching an SMB share as a drive letter in Windows. As a result, this sort of client provides completely transparent read/write WebDAV access to all programs. Applications aren't even aware that WebDAV requests are happening.</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.webdav.clients.fs-impl.windows"></a>WebDrive, NetDrive</h4></div></div></div><p>Both WebDrive and NetDrive are excellent commercial products that allow a WebDAV share to be attached as drive letters in Windows. As a result, you can operate on the contents of these WebDAV-backed pseudodrives as easily as you can against real local hard drives, and in the same ways. You can purchase WebDrive from South River Technologies (<a class="ulink" href="https://webdrive.com/" target="_top">https://webdrive.com/</a>). Novell's NetDrive is freely available online, but requires users to have a NetWare license.</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.webdav.clients.fs-impl.macosx"></a>Mac OS X</h4></div></div></div><p>Apple's OS X operating system has an integrated filesystem-level WebDAV client. From the Finder, select the <span class="guimenuitem">Go→Connect to Server</span> menu item. Enter a WebDAV URL, and it appears as a disk on the desktop, just like any other mounted volume. You can also mount a WebDAV share from the Darwin terminal by using the <code class="literal">webdav</code> filesystem type with the <span class="command"><strong>mount</strong></span> command:</p><div class="informalexample"><pre class="screen"> $ mount -t webdav http://svn.example.com/repos/project /some/mountpoint $ </pre></div><p>Note that if your <span class="command"><strong>mod_dav_svn</strong></span> is older than version 1.2, OS X will refuse to mount the share as read/write; it will appear as read-only. This is because OS X insists on locking support for read/write shares, and the ability to lock files first appeared in Subversion 1.2.</p><p>Also, OS X's WebDAV client can sometimes be overly sensitive to HTTP redirects. If OS X is unable to mount the repository at all, you may need to enable the <code class="literal">BrowserMatch</code> directive in the Apache server's <code class="filename">httpd.conf</code>:</p><div class="informalexample"><pre class="programlisting"> BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully </pre></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="svn.webdav.clients.fs-impl.linux"></a>Linux davfs2</h4></div></div></div><p>Linux davfs2 is a filesystem module for the Linux kernel, whose development is organized at <a class="ulink" href="http://dav.sourceforge.net/" target="_top">http://dav.sourceforge.net/</a>. Once you install davfs2, you can mount a WebDAV network share using the usual Linux mount command:</p><div class="informalexample"><pre class="screen"> $ mount.davfs http://host/repos /mnt/dav </pre></div></div></div></div><div class="footnotes"><br></br><hr style="width:100; text-align:left;margin-left: 0"></hr><div id="ftn.idm15039" class="footnote"><p><a href="#idm15039" class="para"><sup class="para">[76] </sup></a>The Subversion developers colloquially refer to this deviation from the DeltaV standard as <span class="quote">“<span class="quote">HTTPv2</span>”</span>.</p></div><div id="ftn.idm15186" class="footnote"><p><a href="#idm15186" class="para"><sup class="para">[77] </sup></a>WebDAV support was removed from Microsoft Access for some reason, but it exists in the rest of the Office suite.</p></div></div></div><div class="appendix"><div class="titlepage"><div><div><h1 class="title"><a id="svn.copyright"></a>Appendix D. Copyright</h1></div></div></div><p>Copyright (c) 2002-2013 Ben Collins-Sussman, Brian W. Fitzpatrick, C. Michael Pilato.</p><p>This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit <a class="ulink" href="http://creativecommons.org/licenses/by/2.0/" target="_top">http://creativecommons.org/licenses/by/2.0/</a> or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.</p><p>A summary of the license is given below, followed by the full legal text.</p><pre class="programlisting"> You are free: * to copy, distribute, display, and perform the work * to make derivative works * to make commercial use of the work Under the following conditions: Attribution. You must give the original author credit. * For any reuse or distribution, you must make clear to others the license terms of this work. * Any of these conditions can be waived if you get permission from the author. Your fair use and other rights are in no way affected by the above. The above is a summary of the full license below. ==================================================================== Creative Commons Legal Code Attribution 2.0 CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM ITS USE. License THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 1. Definitions a. "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License. b. "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License. c. "Licensor" means the individual or entity that offers the Work under the terms of this License. d. "Original Author" means the individual or entity who created the Work. e. "Work" means the copyrightable work of authorship offered under the terms of this License. f. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. 2. Fair Use Rights. Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws. 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: a. to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works; b. to create and reproduce Derivative Works; c. to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works; d. to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works. e. For the avoidance of doubt, where the work is a musical composition: i. Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work. ii. Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights agency or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions). f. Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions). The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved. 4. Restrictions.The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: a. You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any reference to such Licensor or the Original Author, as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any reference to such Licensor or the Original Author, as requested. b. If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and give the Original Author credit reasonable to the medium or means You are utilizing by conveying the name (or pseudonym if applicable) of the Original Author if supplied; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit. 5. Representations, Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 7. Termination a. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. b. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 8. Miscellaneous a. Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. b. Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. c. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. d. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. e. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor. Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, neither party will use the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time. Creative Commons may be contacted at http://creativecommons.org/. ==================================================================== </pre></div><div class="index"><div class="titlepage"><div><div><h1 class="title"><a id="svn.index"></a>Index</h1></div></div></div><div xmlns:xlink="http://www.w3.org/1999/xlink" class="index"><div class="indexdiv"><h3>A</h3><dl><dt id="ientry-idm4389">ancestry, <a class="indexterm" href="#svn.branchmerge.advanced.ancestry">Noticing or Ignoring Ancestry</a></dt></dl></div><div class="indexdiv"><h3>B</h3><dl><dt id="ientry-idm2066">BASE, <a class="indexterm" href="#svn.tour.revs.keywords">Revision Keywords</a></dt><dt id="ientry-idm934">branches, <a class="indexterm" href="#svn.tour.importing.layout">Recommended Repository Layout</a>, <a class="indexterm" href="#svn.branchmerge.whatis">What's a Branch?</a></dt></dl></div><div class="indexdiv"><h3>C</h3><dl><dt id="ientry-idm724">checkout (see <a href="#ientry-idm438">working copy, creation</a>)</dt><dt id="ientry-idm134">CollabNet, <a class="indexterm" href="#svn.intro.history">Subversion's History</a></dt><dt id="ientry-idm2077">COMMITTED, <a class="indexterm" href="#svn.tour.revs.keywords">Revision Keywords</a></dt><dt id="ientry-idm746">committing (see <a href="#ientry-idm438">working copy, commit</a>)</dt><dt id="ientry-idm69">Concurrent Versions System, <a class="indexterm" href="#svn.preface">Preface</a></dt><dt id="ientry-idm505">conflicts, <a class="indexterm" href="#svn.basic.vsn-models.copy-merge">The copy-modify-merge solution</a></dt><dd><dl><dt>conflict markers, <a class="indexterm" href="#svn.tour.cycle.resolve.pending">Postponing conflict resolution</a></dt><dt>resolution, <a class="indexterm" href="#svn.tour.cycle.resolve.theirsfull">Discarding your changes in favor of a newly fetched revision</a></dt><dd><dl><dt>interactive, <a class="indexterm" href="#svn.tour.cycle.resolve.resolve">Resolving conflict differences interactively</a></dt><dt>manual, <a class="indexterm" href="#svn.tour.cycle.resolve.byhand">Merging conflicts by hand</a></dt><dt>postponing, <a class="indexterm" href="#svn.tour.cycle.resolve.pending">Postponing conflict resolution</a></dt></dl></dd><dt>resolving, <a class="indexterm" href="#svn.tour.cycle.resolve">Resolve Any Conflicts</a></dt><dt>reviewing, <a class="indexterm" href="#svn.tour.cycle.resolve.diff">Viewing conflict differences interactively</a></dt></dl></dd><dt id="ientry-idm71">CVS (see <a href="#ientry-idm69">Concurrent Versions System</a>)</dt></dl></div><div class="indexdiv"><h3>D</h3><dl><dt id="ientry-idm1173">delta, <a class="indexterm" href="#svn.tour.cycle.examine">Review Your Changes</a></dt></dl></div><div class="indexdiv"><h3>H</h3><dl><dt id="ientry-idm2054">HEAD, <a class="indexterm" href="#svn.tour.revs.keywords">Revision Keywords</a></dt></dl></div><div class="indexdiv"><h3>L</h3><dl><dt id="ientry-idm1158">log message, <a class="indexterm" href="#svn.tour.cycle.examine">Review Your Changes</a></dt></dl></div><div class="indexdiv"><h3>M</h3><dl><dt id="ientry-idm3684">merge tracking, <a class="indexterm" href="#svn.branchmerge.basicmerging">Basic Merging</a></dt><dt id="ientry-idm3732">mergeinfo, <a class="indexterm" href="#svn.branchemerge.basicmerging.stayinsync">Keeping a Branch in Sync</a></dt><dd><dl><dt>property, <a class="indexterm" href="#svn.branchmerge.basicmerging.mergeinfo">Mergeinfo and Previews</a></dt></dl></dd><dt id="ientry-idm3829">mergeinfo elision, <a class="indexterm" href="#svn.branchemerge.basicmerging.stayinsync.subtree">Subtree Merges and Subtree Mergeinfo</a></dt><dt id="ientry-idm3944">mergeinfo inheritance, <a class="indexterm" href="#svn.branchmerge.basicmerging.mergeinfo">Mergeinfo and Previews</a></dt><dt id="ientry-idm177">mod_dav_svn, <a class="indexterm" href="#svn.intro.components">Subversion's Components</a></dt></dl></div><div class="indexdiv"><h3>P</h3><dl><dt id="ientry-idm1285">patches, <a class="indexterm" href="#svn.tour.cycle.examine.diff">Examine the details of your local modifications</a></dt><dt id="ientry-idm2089">PREV, <a class="indexterm" href="#svn.tour.revs.keywords">Revision Keywords</a></dt><dt id="ientry-idm936">project root, <a class="indexterm" href="#svn.tour.importing.layout">Recommended Repository Layout</a>, <a class="indexterm" href="#svn.reposadmin.projects.chooselayout">Planning Your Repository Organization</a></dt><dt id="ientry-idm2272">properties, <a class="indexterm" href="#svn.advanced.props">Properties</a></dt></dl></div><div class="indexdiv"><h3>R</h3><dl><dt id="ientry-idm421">repository</dt><dd><dl><dt>defined, <a class="indexterm" href="#svn.basic.repository">The Repository</a></dt><dt>hooks</dt><dd><dl><dt>post-commit, <a class="indexterm" href="#svn.ref.reposhooks.post-commit">post-commit</a></dt><dt>post-lock, <a class="indexterm" href="#svn.ref.reposhooks.post-lock">post-lock</a></dt><dt>post-revprop-change, <a class="indexterm" href="#svn.ref.reposhooks.post-revprop-change">post-revprop-change</a></dt><dt>post-unlock, <a class="indexterm" href="#svn.ref.reposhooks.post-unlock">post-unlock</a></dt><dt>pre-commit, <a class="indexterm" href="#svn.ref.reposhooks.pre-commit">pre-commit</a></dt><dt>pre-lock, <a class="indexterm" href="#svn.ref.reposhooks.pre-lock">pre-lock</a></dt><dt>pre-revprop-change, <a class="indexterm" href="#svn.ref.reposhooks.pre-revprop-change">pre-revprop-change</a></dt><dt>pre-unlock, <a class="indexterm" href="#svn.ref.reposhooks.pre-unlock">pre-unlock</a></dt><dt>start-commit, <a class="indexterm" href="#svn.ref.reposhooks.start-commit">start-commit</a></dt></dl></dd></dl></dd><dt id="ientry-idm528">revisions</dt><dd><dl><dt>as dates, <a class="indexterm" href="#svn.tour.revs.dates">Revision Dates</a></dt><dt>defined, <a class="indexterm" href="#svn.basic.in-action.revs">Revisions</a></dt><dt>global, <a class="indexterm" href="#svn.basic.in-action.revs">Revisions</a></dt><dt>keywords, <a class="indexterm" href="#svn.tour.revs.keywords">Revision Keywords</a></dt><dd><dl><dt>BASE, <a class="indexterm" href="#svn.tour.revs.keywords">Revision Keywords</a></dt><dt>COMMITTED, <a class="indexterm" href="#svn.tour.revs.keywords">Revision Keywords</a></dt><dt>HEAD, <a class="indexterm" href="#svn.tour.revs.keywords">Revision Keywords</a></dt><dt>PREV, <a class="indexterm" href="#svn.tour.revs.keywords">Revision Keywords</a></dt></dl></dd></dl></dd></dl></div><div class="indexdiv"><h3>S</h3><dl><dt id="ientry-idm98">SCM (see <a href="#ientry-idm96">software configuration management</a>)</dt><dt id="ientry-idm96">software configuration management, <a class="indexterm" href="#svn.intro.whatis">What Is Subversion?</a></dt><dt id="ientry-idm3820">subtree merge, <a class="indexterm" href="#svn.branchemerge.basicmerging.stayinsync.subtree">Subtree Merges and Subtree Mergeinfo</a></dt><dt id="ientry-idm3822">subtree mergeinfo, <a class="indexterm" href="#svn.branchemerge.basicmerging.stayinsync.subtree">Subtree Merges and Subtree Mergeinfo</a></dt><dt id="ientry-idm84">Subversion</dt><dd><dl><dt>architecture, <a class="indexterm" href="#svn.intro.architecture">Subversion's Architecture</a></dt><dt>components, <a class="indexterm" href="#svn.intro.components">Subversion's Components</a></dt><dt>defined, <a class="indexterm" href="#svn.intro.whatis">What Is Subversion?</a></dt><dt>history of, <a class="indexterm" href="#svn.intro.history">Subversion's History</a>, <a class="indexterm" href="#svn.intro.whatsnew">What's New in Subversion</a></dt></dl></dd><dt id="ientry-idm169">svn, <a class="indexterm" href="#svn.intro.components">Subversion's Components</a></dt><dd><dl><dt>options, <a class="indexterm" href="#svn.tour.help">Help!</a></dt><dt>subcommands</dt><dd><dl><dt>add, <a class="indexterm" href="#svn.tour.cycle.edit">Make Your Changes </a>, <a class="indexterm" href="#svn.ref.svn.c.add">svn add</a></dt><dt>blame, <a class="indexterm" href="#svn.ref.svn.c.blame">svn blame (praise, annotate, ann)</a></dt><dt>cat, <a class="indexterm" href="#svn.ref.svn.c.cat">svn cat</a></dt><dt>changelist, <a class="indexterm" href="#svn.ref.svn.c.changelist">svn changelist (cl)</a></dt><dt>checkout, <a class="indexterm" href="#svn.basic.in-action.wc-funcdamentals">Fundamental working copy interactions</a>, <a class="indexterm" href="#svn.tour.initial">Creating a Working Copy</a>, <a class="indexterm" href="#svn.ref.svn.c.checkout">svn checkout (co)</a></dt><dt>cleanup, <a class="indexterm" href="#svn.ref.svn.c.cleanup">svn cleanup</a></dt><dt>commit, <a class="indexterm" href="#svn.basic.in-action.wc-funcdamentals">Fundamental working copy interactions</a>, <a class="indexterm" href="#svn.ref.svn.c.commit">svn commit (ci)</a></dt><dt>copy, <a class="indexterm" href="#svn.tour.cycle.edit">Make Your Changes </a>, <a class="indexterm" href="#svn.ref.svn.c.copy">svn copy (cp)</a></dt><dt>delete, <a class="indexterm" href="#svn.tour.cycle.edit">Make Your Changes </a>, <a class="indexterm" href="#svn.ref.svn.c.delete">svn delete (del, remove, rm)</a></dt><dt>diff, <a class="indexterm" href="#svn.tour.cycle.examine.diff">Examine the details of your local modifications</a>, <a class="indexterm" href="#svn.ref.svn.c.diff">svn diff (di)</a></dt><dt>export, <a class="indexterm" href="#svn.ref.svn.c.export">svn export</a></dt><dt>help, <a class="indexterm" href="#svn.tour.help">Help!</a>, <a class="indexterm" href="#svn.ref.svn.c.help">svn help (h, ?)</a></dt><dt>import, <a class="indexterm" href="#svn.tour.importing.import">Importing Files and Directories</a>, <a class="indexterm" href="#svn.ref.svn.c.import">svn import</a></dt><dt>info, <a class="indexterm" href="#svn.ref.svn.c.info">svn info</a></dt><dt>list, <a class="indexterm" href="#svn.ref.svn.c.list">svn list (ls)</a></dt><dt>lock, <a class="indexterm" href="#svn.ref.svn.c.lock">svn lock</a></dt><dt>log, <a class="indexterm" href="#svn.ref.svn.c.log">svn log</a></dt><dt>merge, <a class="indexterm" href="#svn.ref.svn.c.merge">svn merge</a></dt><dt>mergeinfo, <a class="indexterm" href="#svn.ref.svn.c.mergeinfo">svn mergeinfo</a></dt><dt>mkdir, <a class="indexterm" href="#svn.tour.cycle.edit">Make Your Changes </a>, <a class="indexterm" href="#svn.ref.svn.c.mkdir">svn mkdir</a></dt><dt>move, <a class="indexterm" href="#svn.tour.cycle.edit">Make Your Changes </a>, <a class="indexterm" href="#svn.ref.svn.c.move">svn move (mv)</a></dt><dt>patch, <a class="indexterm" href="#svn.ref.svn.c.patch">svn patch</a></dt><dt>propdel, <a class="indexterm" href="#svn.ref.svn.c.propdel">svn propdel (pdel, pd)</a></dt><dt>propedit, <a class="indexterm" href="#svn.ref.svn.c.propedit">svn propedit (pedit, pe)</a></dt><dt>propget, <a class="indexterm" href="#svn.ref.svn.c.propget">svn propget (pget, pg)</a></dt><dt>proplist, <a class="indexterm" href="#svn.ref.svn.c.proplist">svn proplist (plist, pl)</a></dt><dt>propset, <a class="indexterm" href="#svn.ref.svn.c.propset">svn propset (pset, ps)</a></dt><dt>relocate, <a class="indexterm" href="#svn.ref.svn.c.relocate">svn relocate</a></dt><dt>resolve, <a class="indexterm" href="#svn.ref.svn.c.resolve">svn resolve</a></dt><dt>resolved, <a class="indexterm" href="#svn.ref.svn.c.resolved">svn resolved</a></dt><dt>revert, <a class="indexterm" href="#svn.tour.cycle.revert">Fix Your Mistakes</a>, <a class="indexterm" href="#svn.ref.svn.c.revert">svn revert</a></dt><dt>status, <a class="indexterm" href="#svn.tour.cycle.examine.status">See an overview of your changes</a>, <a class="indexterm" href="#svn.ref.svn.c.status">svn status (stat, st)</a></dt><dt>switch, <a class="indexterm" href="#svn.ref.svn.c.switch">svn switch (sw)</a></dt><dt>unlock, <a class="indexterm" href="#svn.ref.svn.c.unlock">svn unlock</a></dt><dt>update, <a class="indexterm" href="#svn.basic.in-action.wc-funcdamentals">Fundamental working copy interactions</a>, <a class="indexterm" href="#svn.tour.cycle.update">Update Your Working Copy</a>, <a class="indexterm" href="#svn.ref.svn.c.update">svn update (up)</a></dt><dt>upgrade, <a class="indexterm" href="#svn.ref.svn.c.upgrade">svn upgrade</a></dt></dl></dd><dt>syntax</dt><dd><dl><dt>URLs, <a class="indexterm" href="#svn.advanced.reposurls">Addressing the Repository</a></dt></dl></dd></dl></dd><dt id="ientry-idm175">svnadmin, <a class="indexterm" href="#svn.intro.components">Subversion's Components</a></dt><dd><dl><dt>subcommands</dt><dd><dl><dt>crashtest, <a class="indexterm" href="#svn.ref.svnadmin.c.crashtest">svnadmin crashtest</a></dt><dt>create, <a class="indexterm" href="#svn.ref.svnadmin.c.create">svnadmin create</a></dt><dt>deltify, <a class="indexterm" href="#svn.ref.svnadmin.c.deltify">svnadmin deltify</a></dt><dt>dump, <a class="indexterm" href="#svn.ref.svnadmin.c.dump">svnadmin dump</a></dt><dt>help, <a class="indexterm" href="#svn.ref.svnadmin.c.help">svnadmin help (h, ?)</a></dt><dt>hotcopy, <a class="indexterm" href="#svn.ref.svnadmin.c.hotcopy">svnadmin hotcopy</a></dt><dt>list-dblogs, <a class="indexterm" href="#svn.ref.svnadmin.c.list-dblogs">svnadmin list-dblogs</a></dt><dt>list-unused-dblogs, <a class="indexterm" href="#svn.ref.svnadmin.c.list-unused-dblogs">svnadmin list-unused-dblogs</a></dt><dt>load, <a class="indexterm" href="#svn.ref.svnadmin.c.load">svnadmin load</a></dt><dt>lslocks, <a class="indexterm" href="#svn.ref.svnadmin.c.lslocks">svnadmin lslocks</a></dt><dt>lstxns, <a class="indexterm" href="#svn.ref.svnadmin.c.lstxns">svnadmin lstxns</a></dt><dt>pack, <a class="indexterm" href="#svn.ref.svnadmin.c.pack">svnadmin pack</a></dt><dt>recover, <a class="indexterm" href="#svn.ref.svnadmin.c.recover">svnadmin recover</a></dt><dt>rmlocks, <a class="indexterm" href="#svn.ref.svnadmin.c.rmlocks">svnadmin rmlocks</a></dt><dt>rmtxns, <a class="indexterm" href="#svn.ref.svnadmin.c.rmtxns">svnadmin rmtxns</a></dt><dt>setlog, <a class="indexterm" href="#svn.ref.svnadmin.c.setlog">svnadmin setlog</a></dt><dt>setrevprop, <a class="indexterm" href="#svn.ref.svnadmin.c.setrevprop">svnadmin setrevprop</a></dt><dt>setuuid, <a class="indexterm" href="#svn.ref.svnadmin.c.setuuid">svnadmin setuuid</a></dt><dt>upgrade, <a class="indexterm" href="#svn.ref.svnadmin.c.upgrade">svnadmin upgrade</a></dt><dt>verify, <a class="indexterm" href="#svn.ref.svnadmin.c.verify">svnadmin verify</a></dt></dl></dd></dl></dd><dt id="ientry-idm181">svndumpfilter, <a class="indexterm" href="#svn.intro.components">Subversion's Components</a></dt><dd><dl><dt>subcommands</dt><dd><dl><dt>exclude, <a class="indexterm" href="#svn.ref.svndumpfilter.commands.c.exclude">svndumpfilter exclude</a></dt><dt>help, <a class="indexterm" href="#svn.ref.svndumpfilter.commands.c.help">svndumpfilter help</a></dt><dt>include, <a class="indexterm" href="#svn.ref.svndumpfilter.commands.c.include">svndumpfilter include</a></dt></dl></dd></dl></dd><dt id="ientry-idm173">svnlook, <a class="indexterm" href="#svn.intro.components">Subversion's Components</a></dt><dd><dl><dt>subcommands</dt><dd><dl><dt>author, <a class="indexterm" href="#svn.ref.svnlook.c.author">svnlook author</a></dt><dt>cat, <a class="indexterm" href="#svn.ref.svnlook.c.cat">svnlook cat</a></dt><dt>changed, <a class="indexterm" href="#svn.ref.svnlook.c.changed">svnlook changed</a></dt><dt>date, <a class="indexterm" href="#svn.ref.svnlook.c.date">svnlook date</a></dt><dt>diff, <a class="indexterm" href="#svn.ref.svnlook.c.diff">svnlook diff</a></dt><dt>dirs-changed, <a class="indexterm" href="#svn.ref.svnlook.c.dirs-changed">svnlook dirs-changed</a></dt><dt>filesize, <a class="indexterm" href="#svn.ref.svnlook.c.filesize">svnlook filesize</a></dt><dt>help, <a class="indexterm" href="#svn.ref.svnlook.c.help">svnlook help (h, ?)</a></dt><dt>history, <a class="indexterm" href="#svn.ref.svnlook.c.history">svnlook history</a></dt><dt>info, <a class="indexterm" href="#svn.ref.svnlook.c.info">svnlook info</a></dt><dt>lock, <a class="indexterm" href="#svn.ref.svnlook.c.lock">svnlook lock</a></dt><dt>log, <a class="indexterm" href="#svn.ref.svnlook.c.log">svnlook log</a></dt><dt>propget, <a class="indexterm" href="#svn.ref.svnlook.c.propget">svnlook propget (pget, pg)</a></dt><dt>proplist, <a class="indexterm" href="#svn.ref.svnlook.c.proplist">svnlook proplist (plist, pl)</a></dt><dt>tree, <a class="indexterm" href="#svn.ref.svnlook.c.tree">svnlook tree</a></dt><dt>uuid, <a class="indexterm" href="#svn.ref.svnlook.c.uuid">svnlook uuid</a></dt><dt>youngest, <a class="indexterm" href="#svn.ref.svnlook.c.youngest">svnlook youngest</a></dt></dl></dd></dl></dd><dt id="ientry-idm13508">svnrdump</dt><dd><dl><dt>subcommands</dt><dd><dl><dt>dump, <a class="indexterm" href="#svn.ref.svnrdump.c.dump">svnrdump dump</a></dt><dt>help, <a class="indexterm" href="#svn.ref.svnrdump.c.help">svnrdump help</a></dt><dt>load, <a class="indexterm" href="#svn.ref.svnrdump.c.load">svnrdump load</a></dt></dl></dd></dl></dd><dt id="ientry-idm179">svnserve, <a class="indexterm" href="#svn.intro.components">Subversion's Components</a></dt><dt id="ientry-idm183">svnsync, <a class="indexterm" href="#svn.intro.components">Subversion's Components</a></dt><dd><dl><dt>subcommands</dt><dd><dl><dt>copy-revprops, <a class="indexterm" href="#svn.ref.svnsync.c.copy-revprops">svnsync copy-revprops</a></dt><dt>help, <a class="indexterm" href="#svn.ref.svnsync.c.help">svnsync help</a></dt><dt>info, <a class="indexterm" href="#svn.ref.svnsync.c.info">svnsync info</a></dt><dt>initialize, <a class="indexterm" href="#svn.ref.svnsync.c.init">svnsync initialize (init)</a></dt><dt>synchronize, <a class="indexterm" href="#svn.ref.svnsync.c.sync">svnsync synchronize (sync)</a></dt></dl></dd><dt>syntax</dt><dd><dl><dt>URLs, <a class="indexterm" href="#svn.advanced.reposurls">Addressing the Repository</a></dt></dl></dd></dl></dd><dt id="ientry-idm171">svnversion, <a class="indexterm" href="#svn.intro.components">Subversion's Components</a>, <a class="indexterm" href="#svn.ref.svnversion.re">svnversion</a></dt></dl></div><div class="indexdiv"><h3>T</h3><dl><dt id="ientry-idm932">tags, <a class="indexterm" href="#svn.tour.importing.layout">Recommended Repository Layout</a>, <a class="indexterm" href="#svn.branchmerge.tags">Tags</a></dt><dt id="ientry-idm1171">text-base, <a class="indexterm" href="#svn.tour.cycle.examine">Review Your Changes</a></dt><dt id="ientry-idm930">trunk, <a class="indexterm" href="#svn.tour.importing.layout">Recommended Repository Layout</a></dt></dl></div><div class="indexdiv"><h3>U</h3><dl><dt id="ientry-idm1271">unified diff, <a class="indexterm" href="#svn.tour.cycle.examine.diff">Examine the details of your local modifications</a></dt><dt id="ientry-idm766">updating (see <a href="#ientry-idm438">working copy, update</a>)</dt></dl></div><div class="indexdiv"><h3>V</h3><dl><dt id="ientry-idm89">VCS (see <a href="#ientry-idm87">version control systems</a>)</dt><dt id="ientry-idm464">version control</dt><dd><dl><dt>models</dt><dd><dl><dt>copy-modify-merge, <a class="indexterm" href="#svn.basic.vsn-models.copy-merge">The copy-modify-merge solution</a></dt><dt>lock-modify-unlock, <a class="indexterm" href="#svn.basic.vsn-models.lock-unlock">The lock-modify-unlock solution</a></dt></dl></dd></dl></dd><dt id="ientry-idm87">version control systems, <a class="indexterm" href="#svn.intro.whatis">What Is Subversion?</a>, <a class="indexterm" href="#svn.basic.version-control-basics">Version Control Basics</a></dt></dl></div><div class="indexdiv"><h3>W</h3><dl><dt id="ientry-idm438">working copy</dt><dd><dl><dt>commit, <a class="indexterm" href="#svn.basic.in-action.wc-funcdamentals">Fundamental working copy interactions</a></dt><dt>creation, <a class="indexterm" href="#svn.basic.in-action.wc-funcdamentals">Fundamental working copy interactions</a></dt><dt>defined, <a class="indexterm" href="#svn.basic.working-copy">The Working Copy</a>, <a class="indexterm" href="#svn.basic.in-action.wc">Subversion Working Copies</a></dt><dt>mixed-revision, <a class="indexterm" href="#svn.basic.in-action.mixedrevs">Mixed-revision working copies</a></dt><dt>update, <a class="indexterm" href="#svn.basic.in-action.wc-funcdamentals">Fundamental working copy interactions</a></dt></dl></dd></dl></div></div></div></div></body></html>

Pages: 1 2 3 4 5 6 7 8 9 10