Pagine

Wednesday 21 December 2016

SVN tutorial n 25 - mergeinfo

The svn mergeinfo command shows the query information related to merges (or potential merges) between a "source url" and "target". If the --show-revs option is not provided, display revisions which have been merged from "source url" to "target". Otherwise, display either merged or eligible revisions as specified by the --show-revs option. The svn mergeinfo command requires a "source" URL (where the changes come from), and takes an optional "target" URL (where the changes merge to). If no target URL is given, it assumes that the current working directory is the target.
The synopsis is:
 svn mergeinfo <source_url>[@<svn_revision>] [<target>[@<svn_revision>]]

Examples

Merge info between a branch and a working copy
 svn mergeinfo https://svnrepo/svn/myproject/branches/myproject-1.1
Merge info between a branch and trunk
 svn mergeinfo https://svnrepo/svn/myproject/branches/myproject-1.1@33 https://svnrepo/svn/myproject/trunk

Tuesday 20 December 2016

SVN tutorial n 24 - unlock

The svn unlock command unlocks files or directories previously locked.  If any file (or directory) is locked by another user or no valid lock token exists in the working copy,
print a warning and continue unlocking the rest of the files (and directories). Use "--force" to break a lock belonging to another user or working copy. The synopsis is:
 svn unlock <path>
When a commit fails due to someone else's locks, it's fairly easy to learn about them. The easiest way is to run:
 svn stat -u

Examples:

1) unlock the files in working copy
 svn unlock file1.txt file2.txt fileN.txt
2) unlock a file already locked by another user
 svn unlock --force file1.txt
3) unlock a file via url
 svn unlock https://svnrepo/svn/myproject/trunk/file3.txt

Monday 19 December 2016

SVN tutorial n 23 - lock

The svn lock command locks working copy a path or an Url in the repository so that no other user can commit changes to them.
If any files are already locked by another user, print a warning and continue locking the rest of files. Use the option "--force" to steal a lock from another user or working copy.
The synopsis is:
 svn lock <path>

Examples:

1) lock the files in working copy
 svn lock file1.txt file2.txt fileN.txt
2) lock a file already locked by another user
 svn lock --force file1.txt
3) lock a file via url
 svn lock https://svnrepo/svn/myproject/trunk/file3.txt

Friday 16 December 2016

SVN tutorial n 22 - log

The "svn log" command shows log messages from the repository. If no arguments are supplied, svn log shows the log messages for all files and directories inside (and including) the current working directory of your working copy. You can refine the results by specifying a path, one or more revisions, or any combination of the two. The default revision range for a local path is BASE:1.
Instead If you specify a URL alone, it prints log messages for everything the URL contains. If you add paths past the URL, only messages for those paths under that URL will be printed. The default revision range for a URL is HEAD:1. The synopsis is:
 svn log [PATH]
or
 svn log URL[@REV] [PATH...] 

Examples:

1) log of current folder
 svn log
2) log of a local file target
 svn log MyFile.txt
3) log of a file via url
 svn log https://mysvnrepo/svn/myproject/trunk/MyFile.txt
4) log for revision
 svn log -r 3:6 MyFile.txt
5) log for revision of a file via url
 svn log -r 3:6 https://mysvnrepo/svn/myproject/trunk/MyFile.txt
6) log in xml format
 svn log --xml https://mysvnrepo/svn/myproject/trunk/MyFile.txt

Thursday 15 December 2016

SVN tutorial n 21 - list

The "svn list" command shows the entry list on repository, this command is simalar to onomimus bash command. The synopsis is:
 svn list <target>[@<svn_revision>]
or
 svn ls <target>[@<svn_revision>]
Where <target> can be the local working copy or remote url. If <target> is not present the command will show the current local directory.
You can use this command for a precise revision using -r option or the sintax with "@".
An other helpful option is --xml for the output format in xml.

Examples:

1) List of trunk via url
 svn list https://svnrepo/svn/myproject/trunk
2) List in myfolder (local copy)
 svn list myfolder
3) List of trunk via url with revision number 40 with xml format
 svn list --xml https://svnrepo/svn/myproject/trunk@40

Wednesday 14 December 2016

SVN tutorial n 20 - export

