ObjectOriented Software Engineering Using UNIX groups and Subversion
Object-Oriented Software Engineering Using UNIX groups and Subversion “Unix is user-friendly. It's just very selective about who its friends are. ”(Magi’s favourite quote ) http: //www. youtube. com/watch? v=d. FUl. AQZB 9 Ng Estimated Time: 30 -40 minutes
Unix Groups • You should now have been placed in a Unix group on the GAUL system • Everyone in your project group (team) should be in the same Unix group • This means that you can share files with your group members without letting members of other groups see them • You will want to do this for the final code submission directory • We will look at several commands • groups – for seeing what Unix groups you are in • chgrp – for assigning the group ownership of a file • chmod – for permitting group members to access a file
Your Unix Groups To find what Unix groups you are in, issue the command groups You should see a group name with the string CS 2212 in it • E. g CS 2212 -YXX where Y is your section number: 1 or 2 and XX is your group number: 07 for group 7 This is the Unix group that all the members of your project group are in • You should also see a group name indicating that you are in an undergrad course (e. g. 2 ndyr or undrgrad) • This is your default group, but does not matter for CS 2212 purposes UWO Computer Science Department 3
Giving a File to Your Group Permitting a file to your Unix group has two stages: • Change the group ownership of the file • Permit it “to group” Every file has two owners: • A user (i. e. you, for your files) • A Unix group By default, your default Unix group is the group owner of your files To change the Unix group of a file or files, issue the command chgrp group file, where • group is the Unix group you want to change it to • file is the name of the file Example: to give ownership of Queue. Types. h to group CS 212 -YXX: chgrp CS 2212 -YXX Queue. Types. h You can do more than one file this way: e. g. chgrp CS 2212 -YXX *. c *. o UWO Computer Science Department 4
Checking Group Ownership To see what group a file belongs to: • Issue the command “ls –lg file” • This will list the group owner after the user owner Example: cartier issues command “ls –lg Queue. Types. h” • System responds with something like: -rw------- 1 cartier CS 2212 -YXX 258 Oct 17 09: 59 Queue. Type. h • CS 2212 -YXX is the group owner A file can only have one group owner; to change it, just use the chgrp command again with a different group name To restore default group ownership to a file, just make a copy of it and delete the original But using only the chgrp command is still not sufficient to let other members of your group to see the file • It is necessary to permit the file by changing the access mode of the file UWO Computer Science Department 5
Permitting Your Group Access To let the members of a Unix group see a file owned by that Unix group, issue the command chmod g+rw file • This permits the group (g) to have read access (+r) to file • It also permits the group (g) to execute (x) file it is already executable • You can do this on multiple files too Example: • cartier issues command chmod g+rx Queue. Types. h • Then cartier issues command ls –lg Queue. Types. h • System should give something like: -rw-r----- 1 cartier CS 2212 -YXX 258 Oct 17 09: 59 Queue. Type. h The second r in –rw-r----- indicates that the group now has access People outside the Unix group (“others”) do not have read access unless you also say chmod o+rx file UWO Computer Science Department 6
Permitting Access to Directories Note: to give access to a file in a directory, you have to chgrp and chmod the directory too! Option –R on chgrp and chmod will do it recursively on all members of the directory Example: from home directory cartier says chgrp –R CS 2212 -YXX project chmod –R g+rx project • Directory project and everything in it now accessible to group CS 2212 -YXX For more details on how to permit files other different ways, see man chmod UWO Computer Science Department 7
Summary User cartier does: groups System response with: 2 ndyr CS 2212 -YXX cartier now does: chgrp –R CS 2212 -YXX project chmod –R g+rx project cd project ls –lg Queue. Types. h System responds with something like: -rw-r----- 1 cartier CS 2212 -YXX 09: 59 Queue. Types. h User bolivar (in the same group) does: groups System responds with: 3 rdyr CS 2212 -YXX bolivar now does: cd ~cartier/project User bolivar will now be able to read Queue. Types. h UWO 251 Computer Science Department Oct 17 8
Code Repositories • Repository for code is used when coding with other team members, where you share the code. • Your whole team has access to the repository. • Some common ones: Subversion (SVN), CVS, Git • Why do we need repositories? —So we don’t overwrite each others changes —To roll back changes —To have a history of who did what —So we always have a working copy UWO Computer Science Department 9
Revision Control: The Problem Take a software project where: • There are several files with several people working on those files • You want one final version of everything Possible Problems • Different people having different versions of files • Inconsistent changes by different people • Changes getting lost UWO Computer Science Department -JAMIE ANDREWS CS 470 10
Example 1: Conflicting Changes 1. Bob has master copy of the files Person. java and Address. java 2. Alice and Chris get copies of both files 3. Alice changes Person. java and Chris changes Address. java (everything still works for them) 4. Alice copies Person. java back to Bobs area, Chris copies Address. java back to Bobs area 5. Bob tries but can’t compile the program anymore 6. Now there is no working master copy! UWO Computer Science Department -JAMIE ANDREWS CS 470 11
Example 2: Changes Getting Lost 1. 2. 3. 4. 5. Alice and Chris both change Person. java Chris sends his copy to Bob Later, Alice sends her changes to Bob Finally, Chris gets Alices changes from Bob Now no one has Chris’s original changes! UWO Computer Science Department -JAMIE ANDREWS CS 470 12
Git Hub We are going to use Git. Hub to hold the repo in a “cloud” - UWO Computer Science Department 13
Minimizing Problems • ALWAYS FOLLOW THESE STEPS: — Start fresh Before starting any work, update all the files in your workspace with the latest updates (In Eclipse you right click on the project in Subversion Repository View and select Checkout) —Run your unit tests Make sure they all pass, if the system is broken before you start and you start making changes, you won’t know if your changes broke it, or there were previous problems —Make changes Do all your editing in your local workspace. Debug until everything works —Run the unit tests again Make sure your changes didn’t break any of the other components that you weren’t even working on. —Synchronize When you are ready to commit, synchronize. Check incoming changes and add them to your files. Resolve changes. Rerun your unit tests to make sure everything is still correct. THEN COMMIT YOUR CHANGES! UWO Computer Science Department 14
Terminology Check Out checks out all the files in the project Update gets the latest version from the repository and inserts it into your stuff (you should always do this first) Sync with repository Shows the modifications between the latest version in the repository and the changes you have made Commit takes your current file and writes it to the repository (so this will be the new master copy) UWO Computer Science Department 15
When you Sync with Repository, you will see something like this: This shows the changes, resolve the changes and then sync again, then commit when you have no changes. UWO Computer Science Department 16
Step 1: Create a Repository • Have one person create an initial repository on Gaul: • In unix, create a directory that will be the repository • Change the permissions on that directory so your group can access it. • Go to that directory and type pwd to find the absolute path • Create the Subversion repository as follows: svnadmin create Repo • Build the repository in Eclipse (build a project, add some files, then go to the Subversion perspective to attach your files to the repository) • Have your group members attach to your repository in Eclipse UWO Computer Science Department 17
Step 2: Change the permission on the directories Make sure that the user who creates the repository on Gaul changes the permission and groups on the appropriate directories NOTE: I read that you have to do a chmod like this: chmod g+rws (set the setgid bit – default group id- now files created in the directory will have the same group as the directory NOT the default group) UWO Computer Science Department 18
Step 3: Share Projects Note: A file is flagged as either ASCII or Binary, this is important when Subversion displays the line-by-line changes. In most cases, text files should be ASCII To share the project: • Right click on the project in Navigator view (Window > Show View > Navigator (MIGHT NOW BE CALLED PROJECT EXPLORER) and select Team, then select Share Project. Just leave the name the same as the project name. • Commit the files in the project to the repository UWO Computer Science Department 19
Step 4: Bring in Another User Another user wants to use files in the repository, so he/she would: • Open the Subversion Perspective • Right click in the window and select new > Repository Location • Type in the same machine (gaul) and absolute path, but his/her own userid and password • Then expand the repository location, then expand HEAD and you should see the project. Right click on the project and choose Checkout As Project, select Navigator view and now the other user sees the project. UWO Computer Science Department 20
- Slides: 20