| 1 | {{{ |
| 2 | #!html |
| 3 | <h1> Basic commands to manage source versions: Subversion (<code>svn</code>)</h1> |
| 4 | }}} |
| 5 | |
| 6 | [[PageOutline]] |
| 7 | |
| 8 | ## How to find help ## |
| 9 | |
| 10 | General help : |
| 11 | |
| 12 | {{{ |
| 13 | #!sh |
| 14 | svn help |
| 15 | }}} |
| 16 | |
| 17 | Help for a specific command (e.g. {{{add}}}) |
| 18 | |
| 19 | {{{ |
| 20 | #!sh |
| 21 | svn help add |
| 22 | }}} |
| 23 | |
| 24 | ## How to create a workspace from a file repository ## |
| 25 | |
| 26 | In one of your directories, from a file repository identified by a URL: |
| 27 | |
| 28 | {{{ |
| 29 | #!sh |
| 30 | svn checkout URL directory |
| 31 | }}} |
| 32 | |
| 33 | ## How to find out about your workspace's status ## |
| 34 | |
| 35 | To find out if a file has been modified since your last update ({{{checkout}}} or {{{update}}}) : |
| 36 | {{{ |
| 37 | #!sh |
| 38 | svn status [namefile] |
| 39 | }}} |
| 40 | |
| 41 | To find out if your file has been modified in its present state : |
| 42 | {{{ |
| 43 | #!sh |
| 44 | svn status -u [namefile] |
| 45 | }}} |
| 46 | |
| 47 | If a file's content has been modified, this will be shown in the 1st column. If a file's property has been modified, this will be shown in the 2nd column. |
| 48 | |
| 49 | A:: |
| 50 | the file has been added in your workspace. It does not exist in the file repository. |
| 51 | D:: |
| 52 | the file has been deleted from your directory. It still exists in the file repository. |
| 53 | M:: |
| 54 | the file has been modified in your workspace. It is different than the file in the repository |
| 55 | |
| 56 | ## How to find out the repository's status ## |
| 57 | |
| 58 | If you want to find out the changes that have been made in the svn sources repository : |
| 59 | |
| 60 | {{{ |
| 61 | #!sh |
| 62 | svn log -rHEAD:BASE |
| 63 | }}} |
| 64 | |
| 65 | To find out all revisions (version number and message) related to a file ; |
| 66 | {{{ |
| 67 | #!sh |
| 68 | svn log [namefile] |
| 69 | }}} |
| 70 | |
| 71 | This information can be accessed via the related [wiki:DocKexterntools#forge forge] with the `Timeline` tag. |
| 72 | |
| 73 | |
| 74 | ## How to update your workspace ## |
| 75 | |
| 76 | [[NoteBox(warn, It is not recommended to update your workspace unless you have previously spoken with the persons in charge of each model components\, configurations or tools.)]] |
| 77 | {{{ |
| 78 | #!sh |
| 79 | svn update [namefile] |
| 80 | }}} |
| 81 | |
| 82 | Example : |
| 83 | {{{ |
| 84 | #!sh |
| 85 | svn update toto |
| 86 | U toto |
| 87 | }}} |
| 88 | |
| 89 | The '''svn update''' command returns a letter (U, A, D, R, G or C) and the file name concerned. Below is the meaning of these letters : |
| 90 | U:: |
| 91 | The file has been updated properly. There is no conflict. |
| 92 | A:: |
| 93 | The file has been added to your directory, it did not exist before. |
| 94 | D:: |
| 95 | The file has been deleted from your directory. |
| 96 | R:: |
| 97 | The file has been replaced in your directory. |
| 98 | G:: |
| 99 | You have changed the original file and these changes are not in conflict with the update. |
| 100 | C:: |
| 101 | There are conflicts between the update and you own changes. You must therefore open the file and solve the problems by hand. |
| 102 | |
| 103 | ## How to add a svn version identifier in a file header ## |
| 104 | |
| 105 | Add the following line in the file's header : |
| 106 | |
| 107 | {{{! $Id$}}} |
| 108 | [[BR]] |
| 109 | or according to type of file (shell script, makefile, etc.) |
| 110 | [[BR]] |
| 111 | {{{# $Id$}}} |
| 112 | |
| 113 | Then type the following command lines : |
| 114 | |
| 115 | {{{ |
| 116 | #!sh |
| 117 | svn propset svn:keywords "Id" *.f90 |
| 118 | }}} |
| 119 | |
| 120 | This modification will be taken into account in the repository in the next [#Propagerlesmodificationsdesonespacedetravailaudépôt "commit"] of this file. |
| 121 | |
| 122 | ## How to add a directory or a file to your workspace ## |
| 123 | |
| 124 | {{{ |
| 125 | #!sh |
| 126 | svn add newnamefile |
| 127 | }}} |
| 128 | |
| 129 | This modification will be taken into account in the repository in the next [#Propagerlesmodificationsdesonespacedetravailaudépôt "commit"] of this file. |
| 130 | |
| 131 | ## How to delete a file ## |
| 132 | |
| 133 | {{{ |
| 134 | #!sh |
| 135 | svn delete namefile |
| 136 | }}} |
| 137 | |
| 138 | This modification will be taken into account in the repository in the next [#Propagerlesmodificationsdesonespacedetravailaudépôt "commit"] of this file. |
| 139 | |
| 140 | ## How to propagate the changes from your workspace to the repository ## |
| 141 | |
| 142 | '''This is only possible if the repository has been retrieved as administrator with ({{{svn checkout svn+ssh://...}}}) ''' |
| 143 | |
| 144 | {{{ |
| 145 | #!sh |
| 146 | svn commit --message "explication modification" [namefile] |
| 147 | }}} |
| 148 | |
| 149 | If {{{namefile}}} does not appear in the command, all modified ({{{M}}}), added ({{{A}}}) or deleted ({{{D}}}) files in the current workspace will be taken into account. |
| 150 | Files identified by the sign {{{!}}} and {{{?}}} by {{{svn status}}} will not be taken into account. |
| 151 | |
| 152 | ## How to change the status of a version retrieved with svn ## |
| 153 | |
| 154 | If you retrieved a model in read-only mode ({{{svn export ...}}}) and if you want to perform a "commit" on it, you can change the status of this version. Here is an example with igcmg: |
| 155 | {{{ |
| 156 | #!sh |
| 157 | svn switch --relocate http://forge.ipsl.jussieu.fr/igcmg/svn svn+ssh://login@forge.ipsl.jussieu.fr/ipsl/forge/projets/igcmg/svn |
| 158 | }}} |
| 159 | |