Pagine

Monday 31 October 2016

SVN tutorial n 12 - cleanup

The svn cleanup executes recursively the clean up the working copy.
The synopsis is:
svn cleanup <local_path>
If <local_path> is omitted, “.” is assumed (default value).
If you ever get a working copy locked error, run this command to remove stale locks and get your working copy into a usable state again. If, for some reason, an svn update fails due to a problem running an external diff program (e.g., user input or network failure), pass the --diff3-cmd to allow the cleanup process to complete any required merging using your external diff program. You can also specify any configuration directory with the --config-dir option, but you should need these options extremely infrequently.

Examples:

Clean up current folder (recursively)
svn cleanup
Clean up of a subfolder (recursively)
svn cleanup myfolder

Friday 28 October 2016

SVN tutorial n 11 - import

The svn import command commits an unversioned file or tree into the repository.
The synopsis is:
 svn import -m "initial commit" <local_path> <url_svn_repository>
If <local_path> is omitted, “.” is assumed (default value).
After importing data, note that the original tree (<local_path>) is not under version control. To start working, you still need to svn checkout a fresh working copy of the tree.

Examples:

This imports the local directory myproject into trunk/project in your repository. The directory trunk/project need not exist before you import into it—svn import will recursively create directories for you.
 svn import -m "initial commit" myproject https://mysvnrepo/svn/trunk/project
Adding         myproject/file.txt
…
Transmitting file data .........
Committed revision 30.
Be aware that this will not create a directory named module-a in the repository. If that's what you want, simply add module-a to the end of the <url_svn_repository>:
 svn import -m "initial commit" module-a https://mysvnrepo/svn/trunk/project/module-a
Adding         module-a/file2.txt
…
Transmitting file data .........
Committed revision 32.

Thursday 27 October 2016

SVN tutorial n 10 - merge

The svn merge command applies the differences between two sources to a working copy path.

The synopsis is:
 svn merge [-c M[,N...] | -r N:M ...]  <source>[@svn_revision] <target>

or
 svn merge --reintegrate  <source>[@svn_revision] <target>

or
 svn merge <source1>[@svn_revision_N] <source2>[@svn_revision_M] <target>

In all three forms <target> is the working copy path that will receive the differences. If <target> is omitted, the changes are applied to the current working directory, unless the sources have identical basenames that match a file within the current working directory.  In this case, the differences will be applied to that file.

In the first two forms, <source> can be either a URL or a working copy path (in which case its corresponding URL is used). If the peg revision "svn_revision" is not specified, then HEAD (latest svn revision) is assumed. In the third form the same rules apply for <source1>, <source2>, "svn_revision_N", and "svn_revision_M" with the only difference being that if either source is a working copy path, then the peg revisions must be explicitly stated.


Sync and Cherrypick Merges

The first form, when used without either the -c or -r options, is called a “sync” merge and -r 1:svn_revision is implied. This variant is used to merge all eligible changes to a branch from its immediate ancestor branch.

When the first form is used with the -c or -r options, this is called a “cherrypick” merge and is used to merge an explicitly defined set of changes from one branch to another.



Multiple -c and/or -r instances may be specified, and mixing of forward and reverse ranges is allowed— the ranges are internally compacted to their minimum representation before merging begins (which may result in a no-op merge or conflicts that cause the merge to stop before merging all of the requested revisions).

In both variants of the first form, <source> in revision "svn_revision" is compared as it existed between revisions "svn_revision_N" and "svn_revision_M" for each revision range provided.




Reintegrate Merges


The second form is called a “reintegrate merge” and is used to bring changes from a feature branch (<source>) back into the feature branch's immediate ancestor branch (<target>). Reintegrate merges support only this specialized use case and as such have a number of special requirements and limitations that the other two merge forms do not posses.



2-URL Merges


In the third form, called a “2-URL Merge”, the difference between <source1> at revision "svn_revision_N" and <source2> at revision "svn_revision_M" is generated and applied to <target>.
The revisions default to HEAD if omitted.

If Merge Tracking is active, then Subversion will internally track metadata (i.e. the svn:mergeinfo property) about merge operations when the two merge sources are ancestrally related—if
the first source is an ancestor of the second or vice versa—this is guaranteed to be the case when using the first two forms. Subversion will also take preexisting merge metadata on the working copy target into account when determining what revisions to merge and in an effort to avoid repeat merges and needless conflicts it may only merge a subset of the requested ranges.

Merge Tracking can be disabled by using the --ignore-ancestry option.


Unlike svn diff, the merge command takes the ancestry of a file into consideration when performing a merge operation. This is very important when you're merging changes from one branch into another and you've renamed a file on one branch but not the other.







Examples:


Merge a branch back into the trunk (assuming that you have an up-to-date working copy of the trunk):
 svn merge --reintegrate https://mysvnrepo/svn/branches/myproject-branch-1.0
 svn commit -m "Merge myproject-branch-1.0 back into trunk."



To merge changes to a single file:
 svn merge -c 31 ^/trunk/myfile.txt myfile.txt 


Merge between two revision revisions:
 svn merge https://mysvnrepo/svn/branches/myproject-branch-1.0 -r103:HEAD

Wednesday 26 October 2016

SVN tutorial n 9 - move

The svn move command move a file or directory. The synopsis is:
 svn move <src> <dst>
or
 svn mv <src> <dst>
The <src> and <dst> can be local path or url.

Examples:

Use move command in your working copy
 svn move myfile.txt myfile2.txt
