en:developer:using_svn
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | en:developer:using_svn [2023/03/13 01:46] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | |||
+ | ====== Using SVN ====== | ||
+ | For notes on installing SVN, read [[en: | ||
+ | |||
+ | |||
+ | =====Checking out projects===== | ||
+ | You need to know the urls of the components you want to checkout. Then you would do either of the following: | ||
+ | < | ||
+ | < | ||
+ | The above will check it all out into a default folder name. For instance: | ||
+ | < | ||
+ | will check out Greenstone 3 into a folder called greenstone3 in the current directory. | ||
+ | |||
+ | You can alternatively provide an optional folder name at the end of the command, to check the contents out into: | ||
+ | < | ||
+ | This will check out Greenstone 3 into a folder called gs3-svn. | ||
+ | |||
+ | =====svn update and revert ===== | ||
+ | An svn update merges the repository' | ||
+ | |||
+ | * To update the local file(s) with just the changes made in the repository, do an "svn update": | ||
+ | < | ||
+ | * To overwrite local file(s) with the one in the repository, do an "svn revert" | ||
+ | < | ||
+ | |||
+ | You can update an entire directory (and subdirectories) by moving into that directory and typing: | ||
+ | < | ||
+ | |||
+ | =====svn diff===== | ||
+ | Note that svn diff does not connect to the repository! It compares your file against the file you had downloaded, not the file as it exists at the moment in the svn repository. | ||
+ | |||
+ | To find out what changes you've made to a greenstone source file: | ||
+ | < | ||
+ | > svn diff < | ||
+ | e.g. | ||
+ | > svn diff util.pm | ||
+ | </ | ||
+ | |||
+ | =====Committing files===== | ||
+ | Perform an svn diff it to look over the changes made since you last updated the file. Then svn update the file, perform the svn diff on the updated file, then svn commit it with a message: | ||
+ | < | ||
+ | Will show you the changes you've made since you last did an svn update on the file. | ||
+ | < | ||
+ | It will merge changes made to the file in the repository with the changes you have on your machine. Your own changes take precedence and these are preserved. However, conflicts may arise if any of the lines that have been modified on your machine have been changed in the repository since you last checked it out/ | ||
+ | < | ||
+ | This diff now shows up the differences between your current file and what's there now in the repository. Check that only the new code you have added is the sum total of the differences. | ||
+ | < | ||
+ | Where the message string is one that explains what changes have been made, why you are committing the file or what purpose a new file serves. | ||
+ | |||
+ | To perform these svn operations on more more than 1 file in one go, separate them by spaces: | ||
+ | < | ||
+ | > svn diff < | ||
+ | > svn update < | ||
+ | > svn diff < | ||
+ | > svn commit - m " | ||
+ | </ | ||
+ | |||
+ | =====Adding a new file to the repository===== | ||
+ | How to add a file (not for creating new folders in the svn repository): | ||
+ | < | ||
+ | svn add < | ||
+ | svn commit -m "This new file will do something useful" | ||
+ | </ | ||
+ | You can add more than one file at a time: | ||
+ | < | ||
+ | svn add < | ||
+ | svn commit -m "These new files work together to add some extra functionality" | ||
+ | </ | ||
+ | =====Deleting a file from the repository===== | ||
+ | To remove a file from the repository, you need to give it the url of the file in the repository: | ||
+ | < | ||
+ | Aliases for svn remove are "svn delete" | ||
+ | If more than one file needs to be removed, you need to perfom the svn remove operation for each file one after another. (You can't remove several files from the repository at the same time in one line.) | ||
+ | |||
+ | =====Helpful svn commands===== | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | If you do an "svn status" | ||
+ | To see what modifications were made to individual files marked with an M, you'd do an "svn diff": | ||
+ | < | ||
+ | |||
+ | < | ||
+ | > svn help | ||
+ | > svn help [item] | ||
+ | eg. svn help status | ||
+ | </ | ||
+ | The last gives instructions on how to use an svn command. | ||
+ | For example: | ||
+ | < | ||
+ | Will tell you that to commit changes, you do "svn commit [path] --message "< | ||
+ | |||
+ | |||
+ | =====Conflicts and resolving them===== | ||
+ | * If, when doing an "svn status" | ||
+ | * Doing an "svn update" | ||
+ | |||
+ | If you ever encounter a file in conflict and you view it in an editor, you will see that conflicted lines will be marked with ===== and >>>> | ||
+ | (If you had done an "svn update" | ||
+ | |||
+ | =====To resolve conflicts in a file marked with a C===== | ||
+ | - Open up the file that's in conflict in an editor. | ||
+ | - Search for all occurrences of >>> | ||
+ | - Deal with marked sections as appropriate: | ||
+ | - Once you've finished editing out the conflicts in the file, you have to set the file's status to resolved for it to be up to date (and updateable with svn): | ||
+ | < | ||
+ | If you now try svn update on the file, it should no longer be marked as being in conflict. | ||
+ | |||
+ | =====svn log and annotate===== | ||
+ | * To find out the list of changes made to code in a file: | ||
+ | < | ||
+ | The above will list the code changes with NUMBERS in front of each line. For example, | ||
+ | < | ||
+ | |||
+ | * To find the message added into the log for making a change | ||
+ | < | ||
+ | That will give all the messages for all the code changes. For example, | ||
+ | < | ||
+ | |||
+ | * Or, if you know the specific line of change for which you want to understand the reasoning or view the log message: | ||
+ | < | ||
+ | For example: | ||
+ | < | ||
+ | |||
+ | * If you want to find all the files in a particular commit and the log message for them: | ||
+ | < | ||
+ | Example output: | ||
+ | < | ||
+ | r18201 | ak19 | 2008-12-15 14:10:06 +1300 (Mon, 15 Dec 2008) | 1 line | ||
+ | Changed paths: | ||
+ | M / | ||
+ | |||
+ | When associated files are renamed with the URLencoded versions of their original filenames, | ||
+ | the spaces are no longer URL encoded, as this conflicted with mp3, wmv and possibly other | ||
+ | media file formats being opened in external or browser-embedded apps | ||
+ | ------------------------------------------------------------------------</ | ||
+ | |||
+ | =====Creating a new project in the svn repository===== | ||
+ | You'd do this if you want to put your program, stored only on your machine at the moment, onto the svn repository. | ||
+ | |||
+ | The program folder on your harddrive, called " | ||
+ | * all the directories (e.g. src, lib, bin) and | ||
+ | * loose files (e.g. build.xml and *.bat, *.sh scripts). | ||
+ | |||
+ | If you want to put this project folder into the repository, inside http:// | ||
+ | then you would type the following in your x-term: | ||
+ | < | ||
+ | svn import -m "my message" | ||
+ | </ | ||
+ | That will put your folder and its contents into the svn repository inside a similarly named folder. | ||
+ | Now, we need to check out our own svn-managed copy: | ||
+ | Move up out of the local my_program directory and make a back-up copy of original program folder, just in case: | ||
+ | < | ||
+ | 4. mv my_program my_program.bak | ||
+ | </ | ||
+ | Finally, checkout the a copy of the program from the svn repository, that will be stored on your machine in my_program: | ||
+ | < | ||
+ | Your program folder is just as before, except that it's now managed with svn. | ||
+ | |||
+ | ===== Copying an older revision of a file or folder back into the current svn revision===== | ||
+ | If you've accidentally deleted an svn repository folder, such as " | ||
+ | < | ||
+ | The revision version number you want to copy should be one where the folder (or file) you accidentally wiped out still exists. | ||
+ | For example: | ||
+ | < | ||
+ | The above copies the folder of revision version 15315 at http:// | ||
+ | |||
+ | =====Checking out an older revision from SVN===== | ||
+ | a. In general, you would do: | ||
+ | < | ||
+ | |||
+ | If there were conflicts, delete everyting and checkout the older version: | ||
+ | < | ||
+ | |||
+ | Comparing versions: comparing current folder contents with contents of an older revision: | ||
+ | < | ||
+ | |||
+ | b. Checking out an older revision of Greenstone 3 is a special situation. For this you would do: | ||
+ | < | ||
+ | < | ||
+ | This will do an ant prepare/ant install/ant command using the revision number specified. Usually, you'd want to do an "ant prepare" | ||
+ | =====Changing an svn property===== | ||
+ | You may want to do this if a regular text file in the svn repository is marked as a binary file and therefore won't let you do an "svn diff" to compare the text contents. | ||
+ | |||
+ | An example situation: | ||
+ | |||
+ | < | ||
+ | Output: | ||
+ | < | ||
+ | |||
+ | |||
+ | ___________________________________________________________________ | ||
+ | |||
+ | |||
+ | Cannot display: file marked as a binary type. | ||
+ | |||
+ | |||
+ | svn: | ||
+ | </ | ||
+ | |||
+ | To view a listing of the svn properties on this file: | ||
+ | < | ||
+ | Output: | ||
+ | < | ||
+ | |||
+ | |||
+ | svn: | ||
+ | |||
+ | |||
+ | svn: | ||
+ | </ | ||
+ | |||
+ | To edit the svn properties of this file: | ||
+ | < | ||
+ | Output: | ||
+ | < | ||
+ | < | ||
+ | The above sets an editor to edit the svn properties with. In the example, it is the editor " | ||
+ | |||
+ | Now you can choose to edit these properties: | ||
+ | < | ||
+ | |||
+ | If you only opened it up in an editor to have a good look at the contents but didn't make (or save) any changes, then when you close the editor, the output will likely be: | ||
+ | < | ||
+ | |||
+ | The troublesome property is the mime-type, which we delete as follows: | ||
+ | < | ||
+ | Output: | ||
+ | < | ||
+ | |||
+ | Now, if we do an "svn diff" on the file (which we couldn' | ||
+ | < | ||
+ | the output will be: | ||
+ | < | ||
+ | |||
+ | |||
+ | ___________________________________________________________________ | ||
+ | |||
+ | |||
+ | Name: svn: | ||
+ | |||
+ | |||
+ | - application/ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | Sending | ||
+ | |||
+ | Committed revision 16545. | ||
+ | </ | ||
+ | |||
+ | =====SVN Externals===== | ||
+ | SVN externals grab folders and files located in another part of the SVN repository, which is handy if you want to avoid duplication. From version 1.6 of SVN, one can have svn externals pointing not only to folders but files. | ||
+ | |||
+ | In order to set up or adjust the svn: | ||
+ | |||
+ | * Use a terminal to set up an editor to adjust the svn externals property. | ||
+ | |||
+ | |||
+ | On Windows: | ||
+ | < | ||
+ | On Linux: | ||
+ | < | ||
+ | * To start editing the svn externals property at //this// folder (.) level, type the following in the terminal: | ||
+ | < | ||
+ | * Add in a line for each new file or folder to be checked out: going from the Source, of where to checkout the file/folder from and which can be a relative path since it's pointing to the same SVN repository, to the Name that the file or folder should have once checked out into this location. E.g. if editing the GS3/ | ||
+ | < | ||
+ | ../ | ||
+ | ../ | ||
+ | * Finally, you need to commit the property changes made at the current level (.) to the repository. Make sure that not else exists at this level or in subfolders that needs commiting& | ||
+ | < | ||
+ | |||
+ | |||
+ | =====Getting the Revision Number of your Subversion Working Copy===== | ||
+ | < | ||
+ | As explained [[http:// | ||
+ | |||
+ | |||
+ | =====Setting executable permissions on a new script committed to SVN===== | ||
+ | [[http:// | ||
+ | * export EDITOR=emacs | ||
+ | * svn propset svn: | ||
+ | or svn propset svn: | ||
+ | (You want the * to appear in the svn: | ||
+ | |||
+ | |||
+ | ===== Changing svn user for commit ===== | ||
+ | When you're committing code from another GS developer' | ||
+ | |||
+ | Usually, this happens when you don't know the password. But if the password is saved, you automatically end up committing under the other user's name anyway. To switch over to your username: | ||
+ | [[http:// | ||
+ | |||
+ | < | ||
+ | |||
+ | ===== Further commands to look at ===== | ||
+ | http:// | ||
+ | |||
+ | |||
+ | ===== SVN status codes ===== | ||
+ | |||
+ | http:// | ||
+ | |||
+ | ===== Removing .svn subfolders ===== | ||
+ | |||
+ | http:// | ||
+ | |||
+ | From the DOS PROMPT: | ||
+ | < | ||
+ | From a batch script: | ||
+ | < |
en/developer/using_svn.txt · Last modified: 2023/03/13 01:46 by 127.0.0.1