secretbase.log

コードはすべてNYSLです

svnversion で subversion の リビジョンが取得できる

svnversion を使えば、シンプルに revision だけ取得できます。

Windows 7 32-bit / TortoiseSVN 1.7.10 / msysgit の環境で実行しています。

$ svnversion
212

$ which svnversion
/c/Program Files/TortoiseSVN/bin/svnversion


svnversion -h で helpがみられます。

$ svnversion -h
usage: svnversion [OPTIONS] [WC_PATH [TRAIL_URL]]

  Produce a compact 'version number' for the working copy path
  WC_PATH.  TRAIL_URL is the trailing portion of the URL used to
  determine if WC_PATH itself is switched (detection of switches
  within WC_PATH does not rely on TRAIL_URL).  The version number
  is written to standard output.  For example:

    $ svnversion . /repos/svn/trunk
    4168

  The version number will be a single number if the working
  copy is single revision, unmodified, not switched and with
  an URL that matches the TRAIL_URL argument.  If the working
  copy is unusual the version number will be more complex:

   4123:4168     mixed revision working copy
   4168M         modified working copy
   4123S         switched working copy
   4123P         partial working copy, from a sparse checkout
   4123:4168MS   mixed revision, modified, switched working copy

  If WC_PATH is an unversioned path, the program will output
  'Unversioned directory' or 'Unversioned file'.  If WC_PATH is
  an added or copied or moved path, the program will output
  'Uncommitted local addition, copy or move'.

  If invoked without arguments WC_PATH will be the current directory.

Valid options:
  -n [--no-newline]        : do not output the trailing newline
  -c [--committed]         : last changed rather than current revisions
  -h [--help]              : display this help
  --version                : show program version information
  -q [--quiet]             : no progress (only errors) to stderr

参考

Subversion実践入門:達人プログラマに学ぶバージョン管理(第2版)

Subversion実践入門:達人プログラマに学ぶバージョン管理(第2版)