CSE 160: Introduction to Parallel Computation Discussion Section SVN Tutorial Based primarily on material provided by Ingolf Krueger Contributions made by Jing Zheng, Yashodhan Karandikar, and Scott B. Baden University of California Department of Computer Science & Engineering September 2013 CSE 160 1
Version Control (a.k.a Configuration Management) with subversion September 2013 CSE 160 2
Scenario I Work alone at a project on your laptop Delete a file accidently How can I revert to yesterday s version? Oh, no! It s on my desktop September 2013 CSE 160 3
Problems of Individual Non-Version Controlled Software If you save your work over what you had before, any prior work is gone forever No ability to revert back to a prior version of a particular file (the one without the error!) No ability to freeze one version for safekeeping and continue to work on a new version No ability to recover from hard-disk failure Does not provide the flexibility to work anywhere. What if you are working on a desktop at school/the office, and want to continue to work at your home desktop? September 2013 CSE 160 4
Scenario II Assume now, you are developing in a small team. The team uses a regularly backed-up file-sharing mechanism (such as a shared network drive). What can go wrong? Bob September 2013 CSE 160 5
Problems of Team Non-Version Controlled Software The last one who saves wins Work gets artificially sequentialized Still no ability to revert back to a prior version of a particular file Still difficult to freeze one version for deployment and continue to work on a new version What if you are working on a desktop at school/the office, and want to continue to work at your home desktop but have no access to the file share? September 2013 CSE 160 6
Solution: Version Management with Dedicated Repository Introduce a Version Management Repository that holds the master copy of all artifacts (code, tests, build files, graphics, ) of your project September 2013 CSE 160 7
Solution: Version Management with Dedicated Repository If needs access to the code, she checks out a local copy check out September 2013 CSE 160 8
Solution: Version Management with Dedicated Repository Now commits (publishes her edited files) svn commit m Changed return statement commit September 2013 CSE 160 9
Let s see how to use svn for our assignment code development! September 2013 CSE 160 10
Lab Assignment Repository Each student has a svn account can be used to access the group repository e.g. alice, bob Each group has a repository directory on BANG e.g. G-alice-bob Email TA if you need to change your partner before each assignment release. Course policy: No group may change once an assignment starts! September 2013 CSE 160 11
Checkout Starter Code Starter code is in /SVN/A1/Provided svn co --username alice \\ svn://ccom-bang-login.ucsd.edu/svn/a1/provided!./provided:! check out September 2013 CSE 160 12
Checkout Your Group SVN Directory Your group ID will be sent to your ucsd.edu email after your group registers through the Google form (check Moodle for the form s link ) svn co --username alice svn://ccom-banglogin.ucsd.edu/svn/a1/turnin/g-alice-bob Turnin!./Turnin:! check out September 2013 CSE 160 13
Import Starter Code To Your Group SVN Directory Add the code in Provided to your own repository $ cp Provided/* Turnin $ cd Turnin $ svn add * $ svn ci m import the starter code Comments are very important. Lack of meaningful comments may hurt your grade./turnin:! commit September 2013 CSE 160 14
and Bob s Collaboration Bob also checks out a local copy into his local folder svn co --username bob svn://ccom-banglogin.ucsd.edu/svn/a1/turnin/g-alice-bob Turnin!./Turnin:!./Turnin:! check out Bob September 2013 CSE 160 15
and Bob s Collaberation Bob and individually make changes to their own local copy int fun(int x){!!int y = x*x + 5;!!return y + 10;! }! int fun(int x){!!int y = x*x + 5;!!return y + 2000;! }! Bob September 2013 CSE 160 16
and Bob s Collaberation Now commits (publishes her edited files) svn commit m Changed return statement commit Bob September 2013 CSE 160 17
Solution: Version Management with Dedicated Repository Scenario 2: Bob updates Conflict! svn update! C! Updated to revision 233.! update conflict Bob September 2013 CSE 160 18
Bob looks at the file to find and resolve the conflict int fun(int x){!!!!int y = x*x + 5;! <<<<<<<.mine!!!!return y + 2000;! =======!!!!return y + 10;! >>>>>>>.r233! }! I better chat with about this September 2013 CSE 160 19
Bob makes decisions to resolve the conflicts int fun(int x){!!!!int y = x*x + 5;!!!!return y + 2000;! }! Looks better already September 2013 CSE 160 20
Solution: Version Management with Dedicated Repository Bob indicates that he has resolved the conflict svn resolved! Resolved conflicted state of '! resolved Bob September 2013 CSE 160 21
Solution: Version Management with Dedicated Repository Once he has resolved all conflicts, Bob commits again. This time he succeeds! svn commit! commit succeeds Bob September 2013 CSE 160 22
Solution: Version Management with Dedicated Repository updates at the beginning of her next work increment and the cycle repeats. svn update! update Bob September 2013 CSE 160 23
Summary Check-out the provided code: svn co --username YOUR_AD svn://ccom-banglogin.ucsd.edu/svn/a1/provided Checkout your development repository directory svn co svn://ccom-bang-login.ucsd.edu/svn/a1/ Turnin/YOUR_GROUP Turnin Add the provided code to your development repository. This needs to be done once, by one team member only cp Provided/* Turnin/ cd./turnin svn add * svn commit -m "import the provided code" September 2013 CSE 160 24
Workflow After Checkout and Import Update Make changes Update Always update before beginning work and before committing changes Resolve conflicts Commit September 2013 CSE 160 25
Some Common Mistakes The starter code import should be done at the beginning only Checkout should be done at the beginning only Use svn update to get the latest version in the repository Commit only after you compile and test locally Don t pollute the repository with non-working code Mess up your co-worker s copy if he/she updates Don t forget to commit!! September 2013 CSE 160 26
Some other SVN Commands Revert local changes svn revert Deleting a file svn delete temp.cpp svn commit m Deleting trial.cpp since the trial code has been incorporated into Rename a file svn mv sort.cpp quicksort.cpp svn commit m Renaming sort.cpp to quicksort.cpp to indicate the sorting method being used Don t forget comments!! September 2013 CSE 160 27
Other Features of subversion Create Branches Isolate changes to separate lines of development Example: one branch is the currently deployed version for maintenance, another branch is the current development version Can merge branches Create Tags Similar to a branch Useful to take a snapshot of the code and save it aside in case we need to retrieve it later if something goes wrong September 2013 CSE 160 28
Use of SVN in assignments You MUST use SVN for submitting your assignments in CSE 160 No other source code control system is allowed Include meaningful comments in both the code and the SVN logs. Lack of meaningful comments may affect your grade Do NOT give out your SVN password to anyone September 2013 CSE 160 29
Documentation We are using svn 1.6.11 svn help lists all commands svn help <command> provides detailed documentation for a specific command Beyond Linux From Scratch Editor's Manual See chapter 3 for command summary http://www.linuxfromscratch.org/blfs/edguide/ chapter03.html Version control with SVN (446 pp, definitive source) http://svnbook.red-bean.com/ September 2013 CSE 160 30
Thank you! Any questions? September 2013 CSE 160 31
Backup Slides September 2013 CSE 160 32
Solution: Version Management with Dedicated Repository Introduce a Version Management Repository that holds the master copy of all artifacts (code, tests, build files, graphics, ) of your project September 2013 CSE 160 33
Solution: Version Management with Dedicated Repository If needs access to the code, she checks out a local copy check out September 2013 CSE 160 34
Solution: Version Management with Dedicated Repository If Bob also needs access to the code, he also checks out a local copy check out Bob September 2013 CSE 160 35
Solution: Version Management with Dedicated Repository Bob and individually make changes to their own local copy Bob September 2013 CSE 160 36
Solution: Version Management with Dedicated Repository When is done with her edits, she commits her local copy to the repository. Her changes are automatically merged into the master copy of the file in the repository. commit Bob September 2013 CSE 160 37
Scenario Now Bob is done with his edits, he also wants to commit. What can happen?? commit Bob September 2013 CSE 160 38
Solution: Version Management with Dedicated Repository Scenario 1: and Bob have edited in different areas of the file No conflict! Bob s changes will be merged into the master copy. commit succeds Bob September 2013 CSE 160 39
Solution: Version Management with Dedicated Repository Scenario 2: and Bob have edited in the same areas of the file Conflict! Bob s changes will NOT be merged into the master copy. commit fails Bob September 2013 CSE 160 40
Solution: Version Management with Dedicated Repository To resolve the conflict, Bob first updates his local copy. update Bob September 2013 CSE 160 41
Solution: Version Management with Dedicated Repository He gets notifications of the conflicts inside the affected files. He makes decisions to resolve the conflicts. update Bob September 2013 CSE 160 42
Solution: Version Management with Dedicated Repository Once he has resolved all conflicts, Bob commits again. This time he succeeds! commit succeeds Bob September 2013 CSE 160 43
Solution: Version Management with Dedicated Repository updates at the beginning of her next work increment. update Bob September 2013 CSE 160 44
SVN Workflow Update Make changes Update Always update before beginning work and before committing changes Resolve conflicts Commit September 2013 CSE 160 45