| 1 | Subversion (SVN) and Change Control |
|---|
| 2 | =================================== |
|---|
| 3 | |
|---|
| 4 | Notes: |
|---|
| 5 | ------ |
|---|
| 6 | * Commands preceded with "$" imply that you should execute the command as |
|---|
| 7 | a general user - not as root. |
|---|
| 8 | * Commands preceded with "#" imply that you should be working as root. |
|---|
| 9 | * Commands with more specific command lines (e.g. "rtr>" or "mysql>") |
|---|
| 10 | imply that you are executing commands on remote equipment, or within |
|---|
| 11 | another program. |
|---|
| 12 | * If a command line ends with "\" this indicates that the command continues |
|---|
| 13 | on the next line and you should treat this as a single line. |
|---|
| 14 | |
|---|
| 15 | Exercises Part I |
|---|
| 16 | ================ |
|---|
| 17 | |
|---|
| 18 | 0. Log in to your PC. |
|---|
| 19 | |
|---|
| 20 | Once you are logged in you can continue with these exercises. |
|---|
| 21 | If Subversion is not already installed: |
|---|
| 22 | |
|---|
| 23 | $ sudo bash (become root user) |
|---|
| 24 | |
|---|
| 25 | # apt-get install subversion (install subversion) |
|---|
| 26 | |
|---|
| 27 | 1. Create a root directory for the SVN repository: |
|---|
| 28 | |
|---|
| 29 | # mkdir /svn |
|---|
| 30 | |
|---|
| 31 | 2. Create the repository: |
|---|
| 32 | |
|---|
| 33 | # svnadmin create /svn/nmmarchive |
|---|
| 34 | |
|---|
| 35 | 3. Create user and password |
|---|
| 36 | |
|---|
| 37 | # vi /svn/nmmarchive/conf/passwd |
|---|
| 38 | nmm = CLASSPASSWORD |
|---|
| 39 | |
|---|
| 40 | 4. Configure access |
|---|
| 41 | |
|---|
| 42 | # vi /svn/nmmarchive/conf/svnserve.conf |
|---|
| 43 | |
|---|
| 44 | Remove comments and don't leave one space at the start of the lines: |
|---|
| 45 | |
|---|
| 46 | auth-access=write |
|---|
| 47 | passwd-db=passwd |
|---|
| 48 | |
|---|
| 49 | Exit and save the file. |
|---|
| 50 | |
|---|
| 51 | 5. Start the service: |
|---|
| 52 | |
|---|
| 53 | # svnserve -d -r /svn/nmmarchive |
|---|
| 54 | |
|---|
| 55 | 6. Go to your home directory and create a test file: |
|---|
| 56 | |
|---|
| 57 | # cd |
|---|
| 58 | # vi config.txt |
|---|
| 59 | |
|---|
| 60 | Add some text in the file. Save and exit. |
|---|
| 61 | |
|---|
| 62 | 7. Import the test file in to the repository: |
|---|
| 63 | |
|---|
| 64 | # svn import config.txt svn://localhost/config.txt |
|---|
| 65 | |
|---|
| 66 | You'll be placed in an editor where you can make a comment about the |
|---|
| 67 | file being placed in the repository. At the top of the file add some |
|---|
| 68 | short comment, then save and exit from the file. Accept the default filename. |
|---|
| 69 | |
|---|
| 70 | You'll likely end up in the "joe" editor. If so, add a comment at the top of the file, |
|---|
| 71 | then press CTRL-K-X to exit and save. |
|---|
| 72 | |
|---|
| 73 | Next you'll need to enter in a root password, the username you defined and |
|---|
| 74 | the password for the user. |
|---|
| 75 | |
|---|
| 76 | Finally, you may see a warning about storing unencrypted passwords. For now |
|---|
| 77 | say "yes" to the prompt to continue. |
|---|
| 78 | |
|---|
| 79 | If it all works you should see something like: |
|---|
| 80 | |
|---|
| 81 | Sore password unencrypted (yes/no)? yes |
|---|
| 82 | Adding config.txt |
|---|
| 83 | |
|---|
| 84 | Committed revision 1. |
|---|
| 85 | |
|---|
| 86 | 8. List the repository: |
|---|
| 87 | |
|---|
| 88 | # svn list svn://localhost |
|---|
| 89 | |
|---|
| 90 | You should just see the name of the file we have committed, or: |
|---|
| 91 | |
|---|
| 92 | config.txt |
|---|
| 93 | |
|---|
| 94 | 9. Create a local copy of the repository |
|---|
| 95 | |
|---|
| 96 | # cd /tmp |
|---|
| 97 | # svn checkout svn://localhost |
|---|
| 98 | # cd localhost |
|---|
| 99 | |
|---|
| 100 | The default directory name is "localhost" in this case. |
|---|
| 101 | |
|---|
| 102 | 10. Edit and make changes to config.txt |
|---|
| 103 | |
|---|
| 104 | # vi config.txt |
|---|
| 105 | |
|---|
| 106 | 11. Commit the changes you just made in your local repository to the master SVN |
|---|
| 107 | repository: |
|---|
| 108 | |
|---|
| 109 | # svn commit |
|---|
| 110 | |
|---|
| 111 | Again you'll have a change to add some comments. Do this save the file |
|---|
| 112 | and exit. |
|---|
| 113 | |
|---|
| 114 | You should see: |
|---|
| 115 | |
|---|
| 116 | Committed revision 2. |
|---|
| 117 | |
|---|
| 118 | That's it. You are now using subversion in a local repository: |
|---|
| 119 | |
|---|
| 120 | /tmp/localhost |
|---|
| 121 | |
|---|
| 122 | In conjunction with the master repository: |
|---|
| 123 | |
|---|
| 124 | /svn/nmmarchive |
|---|
| 125 | |
|---|
| 126 | 12. Run a few more svn commands on the local copy of the master repository |
|---|
| 127 | |
|---|
| 128 | As you are in /tmp/localhost if you type: |
|---|
| 129 | |
|---|
| 130 | # ls -lah |
|---|
| 131 | |
|---|
| 132 | you'll see a hidden directory ".svn" - This is what tells the svn |
|---|
| 133 | command that there is a repository. So, if you type: |
|---|
| 134 | |
|---|
| 135 | # svn list |
|---|
| 136 | |
|---|
| 137 | You'll get back: |
|---|
| 138 | |
|---|
| 139 | config.txt |
|---|
| 140 | |
|---|
| 141 | Try running a few more svn commands: |
|---|
| 142 | |
|---|
| 143 | # svn log |
|---|
| 144 | # svn info |
|---|
| 145 | # svn help |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | |
|---|