SVN tips in Linux: create root repository, system-delete, conflict and partial checkout

1. create the  folder in the repository:
(1) Create root repository.
svn mkdir svn+ssh://username@hostname/projectname/trunk -m "Create the trunk folder"
Then the first version can be checked out.
(2) Create sub-folder in the root repository
svn mkdir svn+ssh://username@hostname/projectname/trunk/test -m "Create the test folder"
And this new folder needs to be checked out. Even you already created a folder using the same name in the local copy. Your local folder and files will not be overwritten.  And then you can commit your local files in the new folder into the repository.

2. Delete the svn local copy
As the .svn folder in the checkout is an hide recursive folders, when you directly remove the folder, you will get the "protected file " warning and it is not easy to delete all the files in the folder. Below is the way to completely delete the folder.
$cd file/with/.svn
$find -name .svn -exec rm -r -f {} + 
/* delete the recursive folders in the .svn folder and the .svn folder
/* rm = remove
/* -r = recursive (folders)
/* -f = force, avoids a lot of "are your sure you want to delete file *".

rm -r file/without/.svn
/* delete the checkout folder

3.  Conflict
References: update, conflict
When you update a file from repository and you also changed that file in the local repository copy, then you will get this problem.

$svn update local/copy/path
Conflict discovered in 'local/copy/path/test.sh'.
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: p
C    local/copy/path/test.sh
Updated to revision 20.

If you first select "p" as postpone,then you will have 4 test.sh files.local/copy/path/test.sh.r19
local/copy/path/test.sh.r20
local/copy/path/test.sh.mine
local/copy/path/test.sh
And you can update the file to any version you want.
The version in the repository:
$svn resolve --accept theirs-full local/copy/path/test.sh
Resolved conflicted state of 'local/copy/path/test.sh'

4. Partial checkout
svn checkout --depth empty svn+ssh://username@host/trunk/subfolder proj
svn update --set-depth infinity proj/subfolder/foo
svn update --set-depth infinity proj/subfolder/bar
Check out an empty subfolder: 
svn update --depth empty proj/subfolder/

If need to checkout a single file which is recently added:
cd <rootfolder>
svn checkout svn+ssh:username@rootfolder/targetfolder/ --depth empty
cd <targetfolder>
svn up <file_you_want>

5. locked & cleanup 
When there is something not committed correctly before, for example, you delete some files and not commit it, and then you move your folder. (This is my case which cause locked issue and cleanup dose not work)
You will got some error info like below:
- You did something wrong and when you svn add/commit to the local folder like:
$svn add proj/sample/too.php
svn: Working copy 'proj/sample' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)

First cleanup the folder has the lock problem. Then you may get some detail info for why it is locked.

$svn cleanup proj/sample
svn: In directory '.'
svn: Error processing command 'committed' in '.'
svn: Error getting 'affected time' of 'foo.php'
svn: Can't stat 'foo.php': No such file or directory
svn: In directory 'tatooine/cake'
For my case, I delete a file but forget to commit before. Then I delete the file using :
$svn delete proj/sample/foo.php
$svn cleanup proj/sample
$svn cleanup proj
After this, I re-run the cleanup, then it works. 
And pls also remember to cleanup the parent folder  proj/ in case it is also locked because of the problem subfolder proj/sample.

6. rename files 
svn rm new_file_name
svn mv old_file_name new_file_name
svn commit


Comments

Popular posts from this blog

install postgreSQL in ubuntu 16.04

timestamp with 16, 13 and 10 digits to Qlik date

install ipython in Cloudera VM using pip