Personal tools

SubversionTips

From OpenLaszlo

Tips on using Subversion

Q: What OpenLaszlo documents talk about subversion?

A: See Subversion


Q: How do I update to the very latest?

A: svn up updates the working directory and all its descendants to the very latest revision checked in. (Note that 'svn up' does' bring the working directory up to the HEAD revision. See the svn book for details.) Run svn up from the directory you want to update.


Q: How do I list my modified files, without seeing all the "?"'s on autogenerated files ?

A: svn status -q


Q: What do the status codes on svn status and svn update mean?

A: See SVNStatusCodes


Q: How can I do p4 describe?

A: This is possible in the new svn client, 1.4. svn diff --summarize gives a list of changed files, and you can say just -c1816 instead of -r1815:1816.

so p4 describe 1816 can be expressed in subversionville with svn diff --summarize -c1816 http://svn.openlaszlo.org/openlaszlo


Q: How do I list files other people have committed revisions of, that I don't have?

A: svn status -u tells you if there are more recent revisions to the files listed.


Q: What is a good Subversion package for Emacs?

A: http://svn.collab.net/viewvc/*checkout*/svn/trunk/contrib/client-side/vc-svn.el or http://svn.collab.net/viewvc/*checkout*/svn/trunk/contrib/client-side/vc-svn.el


Q: What is the new makechangepackage?

A: See http://svn.openlaszlo.org/tools/trunk/svn/README.txt


Q: What's an easy way to browse around in the repository?

A: We like websvn: http://www.openlaszlo.org/websvn/


Q: How do I monitor changes to the repository?

A: Subscribe to http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins


Q: What if I just want to see changes to a subtree?

A: Use the RSS feed feature of websvn. For example, this link will give you a feed for the trunk.


Q: How do I do a dry-run of a command without having side effects?

A: svn delete --dry-run important.xml


Q: How do I avoid seeing build products in my 'svn status' output?

A: Enable the global-ignores option in your config file. See the svn book for more.


Q: How to I ensure that eol style will be mapped to native format when I checkout/checkin?

A: Unfortunately this is a file property rather than a client property in subversion. You need to set the svn:eol=native property value on each file that is to be automatically translated in this way. Enabling the enable-auto-props config option (see svn book) and configuring your auto-props table will ensure you set the property correctly for each file you add or import.

Here is the ~/.subversion/conf file used by OpenLaszlo Developers that constains correct auto-prop definitions


Q: Where is WebSVN?

A: http://www.openlaszlo.org/websvn/listing.php?repname=OpenLaszlo&path=%2F&sc=0


Q: How do I sync to a given revision #?

A: svn up -r 857


Q: How do I integrate a change from branch to trunk?

A: If the revision of the legals change is 1024, then do the following:

> cd /path/to/trunk
> svn merge -r 1023:1024 http://svn.openlaszlo.org/openlaszlo/branches/legals

Then build, test, submit.


Q: How do I sync to head?

A: svn up -r HEAD


Q: How do I revert/synchronize a workspace tree ?

A:
cd $LPS_HOME            # because svn operates only on subdirectories
svn revert -R           # without -R, you only revert the current directory
svn up                  # this should update you to HEAD

Q: But that left all the files that I have added?

A: From http://svn.haxx.se/users/archive-2005-07/0861.shtml

#!/bin/bash
#
# Applies arbitrary commands to any svn status. e.g.
#
# Delete all non-svn files (escape the ? from the shell):
# svnapply \? rm
#
# List all conflicted files:
# svnapply C ls -l

APPLY=$1
shift

svn st | egrep "^\\${APPLY}[ ]+" | \
   sed -e "s|^\\${APPLY}[ ]*||" | \
   xargs -i "$@" '{}'

Q: So if I wanted to create a clean copy of my workspace without having to (re-)drag all those files over my network?

A:

% cp -Rp messy clean
% cd clean
% svn revert -R .
% svn-apply \? rm
% svn update

Q: How do I move a file from one place to another and preserve version history?

A: svn move


Q: I'm getting the error: "'pre-commit' hook failed with error output". What do I do?

A: For every file you're trying to commit, four things must be true:

1) It must contain "Copyright 2006 Laszlo Systems".

2) It must have the svn:eol-style set to native, which you do by svn propset svn:eol-style native foo.lzx

3) It must have its mime-type set, much the same, svn propset svn:mime-type text/plain foo.lzx (or whichever mime-type is appropriate for the file; if it's a binary file, the config should be able to guess)

4) A message must be included with the commit command. For instance: svn commit foo.lzx --user Felix --password litterbox --message textgoeshere

Arcana

Q: How do you bypass the pre-commit hook?

A: Put the string skip-pre-commit-checks in the svn commit log message

Q: How did you tag all the text files in the repository so that they have proper mime type and eol-style=native?

A: Boy, this is fun.

Portions of this came from the Apache Cocoon community: [1]. Thanks also to Wikipedia.

First collect all the text files in the repository. On my OS X install, file(1) thought .swf and .png files were text files, so I had to strip them out in an extra step.

find . -type f \! -path *.svn/* | xargs file | grep -i -w text | cut -f1 -d: > text-files.txt
grep -v .png$ text-files.txt > text-files2.txt
grep -v .swf$ text-files2.txt > text-files3.txt
grep -v .gif$ text-files3.txt > text-files.txt
rm text-files2.txt text-files3.txt

Now tag all text files with text/plain mime type, and then mask out the css, html, and xml files appropriately. (We don't have any .xhtml or .htm files in our repository.)

cat text-files.txt | xargs svn propset svn:mime-type text/plain
grep .css$ text-files.txt | xargs svn propset svn:mime-type text/css
grep .html$ text-files.txt | xargs svn propset svn:mime-type text/html
grep .xml$ text-files.txt | xargs svn propset svn:mime-type text/xml

Finally, set eol-style to native for all text files. Note that this will convert line endings for files that don't already have Unix line endings. We use a for loop in case there are files with inconsistent line endings.

for f in `cat text-files.txt` ; do svn propset svn:eol-style native $f ; done

You'll need to go through the output of this and pick out any propset failures due to inconsistent newlines. Convert those files to Unix line endings, save, and individually set their eol-style to native.