Author: danielsh
Date: Thu Apr 21 20:40:37 2011
New Revision: 1095813

URL: http://svn.apache.org/viewvc?rev=1095813&view=rev
Log:
Add format-number verification to fsfsfixer.

* contrib/server-side/fsfsfixer/fixer/fix-rev.py
  (MAX_FSFS_FORMAT): New, after consulting Julian.
  (check_formats): New helper.
  (fix_rev): Call check_formats().

Modified:
    subversion/trunk/contrib/server-side/fsfsfixer/fixer/fix-rev.py

Modified: subversion/trunk/contrib/server-side/fsfsfixer/fixer/fix-rev.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/contrib/server-side/fsfsfixer/fixer/fix-rev.py?rev=1095813&r1=1095812&r2=1095813&view=diff
==============================================================================
--- subversion/trunk/contrib/server-side/fsfsfixer/fixer/fix-rev.py (original)
+++ subversion/trunk/contrib/server-side/fsfsfixer/fixer/fix-rev.py Thu Apr 21 
20:40:37 2011
@@ -21,10 +21,14 @@ SVNLOOK = 'svnlook'
 # Verbosity: True for verbose, or False for quiet
 VERBOSE = True
 
+URL = 
"https://svn.apache.org/repos/asf/subversion/trunk/contrib/server-side/fsfsfixer/fixer/fix-rev.py";
+
 # Global dictionaries recording the fixes made
 fixed_ids = {}
 fixed_checksums = {}
 
+# Youngest FSFS format we know how to handle.
+MAX_FSFS_FORMAT = 5
 
 # ----------------------------------------------------------------------
 # Functions
@@ -203,6 +207,23 @@ def fix_one_error(repo_dir, rev):
 
   raise FixError("unfixable error:\n  " + "\n  ".join(svnadmin_err))
 
+def check_formats(repo_dir):
+  """Check that REPO_DIR isn't newer than we know how to handle."""
+
+  repos_format = int(open(os.path.join(repo_dir, 'format')).readline())
+  if repos_format not in [3,5]:
+    raise FixError("Repository '%s' too new (format %d); try the version at %s"
+                   % (repo_dir, repos_format, URL))
+
+  fs_type = open(os.path.join(repo_dir, 'db', 'fs-type')).read().rstrip()
+  if fs_type != 'fsfs':
+    raise FixError("Repository '%s' has wrong FS backend: "
+                   "found '%s', expected '%s'" % (fs_type, 'fsfs'))
+
+  fsfs_format = int(open(os.path.join(repo_dir, 'db', 'format')).readline())
+  if fsfs_format > MAX_FSFS_FORMAT:
+    raise FixError("Filesystem '%s' is too new (format %d); try the version at 
%s"
+                   % (os.path.join(repo_dir, 'db'), fsfs_format, URL))
 
 # ----------------------------------------------------------------------
 # Main program
@@ -210,6 +231,8 @@ def fix_one_error(repo_dir, rev):
 def fix_rev(repo_dir, rev):
   """"""
 
+  check_formats(repo_dir)
+
   # Back up the file
   if not os.path.exists(rev_file_path(repo_dir, rev) + '.orig'):
     pass


Reply via email to