The svn export command can be used in two modes: the first exports a clean directory tree from the repository specified by <svn_url> at revision <svn_revision> if it is given; otherwise, at <head>, into <path>. If <path> is omitted, the last component of the <svn_url> is used for the local directory name. The synopsis is:
 svn export [-r <svn_revision>] <svn_url> [<path>]
Example:
 svn export https://svnrep/svn/myproject/trunk/folder folder-new
A    folder-new
Exported revision 4.
Instead the second mode exports a clean directory tree from the working copy specified by <path1> into <path2>. All local changes will be preserved, but files not under version control will not be copied.
The synopsis is:
 svn export [-r <svn_revision>] <path1> [<path2>]
Example:
 svn export folder folder-new
Export complete. When rolling operating-system-specific release packages, it can be useful to export a tree that uses a specific EOL character for line endings. The --native-eol option will do this, but it affects only files that have svn:eol-style = native properties attached to them. For example, to export a tree with all CRLF line endings (possibly for a Windows .zip file distribution):
 svn export https://svnrep/svn/myproject/trunk/folder folder-new --native-eol CRLF
A    folder-new
Exported revision 4.
You can specify LR, CR, or CRLF as a line-ending type with the --native-eol option.

Tuesday 13 December 2016

SVN tutorial n 19 - changelist

The svn changelist command associates (or deassociates) local paths with a changelist. I suggest to use this command when a svn commit is associated to a specific issue. The synopsis for associate is:
 svn changelist <clname> <files>
or
 svn cl <clname> <files>
instead the synopsis for deassociate is:
 svn changelist --remove <files>

Examples: 

1) Create a changelist:
 svn changelist issue1 Myfile.txt Myfile2.txt
 svn status
M       Myfile3.txt
--- Changelist 'issue1':
M       Myfile.txt
A       Myfile2.txt
 svn commit --changelist issue1 -m "Issue 1"
 svn status
M       Myfile3.txt
2) Deassociate files:
 svn changelist issue2 Myfile3.txt
 svn status
--- Changelist 'issue2':
M       Myfile3.txt
 svn changelist --remove Myfile3.txt
 svn status
M       Myfile3.txt

Monday 12 December 2016

SVN tutorial n 18 - cat

The svn cat command displays on standard output the contents of the specified files or URLs. This command is similar as homonym bash command. The synopsis is:
svn cat <path>
The option -r is used for display the file with a specific revision number.
Examples:
svn cat MyFile.txt
svn cat https://mysvnrepo/svn/trunk/MyFile.txt
svn cat -r 123 MyFile.txt

Wednesday 7 December 2016

SVN tutorial n 2 - status

Display the status of working copy files and directories. Diff between your workspace and code repository.
 svn stat <path>
or
 svn st <path>
or
 svn status <path>
<path> is optional parameter, the default value is current folder ( . ). The command output shows the file list with the status for each file. The following status are the most common:  'A' Item is scheduled for addition.
 'D' Item is scheduled for deletion.
 'M' Item has been modified.
 '?' Item is not under version control.
 '!' Item is missing (e.g., you moved or deleted it without using svn). This also indicates that a directory is incomplete (a checkout or update was interrupted).
 '~' Item is versioned as one kind of object (file, directory, link), but has been replaced by a different kind of object.
The full list you can see the following link: http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.status.html The option '--xml' gets the output in XML format
svn status --xml 
This XML can be redirected to a file, this can be useful, for example, for an automation procedure
svn status --xml > myproject-status.xml

SVN tutorial n 17 - blame

The "svn blame" command shows author and revision information inline for the specified files or URLs. In detail for each line of a file gets three fields:
  1. author
  2. svn revision number
  3. text
The synopsis is:
 svn blame <path>[@<svn_revision>]
Examples:
Usage in local working copy:
 svn blame MyFile.txt
Use in remote url and svn revision number
 svn blame https://mysvnrepo/svn/myproject/trunk/MyFile.txt@123
The option "--extensions (-x)" does not consider the minimal modifications as whitespace.
 svn blame --extensions MyFile.txt
Instead with option --xml you can get XML output:
 svn blame --xml MyFile.txt

Tuesday 6 December 2016

SVN tutotial n 16 - diff

The "svn diff" command displays the differences between two revisions or paths. You can use svn diff in the following ways:
1) Use just svn diff to display local modifications in a working copy.
 svn diff [-c M | -r N[:M]] [TARGET[@REV]...]
Examples:
Compare BASE and your working copy
 svn diff MyFile.txt 
