Differences between revisions 16 and 17
Revision 16 as of 2013-08-23 15:29:17
Size: 448
Comment:
Revision 17 as of 2013-08-23 15:47:48
Size: 6669
Comment: revert to rev 11 (pre-spam)
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Nena Wittman is my concept though I don't really love being called like that do. To ride horses is something I will never give up. Filing is my profession. My house is now across North Dakota but I will have to move within a year or two. I've been working on my brand new website for some a period of time now. Check it away from here: http://bwshvac.com<<BR>>
<<BR>>
Here is my homepage - [[http://bwshvac.com|heating and cooling minneapolis]]
SvnHelp >

 1. [[SvnSetup|Set up and optimize SVN to access the GCC repository]].
 1. [[SvnIntro|A conceptual introduction to SVN for CVS users]].
 1. [[SvnBasic|SVN Basic commands]].
 1. [[SvnMerge|Moving patches around: merging and backporting]].
 1. [[SvnBranch|How to maintain a branch]].
 1. [[SvnTricks|Various tricks and recipes]].
 1. [[SvnProblems|Troubleshooting]].

= Various tricks and recipes =

<<TableOfContents(2)>>

== How can I get a list of the branches or of the tags? ==

{{{
$ svn ls svn://gcc.gnu.org/svn/gcc/branches/
$ svn ls svn://gcc.gnu.org/svn/gcc/tags/
}}}


== Which is the revision of my tree? ==

{{{
$ svnversion . # additional tool shipped with SVN clients
105374M
}}}

=M= means that there are local modifies. Otherwise, you can find out the same with {{{svn}}} itself:

{{{
$ svn info | grep Revision
Revision: 105374
}}}

Notice that you can use the keyword {{{BASE}}} as argument of {{{--revision}}} for all commands, to specify the revision of the tree without spelling it out.

== How can I find out which branch this working copy belongs to? ==

{{{
$ svn info | grep URL
URL: svn+ssh://giovannibajo@gcc.gnu.org/svn/gcc/branches/reload-rewrite
}}}


== How can I view the contents of a file at a given revision? ==

{{{
$ svn cat --revision=345 gcc/reload.c # in a working copy
$ svn cat --revision=345 svn://gcc.gnu.org/svn/gcc/trunk/gcc/reload.c # without a working copy around
}}}


== How can I revert an offending commit? ==

Assuming the commit went in as r6600, the following is sufficient:
{{{
$ svn merge -r6600:r6599 .
}}}

== How can I get context diffs? How do I configure an external diff tool? ==

The internal diff engine of Subversion supports only unified diffs, and it does not feature the dozen of options of GNU diff. You may want to use an external tool.

Edit {{{~/.subversion/config}}} and specify the diff utilities to use as {{{diff-cmd}}} and {{{diff3-cmd}}} in the {{{[helpers]}}} section of that file. Then, to pass options to this diff command, you have to use the {{{-x}}} option, e.g:

{{{
$ svn diff -x -cp
}}}

will pass the options {{{-cp}}} to the external diff program.

This can get annoying pretty fast, so if you want to set default options for your diff command, you create a wrapper script, such as:

{{{
#!/bin/bash
diff=/usr/bin/diff

# Additional -F for .md files
extra_args="-F^(define"

# Do not pass multiple -c/-u options
case "$1" in
  -c*|-C*) exec ${diff} -p ${extra_args} "$@" ;;
  -u*|-U*) exec ${diff} -p ${extra_args} "$@" ;;
  *) exec ${diff} -up ${extra_args} "$@" ;;
esac
}}}

Then put this file as diff command to be executed in {{{~/.subversion/config}}} and you are done.

If you get an error message like:
{{{
svn: /home/username/.subversion/config:37: Section header expected
}}}
, then you need to uncomment or create a section header first, e.g.:

{{{
[helpers]
# editor-cmd = editor (vi, emacs, notepad, etc.)
# diff-cmd = diff_program (diff, gdiff, etc.)
diff-cmd = /home/username/bin/gccdiff
}}}


== Is there support for Emacs and/or xemacs? ==

