Version Control with Subversion
For Subversion 1.7
(Compiled from r4230)
Ben Collins-Sussman
Brian W. Fitzpatrick
C. Michael Pilato
Version Control with Subversion: For Subversion 1.7: (Compiled from r4230)
by Ben Collins-Sussman, Brian W. Fitzpatrick, and C. Michael Pilato
Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ben Collins-Sussman, Brian W. Fitzpatrick, C. Michael
Pilato
This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.0/ or send a
letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Table of Contents
Foreword .....................................................................................................................................................xii
Preface ....................................................................................................................................................... xiv
What Is Subversion? ............................................................................................................................. xiv
Is Subversion the Right Tool? ......................................................................................................... xiv
Subversion's History ......................................................................................................................xv
Subversion's Architecture ...............................................................................................................xv
Subversion's Components ............................................................................................................. xvii
What's New in Subversion ............................................................................................................ xvii
Audience .......................................................................................................................................... xviii
How to Read This Book ...................................................................................................................... xviii
Organization of This Book .....................................................................................................................xix
This Book Is Free .................................................................................................................................. xx
Acknowledgments ................................................................................................................................ xxi
1. Fundamental Concepts ................................................................................................................................. 1
Version Control Basics ............................................................................................................................ 1
The Repository .............................................................................................................................. 1
The Working Copy ......................................................................................................................... 2
Versioning Models ......................................................................................................................... 2
Version Control the Subversion Way ......................................................................................................... 7
Subversion Repositories .................................................................................................................. 7
Revisions ...................................................................................................................................... 7
Addressing the Repository ............................................................................................................... 8
Subversion Working Copies ............................................................................................................. 9
Summary .............................................................................................................................................14
2. Basic Usage ..............................................................................................................................................15
Help! ..................................................................................................................................................15
Getting Data into Your Repository ...........................................................................................................16
Importing Files and Directories ........................................................................................................16
Recommended Repository Layout ....................................................................................................17
What's In a Name? ........................................................................................................................ 17
Creating a Working Copy .......................................................................................................................18
Basic Work Cycle .................................................................................................................................19
Update Your Working Copy ............................................................................................................20
Make Your Changes ......................................................................................................................20
Review Your Changes ...................................................................................................................22
Fix Your Mistakes .........................................................................................................................25
Resolve Any Conflicts ...................................................................................................................26
Commit Your Changes ...................................................................................................................33
Examining History ................................................................................................................................34
Examining the Details of Historical Changes ......................................................................................34
Generating a List of Historical Changes .............................................................................................36
Browsing the Repository ................................................................................................................38
Fetching Older Repository Snapshots ................................................................................................39
Sometimes You Just Need to Clean Up ..................................................................................................... 40
Disposing of a Working Copy .........................................................................................................40
Recovering from an Interruption ......................................................................................................40
Dealing with Structural Conflicts .............................................................................................................41
An Example Tree Conflict ..............................................................................................................41
Summary .............................................................................................................................................46
3. Advanced Topics .......................................................................................................................................47
Revision Specifiers ................................................................................................................................47
Revision Keywords .......................................................................................................................47
Revision Dates .............................................................................................................................48
iv
Peg and Operative Revisions ...................................................................................................................49
Properties ............................................................................................................................................53
Why Properties? ........................................................................................................................... 54
Manipulating Properties ................................................................................................................. 55
Properties and the Subversion Workflow ...........................................................................................58
Automatic Property Setting ............................................................................................................. 60
File Portability ...................................................................................................................................... 61
File Content Type .........................................................................................................................61
File Executability .......................................................................................................................... 62
End-of-Line Character Sequences ....................................................................................................62
Ignoring Unversioned Items .................................................................................................................... 63
Keyword Substitution ............................................................................................................................67
Sparse Directories .................................................................................................................................70
Locking ...............................................................................................................................................75
Creating Locks .............................................................................................................................76
Discovering Locks ........................................................................................................................78
Breaking and Stealing Locks ...........................................................................................................79
Lock Communication .....................................................................................................................81
Externals Definitions ............................................................................................................................. 82
Changelists ..........................................................................................................................................88
Creating and Modifying Changelists .................................................................................................88
Changelists As Operation Filters ......................................................................................................90
Changelist Limitations ...................................................................................................................92
Network Model ....................................................................................................................................92
Requests and Responses ................................................................................................................. 92
Client Credentials ..........................................................................................................................93
Summary ............................................................................................................................................. 95
4. Branching and Merging .............................................................................................................................. 96
What's a Branch? ..................................................................................................................................96
Using Branches ....................................................................................................................................96
Creating a Branch .........................................................................................................................98
Working with Your Branch .............................................................................................................99
The Key Concepts Behind Branching .............................................................................................. 102
Basic Merging .................................................................................................................................... 102
Changesets ................................................................................................................................ 102
Keeping a Branch in Sync ............................................................................................................. 103
Reintegrating a Branch ................................................................................................................. 108
Mergeinfo and Previews ............................................................................................................... 110
Undoing Changes ........................................................................................................................ 113
Resurrecting Deleted Items ........................................................................................................... 114
Advanced Merging .............................................................................................................................. 116
Cherrypicking ............................................................................................................................ 116
Merge Syntax: Full Disclosure ....................................................................................................... 118
Merges Without Mergeinfo ........................................................................................................... 119
More on Merge Conflicts .............................................................................................................. 120
Blocking Changes ....................................................................................................................... 122
Keeping a Reintegrated Branch Alive ............................................................................................. 123
Merge-Sensitive Logs and Annotations ........................................................................................... 124
Noticing or Ignoring Ancestry ....................................................................................................... 126
Merges and Moves ...................................................................................................................... 127
Blocking Merge-Unaware Clients .................................................................................................. 127
The Final Word on Merge Tracking ................................................................................................ 128
Traversing Branches ............................................................................................................................ 129
Tags ................................................................................................................................................. 131
Creating a Simple Tag .................................................................................................................. 131
Creating a Complex Tag ............................................................................................................... 131
Branch Maintenance ............................................................................................................................ 132
Repository Layout ....................................................................................................................... 132
Version Control with Subversion
v