See what changed in the file MyFile.txt revision 3000:
 svn diff -c 3000 MyFile.txt
2) Display the changes made to TARGETs as they are seen in REV between two revisions. TARGETs may be all working copy paths or all URLs. If TARGETs are working copy paths, N defaults to BASE and M to the working copy; if TARGETs are URLs, N must be specified and M defaults to HEAD. The -c M option is equivalent to -r N:M where N = M-1. Using -c -M does the reverse: -r M:N where N = M-1.
 svn diff [-r N[:M]] --old=OLD-TGT[@OLDREV] [--new=NEW-TGT[@NEWREV]] [PATH...]
Example:
Compare revision 3000 to revision 5000 using range notation (pass only the one URL in this case):
 svn diff -r 3000:5000 http://mysvnrepo/svn/trunk/MyFile.txt
3) Display the differences between OLD-TGT as it was seen in OLDREV and NEW-TGT as it was seen in NEWREV. PATHs, if given, are relative to OLD-TGT and NEW-TGT and restrict the output to differences for those paths. OLD-TGT and NEW-TGT may be working copy paths or URL[@REV]. NEW-TGT defaults to OLD-TGT if not specified. -r N makes OLDREV default to N; -r N:M makes OLDREV default to N and NEWREV default to M.
 svn diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]
Example:
Compare two tags:
 svn diff http://mysvnrepo/svn/tags/tag-1 http://mysvnrepo/svn/tags/tag-2
The versions are managed via the --revision (-r) option or by using the “@” notation as described earlier. Example:
 svn diff http://mysvnrepo/svn/trunk/MyFile.txt@3000 http://mysvnrepo/svn/trunk/MyFile.txt@5000
You can use the --xml option along with the --summarize option to view XML describing the changes that occurred between revisions, but not the contents of the diff itself:
 svn diff --summarize --xml http://mysvnrepo/svn/trunk/MyFile.txt@3000 http://mysvnrepo/svn/trunk/MyFile.txt@5000

Thursday 1 December 2016

SVN tutorial n 15 - mkdir - How to create a new directory by CLI

The svn "mkdir" command creates a new directory under version control. This command can be used in two modes. First, using a local path as below:
 svn mkdir <path>
Example:
 svn mkdir myDirectory
 A         myDirectory
 ...
 svn commit -m "created a new directory" myDirectory
Second mode, using the remote url as below:
 svn mkdir <svn_url> -m "comment..."
Example:
 svn mkdir https://my-svn-repo/svn/trunk/myDirectory -m "created a new directory"

Friday 25 November 2016

SVN tutorial n 14 - resolve

The svn "resolve" command resolves the “conflicted” state on working copy files or directories. The synopsis is:
 svn resolve <path>
This routine does not semantically resolve conflict markers; however, it replaces <path> with the version specified by the "--accept" argument and then removes conflict-related artifact files. This allows <path> to be committed again that is, it tells Subversion that the conflicts have been “resolved.”
Example:
Using the same example used in [1]
> svn update
 Updating '.':
 C    MyFile.txt
 Updated to revision 31.
 Summary of conflicts:
 Text conflicts: 1
After a postponed conflict resolution during update, svn resolve replaces the all conflicts in file MyFile.txt with your edits:
> svn resolve --accept mine-full MyFile.txt

Link

[1] http://informaticaamodomio.blogspot.com/2016/11/svn-step-13-resolved.html

Thursday 24 November 2016

SVN tutorial n13 - resolved

The svn resolved command removes “conflicted” state on working copy files or directories. The synopsis is:
 svn resolved <path>
Example:
> svn update
 Updating '.':
 C    MyFile.txt
 Updated to revision 31.
 Summary of conflicts:
 Text conflicts: 1
> ls MyFile.txt*
 MyFile.txt
 MyFile.txtmine
 MyFile.txt.r30
 MyFile.txt.r31
where:
MyFile.txt – the original with markers
MyFile.txt.mine – your version
MyFile.txt.r30 – the original your worked with
MyFile.txt.r31 – the most update version from other user
If you want use your version
> cp MyFile.txt.mine MyFile.txt
> svn resolved MyFile.txt
> svn commit -m "resolved..." MyFile.txt
This command has been deprecated in favor of running "svn resolve --accept working PATH."
The svn resolve command will be described in next posts.

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"