Distributed Revision Control with Mercurial

Total Page:16

File Type:pdf, Size:1020Kb

Distributed Revision Control with Mercurial Distributed revision control with Mercurial Bryan O’Sullivan Copyright c 2006, 2007 Bryan O’Sullivan. This material may be distributed only subject to the terms and conditions set forth in version 1.0 of the Open Publication License. Please refer to Appendix D for the license text. This book was prepared from rev 028543f67bea, dated 2008-08-20 15:27 -0700, using rev a58a611c320f of Mercurial. Contents Contents i Preface 2 0.1 This book is a work in progress ...................................... 2 0.2 About the examples in this book ..................................... 2 0.3 Colophon—this book is Free ....................................... 2 1 Introduction 3 1.1 About revision control .......................................... 3 1.1.1 Why use revision control? .................................... 3 1.1.2 The many names of revision control ............................... 4 1.2 A short history of revision control .................................... 4 1.3 Trends in revision control ......................................... 5 1.4 A few of the advantages of distributed revision control ......................... 5 1.4.1 Advantages for open source projects ............................... 6 1.4.2 Advantages for commercial projects ............................... 6 1.5 Why choose Mercurial? .......................................... 7 1.6 Mercurial compared with other tools ................................... 7 1.6.1 Subversion ............................................ 7 1.6.2 Git ................................................ 8 1.6.3 CVS ................................................ 8 1.6.4 Commercial tools ......................................... 9 1.6.5 Choosing a revision control tool ................................. 9 1.7 Switching from another tool to Mercurial ................................ 9 2 A tour of Mercurial: the basics 10 2.1 Installing Mercurial on your system ................................... 10 2.1.1 Linux ............................................... 10 2.1.2 Solaris .............................................. 10 2.1.3 Mac OS X ............................................ 11 2.1.4 Windows ............................................. 11 2.2 Getting started ............................................... 11 2.2.1 Built-in help ........................................... 11 2.3 Working with a repository ........................................ 12 2.3.1 Making a local copy of a repository ............................... 12 2.3.2 What’s in a repository? ...................................... 12 2.4 A tour through history .......................................... 13 2.4.1 Changesets, revisions, and talking to other people ........................ 14 2.4.2 Viewing specific revisions .................................... 15 2.4.3 More detailed information .................................... 16 i 2.5 All about command options ........................................ 16 2.6 Making and reviewing changes ...................................... 17 2.7 Recording changes in a new changeset .................................. 18 2.7.1 Setting up a username ...................................... 18 2.7.2 Writing a commit message .................................... 19 2.7.3 Writing a good commit message ................................. 19 2.7.4 Aborting a commit ........................................ 20 2.7.5 Admiring our new handiwork .................................. 20 2.8 Sharing changes .............................................. 20 2.8.1 Pulling changes from another repository ............................. 20 2.8.2 Updating the working directory ................................. 21 2.8.3 Pushing changes to another repository .............................. 23 2.8.4 Sharing changes over a network ................................. 23 3 A tour of Mercurial: merging work 25 3.1 Merging streams of work ......................................... 25 3.1.1 Head changesets ......................................... 27 3.1.2 Performing the merge ...................................... 28 3.1.3 Committing the results of the merge ............................... 29 3.2 Merging conflicting changes ....................................... 29 3.2.1 Using a graphical merge tool ................................... 30 3.2.2 A worked example ........................................ 30 3.3 Simplifying the pull-merge-commit sequence .............................. 33 4 Behind the scenes 35 4.1 Mercurial’s historical record ....................................... 35 4.1.1 Tracking the history of a single file ............................... 35 4.1.2 Managing tracked files ...................................... 35 4.1.3 Recording changeset information ................................ 35 4.1.4 Relationships between revisions ................................. 35 4.2 Safe, efficient storage ........................................... 36 4.2.1 Efficient storage ......................................... 37 4.2.2 Safe operation .......................................... 37 4.2.3 Fast retrieval ........................................... 37 4.2.4 Identification and strong integrity ................................ 38 4.3 Revision history, branching, and merging ................................ 38 4.4 The working directory .......................................... 38 4.4.1 What happens when you commit ................................. 39 4.4.2 Creating a new head ....................................... 39 4.4.3 Merging heads .......................................... 39 4.5 Other interesting design features ..................................... 40 4.5.1 Clever compression ........................................ 40 4.5.2 Read/write ordering and atomicity ................................ 41 4.5.3 Concurrent access ........................................ 41 4.5.4 Avoiding seeks .......................................... 41 4.5.5 Other contents of the dirstate ................................... 42 5 Mercurial in daily use 47 5.1 Telling Mercurial which files to track ................................... 47 5.1.1 Explicit versus implicit file naming ............................... 47 5.1.2 Aside: Mercurial tracks files, not directories ........................... 48 5.2 How to stop tracking a file ........................................ 49 ii 5.2.1 Removing a file does not affect its history ............................ 49 5.2.2 Missing files ........................................... 49 5.2.3 Aside: why tell Mercurial explicitly to remove a file? ...................... 50 5.2.4 Useful shorthand—adding and removing files in one step .................... 50 5.3 Copying files ............................................... 50 5.3.1 The results of copying during a merge .............................. 51 5.3.2 Why should changes follow copies? ............................... 52 5.3.3 How to make changes not follow a copy ............................. 52 5.3.4 Behaviour of the “hg copy” command ............................. 52 5.4 Renaming files .............................................. 53 5.4.1 Renaming files and merging changes .............................. 54 5.4.2 Divergent renames and merging ................................. 54 5.4.3 Convergent renames and merging ................................ 55 5.4.4 Other name-related corner cases ................................. 55 5.5 Recovering from mistakes ........................................ 55 6 Collaborating with other people 57 6.1 Mercurial’s web interface ......................................... 57 6.2 Collaboration models ........................................... 57 6.2.1 Factors to keep in mind ...................................... 57 6.2.2 Informal anarchy ......................................... 58 6.2.3 A single central repository .................................... 58 6.2.4 Working with multiple branches ................................. 58 6.2.5 Feature branches ......................................... 61 6.2.6 The release train ......................................... 61 6.2.7 The Linux kernel model ..................................... 61 6.2.8 Pull-only versus shared-push collaboration ........................... 62 6.2.9 Where collaboration meets branch management ......................... 62 6.3 The technical side of sharing ....................................... 62 6.4 Informal sharing with “hg serve” .................................... 62 6.4.1 A few things to keep in mind ................................... 63 6.5 Using the Secure Shell (ssh) protocol ................................... 63 6.5.1 How to read and write ssh URLs ................................. 63 6.5.2 Finding an ssh client for your system .............................. 64 6.5.3 Generating a key pair ....................................... 64 6.5.4 Using an authentication agent .................................. 65 6.5.5 Configuring the server side properly ............................... 65 6.5.6 Using compression with ssh ................................... 66 6.6 Serving over HTTP using CGI ...................................... 67 6.6.1 Web server configuration checklist ................................ 67 6.6.2 Basic CGI configuration ..................................... 67 6.6.3 Sharing multiple repositories with one CGI script ........................ 69 6.6.4 Downloading source archives .................................. 70 6.6.5 Web configuration options .................................... 70 7 File names and pattern matching 73 7.1 Simple file naming ...........................................
Recommended publications
  • Pragmatic Version Control Using Subversion
    What readers are saying about Pragmatic Version Control using Subversion I expected a lot, but you surprised me with even more. Hav- ing used CVS for years I hesitated to try Subversion until now, although I knew it would solve many of the shortcom- ings of CVS. After reading your book, my excuses to stay with CVS disappeared. Oh, and coming from the Pragmatic Bookshelf this book is fun to read too. Thanks Mike. Steffen Gemkow Managing Director, ObjectFab GmbH I’m a long-time user of CVS and I’ve been skeptical of Sub- version, wondering if it would ever be “ready for prime time.” Until now. Thanks to Mike Mason for writing a clear, con- cise, gentle introduction to this new tool. After reading this book, I’m actually excited about the possibilities for version control that Subversion brings to the table. David Rupp Senior Software Engineer, Great-West Life & Annuity This was exactly the Subversion book I was waiting for. As a long-time Perforce and CVS user and administrator, and in my role as an agile tools coach, I wanted a compact book that told me just what I needed to know. This is it. Within a couple of hours I was up and running against remote Subversion servers, and setting up my own local servers too. Mike uses a lot of command-line examples to guide the reader, and as a Windows user I was worried at first. My fears were unfounded though—Mike’s examples were so clear that I think I’ll stick to using the command line from now on! I thoroughly recommend this book to anyone getting started using or administering Subversion.
    [Show full text]
  • Debian Developer's Reference Version 12.0, Released on 2021-09-01
    Debian Developer’s Reference Release 12.0 Developer’s Reference Team 2021-09-01 CONTENTS 1 Scope of This Document 3 2 Applying to Become a Member5 2.1 Getting started..............................................5 2.2 Debian mentors and sponsors......................................6 2.3 Registering as a Debian member.....................................6 3 Debian Developer's Duties 9 3.1 Package Maintainer's Duties.......................................9 3.1.1 Work towards the next stable release............................9 3.1.2 Maintain packages in stable .................................9 3.1.3 Manage release-critical bugs.................................. 10 3.1.4 Coordination with upstream developers............................ 10 3.2 Administrative Duties.......................................... 10 3.2.1 Maintaining your Debian information............................. 11 3.2.2 Maintaining your public key.................................. 11 3.2.3 Voting.............................................. 11 3.2.4 Going on vacation gracefully.................................. 12 3.2.5 Retiring............................................. 12 3.2.6 Returning after retirement................................... 13 4 Resources for Debian Members 15 4.1 Mailing lists............................................... 15 4.1.1 Basic rules for use....................................... 15 4.1.2 Core development mailing lists................................. 15 4.1.3 Special lists........................................... 16 4.1.4 Requesting new
    [Show full text]
  • Version Control 101 Exported from Please Visit the Link for the Latest Version and the Best Typesetting
    Version Control 101 Exported from http://cepsltb4.curent.utk.edu/wiki/efficiency/vcs, please visit the link for the latest version and the best typesetting. Version Control 101 is created in the hope to minimize the regret from lost files or untracked changes. There are two things I regret. I should have learned Python instead of MATLAB, and I should have learned version control earlier. Version control is like a time machine. It allows you to go back in time and find out history files. You might have heard of GitHub and Git and probably how steep the learning curve is. Version control is not just Git. Dropbox can do version control as well, for a limited time. This tutorial will get you started with some version control concepts from Dropbox to Git for your needs. More importantly, some general rules are suggested to minimize the chance of file losses. Contents Version Control 101 .............................................................................................................................. 1 General Rules ................................................................................................................................... 2 Version Control for Files ................................................................................................................... 2 DropBox or Google Drive ............................................................................................................. 2 Version Control on Confluence ...................................................................................................
    [Show full text]
  • Beginning Portable Shell Scripting from Novice to Professional
    Beginning Portable Shell Scripting From Novice to Professional Peter Seebach 10436fmfinal 1 10/23/08 10:40:24 PM Beginning Portable Shell Scripting: From Novice to Professional Copyright © 2008 by Peter Seebach All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-1043-6 ISBN-10 (pbk): 1-4302-1043-5 ISBN-13 (electronic): 978-1-4302-1044-3 ISBN-10 (electronic): 1-4302-1044-3 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Frank Pohlmann Technical Reviewer: Gary V. Vaughan Editorial Board: Clay Andres, Steve Anglin, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Manager: Richard Dal Porto Copy Editor: Kim Benbow Associate Production Director: Kari Brooks-Copony Production Editor: Katie Stence Compositor: Linda Weidemann, Wolf Creek Press Proofreader: Dan Shaw Indexer: Broccoli Information Management Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013.
    [Show full text]
  • Leitfaden Für Debian-Betreuer
    Leitfaden für Debian­Betreuer Osamu Aoki, Helge Kreutzmann, and Mechtilde Stehmann August 27, 2021 Leitfaden für Debian­Betreuer by Osamu Aoki, Helge Kreutzmann, and Mechtilde Stehmann Copyright © 2014­2020 Osamu Aoki Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ”Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ”AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM­ PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Diese Anleitung wurde mit den nachfolgenden Dokumenten als Referenz erstellt: • »Making a Debian Package (AKA the Debmake Manual)«, Copyright © 1997 Jaldhar Vyas. • »The New­Maintainer’s Debian Packaging Howto«, Copyright © 1997 Will Lowe. • »Debian­Leitfaden für Neue Paketbetreuer«, Copyright © 1998­2002 Josip Rodin, 2005­2017 Osamu Aoki, 2010 Craig Small und 2010 Raphaël Hertzog. Die neuste Version dieser Anleitung sollte • im Paket debmake­doc und • auf der Debian­Dokumentations­Website verfügbar sein.
    [Show full text]
  • Distributed Configuration Management: Mercurial CSCI 5828 Spring 2012 Mark Grebe Configuration Management
    Distributed Configuration Management: Mercurial CSCI 5828 Spring 2012 Mark Grebe Configuration Management Configuration Management (CM) systems are used to store code and other artifacts in Software Engineering projects. Since the early 70’s, there has been a progression of CM systems used for Software CM, starting with SCCS, and continuing through RCS, CVS, and Subversion. All of these systems used a single, centralized repository structure. Distributed Configuration Management As opposed to traditional CM systems, Distributed Configuration Management Systems are ones where there does not have to be a central repository. Each developer has a copy of the entire repository and history. A central repository may be optionally used, but it is equal to all of the other developer repositories. Advantages of Distributed Configuration Management Distributed tools are faster than centralized ones since metadata is stored locally. Can use tool to manage changes locally while not connected to the network where server resides. Scales more easily, since all of the load is not on a central server. Allows private work that is controlled, but not released to the larger community. Distributed systems are normally designed to make merges easy, since they are done more often. Mercurial Introduction Mercurial is a cross-platform, distributed configuration management application. In runs on most modern OS platforms, including Windows, Linux, Solaris, FreeBSD, and Mac OSX. Mercurial is written 95% in Python, with the remainder written in C for speed. Mercurial is available as a command line tool on all of the platforms, and with GUI support programs on many of the platforms. Mercurial is customizable with extensions, hooks, and output templates.
    [Show full text]
  • Microservices and Monorepos
    Microservices and Monorepos Match made in heaven? Sven Erik Knop, Perforce Software Overview . Microservices refresher . Microservices and versioning . What are Monorepos and why use them? . These two concepts seem to contradict – why mix them together? . The magic of narrow cloning . A match made in heaven! 2 Why Microservices? . Monolithic approach: App 3 Database Microservices approach . Individual Services 4 DB DB Database Versioning Microservices . Code . Executables and Containers . Configuration . Natural choice: individual repositories for each service Git . But: • Security • Visibility • Refactoring • Single change id to rule them all? 5 Monorepo . Why would you use a monorepo? . Who is using monorepos? . How would you use a monorepo? 6 Monorepos: Why would you do this? . Single Source of Truth for all projects . Simplified security . Configuration and Refactoring across entire application . Single change id across all projects . Examples: • Google, Facebook, Twitter, Salesforce, ... 7 Single change across projects change 314156 8 Monorepos: Antipatterns User workspace User workspace 9 Monorepos – view mapping User workspace . Map one or more services . Users only access files they need . Simplified pushing of changes 10 What does this have to do with Git? . Git does not support Monorepos • Limitations on number and size of files, history, contributing users • Companies have tried and failed . Android source spread over a thousand Git repositories • Requires repo and gerrit to work with 11 How can we square this circle? https://en.wikipedia.org/wiki/Squaring_the_circle 12 Narrow cloning! . Clone individual projects/services . Clone a group of projects into a single repo 13 Working with narrowly cloned repos . Users work normally in Git . Fetch and push changes from and to monorepo .
    [Show full text]
  • Version Control – Agile Workflow with Git/Github
    Version Control – Agile Workflow with Git/GitHub 19/20 November 2019 | Guido Trensch (JSC, SimLab Neuroscience) Content Motivation Version Control Systems (VCS) Understanding Git GitHub (Agile Workflow) References Forschungszentrum Jülich, JSC:SimLab Neuroscience 2 Content Motivation Version Control Systems (VCS) Understanding Git GitHub (Agile Workflow) References Forschungszentrum Jülich, JSC:SimLab Neuroscience 3 Motivation • Version control is one aspect of configuration management (CM). The main CM processes are concerned with: • System building • Preparing software for releases and keeping track of system versions. • Change management • Keeping track of requests for changes, working out the costs and impact. • Release management • Preparing software for releases and keeping track of system versions. • Version control • Keep track of different versions of software components and allow independent development. [Ian Sommerville,“Software Engineering”] Forschungszentrum Jülich, JSC:SimLab Neuroscience 4 Motivation • Keep track of different versions of software components • Identify, store, organize and control revisions and access to it • Essential for the organization of multi-developer projects is independent development • Ensure that changes made by different developers do not interfere with each other • Provide strategies to solve conflicts CONFLICT Alice Bob Forschungszentrum Jülich, JSC:SimLab Neuroscience 5 Content Motivation Version Control Systems (VCS) Understanding Git GitHub (Agile Workflow) References Forschungszentrum Jülich,
    [Show full text]
  • Revision Control
    Revision Control Tomáš Kalibera, (Peter Libič) Department of Distributed and Dependable Systems http://d3s.mff.cuni.cz CHARLES UNIVERSITY PRAGUE Faculty of Mathematics and Physics Problems solved by revision control What is it good for? Keeping history of system evolution • What a “system” can be . Source code (single file, source tree) . Textual document . In general anything what can evolve – can have versions • Why ? . Safer experimentation – easy reverting to an older version • Additional benefits . Tracking progress (how many lines have I added yesterday) . Incremental processing (distributing patches, …) Allowing concurrent work on a system • Why concurrent work ? . Size and complexity of current systems (source code) require team work • How can concurrent work be organized ? 1. Independent modifications of (distinct) system parts 2. Resolving conflicting modifications 3. Checking that the whole system works . Additional benefits . Evaluating productivity of team members Additional benefits of code revision control • How revision control helps . Code is isolated at one place (no generated files) . Notifications when a new code version is available • Potential applications that benefit . Automated testing • Compile errors, functional errors, performance regressions . Automated building . Backup • Being at one place, the source is isolated from unneeded generated files . Code browsing • Web interface with hyperlinked code Typical architecture Working copy Source code repository (versioned sources) synchronization Basic operations • Check-out . Create a working copy of repository content • Update . Update working copy using repository (both to latest and historical version) • Check-in (Commit) . Propagate working copy back to repository • Diff . Show differences between two versions of source code Simplified usage scenario Source code Check-out or update repository Working 1 copy 2 Modify & Test Check-in 3 Exporting/importing source trees • Import .
    [Show full text]
  • Compiling C Programs
    CSCI 2132: Software Development Lab 6: Exploring bash and C Compilation Synopsis In this lab, you will: • Customize the behaviour your bash shell • Write and compile some simple C programs • Practice the edit-compile-fix cycle using emacs and the shell • Learn to patch programs using diff and patch Contents Overview......................................................................................................2 Step 1: Login and lab setup.................................................................................3 Step 2: The name of your shell.............................................................................3 Step 3: The .bashrc file.....................................................................................3 Step 4: Customize rm ........................................................................................4 Optional Step: Install bashrc.new as your new .bashrc file............................................7 Step 5: Edit .profile .......................................................................................8 Optional Step: Install profile.new as your new .profile file.......................................... 10 Step 6: Write a simple C program.......................................................................... 11 Step 7: Explore exit codes................................................................................... 12 Step 8: diff .................................................................................................. 14 Step 9: patch................................................................................................
    [Show full text]
  • FAKULTÄT FÜR INFORMATIK Leveraging Traceability Between Code and Tasks for Code Reviews and Release Management
    FAKULTÄT FÜR INFORMATIK DER TECHNISCHEN UNIVERSITÄT MÜNCHEN Master’s Thesis in Informatics Leveraging Traceability between Code and Tasks for Code Reviews and Release Management Jan Finis FAKULTÄT FÜR INFORMATIK DER TECHNISCHEN UNIVERSITÄT MÜNCHEN Master’s Thesis in Informatics Leveraging Traceability between Code and Tasks for Code Reviews and Release Management Einsatz von Nachvollziehbarkeit zwischen Quellcode und Aufgaben für Code Reviews und Freigabemanagement Author: Jan Finis Supervisor: Prof. Bernd Brügge, Ph.D. Advisors: Maximilian Kögel, Nitesh Narayan Submission Date: May 18, 2011 I assure the single-handed composition of this master’s thesis only supported by declared resources. Sydney, May 10th, 2011 Jan Finis Acknowledgments First, I would like to thank my adviser Maximilian Kögel for actively supporting me with my thesis and being reachable for my frequent issues even at unusual times and even after he left the chair. Furthermore, I would like to thank him for his patience, as the surrounding conditions of my thesis, like me having an industrial internship and finishing my thesis abroad, were sometimes quite impedimental. Second, I want to thank my other adviser Nitesh Narayan for helping out after Max- imilian has left the chair. Since he did not advise me from the start, he had more effort working himself into my topic than any usual adviser being in charge of a thesis from the beginning on. Third, I want to thank the National ICT Australia for providing a workspace, Internet, and library access for me while I was finishing my thesis in Sydney. Finally, my thanks go to my supervisor Professor Bernd Brügge, Ph.D.
    [Show full text]
  • Source Code Revision Control Systems and Auto-Documenting
    Source Code Revision Control Systems and Auto-Documenting Headers for SAS® Programs on a UNIX or PC Multiuser Environment Terek Peterson, Alliance Consulting Group, Philadelphia, PA Max Cherny, Alliance Consulting Group, Philadelphia, PA ABSTRACT This paper discusses two free products available on UNIX and PC RCS, which is a more powerful utility than SCCS, was written in environments called SCCS (Source Code Control System) and early 1980s by Walter F. Tichy at Purdue University in Indiana. It RCS (Revision Control System). When used in a multi-user used many programs developed in the 1970s, learning from environment, these systems give programmers a tool to enforce mistakes of SCCS and can be seen as a logical improvement of change control, create versions of programs, document changes SCCS. Since RCS stores the latest version in full, it is much to programs, create backups during reporting efforts, and faster in retrieving the latest version. RCS is also faster than automatically update vital information directly within a SASâ SCCS in retrieving older versions and RCS has an easier program. These systems help to create an audit trail for interface for first time users. RCS commands are more intuitive programs as required by the FDA for a drug trial. than SCCS commands. In addition, there are less commands, the system is more consistent and it has a greater variety of options. Since RCS is a newer, more powerful source code INTRODUCTION control system, this paper will primarily focus on that system. The pharmaceutical industry is one of the most regulated industries in this country. Almost every step of a clinical trial is subject to very strict FDA regulations.
    [Show full text]