And check out a copy of your group's source tree, where N is your one-digit group number and user is your rss username

Similar documents
Handout 4: Version Control Reference

Subversion FOUR. 4.1 What is Version Control? 4.2 What is Subversion? Types of Version Control SESSION

Chapter 3. Revision Control

CS2720 Practical Software Development

9 and 11-Jan CSCI 4152/6509 Natural Language Processing Lab 1: FCS Computing Environment, SVN Tutorial. FCS Computing Environment, SVN Tutorial

CSE 374 Programming Concepts & Tools. Hal Perkins Winter 2012 Lecture 16 Version control and svn

What is version control? (discuss) Who has used version control? Favorite VCS? Uses of version control (read)

Version Control System. -- base on Subversion 1.4

Software Tools Subversion

Git Tutorial. Version: 0.2. Anders Nilsson April 1, 2014

Software Development I

TDDC88 Lab 4 Software Configuration Management

Git. Charles J. Geyer School of Statistics University of Minnesota. Stat 8054 Lecture Notes

A Short Introduction to Subversion

Common Configuration Management Tasks: How to Do Them with Subversion

Portions adapted from A Visual Guide to Version Control. Introduction to CVS

2/9/2013 LAB OUTLINE INTRODUCTION TO VCS WHY VERSION CONTROL SYSTEM(VCS)? II SENG 371 SOFTWARE EVOLUTION VERSION CONTROL SYSTEMS

Systems Software. Recitation 1: Intro & Revision Control. Quite different from 213. Our Philosophy. Partly-free lunch

CSCI 4152/6509 Natural Language Processing. Lab 1: FCS Computing Environment

Task-Oriented Solutions to Over 175 Common Problems. Covers. Eclipse 3.0. Eclipse CookbookTM. Steve Holzner

[Software Development] Development Tools. Davide Balzarotti. Eurecom Sophia Antipolis, France

CSE 160: Introduction to Parallel Computation

Source control with Subversion A user perspective

Subversion. CS 490MT/5555, Fall 2015, Yongjie Zheng

git commit --amend git rebase <base> git reflog git checkout -b Create and check out a new branch named <branch>. Drop the -b

Version Control Systems

CSE 390 Lecture 9. Version control and Subversion (svn)

Terminal Windows, Emacs, Subversion and Make

Revision control systems (RCS) and. Subversion

Implement an ADT while using Subversion

Using the Zoo Workstations

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

Version Control with CVS

About CVS. 1 Version Control - what is it? why is it useful?

WORKING IN TEAMS WITH CASECOMPLETE AND SUBVERSION. Contents

Storing and Managing Code with CVS

Version Control. CSC207 Fall 2014

Computer Labs: Version Control with Subversion

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger.

Using Git to Manage Source RTL

Using GitHub to Share with SparkFun a

Section 2: Developer tools and you. Alex Mariakakis (staff-wide)

Revision Control II. - svn

Using Subversion with LeMANS and MONACO

2/8/18. Overview. Project Management. The First Law. What is Project Management? What Are These Changes? Software Configuration Management (SCM)

Version Control. Kyungbaek Kim. Chonnam National University School of Electronics and Computer Engineering. Original slides from James Brucker

Project Management. Overview

Exercise 3: Adding a file to the master directory

Using CVS to Manage Source RTL

CVS. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 21

Warmup. A programmer s wife tells him, Would you mind going to the store and picking up a loaf of bread? Also, if they have eggs, get a dozen.

How to version control like a pro: a roadmap to your reproducible & collaborative research

WORKING IN TEAMS WITH CASECOMPLETE AND THE CASECOMPLETE PROJECT SHARING ADDIN. Contents

CPSC 491. Lecture 19 & 20: Source Code Version Control. VCS = Version Control Software SCM = Source Code Management

Introduction to Revision Control

AccuBridge for IntelliJ IDEA. User s Guide. Version March 2011

Introduction to the Emacs Editor

Computer Science 62 Lab 8

A CVS Repository for the RNB Group

Source Control: Perforce

AccuRev Plug-In for IntelliJ IDEA. User s Guide. Version

Subversion Repository Layout

A Brief Git Primer for CS 350

ADOBE DRIVE 4.2 USER GUIDE

Version Control. 1 Version Control Systems. Ken Bloom. Linux User Group of Davis March 1, 2005

An Introduction to Subversion

ENCM 339 Fall 2017: Editing and Running Programs in the Lab

Source Control: Subversion

Source Control: Subversion

Week - 01 Lecture - 04 Downloading and installing Python

