How do I say something like HEAD-1 in svn?

Long story short - you can't without running a command. With check-in hooks you can get access to 'the version before this one', otherwise you need to query it dynamically. Here's an example that populates a shell variable with the revision of the current head, minus one.

HEAD_MINUS_ONE=$(svn info http://svn/path/to/head | grep ^Revision | awk '{print $2-1}')

There's are a few built in revision key words in Subversion which may solve most of your problems:

  • BASE: This is the revision used in your current working directory.
  • HEAD: This is the current tip of the branch.
  • COMMITTED: This is the last committed revision of a file before BASE.
  • PREV: This is the last changed revision from BASE. It's pretty much COMMITTED-1.

For everything else, you'll need to do a calculation as synthesizeerpatel showed you.

Tags:

Svn

Revision