Practical software engineering: Revision control & makeOverviewDealing with large codebasesBasic RCS features (1/2)Basic RCS features (2/2)Typical RCS workflowRCS implementationsConcurrent edits (1/2)Concurrent edits (2/2)Resolving conflictsInteracting with SVNCommand line SVN example (1/2)Command line SVN example (2/2)General SVN tipsKnow moreMakeSlide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Slide 33Slide 34Slide 35Practical software engineering:Revision control & make15-441 Spring 2010, Recitation #2Overview•Revision control systems–Motivation–Features–Subversion primer•Make–Simple gcc–Make basics and variables–Testing•Useful Unix commandsDealing with large codebases•Complications–Code synchronization–Backups–Concurrent modifications•Solution: Revision Control System (RCS)–Store all of your code in a repository on a server–Metadata to track changes, revisions, etc…–Also useful for writing books, papers, etc…Basic RCS features (1/2)•Infinite undo –go back to previous revisions•Automatic backups–all your code ever, forever saved•Changes tracking–see differences between revisionsBasic RCS features (2/2)•Concurrency–Multiple people working at the same time •Snapshots–Save stable versions on the side (i.e. handin)•Branching–Create diverging code paths for experimentationTypical RCS workflow1. Create repository on RCS server2. Checkout the repository to your local machine3. Work locally: create, delete and modify files4. Update the repository to check for changes other people might have made5. Resolve any existing conflicts6. Commit your changes to the repositoryRCS implementations•Revision Control System (RCS)–Early system, no concurrency or conflict resolution•Concurrent Versions System (CVS)–Concurrency, versioning of single files•Subversion (SVN)–File and directory moving and renaming, atomic commitsConcurrent edits (1/2)CarnegieMellonFile v1Both check out fileEdits (lines 1-20)File v2Edits (lines 30-40)commitUpdateMerged automatically!Concurrent edits (2/2)CarnegieMellonFile v1Both check out fileEdits (lines 1-20)File v2Edits (lines 10-20)commitUpdateConflict needing manual intervention!Resolving conflicts•When changes can’t be merged automatically–SVN gives you 3 files:•file.mine : your file•file.rx : the remote file•file : original file with marked conflicts•You can–Discard your changes–Discard others’ changes–Go over each conflict and arbitrate as appropriateInteracting with SVN•Command line–Readily available in andrew machines•Graphical tools–Easier to use–Subclipse for Eclipse gives IDE/SVN integrationCommand line SVN example (1/2)$ svn co https://moo.cmcl.cs.cmu.edu/441-s10/svn/Project1Team63A Project1Team63/trunkA Project1Team63/branchesA Project1Team63/tagsChecked out revision 1.$ cd Project1Team63/trunk/$ echo -e ”hello world" > sircd.c$ svn add sircd.c$ vim Makefile$ svn add Makefile$ svn commit -m 'adding Makefile and sircd.c!'$ cd ../$ svn cp trunk tags/checkpoint1$ svn commit -m 'making a tag of the trunk for checkpoint1!'Command line SVN example (2/2)Revision control lets you note (and then see) what you changed:> svn log gtcd.ccr986 | ntolia | 2006-08-01 17:13:38 -0400 (Tue, 01 Aug 2006) | 6 linesThis allows the sp to get rid of chunks early before a transfer is complete.Useful when a file is requested in-order and the file size > mem cache size> svn diff -r 1:2 fileIndex: file===================================================================--- file (revision 1)+++ file (revision 2)@@-1,2+1,3@@ This isatestfile -It startedwithtwolines +It nolongerhastwolines +it hasthreeGeneral SVN tips•Update, make, test, only then commit•Merge often•Comment commits•Avoid commit races•Modular design avoids conflictsKnow more•Chapter 2 of Dave Andersen’s notes “SE for Systems Hackers” (link on course website)•subversion.tigris.org for SVN software & info•svnbook.red-bean.com for SVN bookMake•Utility for executable building automation•Saves you time and frustration•Helps you test more and betterSimple gccIf we have files:• prog.c: The main program file• lib.c: Library .c file• lib.h: Library header file% gcc -c prog.c -o prog.o% gcc -c lib.c -o lib.o% gcc lib.o prog.o -o binarygcc flags•Useful flags1. -g: debugging hook2. -Wall: show all warnings3. -Werror: treat warning as errors4. -O0, -O1, -O2, -O3: optimization level5. -DDEBUG: macro for DEBUG (#define DEBUG)•Avoid using dangerous optimizations that could affect correctnessMore gcc%gcc -g -Wall -Werror -c prog.c -o prog.o%gcc -g -Wall -Werror -c lib.c -o lib.o%gcc -g -Wall -Werror lib.o prog.o -o binaryThis gets boring, fast!Makefile basics •Build targetstarget: dependency1 dependency2 ...unix command (start line with TAB)unix commandbinary: lib.o prog.ogcc -g -Wall lib.o prog.o -o binarylib.o: lib.cgcc -g -Wall -c lib.c -o lib.oprog.o: prog.cgcc -g -Wall -c prog.c -o prog.oclean:rm *.o binaryMakefile exampleMakefile variables (1/7)•VariablesCC = gccCFLAGS = -g -Wall -WerrorOUTPUT = binarybinary: lib.o prog.ogcc -g -Wall lib.o prog.o -o binarylib.o: lib.cgcc -g -Wall -c lib.c -o lib.oprog.o: prog.cgcc -g -Wall -c prog.c -o prog.oclean:rm *.o binaryMakefile variables (2/7)CC = gccCFLAGS = -g -WallOUTPUT = binary$(OUTPUT): lib.o prog.o$(CC) $(CFLAGS) lib.o prog.o -o binarylib.o: lib.c$(CC) $(CFLAGS) -c lib.c -o lib.oprog.o: prog.c$(CC) $(CFLAGS) -c prog.c -o prog.oclean:rm *.o $(OUTPUT)Makefile variables (3/7)CC = gccCFLAGS = -g -WallOUTPUT = binary$(OUTPUT): lib.o prog.o$(CC) $(CFLAGS) lib.o prog.o -o binarylib.o: lib.c$(CC) $(CFLAGS) -c lib.c -o lib.oprog.o: prog.c$(CC) $(CFLAGS) -c prog.c -o prog.oclean:rm *.o $(OUTPUT)Makefile variables (4/7)CC = gccCFLAGS = -g -WallOUTPUT = binaryOBJFILES = lib.o prog.o$(OUTPUT): $(OBJFILES)$(CC) $(CFLAGS) $(OBJFILES) -o binarylib.o: lib.c$(CC) $(CFLAGS) -c lib.c -o lib.oprog.o: prog.c$(CC) $(CFLAGS) -c prog.c -o prog.oclean:rm *.o $(OUTPUT)Makefile variables (5/7)CC = gccCFLAGS = -g -WallOUTPUT = binaryOBJFILES = lib.o prog.o$(OUTPUT): $(OBJFILES)$(CC) $(CFLAGS) $(OBJFILES) -o binarylib.o: lib.c$(CC) $(CFLAGS) -c lib.c -o lib.oprog.o: prog.c$(CC) $(CFLAGS) -c prog.c -o prog.oclean:rm *.o $(OUTPUT)Makefile variables (6/7)CC = gccCFLAGS = -g -WallOUTPUT = binaryOBJFILES = lib.o prog.o$(OUTPUT): $(OBJFILES)$(CC) $(CFLAGS) $(OBJFILES) -o binary%.o:
View Full Document