LAB 0: LINUX COMMAND LINE AND SVN

Systems Programming Advanced Software Development

Version Control Systems (Part 1)

Version Control for Fun and Profit

CSCI 2132 Software Development. Lecture 5: File Permissions

Lab #2 Physics 91SI Spring 2013

Source Control: Perforce

Intro to Git. Getting started with Version Control. Murray Anderegg February 9, 2018

Managing Source Code With Subversion

Computer Labs: Version Control with Subversion

Working with GIT. Florido Paganelli Lund University MNXB Florido Paganelli MNXB Working with git 1/47

Perforce in FreeBSD Development

Version Control Systems: Overview

ACE Operation Manual

Laboratory 5: Implementing Loops and Loop Control Strategies

Revision control. INF5750/ Lecture 2 (Part I)

Submitting your Work using GIT

Git. It is easy to shoot your foot off with git, but also easy to revert to a previous foot and merge it with your current leg.

Introduction to CVS. Sivan Toledo Tel-Aviv University

Unix Tutorial Haverford Astronomy 2014/2015

A Brief Introduction to Git. Sylverie Herbert (based on slides by Hautahi Kingi)

Tutorial 2 GitHub Tutorial

USER GUIDE MADCAP LINGO Source Control: Git

1. Git. Robert Snapp

CSE115 Lab exercises for week 1 of recitations Spring 2011

(Refer Slide Time: 1:26)

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

WinCvs Version 1.1. Users Guide. Don Harper

at Rocket Software Mainframe CVS z/os Unix System Services CVS client Extending the functionality of the Lisa Bates

Assumptions. GIT Commands. OS Commands

Transcription:

RSS webmaster Subversion is a powerful, open-source version control system favored by the RSS course staff for use by RSS teams doing shared code development. This guide is a primer to the use of Subversion within RSS. Subversion provides a simple command set with which you can: Check out a local, working copy of code from a shared repository; Track the status of your local copy with respect to the repository; Commit your local changes back into the repository; Update your local copy to reflect changes committed by others; Merge sources and resolve conflicts as needed; and Revert to an earlier, stable version if anything goes awry. The on-line version of this document (posted in the Labs/ area of the RSS home page) links to documentation on the Subversion web site. Many of the example Subversion command lines shown below are derived from that site. Getting Started As alluded to in lecture and lab, Subversion supports a source control model in which multiple users share read/write access to a source repository, which represents the group s consensus version of its collective code-base or source tree. Users modify the repository only through a well-defined set of actions implemented by the program svn, which manages files on the user s behalf. A user wishing to add or modify code in the repository must first retrieve or check out a local working copy of the repository. S/he then edits the local version and tests it locally. When the user s local copy is once again functional (and hopefully, improved), the user can commit his/her changes to the repository, at which time the modified code becomes visible to other users. All users can monitor the status of the repository, and the state of their own local files with respect to their (presumably stable) counterparts there. Finally, users can update and merge their local copies to incorporate changes committed by others to the repository, resolve conflicts between their own edits and changes made by others, and revert to earlier committed versions if necessary. Checking Out Your Group Repository First, you may wish to add a line like this to your shell's run-time command file (e.g. ~/.bashrc) to reflect your choice of editor (this just controls which editor gets invoked when svn needs you to edit a file or enter a commit message, as described below; your account in the hangar will use emacs here by default): export SVN_EDITOR=vim # or other text editor of your choice If you do so, then update your active shell to reflect these changes (either by cutting and pasting the lines above to the shell and executing them, or by exiting your shell and starting a new one). Now cd into your home director: cd And check out a copy of your group's source tree, where N is your one-digit group number and user is your rss username svn checkout --username=rss-student https://svn.csail.mit.edu/rss-2013/groupn ~/RSS-I-group