Sufficiently new versions of emacs have vc support for svn through vc-svn.
You can also find it on Savannah [[http://savannah.gnu.org/cgi-bin/viewcvs/emacs/emacs/lisp/vc-svn.el|vc-svn.el]]

Due to divergence between xemacs's vc and emacs's vc, vc-svn doesn't work with xemacs.
There is also psvn, which should work on xemacs, available in contrib/client-side/psvn in the subversion source distribution.


== How can I speed up SVN? ==
== How can I reduce disk space usage? ==

These questions are answered in the SvnSetup page


== How can I get the revision number of a tag? ==

To find out which branch and revision number the tag''tags'' it's sufficient to do:

{{{
$ svn log -v -q --stop-on-copy svn://gcc.gnu.org/svn/gcc/tags/tree-ssa-post-merge | grep " A"
   A /tags/tree-ssa-post-merge (from /trunk:81764)
}}}

This shows us that {{{/tags/tree-ssa-post-merge}}} is a copy of {{{/trunk}}} at revision {{{81764}}}

Note that for branches you must use {{{/branch/gcc-4_1-branch}}}

== These svn+ssh URLs are too long to type! What can I do? ==

Use an environment variable to store the base address.

Like the following for Bourne based shells:

{{{
repo=svn+ssh://gcc.gnu.org/svn/gcc
export repo
}}}

Or csh/tcsh:
{{{
setenv repo svn+ssh://gcc.gnu.org/svn/gcc
}}}

and then you can use it as in:
{{{
$ svn ls $repo/tags
}}}

== I'm also tired of always typing mygccuserid@gcc.gnu.org. Am I able to set a default username? ==

Create or modify your {{{~/.ssh/config}}} file to contain:
{{{
Host gcc.gnu.org
  User mygccuserid
}}}

== Who changed/created this line of code? Who should I contact? ==

Just like CVS, you can do:
{{{
$ svn annotate FILE
}}}

or if you prefer:
{{{
$ svn blame FILE
}}}

or:
{{{
$ svn praise FILE
}}}


I consider this quite useful for discussing code. In SVN, it even works for past revisions {{{--revision}}} and branches!

== Ordered diffs ==

CVS used to order diffs alphabetically with capitals first. Subversion currently doesn't. The following script will take a diff file as argument and output an ordered diff to the console. Be careful, as it doesn't check if its output overwrites its input.
{{{
#!/bin/bash
for I in `lsdiff "$@" | LC_ALL=C sort`; do
   filterdiff -i $I $1
done
}}}

== the update script is not working ==

The SCM independent method for updating your copy of the repo is to run the contrib/gcc_update script.
{{{
$ bash contrib/gcc_update
Updating SVN tree
svn: E155036: Please see the 'svn upgrade' command
svn: E155036: Working copy '/u/gnu/proj/gcc' is too old (format 10, created by Subversion 1.6)
Adjusting file timestamps
Touching Makefile.in...
SVN update of full tree failed.
}}}
Do as it says and run "svn upgrade". This may take a few minutes to a few tens of minutes,
depending on your disk speed.

== how can I remove the "-q" option? ==

Several contexts can wind up asking you to remove the -q option when you've never used any -q option.
Somewhere, buried deep in nested commands, ssh is being invoked to perform some service.
But it is not working correctly. The "remove the -q option" comment is telling you to have
ssh invoked in a non-quiet mode in order to help debug the issue.

== How can I get the diff for a single revision of a branch? ==

From your toplevel trunk checkout directory, do:

{{{
svn diff -cREVISION "^/branches"
}}}

SvnHelp >

  1. Set up and optimize SVN to access the GCC repository.

  2. A conceptual introduction to SVN for CVS users.

  3. SVN Basic commands.

  4. Moving patches around: merging and backporting.

  5. How to maintain a branch.

  6. Various tricks and recipes.

  7. Troubleshooting.

Various tricks and recipes

How can I get a list of the branches or of the tags?

$ svn ls svn://gcc.gnu.org/svn/gcc/branches/
$ svn ls svn://gcc.gnu.org/svn/gcc/tags/

Which is the revision of my tree?

$ svnversion .      # additional tool shipped with SVN clients
105374M

=M= means that there are local modifies. Otherwise, you can find out the same with svn itself:

$ svn info | grep Revision
Revision: 105374

Notice that you can use the keyword BASE as argument of --revision for all commands, to specify the revision of the tree without spelling it out.

How can I find out which branch this working copy belongs to?

$ svn info | grep URL
URL: svn+ssh://giovannibajo@gcc.gnu.org/svn/gcc/branches/reload-rewrite

How can I view the contents of a file at a given revision?

$ svn cat --revision=345 gcc/reload.c                                          # in a working copy
$ svn cat --revision=345 svn://gcc.gnu.org/svn/gcc/trunk/gcc/reload.c          # without a working copy around

How can I revert an offending commit?

Assuming the commit went in as r6600, the following is sufficient:

$ svn merge -r6600:r6599 .

How can I get context diffs? How do I configure an external diff tool?

The internal diff engine of Subversion supports only unified diffs, and it does not feature the dozen of options of GNU diff. You may want to use an external tool.

Edit ~/.subversion/config and specify the diff utilities to use as diff-cmd and diff3-cmd in the [helpers] section of that file. Then, to pass options to this diff command, you have to use the -x option, e.g:

$ svn diff -x -cp

will pass the options -cp to the external diff program.

This can get annoying pretty fast, so if you want to set default options for your diff command, you create a wrapper script, such as:

diff=/usr/bin/diff

# Additional -F for .md files
extra_args="-F^(define"

# Do not pass multiple -c/-u options
case "$1" in
  -c*|-C*) exec ${diff} -p ${extra_args} "$@" ;;
  -u*|-U*) exec ${diff} -p ${extra_args} "$@" ;;
  *) exec ${diff} -up ${extra_args} "$@" ;;
