Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
noresm:svntutorial [2013-12-10 13:36:18] alfg |
noresm:svntutorial [2022-05-31 09:29:32] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ======SVN | + | ======SVN |
| NOTE: THE EXAMPLES ARE DONE ON ALFS PC, AND ANY DIRECTORY NAMES CONTAINING | NOTE: THE EXAMPLES ARE DONE ON ALFS PC, AND ANY DIRECTORY NAMES CONTAINING | ||
| " | " | ||
| - | ==== PART 1 : Create a repository and put a file there ==== | + | ===== PART 1 : Create a repository and put a file there ===== |
| CREATE A REPOSITORY | CREATE A REPOSITORY | ||
| - | + | < | |
| alfg@pc4400: | alfg@pc4400: | ||
| + | </ | ||
| CREATE A WORKING DIRECTORY WITH CODE | CREATE A WORKING DIRECTORY WITH CODE | ||
| + | < | ||
| alfg@pc4400: | alfg@pc4400: | ||
| + | </ | ||
| Use the following as the file test.F90: | Use the following as the file test.F90: | ||
| Line 30: | Line 32: | ||
| CD TO WORKING DIRECTORY AND VERIFY THAT THE TEST FILE IS THERE | CD TO WORKING DIRECTORY AND VERIFY THAT THE TEST FILE IS THERE | ||
| + | < | ||
| alfg@pc4400: | alfg@pc4400: | ||
| total 4 | total 4 | ||
| -rw-rw-r-- 1 alfg alfg 166 Dec 6 14:51 test.F90 | -rw-rw-r-- 1 alfg alfg 166 Dec 6 14:51 test.F90 | ||
| + | </ | ||
| CD TO THE FRESHLY CREATED REPOSITORY AND CREATE " | CD TO THE FRESHLY CREATED REPOSITORY AND CREATE " | ||
| + | < | ||
| alfg@pc4400: | alfg@pc4400: | ||
| + | </ | ||
| IMPORT YOUR WORKING-DIRECTORY TO THE REPOSITORY | IMPORT YOUR WORKING-DIRECTORY TO THE REPOSITORY | ||
| + | < | ||
| alfg@pc4400: | alfg@pc4400: | ||
| + | </ | ||
| MAKE A BRANCHES-DIRECTORY | MAKE A BRANCHES-DIRECTORY | ||
| + | < | ||
| alfg@pc4400: | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | ==>YOU NOW HAVE A REPOSITORY CONTAINING TRUNK AND (EMPTY) BRANCHES DIRECTORY. YOU CAN START TO USE IT | ||
| + | |||
| + | ===== PART 2: Create a working directory for two developers ==== | ||
| + | |||
| + | < | ||
| + | alfg@pc4400: | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | CHECK OUT TRUNK FOR ONE DEVELOPER | ||
| + | < | ||
| + | alfg@pc4400: | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | CREATE A BRANCH BASED ON TRUNK | ||
| + | < | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | CD BACK ONE STEP AND CHECK OUT THE BRANCH FOR THE OTHER DEVELOPER | ||
| + | < | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==> THE DIRECTORY " | ||
| + | USING THE " | ||
| + | |||
| + | < | ||
| + | alfg@pc4400: | ||
| + | total 8 | ||
| + | drwxrwxr-x 3 alfg alfg 4096 Dec 9 08:36 trunk | ||
| + | drwxrwxr-x 3 alfg alfg 4096 Dec 9 09:40 aBranch | ||
| + | </ | ||
| + | |||
| + | |||
| + | =====PART 3: Create conflict in the file test.F90 ===== | ||
| + | |||
| + | EDIT FILE ON TRUNK | ||
| + | < | ||
| + | alfg@pc4400: | ||
| + | alfg@pc4400: | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | EDIT FILE ON BRANCH | ||
| + | < | ||
| + | alfg@pc4400: | ||
| + | alfg@pc4400: | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | ==> We have now created a conflict between the branch " | ||
| + | |||
| + | < | ||
| + | alfg@pc4400: | ||
| + | 9c9 | ||
| + | < print*, "Hi Man! a+b is " , a+b | ||
| + | --- | ||
| + | > print*, "Hello a+b is " , a+b | ||
| + | </ | ||
| + | |||
| + | ===== PART 4: Test the merge dialog ===== | ||
| + | |||
| + | TRY TO MERGE TRUNK INTO BRANCH | ||
| + | < | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | You will get the message that there is a conflict in file test.F90, you will have to resolve the conflict | ||
| + | Push the " | ||
| + | |||
| + | UNDO THE MERGE WITH | ||
| + | < | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | ==> You have undone the merge, nothing has happened | ||
| + | < | ||
| + | alfg@pc4400: | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | ===== PART 5: Set up favourite editor as merge tool ===== | ||
| + | |||
| + | 1) Create a file somewhere in your pc, for example I use | ||
| + | $HOME/ | ||
| + | |||
| + | For emacs users, the content of the script is: | ||
| + | |||
| + | < | ||
| + | #!/bin/sh | ||
| + | emacs -q --eval " | ||
| + | </ | ||
| + | |||
| + | For vi users, the content of the script is: | ||
| + | |||
| + | < | ||
| + | #!/bin/sh | ||
| + | vim -d " | ||
| + | </ | ||
| + | |||
| + | 2) Open your $HOME/ | ||
| + | < | ||
| + | merge-tool-cmd = / | ||
| + | </ | ||
| + | |||
| + | |||
| + | MAKE SURE SCRIPT IS EXECUTABLE | ||
| + | < | ||
| + | chmod +x $HOME/ | ||
| + | </ | ||
| + | |||
| + | ==> You should now have working merge tools. This will make merging EASY!! | ||
| + | |||
| + | |||
| + | =====PART 6: Go back to merge operation and use merge tool ===== | ||
| + | |||
| + | < | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | type " | ||
| + | |||
| + | ==> emacs or vi should be invoked in "merge mode" | ||
| + | |||
| + | //The vi script// shows (your, ancestor, mine) on top and output below. Move around in the different windows with " | ||
| + | |||
| + | //the emacs script// shows (yours, mine) on top and merged version (including common ancestor) below | ||
| + | |||
| + | All editing should happen in the lowest part of the editor window | ||
| + | |||
| + | When done editing, save the file and quit the editor | ||
| + | |||
| + | When back in the merge-dialog, | ||
| + | |||
| + | |||
| + | ===== PART 7: Verify that you are happy with merge ===== | ||
| + | |||
| + | < | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | Note how it is difficult to understand the diff ==> we need to configure a diff tool! | ||
| + | |||
| + | To configure a nice diff-viewer, | ||
| + | |||
| + | < | ||
| + | diff-cmd = / | ||
| + | </ | ||
| + | |||
| + | The script " | ||
| + | |||
| + | The content of this script (only two lines) for emacs users can be: | ||
| + | |||
| + | < | ||
| + | #!/bin/sh | ||
| + | emacs --eval " | ||
| + | </ | ||
| + | |||
| + | (In emacs, use | (pipeline) key in the " | ||
| + | |||
| + | The content of this script for vi users can be | ||
| + | |||
| + | < | ||
| + | #!/bin/sh | ||
| + | vimdiff $6 $7 | ||
| + | </ | ||
| + | |||
| + | Visually verify the diff again using the diff viewer | ||
| + | < | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | When you are happy with the diffs, do | ||
| + | |||
| + | < | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | ==> DONE | ||
| + | |||
| + | ===== PART 8: Merge back to trunk ===== | ||
| + | |||
| + | After the conflict is resolved and committed from branch, go back to trunk | ||
| + | |||
| + | < | ||
| + | alfg@pc4400: | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | AT THIS POINT YOU WANT TO PASS THE TESTS (IF THIS WAS NORESM) | ||
| + | |||
| + | < | ||
| + | alfg@pc4400: | ||
| + | </ | ||
| + | |||
| + | ==> Observe that you don't get any conflict this time. Svn knows that the conflict is already resolved. | ||
| - | ==> YOU NOW HAVE A REPOSITORY CONTAINING TRUNK AND (EMPTY) BRANCHES DIRECTORY. YOU CAN START TO USE IT | + | ===== Other important points ===== |
| + | * The merge is not completed until you commit! | ||
| + | * You have to know if you are doing a reintegrate merge or a merge from trunk (see noresm wiki) | ||
| + | * You can undo the merge with alfg@pc4400: | ||
| + | * When you have done a " | ||
| + | * If you insist on keeping reintegrated branches alive, there are two options: | ||
| + | - Start using another version control system | ||
| + | - Make sure you have latest svn version (version >= 1.7), Then read (and understand) | ||
| + | | ||