where X is your team/group number(your TA should have the password for your group). Editing and Committing Changes Change directories down into your local source tree. Now you can begin collaborative code development with your teammates. Each of you should use the editor of your choice. We ve provided one display, keyboard and mouse per workstation, but if you bring a laptop into the lab, you can ssh in and work simultaneously with your teammates. Once you have edited, compiled, tested, and documented one or more files, you will use to propagate your local revisions back into the repository, incrementing the version number of the repository file as a side-effect. You can do this on a per-file basis (recommended for beginners) using: filename Or you can simply rely on Subversion to figure out exactly what has changed in the sub-tree rooted at the current directory, and commit it: For each commit action, Subversion will bring up an editor and ask you to enter a brief comment describing the purpose of the commit. These comments will be displayed to you and your teammates when you ask Subversion for the edit history of a file, and are among the most valuable metadata (along with filenames and modification dates) that Subversion associates with your code. Even if you feel that the changes you just made are completely obvious in their purpose and function, they may not be obvious to your teammates or the staff, and frankly they may not be obvious to you either after a few hours have passed. So, type in a brief, meaningful comment whenever Subversion asks you to. Typically the commit will occur successfully. But if someone else has committed changes since your most recent checkout or update, you ll have to merge their changes with yours, resolving conflicts as needed before Subversion allows the commit (see below). Adding and Removing Files Suppose you decide to design a new Java class, and create a file MyClass.java to implement it. Subversion s data model, in which each user edits only a local copy of the source tree, has some implications that take a bit of getting used to. For example, there s no such thing as adding a file directly to the repository. Instead, the user creates the file locally (typically with a text editor), then adds it to the local tree, then commits it to the repository: emacs MyClass.java # create local copy svn add MyClass.java # schedule file for addition to repository # propagate file MyClass.java to repository Similarly, to delete a file, a user must first delete the local copy of the file, then inform Subversion that it should be deleted from the repository as well (otherwise, Subversion will simply replace the file as part of the next update): rm MyClass.java svn delete MyClass.java # delete local copy # schedule file for removal from repository # MyClass.java must not exist in current directory # propagate deletion of MyClass.java to repository Use svn add and svn delete wisely. Don t add temporary files (editor backup files,.o files from compilation, etc.). Don t delete files added by another user without first talking to that user. You can use svn revert (see below) to correct these sorts of errors before they are committed.

Checking Status, and Updating to Incorporate Changes Made by Others In a source tree with dozens or hundreds of files shared by even a few people, it will naturally occur that two or more people change the same file at about the same time. This happens even when teammates try hard to keep each other informed about the edits they plan to make. To facilitate communication about overlapping edits, Subversion provides a mechanism called svn status that compares a local file or subtree to its counterpart in the repository. As with commit, status can be requested for a single file: svn status filename Or, status can be requested for the sub-tree rooted at the user s current directory: svn status In either case, svn produces a listing of every file that differs from its repository counterpart, and for each file a one-letter code describing the difference. There are many one-letter codes, but the most important for our purposes are: M foo (user s copy of foo has been locally modified) C foo (file has conflicts from an update) A foo (file is scheduled for addition to repository) D foo (file is scheduled for deletion from repository) L foo (svn has locked foo; at this moment, it is managing foo for another user)? foo.o (foo.o is not part of the repository; svn does not manage it) Locked files can be a mysterious part of version control. Locks usually clear after a few seconds as the (other user s) locking operation completes. Occasionally, though, locks persist indefinitely. This can happen due to network disruptions or (more likely) Subversion terminating prematurely on the client or server due to an error condition of some kind. If you see a lock that lasts more than a minute, call an RSS staff member over or email rss-help for assistance. Merging, and Resolving Conflicts with, Changes Made by Others Typically, team members communicate in order to avoid simultaneous revision of the same file. However, in some cases (for example when two people add methods to the same class), overlapping changes are hard to avoid. This is not a problem for the first person to commit her changes; Subversion simply accepts the commit with no errors or warnings, as usual. However, the second person to attempt a commit will find that her local copy is not up to date with the repository version; this person will be required to merge any conflicts before committing. Subversion provides several tools to support file merging: svn log filename svn status filename svn status u filename svn diff filename # show history of file over time # show current file status, see above # show status, and predict conflicts on update # diffs file with its committed counterpart It is good practice to invoke svn status frequently, especially before committing your own changes, to see what conflicts (if any) your local changes may cause with material already committed to the repository. Again, if others have modified overlapping areas of the repository, Subversion requires that you incorporate or merge their changes into your local tree before committing your own changes: svn update The update command will print a one-letter code for each updated file: U (file updated from repository), G (file merged with non-overlapping updates from repository), or C (conflict found between your local edits and the repository version of the file, typically because someone else has committed changes in the same region of the same file). Subversion inserts marker lines (typically <<<<<, =====, and >>>>>) into conflicting files to demarcate conflict regions. You will have to

