You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2010/09/08 23:27:58 UTC

svn commit: r995260 - /subversion/trunk/tools/dev/wc-format.py

Author: danielsh
Date: Wed Sep  8 21:27:58 2010
New Revision: 995260

URL: http://svn.apache.org/viewvc?rev=995260&view=rev
Log:
Add a helper script, ported to Python.

* tools/dev/wc-format.py:  New.
      Prints the working copy format of a given directory.

Added:
    subversion/trunk/tools/dev/wc-format.py   (with props)

Added: subversion/trunk/tools/dev/wc-format.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/wc-format.py?rev=995260&view=auto
==============================================================================
--- subversion/trunk/tools/dev/wc-format.py (added)
+++ subversion/trunk/tools/dev/wc-format.py Wed Sep  8 21:27:58 2010
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+import os
+import sqlite3
+import sys
+
+# helper
+def usage():
+  sys.stderr.write("USAGE: %s [PATH]\n" + \
+                   "\n" + \
+                   "Prints to stdout the format of the working copy at PATH.\n")
+
+# parse argv
+wc = (sys.argv[1:] + ['.'])[0]
+
+# main()
+entries = os.path.join(wc, '.svn', 'entries')
+wc_db = os.path.join(wc, '.svn', 'wc.db')
+
+if os.path.exists(entries):
+  formatno = int(open(entries).readline())
+elif os.path.exists(wc_db):
+  formatno = sqlite3.connect(wc_db).execute('pragma user_version;').fetchone()[0]
+else:
+  usage()
+  sys.exit(1)
+
+# 1.0.x -> 1.3.x: format 4
+# 1.4.x: format 8
+# 1.5.x: format 9
+# 1.6.x: format 10
+# 1.7.x: format XXX
+print("%s: %d" % (wc, formatno))
+

Propchange: subversion/trunk/tools/dev/wc-format.py
------------------------------------------------------------------------------
    svn:executable = *