Thursday, 29 August 2013

SVN commands Help

svn checkout file:///tmp/repos/test  ------- checking out the repository

svn add testdir --------- When adding a directory, the default behavior of svn add is to recurse


svn add --non-recursive otherdir ---- You can add a directory without adding its contents


svn add * --force ------


svn cat http://svn.red-bean.com/repos/test/readme.txt ------- If you want to view readme.txt in your repository without checking it out


svn checkout file:///tmp/repos/test mine --- Check out a working copy into a directory called mine


svn checkout file:///tmp/repos/test  file:///tmp/repos/quiz ------ Check out 2 different directories into two separate working copies


svn checkout file:///tmp/repos/test  file:///tmp/repos/quiz working-copies
---- Check out 2 different directories into two separate working copies, but place both into a directory called working-copies.

svn propset svn:mime-type image/jpeg foo.jpg ---- Set the mimetype on a file


svn propset svn:executable ON somescript  -------- On a UNIX system, if you want a file to have the executable permission set


svn propset --revprop -r 25 svn:log "Journaled about trip to New York."
  ----------- If you made a mistake in a log message for a particular revision and want to change it, use --revprop and set svn:log  to the new log message.


svn delete myfile --------- Using svn to delete a file from your working copy merely schedules it to be deleted. When you commit, the file is deleted in the svn commit -m "Deleted file 'myfile'."  repository.

svn delete -m "Deleting file 'yourfile'" file:///tmp/repos/test/yourfile
   ---------- Deleting a URL, however, is immediate, so you have to supply a log message     


svn status wc ------- This is the easiest way to find out what changes you have made to your working copy

svn status --show-updates wc -------- if you want to find out what files in your working copy are out-of-date, pass the --show-updates switch.


svn status --show-updates --verbose wc

svn update ------- Pick up repository changes that have happened since your last update

svn update -r30 ---------- You can also update your working copy to an older revision.

svn commit -m "added howto section." ------- Commit a simple modification to a file with the commit message on the command line and an implicit target of your current directory.


svn commit -F msg foo.c ----- Commit a modification to the file foo.c with the commit message in a file named msg

svn commit -m "removed file 'c'." ----- To commit a file scheduled for deletion

svn move foo.c bar.c  ---------- Move a file in your working copy

svnadmin dump /usr/local/svn/repos ---- Dump your whole repository.

svnadmin dump /usr/local/svn/repos -r 21 --incremental ----- Incrementally dump a single transaction from your repository

svnadmin recover ---- Recover a hung repository, Bring a repository database back into a consistent state.

svnadmin dump /path/to/reponame > /tmp/reponame.dump ; scp -rp /tmp/reponame.dump user@server.domain.com:/tmp/
  ------- dump

svnadmin load /path/to/reponame < /tmp/repo1.dump  ------------ restoring svn repository from dump 


 SVN Dump 

# svnadmin dump /usr/local/svn/repos > full.dump ---- Dump your whole repository.

# svnadmin dump /usr/local/svn/repos -r 21 --incremental > incr.dump ---- Incrementally dump a single transaction from your repository.

# svnadmin recover --------- Recover a hung repository, Bring a repository database back into a consistent state.

# svnadmin dump /path/to/reponame > /tmp/reponame.dump ; scp -rp /tmp/reponame.dump user@server.domain.com:/tmp/ ------- dump.

# svnadmin load /path/to/reponame < /tmp/repo1.dump --- restoring svn repository from dump.

# cd /var/www/svn/
# svnadmin create test2
# svnadmin load /var/www/svn/test2 < svn.dump (dump of script repo)


To Restore Svn Dump

# svnadmin create /var/www/SVN/Project
# svnadmin load /var/www/SVN/project < project4.dump
# svnadmin load /var/www/SVN/project < project4_trunk.dump ----> If need to restore only the trunk. 


Importing from remote machine

svn import --username ctechz workingDir http://192.168.0.54/projectName/trunk -m "prodmlserver"
if u are committing files for the first time do this much.


if any changes are made by developers by checkout it and we want to add it into the server use the 'svn add' cmd

if we modify any changes in checkout file, just specify # svn update --- so that the updation will get for all the users if add and folders or touched any files give # svn add before committing them 

# svn ci

Renaming an SVN(Subversion) Repository 

SVN is document versioning software commonly used by software developers as a repository for source code.

Issue: Renaming a Repository
Here's the scenario: We have an SVN repository and we want to change it's name.

The solution: svnadmin dump & svnadmin load


The correct way to do this is to actually create a repository with the new name, and then import all revisions from the old repository into the newly created one. This way, all the revision history will be preserved

So, first we create a repository with the new name. Assuming /path/to/new/repository/ is the path where you want the new repository to be created, and <new-repo-name> is the new name, the command would look like this..

# svnadmin create /path/to/new/repository/<new-repo-name>


Then we dump all the data from the old respository into a file called old-repo.dump. We will assume /the/path/to/old/repository/ is the path to the repository and that the old repository was called old-repo-name.

# svnadmin dump /the/path/to/old/repository/<old-repo-name> > old-repo.dump

 
Now, we can import the dump file into the newly created repository. In order to to that we use the SVN load command.

# svnadmin load /the/path/to/new/repository/<new-repo-name> < old-repo.dump
NOTE: One thing to note is that for this method to be successful, the newly created repository has to be empty. Otherwise you may get all sorts of errors and/or funny results.


The other observation that I would make is that in case of a large project, this process may take a while and the resulting dump file and new repository may be rather large.


To remove a directory from svn 

# svn remove dir
# svn list file:///var/www/svn/script/trunk/
# svn ci -m "commit"
# svn list file:///var/www/svn/script/trunk/


To re-name a directory in svn 

# svn ren sqlbkp.sh sqlbkp1.sh
# svn list file:///var/www/svn/script/trunk/
# svn ci -m "commit"
# svn list file:///var/www/svn/script/trunk/


To backup only your latest revision

First you need to find out the latest revision number from your repository. To do that just run below command:

# svnadmin verify [REPO_PATH]
 

It will list out the revision number and the most bottom will be your latest revision number. That will be referenced by [LATEST_REVISION_NUM] from now on.

Run below command to backup only the latest revision from [REPO_PATH].
 

# svnadmin dump -r [LATEST_REVISION_NUM] [REPO_PATH] > [DUMP_FILE_PATH] 

The version number is just a shortcut to the date at which the project is stamped. Let's now get a copy of the previous version(assuming the revision number is 4)
 

cd /tmp/
$ svn checkout -r 3 file:///home/user/svn project
U project/project/trunk/src/main.cpp
U project/project/trunk/src/Makefile
D project/project/trunk/src/class.cpp
D project/project/trunk/src/class.h
Checked out revision 3.


Have a closer look at the output. It shows how clever svn is. We asked for version 3 but because of our previous command, the version 4 is already in /tmp.

No problem, svn does all the necessary things and indicate them : the main.cpp and Makefile are updated and the class.{h,cpp} files are deleted.












No comments:

Post a Comment