For notes on installing SVN, read install SVN.
You need to know the urls of the components you want to checkout. Then you would do either of the following:
svn checkout url
svn co url
The above will check it all out into a default folder name. For instance:
svn checkout http://svn.greenstone.org/main/trunk/greenstone3
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:
svn checkout http://svn.greenstone.org/main/trunk/greenstone3 gs3-svn
This will check out Greenstone 3 into a folder called gs3-svn.
An svn update merges the repository's changes with the local changed code, or shows places where conflicts have arisen (conflicts are shown with a C next to the files you tried to update). If someone else had committed changes to the repository and if these did not conflict with the changes in your own version, the svn update would show up a "G", not a "C". To deal with conflicts (C), see a later section.
> svn update <filename1> <filename2> ... <filenameN>
> svn revert <filename1> ... <filenameN>
You can update an entire directory (and subdirectories) by moving into that directory and typing:
>svn update
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:
> cd <folder containing source file> > svn diff <filename> e.g. > svn diff util.pm
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:
> svn diff <filename>
Will show you the changes you've made since you last did an svn update on the file.
> svn update <filename>
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/svn-updated it.
> svn diff <filename>
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.
> svn commit - m "message" <filename>
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 <filename> <filename2> <filenameN> > svn update <filename> <filename2> <filenameN> > svn diff <filename> <filename2> <filenameN> > svn commit - m "message" <filename> <filename2> <filenameN>
How to add a file (not for creating new folders in the svn repository):
svn add <filename> svn commit -m "This new file will do something useful" <filename>
You can add more than one file at a time:
svn add <filename1> <filename2> <filenameN> svn commit -m "These new files work together to add some extra functionality" <filename1> <filename2> <filenameN>
To remove a file from the repository, you need to give it the url of the file in the repository:
svn remove -m "I deleted this file for a reason" http://svn.greenstone.org/....../thefile.ext
Aliases for svn remove are "svn delete" and "svn rm". 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.)
> svn info
> svn switch
> svn status
If you do an "svn status" in a folder, it recursively lists all the Modified (M), Deleted (D) and Added (A) files. It will also show up files that are in conflict (C) and those about which svn does not know (?). To see what modifications were made to individual files marked with an M, you'd do an "svn diff":
> svn diff <filename>
> svn help > svn help [item] eg. svn help status
The last gives instructions on how to use an svn command. For example:
> svn help commit
Will tell you that to commit changes, you do "svn commit [path] –message "<reasoning>"
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 »». Both the changes you made and the conflicting changes in the repository will be embedded inside such special marks. (If you had done an "svn update" on files that turned out to conflict, the action would have created a couple of additional versions of the file: conflict-filename.mine and conflict-filename.<revisionnumber>. The first is your local version containing the changes you made. The second is the file as it is in the svn repository.)
svn resolved <filename>
If you now try svn update on the file, it should no longer be marked as being in conflict.
>svn annotate <filename>
The above will list the code changes with NUMBERS in front of each line. For example,
svn annotate GathererProg.java | less
>svn log <filename>
That will give all the messages for all the code changes. For example,
svn log GathererProg.java | less
>svn log -rNUMBER <filename>
For example:
svn log -r10242 GathererProg.java
svn -v log http://svn.greenstone.org -r18201
Example output:
------------------------------------------------------------------------ r18201 | ak19 | 2008-12-15 14:10:06 +1300 (Mon, 15 Dec 2008) | 1 line Changed paths: M /gsdl/trunk/perllib/unicode.pm 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 ------------------------------------------------------------------------
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 "my_program" for instance, may contain:
If you want to put this project folder into the repository, inside http://svn.greenstone.org/other-projects/trunk/ then you would type the following in your x-term:
cd my_program svn import -m "my message" . http://svn.greenstone.org/other-projects/trunk/my_program
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:
3. cd .. 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:
5. svn co http://svn.greenstone.org/other-projects/trunk/my_program
Your program folder is just as before, except that it's now managed with svn.
If you've accidentally deleted an svn repository folder, such as "my_program", and want to bring it back (the older version is, after all, stored in the svn repository):
svn copy -r <older version number> from-svn-url to-svn-url -m "message"
The revision version number you want to copy should be one where the folder (or file) you accidentally wiped out still exists. For example:
svn copy -r 15315 http://svn.greenstone.org/other-projects/trunk/my_program http://svn.greenstone.org/other-projects/trunk/my_program -m "Accidental delete restored"
The above copies the folder of revision version 15315 at http://svn.greenstone.org/other-projects/trunk/my_program into the same url at the current revision/head.
a. In general, you would do:
/my/local/path/>svn update -r {2008-04-26}
If there were conflicts, delete everyting and checkout the older version:
/my/local/path/>svn co -r {2007-10-01} http://svn.greenstone.org/greenstone3/trunk .
Comparing versions: comparing current folder contents with contents of an older revision:
/my/local/path>svn diff -r {2008-04-26} .
b. Checking out an older revision of Greenstone 3 is a special situation. For this you would do:
ant <target> -Dbranch.revision=<number>
eg. ant prepare -Dbranch.revision=15190
This will do an ant prepare/ant install/ant command using the revision number specified. Usually, you'd want to do an "ant prepare" with the revision flag. (And thereafter compile your greenstone 3 up again with a normal "ant install".)
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:
/my/full/path>svn diff file.ext
Output:
Index: file.ext ___________________________________________________________________ Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
To view a listing of the svn properties on this file:
/my/full/path>svn proplist file.ext
Output:
Properties on 'file.ext': svn:executable svn:mime-type
To edit the svn properties of this file:
/my/full/path>svn propedit svn:mime-type file.ext
Output:
svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR is set, and no 'editor-cmd' run-time configuration option was found
/my/full/path>export EDITOR=emacs
The above sets an editor to edit the svn properties with. In the example, it is the editor "emacs". On Windows you might set this to Notepad for instance.
Now you can choose to edit these properties:
/my/full/path>svn propedit svn:mime-type file.ext
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:
No changes to property 'svn:mime-type' on 'file.ext'
The troublesome property is the mime-type, which we delete as follows:
/my/full/path>svn propdel svn:mime-type file.ext
Output:
property 'svn:mime-type' deleted from 'file.ext'.
Now, if we do an "svn diff" on the file (which we couldn't do before because the file's MIME type was set to binary):
/my/full/path>svn diff file.ext
the output will be:
Property changes on: file.ext ___________________________________________________________________ Name: svn:mime-type - application/octet-stream
/my/full/path>svn commit -m "Property change from binary file into no longer having the mime-type property set (which didn't allow me to do a diff on the file)." file.ext
Sending file.ext Committed revision 16545.
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:externals property on a folder, so it knows upon checkout which other folders and files to grab from SVN as its subelements:
On Windows:
set EDITOR=Notepad
On Linux:
export EDITOR=emacs
svn propedit svn:externals .
../greenstone2/setup.bash setup.bash ../greenstone2/setup.bat setup.bat ../greenstone2/setup.csh setup.csh
svn commit -m "The svn externals property changed for this folder to grab files/folders from elsewhere" .
svnversion .
As explained here.
Changing Permissions in Subversion
or svn propset svn:executable * <filename> (You want the * to appear in the svn:executable property file for the filename)
When you're committing code from another GS developer's account, you may need to change user.
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: SVN: switching active user on checked out repository
For version 1.7 on Windows, it's under %APPDATA%\Subversion\auth. For me, there was a file under svn.simple with a hex filename that I deleted.
http://stackoverflow.com/questions/2532740/windows-batch-file-to-delete-svn-files-and-folders
From the DOS PROMPT:
FOR /R myfolder %X IN (.svn) DO (RD /S /Q "%X" 2>nul)
From a batch script:
FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X" 2>nul)