1 / 16

Software Engineering – Introduction

Software Engineering – Introduction. VERSION CONTROL - SVN Good software engineering practice manages the development and change of your source code as well as any other documents (to a point) you use to maintain information about your project.

gavin
Télécharger la présentation

Software Engineering – Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Software Engineering – Introduction VERSION CONTROL - SVN Good software engineering practice manages the development and change of your source code as well as any other documents (to a point) you use to maintain information about your project. SVN is one of many version control systems. Others include: SourceSafe, CVS, etc. To implement SVN you can use a UNIX account. Tux will do nicely. From the prompt, type “bash” to get a simpler interface to the kernel. The next step is to create a directory for the repository. mkdir svnroot then create a directory for the project you wish to work on. mkdir svnroot/myproject

  2. Software Engineering – Introduction VERSION CONTROL - SVN Now we need to change the permissions on the directory so that your group (you will need to get a group) will have access to your files and no other people. chgrp –R groupname svnroot //assigns the svnroot to a group chmod –R g+rws svnroot //assigns the correct permissions for group // sharing Note if you have multiple projects, assign the group name to a project directory rather than the svnroot. Create an empty repository at the path we created svnadmin create svnroot/myproject/ SVN repository is now created.

  3. Software Engineering – Introduction VERSION CONTROL - SVN Each group member needs to access the SVN repository. Check out the current revision of the repository to the directory specified, in this case svn. svn co file:///home/UserName/svnroot/myproject/ svn Enter the newly created directory cd svn Observe the information for your local copy of the repository svn info Type svn help at any time to get a list of the possible commands.

  4. Software Engineering – Introduction VERSION CONTROL - SVN Once the repository is checked out, you may begin your development. Make the code directory mkdir source Now create your source file. vi source/fletch.c #include <stdio.h> int main() { printf(“Fletch Lives!\n”); return 0; }

  5. Software Engineering – Introduction VERSION CONTROL - SVN Add the file (directory) to the repository svn add source The file is loaded, but not committed. To commit the file type: svn commit –m “Place a message so that the group understands what you did”

  6. Software Engineering – Introduction VERSION CONTROL - SVN If you wish to see what activity has transpired within the repository, type: svn log source Output similar to the following will appear: jsalvage@tux64-04:~/svn$ svn log source ------------------------------------------------------------------------ r3 | jsalvage | 2007-08-02 11:28:03 -0400 (Thu, 02 Aug 2007) | 1 line removed kyle's crappy work ------------------------------------------------------------------------ r2 | kfu22 | 2007-08-02 11:17:51 -0400 (Thu, 02 Aug 2007) | 1 line forcing conflict ------------------------------------------------------------------------ r1 | jsalvage | 2007-08-02 10:34:18 -0400 (Thu, 02 Aug 2007) | 1 line Initial creation of Fletch ------------------------------------------------------------------------ jsalvage@tux64-04:~/svn$

  7. Software Engineering – Introduction VERSION CONTROL - SVN Now, let’s show the power of SVN and modify the fletch.c file from two different group members. However, before you start making changes to your local code it is a good idea to issue an update command to bring your copy up to date with the latest code in the repository. Type the following: svn update Now let’s will change the output to “Fletch hates the Red Sox” while the other group member will change it to “Hello world”. Once your changes have been saved locally, you now must load them to the repository. To do this type: svn commit –m “New message”

  8. Software Engineering – Introduction VERSION CONTROL - SVN The first person to commit the file will not receive an error, however the second person will receive a conflict as shown below: jsalvage@tux64-04:~/svn$ svn commit -m "update to fletch" Sending source/fletch.c svn: Commit failed (details follow): svn: Out of date: '/source/fletch.c' in transaction '2-1' jsalvage@tux64-04:~/svn$ To fix this situation, issue an svn update command as follows: svn update jsalvage@tux64-04:~/svn$ svn update C source/fletch.c Updated to revision 2. C stands for conflict

  9. Software Engineering – Introduction VERSION CONTROL - SVN Observe the following screen capture which appears after typing svn update

  10. Software Engineering – Introduction VERSION CONTROL - SVN Delete the code you do not wish to keep. Clearly Fletch is not a Red Sox fan!

  11. Software Engineering – Introduction VERSION CONTROL - SVN If you try to commit your code now, you will still fail. jsalvage@tux64-04:~/svn$ svn commit svn: Commit failed (details follow): svn: Aborting commit: '/home/jsalvage/svn/source/fletch.c' remains in conflict You must first resolve the state of conflict. You can do this by typig the following: svn resolved jsalvage@tux64-04:~/svn$ svn resolved source/fletch.c Resolved conflicted state of 'source/fletch.c' Then you can commit your code: svn commit jsalvage@tux64-04:~/svn$ svn commit -m "removed kyle's crappy work" Sending source/fletch.c Transmitting file data . Committed revision 3.

  12. Software Engineering – Introduction VERSION CONTROL - SVN In contrast, if you do an svn update without having made local modifications to the same files. Your update will appear as follows: jsalvage@tux64-04:~/svn$ svn update U source/fletch.c Updated to revision 4.

  13. Software Engineering – Introduction VERSION CONTROL - SVN If both users make changes, but to separate lines of code, SVN will automatically merge the two files when they are both committed. Be careful. This may not do what you expect. Imagine one developer sees that there is an inconstancy in the code. i.e. the use of .h. The other developer may also see this. What happens if each developer implements their changes differently?

  14. Software Engineering – Introduction VERSION CONTROL - SVN

  15. Software Engineering – Introduction VERSION CONTROL - SVN jsalvage@tux64-04:~/svn$ svn update G source/fletch.c Updated to revision 5. Notice the G, it means successful merge, but what does that mean?

  16. Software Engineering – Introduction VERSION CONTROL - SVN At any time you can type svn status and it will show you the state of your local files. For example: jsalvage@tux64-04:~/svn$ svn status M source/fletch.c The M shows the local file fletch.c has been modified locally.

More Related