Subversion Version Control
Total Page:16
File Type:pdf, Size:1020Kb
i “svnbook” — 2005/4/14 — 14:55 — page i — #1 i i i Subversion Version Control i i i i perens_series_7x9.25.fm Page 1 Tuesday, March 29, 2005 4:29 PM BRUCE PERENS’ OPEN SOURCE SERIES http://www.phptr.com/perens ◆ Java™ Application Development on Linux® Carl Albing and Michael Schwarz ◆ C++ GUI Programming with Qt 3 Jasmin Blanchette and Mark Summerfield ◆ Managing Linux Systems with Webmin: System Administration and Module Development Jamie Cameron ◆ The Linux Book David Elboth ◆ Understanding the Linux Virtual Memory Manager Mel Gorman ◆ PHP 5 Power Programming Andi Gutmans, Stig Bakken, and Derick Rethans ◆ Linux® Quick Fix Notebook Peter Harrison ◆ Linux Desk Reference, Second Edition Scott Hawkins ◆ Implementing CIFS: The Common Internet File System Christopher Hertel ◆ Open Source Security Tools: A Practical Guide to Security Applications Tony Howlett ◆ Apache Jakarta CommonsReusable Java™ Components Will Iverson ◆ Embedded Software Development with eCos Anthony Massa ◆ Rapid Application Development with Mozilla Nigel McFarlane ◆ Subversion Version Control: Using the Subversion Version Control System in Development Projects William Nagel ◆ Linux Assembly Language Programming Bob Neveln ◆ Intrusion Detection with SNORT: Advanced IDS Techniques Using SNORT, Apache, MySQL, PHP, and ACID Rafeeq Ur Rehman ◆ Cross-Platform GUI Programming with wxWidgets Julian Smart and Kevin Hock with Stefan Csomor ◆ Samba-3 by Example: Practical Exercises to Successful Deployment John H. Terpstra ◆ The Official Samba-3 HOWTO and Reference Guide John H. Terpstra and Jelmer R. Vernooij, Editors ◆ Real World Linux Security, Second Edition Bob Toxen i “svnbook” — 2005/4/14 — 14:55 — page iii — #2 i i i Subversion Version Control Using The Subversion Version Control System in Development Projects William Nagel Prentice Hall Professional Technical Reference Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City i i i i i “svnbook” — 2005/4/14 — 14:55 — page iv — #3 i i i Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trade- mark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 [email protected] For sales outside the U.S., please contact: International Sales [email protected] Visit us on the Web: www.phptr.com Library of Congress Cataloging-in-Publication Data Nagel, William A. Subversion version control : using the Subversion version control system in development projects / William Nagel. p. cm. Includes index. ISBN 0-13-185518-2 (pbk. : alk. paper) 1. Computer software–Development. 2. Open source software. I. Title. QA76.76.D47N35 2005 005.1–dc22 2005005872 Copyright © 2005 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copy- right, and permission must be obtained from the publisher prior to any prohibited reproduction, stor- age in a retrieval system, or transmission in any form or by any means, electronic, mechanical, pho- tocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc. Rights and Contracts Department One Lake Street Upper Saddle River, NJ 07458 ISBN 0-13-185518-2 Text printed in the United States on recycled paper at Courier in Stoughton, Massachusetts. First printing, May 2005 i i i i i “svnbook” — 2005/4/14 — 14:55 — page i — #4 i i i To Sara, and the wonderful life we’ll have together i i i i i “svnbook” — 2005/4/14 — 14:55 — page ii — #5 i i i i i i i i “svnbook” — 2005/4/14 — 14:55 — page vii — #6 i i i Contents Preface xvii Acknowledgments xxi Part I An Introduction to Version Control and Subversion 1 Chapter 1 An Introduction to Version Control 3 1.1 What Is Version Control? 4 1.2 Why Use It? 4 1.2.1 Data Integrity 4 1.2.2 Productivity 5 1.2.3 Accountability 5 1.2.4 Software Engineering Process Support 5 1.2.5 Development Branching 6 1.2.6 Record Keeping 6 1.2.7 Distribution of Work 6 1.2.8 Rapid Development 7 1.3 The Elements of Version Control 7 1.3.1 The Repository and Working Directory 7 1.3.2 Revisions 8 1.3.3 Logs 9 1.3.4 Tagging 10 1.3.5 Branching 10 1.3.6 Locking versus Merging 11 1.4 Summary 12 vii i i i i i “svnbook” — 2005/4/14 — 14:55 — page viii — #7 i i i viii Contents Chapter 2 An Introduction to Subversion 15 2.1 Why Subversion? 15 2.1.1 A Software Engineering Tool 15 2.1.2 Open Source Solutions 16 2.1.3 Major Features of SVN 17 2.2 Limitations of Subversion 21 2.3 Summary 23 Chapter 3 Installing Subversion 25 3.1 Installing on Linux 25 3.1.1 Subversion’s Prerequisites 25 3.1.2 Downloading the Source 27 3.1.3 Compiling and Installing 27 3.2 Installing on Mac OS X 29 3.2.1 Installing OS X Binaries 29 3.2.2 Compiling Subversion on OS X 29 3.2.3 Using Fink 30 3.3 Installing on Windows 30 3.4 Configuring SVN to Use Apache 31 3.4.1 Loading the Modules 31 3.4.2 Setting Up Access 32 3.4.3 Using Apache 2 and Apache 1 Together 33 3.5 Configuring to Use Svnserve 34 3.5.1 Running as a Daemon 34 3.5.2 Running with inetd 35 3.5.3 Tunneling over SSH 36 3.6 Summary 36 Chapter 4 Basic Subversion Usage 37 4.1 Creating the Repository 37 4.2 Getting Files into the Repository 38 4.3 Creating a Working Copy 40 4.4 Editing Files 40 4.5 Committing Changes 42 4.6 Viewing the Logs 42 4.7 Creating a Tag 43 4.8 Creating a Branch 44 i i i i i “svnbook” — 2005/4/14 — 14:55 — page ix — #8 i i i Contents ix 4.9 Merging a Branch 46 4.10 Handling Conflicts 48 4.11 Summary 51 Part II Subversion from a Client User’s Perspective 53 Chapter 5 Working with a Working Copy 55 5.1 The Subversion Client 55 5.1.1 Common Command Options 56 5.1.2 Paths 57 5.2 Checking Out and Maintaining a Working Copy 57 5.2.1 Keeping Up-to-Date 59 5.3 Modifying and Committing Data 61 5.3.1 Adding New Files 63 5.3.2 Removing Files 64 5.3.3 Moving Things Around 65 5.4 Getting Information about the Repository 67 5.4.1 Getting Information on the Current State 67 5.4.2 Getting the Repository’s History 72 5.5 Changing the Working Copy Target 76 5.6 Resolving Conflicts 76 5.7 Branching, Tagging, and Merging 78 5.7.1 Creating a Branch or Tag 78 5.7.2 Merging a Branch 80 5.8 Troubleshooting the Working Copy 82 5.9 Summary 83 Chapter 6 Using Properties 85 6.1 Storing Metadata 85 6.1.1 Editing Properties 86 6.1.2 Automatically Setting Properties 86 6.1.3 Committing Properties 87 6.1.4 Storing Revision Properties 87 6.2 Retrieving Metadata 87 6.2.1 Listing Properties 88 6.2.2 Outputting Multiple Binary Properties 89 6.2.3 Getting Revision Properties 89 i i i i i “svnbook” — 2005/4/14 — 14:55 — page x — #9 i i i x Contents 6.3 Built-in Properties 90 6.3.1 File Properties 90 6.3.2 Revision Properties 95 6.4 Summary 96 Chapter 7 Configuring the Client 97 7.1 Finding the Configuration Files 97 7.2 Editing the Configuration Files 97 7.2.1 The config File 98 7.2.2 The servers File 101 7.3 Summary 104 Chapter 8 Integrating with Other Tools 105 8.1 Accessing SVN through a GUI Client 105 8.1.1 RapidSVN 105 8.1.2 TortoiseSVN 107 8.1.3 ViewCVS 108 8.1.4 WebSVN 110 8.2 Accessing Directly from an IDE 111 8.2.1 Visual Studio.Net 111 8.2.2 Eclipse 112 8.3 Using Autoversioning with WebDAV 114 8.4 Summary 116 Part III Subversion from an Administrator’s Perspective 117 Chapter 9 Organizing Your Repository 119 9.1 Laying Out the Repository 119 9.1.1 The Two Basic Layouts 119 9.1.2 Organizing the Trunk 121 9.1.3 Organizing Branches 122 9.1.4 Organizing Tags 124 9.2 Planning for Growth 126 9.2.1 Merging and Splitting a Repository 127 9.3 Migrating an Existing Repository 129 9.3.1 The Basic Migration Process 130 9.3.2 Migrating from CVS 130 i i i i i “svnbook” — 2005/4/14 — 14:55 — page xi — #10 i i i Contents xi 9.3.3 Migrating from SourceSafe 133 9.3.4 Migrating from Other VCSs 134 9.3.5 What If There’s No Migration Tool? 134 9.4 Summary 136 Chapter 10 Administrating the Repository 137 10.1 Controlling Access to the Repository 137 10.1.1 Direct Access Control 138 10.1.2 svnserve Access Control 138 10.1.3 HTTP/HTTPS Access Control 140 10.1.4 Authenticating against a Windows Domain Controller 146 10.2 Backing Up the Repository 149 10.2.1 Hotcopying the Repository 149 10.2.2 Dumping the Repository 150 10.2.3 Automating Your Backups 151 10.2.4 Recovering 153 10.3 Unwedging Your Repository 154 10.4 Upgrading Subversion 156 10.5 Summary 156 Chapter 11 The Joy of Automation 159 11.1 An Introduction to Hooks 160 11.1.1 Available Hook Scripts 160 11.1.2 What a Hook Script Can Do 162 11.1.3 What a Hook Script Can’t Do 163 11.1.4 Tips for a Good Hook Script 164 11.1.5 The Pre-made Subversion Scripts 167 11.2 Making the Most of Hook Scripts 167 11.2.1 Automatically Send E-mails