A myfile2.txt
D myfile.txt
Use the commit command to update the svn repository  
svn ci -m "move example"
Committed revision 1233
Use move command with url
 svn move -m "move example 2" https://mysvnrepo/svn/trunk/myfile.txt https://mysvnrepo/svn/trunk/myfile2.txt
Committed revision 1234

Tuesday 25 October 2016

SVN tutorial n 8 - revert

The svn revert command undo all locat edits. Yuo can revert all files or folders with status A, M and D. The synopsis is:
 svn revert <path>

Examples:

Revert a folder edited
 svn revert myfolder
Reverted myfolder
Revert a file added
 svn add myfile.txt
A myfile.txt
 svn revert myfile.txt
Reverted myfile.txt
 svn status
? myfile.txt
If you want to revert a whole directory of files, use the "--depth=infinity" option:
 svn revert --depth=infinity .
Reverted myfolder Reverted myfile.txt

Thursday 20 October 2016

SVN tutorial n 7 - delete

The svn delete command deletes an item from a working copy or the repository. The synopsis is:
 svn delete <url or path file>
or
 svn del <url or path file>
or
 svn remove <url or path file> 
or
 svn rm <url or path file>
To delete a file or a directory from your working copy use the following command:
 svn delete MyFile.txt 
After that, you can see the local status
 svn stat
The output will be:
 D MyFile.txt
If you want delete the file in repository then you must execute the commit
 svn ci -m "Delete MyFile"
Instead to delete an item from repository, for example, an obsolete branch, use the following command:
 svn delete https://mysvnrep/svn/myproject/branches/myproject-0.0.1 -m "delete obsolete branch" 

Wednesday 19 October 2016

SVN tutorial n 6 - copy

The svn copy command copies a file or directory in a working copy or in the repository. This command can be used to create a branch and / or a tag. The synopsis is:
 svn copy <src_path> <dts_path>
or
 svn cp <src_path> <dts_path>

Examples:

Create a new tag from trunk
 svn copy https://mysvnrep/svn/myproject/trunk/ https://mysvnrep/svn/myproject/tags/myproject-0.0.1 -m "myproject tag 0.0.1"
Create a new branch from tag
 svn copy https://mysvnrep/svn/myproject/tags/myproject-0.0.1 https://mysvnrep/svn/myproject/branches/myproject-0.0.1 -m "new branch from tag: myproject-0.0.1"
It's possible to copy from a specific revision number using -r option:
 svn copy -r 1234 https://mysvnrep/svn/myproject/trunk/ https://mysvnrep/svn/myproject/tags/myproject-0.0.1 -m "myproject tag 0.0.1"

Tuesday 18 October 2016

SVN tutorial n 5 - info

The svn info command shows information about a local or remote item. The synopsis for local info is:
 svn info 
or
 svn info <path>
Example:
 svn info .
Instead for svn remote info use the command:
 svn info <url_repository>
Example
 svn info https://mysvnrep/svn/myproject/trunk
You can use the -r option for info about a precise version, without this option refers to the head version
 svn info -r 1234
The output is available in XML format by passing the --xml option:
 svn info --xml

Monday 17 October 2016

SVN tutorial n 4 - add and commit

The "commit" send changes from your working copy to the code repository. After the commit from an user X, the changes are available from other users using the svn update command. For commit all files with status changed (M, A, D, etc...) use:
 svn commit -m "<a comment>"
or
 svn ci -m "<a comment>"
If you want commit only a subset of files:
 svn commit -m "<a comment>" file1 file2 ....
Example: Status before commit:
 svn stat
M Employ.java
A myPackage/Person.java
Commit only Person.java
 svn commit -m "added Person.java" myPackage/Person.java
Status after commit
 svn stat
M Employ.java
If you want add a new file (or folder) under source control, use the add command:
 svn add <file>
After that use the commit command for send the changes to code repository.
 svn ci -m "a comment" <file>

SVN tutorial n 3 - update

Update your working copy with a revision version.
 svn up [-r<revision>]
or
 svn update [-r<revision>]
Note: -r (alias --revision). If you want update your working copy with the last revision use (without -r option):
 svn update
or
 svn up

Friday 14 October 2016

SVN tutorial n 1 - checkout

Checkout of last revision

svn co <path_svn>
Example:
svn co https://mysvnrep/svn/myproject/trunk
or
svn checkout <path_svn>
Example:
svn checkout https://mysvnrep/svn/myproject/trunk

Checkout with rename the folder name target

svn co <path_svn> <folder_name>
Example:
svn co https://mysvnrep/svn/myproject/trunk myproject

Checkout of a precision revision

svn co -r <revision_number> <path_svn>
Example:
svn co -r 236 https://mysvnrep/svn/myproject/trunk

Some useful bash commands

This page collects some useful bash commands that sometimes I don't remember.

Disk 

The following command shows the partition list of your disk:
$ df -f

Disk Usage - report the amount of disk space used by the specified files and for each subdirectory
$ du -h

RAM

Display on standard output the RAM size in KB (kilobyte):
$ grep MemTotal /proc/meminfo | awk '{print $2}'


Network

Check the status of  port '8080'. The status can be: CONNECTED, LISTENING, etc...
$ netstat -an | grep 8080

Kill a connection on a specific port, for example 8080
$ tcpkill -i eth0 port 8080

Miscellaneous

Remove all .svn (recursively)
$ find . -name .svn -exec rm -rf {} \;

Find all snapshot version in a maven project
$ find . -name pom.xml | xargs grep "SNAPSHOT"