wiki:HowToSVN

Version 17 (modified by hamish, 17 years ago) ( diff )

svn up, diff, etc

Getting development information and code history from SVN

  • "ChangeLog" style file: install and run svn2cl
  • File history in SVN:
    cd path/to/directory/
    svn log [file.c]

    # or time reverted:
    svn log [file.c] | tac

Switch the repository

To switch from SVN 'trunk' (now GRASS 7 development) to 'develbranch_6' (now GRASS 6.4 development) use

    cd /path/to/your/local/copy/trunk
    svn switch https://svn.osgeo.org/grass/grass/branches/develbranch_6 .

The switch command preserves local, uncommited changes.

SVN usage

Checkout source code

Making changes

  • Double check that you are using the latest revision of the development branch before embarking on any changes.
    svn up raster/r.digit/

Diffs

  • Before committing a change or submitting a patch you should review the changes. Viewing a diff is a nice way to do that. It is preferable to keep your patches concise- needless whitespace changes or a mixture of tasks can make it difficult to spot subtle changes introduced by your change.

View changes:

    svn diff raster/r.digit/

Save patch to a file: (run from top dir not the module dir. There are many "main.c" and "description.html" files to choose from and without the directory name it is hard to figure out where your patch should be applied)

    svn diff raster/r.digit/ > fancy_new.diff

Commits back into the repository

(must have write access)

  • SVN prefers "atomic commits", i.e. commit changes to all files affected by a change at the same time, not in a series of commits (one for each file).
  • Please make the -m commit log message meaningful. It is your chance to explain "why". If you refer to bug numbers in the form "#123" the Trac system will automatically create a link from the message to the bug report. The same is true for revision changes, e.g. "r12345".
        svn diff raster/r.digit/main.c | less
        svn commit raster/r.digit/main.c \
          -m "fix bug #123: uninitialized variable (merge r12345 from trunk)"
    

Merge between branches (backporting)

Run the command from within the target branch.

  • Example 1: pull a change from trunk into the 6.3 release branch:
        cd releasebranch_6_3/
        svn merge -c 30749 https://svn.osgeo.org/grass/grass/trunk
        svn diff raster/r.digit/main.c
        svn commit raster/r.digit/main.c \
          -m "fix bug #456: unsafe quoting (merge from trunk, r30749)"
    

where 30749 is the revision number of the changeset you wish to backport.

  • Example 2: merge a change from the 6.4 development branch into GRASS 7 (trunk):
        cd trunk/
        svn merge -c 31154 https://svn.osgeo.org/grass/grass/branches/develbranch_6
    
    

Non-recursive checkout

  • SVN does not allow you to check out a single file at a time. Sometimes this can be awkward as it can force you to checkout the entire repository for the sake of changing one file in the top directory.

Solution: do a --non-recursive checkout:

    svn checkout --non-recursive https://svn.osgeo.org/grass/grass-web/trunk/ trunk/

See Also

Note: See TracWiki for help on using the wiki.