esac

Then put this file as diff command to be executed in ~/.subversion/config and you are done.

If you get an error message like:

svn: /home/username/.subversion/config:37: Section header expected

, then you need to uncomment or create a section header first, e.g.:

[helpers]
# editor-cmd = editor (vi, emacs, notepad, etc.)
# diff-cmd = diff_program (diff, gdiff, etc.)
diff-cmd = /home/username/bin/gccdiff

Is there support for Emacs and/or xemacs?

Sufficiently new versions of emacs have vc support for svn through vc-svn. You can also find it on Savannah vc-svn.el

Due to divergence between xemacs's vc and emacs's vc, vc-svn doesn't work with xemacs. There is also psvn, which should work on xemacs, available in contrib/client-side/psvn in the subversion source distribution.

How can I speed up SVN?

How can I reduce disk space usage?

These questions are answered in the SvnSetup page

How can I get the revision number of a tag?

To find out which branch and revision number the tagtags it's sufficient to do:

$ svn log -v -q --stop-on-copy svn://gcc.gnu.org/svn/gcc/tags/tree-ssa-post-merge | grep "   A"
   A /tags/tree-ssa-post-merge (from /trunk:81764)

This shows us that /tags/tree-ssa-post-merge is a copy of /trunk at revision 81764

Note that for branches you must use /branch/gcc-4_1-branch

These svn+ssh URLs are too long to type! What can I do?

Use an environment variable to store the base address.

Like the following for Bourne based shells:

repo=svn+ssh://gcc.gnu.org/svn/gcc
export repo

Or csh/tcsh:

setenv repo svn+ssh://gcc.gnu.org/svn/gcc

and then you can use it as in:

$ svn ls $repo/tags

I'm also tired of always typing mygccuserid@gcc.gnu.org. Am I able to set a default username?

Create or modify your ~/.ssh/config file to contain:

Host gcc.gnu.org
  User mygccuserid

Who changed/created this line of code? Who should I contact?

Just like CVS, you can do:

$ svn annotate FILE

or if you prefer:

$ svn blame FILE

or:

$ svn praise FILE

I consider this quite useful for discussing code. In SVN, it even works for past revisions --revision and branches!

Ordered diffs

CVS used to order diffs alphabetically with capitals first. Subversion currently doesn't. The following script will take a diff file as argument and output an ordered diff to the console. Be careful, as it doesn't check if its output overwrites its input.

for I in `lsdiff "$@" | LC_ALL=C sort`; do
   filterdiff -i $I $1
done

the update script is not working

The SCM independent method for updating your copy of the repo is to run the contrib/gcc_update script.

$ bash contrib/gcc_update 
Updating SVN tree
svn: E155036: Please see the 'svn upgrade' command
svn: E155036: Working copy '/u/gnu/proj/gcc' is too old (format 10, created by Subversion 1.6)
Adjusting file timestamps
Touching Makefile.in...
SVN update of full tree failed.

Do as it says and run "svn upgrade". This may take a few minutes to a few tens of minutes, depending on your disk speed.

how can I remove the "-q" option?

Several contexts can wind up asking you to remove the -q option when you've never used any -q option. Somewhere, buried deep in nested commands, ssh is being invoked to perform some service. But it is not working correctly. The "remove the -q option" comment is telling you to have ssh invoked in a non-quiet mode in order to help debug the issue.

How can I get the diff for a single revision of a branch?

From your toplevel trunk checkout directory, do:

svn diff -cREVISION "^/branches"

None: SvnTricks (last edited 2013-08-23 15:47:48 by JonathanWakely)