inspect and reconcile these regions in your editor. Subversion tries to help you by placing files with the same base name as the conflicted file, but suffixes.mine,.rnewrev, and.roldrev, in your working directory, which represent your pre-update local copy, the repository s pre-checkout committed copy, and the repository s current committed copy, respectively. Note that you ll almost always want to remove the conflict demarcation lines as part of your resolution process, since the presence of such lines in program text (as opposed to within comments) will prevent compilation. Once you have resolved the conflicts to your satisfaction, remove these temporary files using rm and invoke: svn resolved filename to inform Subversion that you have resolved the conflict. Subversion will now allow the file to be committed. For advanced Subversion users, svn merge can patch specified committed versions into a working version. Reverting to an Earlier Version Sometimes, you ll realize that you ve made a mistake: pursued an ill-advised implementation strategy, accidentally edited the wrong file, added a temporary file, or deleted source files that you actually cared about, for example. If you wish to reverse these changes before you have committed them, Subversion already provides a safety net for such cases, called svn revert. This command requires at least one argument: either a list of one or more filenames, or a --recursive flag and location of an entire directory to revert: svn revert filename svn revert --recursive. # revert a single file # revert entire working directory The revert action is comprehensive; in addition to undoing any local edits you have made, it unschedules any file additions or deletions you have scheduled (but not yet committed). You can also revert to earlier versions across commit boundaries, using svn update --revision <version>, where the version specifier can be an absolute version number, a relative version number, or a date (or date/time) specifier: svn update --revision PREV foo svn update --revision 1729 svn update --revision {2005-02-17} svn update --revision {15:30} svn update --revision {"2005-02-17 15:30"} # decrement foo s working revision # updates existing working copy to r1729 # update to 12:00:00am, start of February 17th # update to 2:30pm today # update to 2:30pm on February 17th If you would rather not modify your working copy, create a directory elsewhere and use the svn checkout form of the commands above to check out a fresh local copy to that directory. Be very careful with revert and update: they can wipe out hours of hard work in an instant. Remember that revert and update actions may have irreversible effects on your (previous) working copies. Advanced Subversion Capabilities Subversion is a distributed file-sharing and file-versioning system with extensive local caching. Its actions often involve the network, take a significant amount of time to complete, and can be interrupted or otherwise fail. For these (hopefully infrequent) failure cases, Subversion provides a cleanup command that uses logs to put your working copy back into a consistent state. (Take 6.033 for more about logs and transaction consistency.) Subversion has many other powerful capabilities. It can be configured to email all team members whenever any team member commits a change to the repository. It supports branches and tags, general metadata association with files, and a host of other complex functions whose descriptions are beyond the scope of this document. Refer to the on-line reference Version Control with Subversion (Collins-Sussman,

Fitzpatrick, and Pilato) for comprehensive documentation. General Tips This section collects a few words of wisdom gained through the RSS staff s experience with a variety of source control systems. These are meant to be read with care, along with the admonitions mixed in to the descriptions of Subversion functionality above. We hope that you ll heed these tips in your own software development. But you ll probably learn these lessons the hard way, like we did. Version control systems are meant to enhance teamwork and communication, not replace it. Don t stop talking to your teammates just because you re using Subversion. If anything, the sharing model imposed by the system should prompt you to talk (and think!) more with your teammates, about exactly who is going to make what changes to your source, when, and how. More talk equals less stepping on each others toes with unintended changes and consequent unpleasant merges and conflicts. Communicate with your teammates. Ignore the.svn subdirectory and its contents. Every directory checked out with svn contains one, which Subversion uses to hold local versioning information and a partial cache of the repository. Do not modify or delete anything in this directory. (If you do, it will end in tears.) Check status and update frequently, especially for files you are about to edit. Checking status tells you when your local copy is out of date, i.e. when someone else has committed changes to the repository since your most recent checkout or update. Doing an update brings you up to date by incorporating those changes into your local copy. There s no sense charging ahead to edit anything until you ve got your teammates most recent versions. If you do, you re just setting yourself up for a possibly painful merge and/or conflict task later, whenever you decide to commit your own changes. Exit your editor buffers when updating, at least until you become completely comfortable with your editor and Subversion s repository model. Otherwise you can get into a quite confusing situation in which your editor overwrites new, good code from your teammates with your own older, not-as-good code. Some editors even do this automatically (example: emacs auto-save ), thinking they are doing you a favor. (They re not.) Commit stable versions often typically whenever you make a substantive functional change. Each commit provides a potential island of stability, amongst a sea of changes, to which you and your teammates can revert in case of problems. Remember, if you work for eight hours and commit only once at the end, then the only reversion point available to you will be to the state you were in before all of your work was started. Don t be afraid to commit often. Don t worry; the svn tools can handle it. (But be reasonable; committing every time you add a comment or some whitespace to your code is going too far.) RSS webmaster