You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2012/05/13 06:43:35 UTC

svn commit: r1337776 - in /subversion/trunk: subversion/tests/cmdline/svntest/err.py tools/dev/gen-py-errors.py

Author: gstein
Date: Sun May 13 04:43:35 2012
New Revision: 1337776

URL: http://svn.apache.org/viewvc?rev=1337776&view=rev
Log:
Rebuild gen-py-errors.py to use svn_error_codes.h rather than the
Python bindings. Generate a new err.py.

* tools/dev/gen-py-errors.py:
  (...): full revamp

* subversion/tests/cmdline/svntest/err.py:
  (...): a few new error codes.
  (CATEGORY_SIZE, LAST): removed; not real errors

Modified:
    subversion/trunk/subversion/tests/cmdline/svntest/err.py
    subversion/trunk/tools/dev/gen-py-errors.py

Modified: subversion/trunk/subversion/tests/cmdline/svntest/err.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/err.py?rev=1337776&r1=1337775&r2=1337776&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/err.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/err.py Sun May 13 04:43:35 2012
@@ -22,6 +22,7 @@ AUTHZ_PARTIALLY_READABLE = 220002
 AUTHZ_ROOT_UNREADABLE = 220000
 AUTHZ_UNREADABLE = 220001
 AUTHZ_UNWRITABLE = 220004
+BAD_ATOMIC = 125015
 BAD_CHANGELIST_NAME = 125014
 BAD_CHECKSUM_KIND = 125011
 BAD_CHECKSUM_PARSE = 125012
@@ -40,21 +41,24 @@ BAD_UUID = 125008
 BAD_VERSION_FILE_FORMAT = 125006
 BASE = 200000
 CANCELLED = 200015
-CATEGORY_SIZE = 5000
 CEASE_INVOCATION = 200021
 CHECKSUM_MISMATCH = 200014
 CLIENT_BAD_REVISION = 195002
 CLIENT_CYCLE_DETECTED = 195019
 CLIENT_DUPLICATE_COMMIT_URL = 195003
 CLIENT_FILE_EXTERNAL_OVERWRITE_VERSIONED = 195017
+CLIENT_FORBIDDEN_BY_SERVER = 195023
 CLIENT_INVALID_EXTERNALS_DESCRIPTION = 195005
+CLIENT_INVALID_MERGEINFO_NO_MERGETRACKING = 195021
 CLIENT_INVALID_RELOCATION = 195009
 CLIENT_IS_BINARY_FILE = 195004
 CLIENT_IS_DIRECTORY = 195007
+CLIENT_MERGE_UPDATE_REQUIRED = 195020
 CLIENT_MISSING_LOCK_TOKEN = 195013
 CLIENT_MODIFIED = 195006
 CLIENT_MULTIPLE_SOURCES_DISALLOWED = 195014
 CLIENT_NOT_READY_TO_MERGE = 195016
+CLIENT_NO_LOCK_TOKEN = 195022
 CLIENT_NO_VERSIONED_PARENT = 195015
 CLIENT_PATCH_BAD_STRIP_COUNT = 195018
 CLIENT_PROPERTY_NAME = 195011
@@ -95,6 +99,7 @@ FS_CONFLICT = 160024
 FS_CORRUPT = 160004
 FS_GENERAL = 160000
 FS_ID_NOT_FOUND = 160014
+FS_INCORRECT_EDITOR_COMPLETION = 160050
 FS_LOCK_EXPIRED = 160041
 FS_LOCK_OWNER_MISMATCH = 160039
 FS_MALFORMED_SKEL = 160027
@@ -143,11 +148,11 @@ IO_CORRUPT_EOL = 135002
 IO_INCONSISTENT_EOL = 135000
 IO_PIPE_FRAME_ERROR = 135004
 IO_PIPE_READ_ERROR = 135005
+IO_PIPE_WRITE_ERROR = 135007
 IO_UNIQUE_NAMES_EXHAUSTED = 135003
 IO_UNKNOWN_EOL = 135001
 IO_WRITE_ERROR = 135006
 ITER_BREAK = 200023
-LAST = 235002
 MALFORMED_FILE = 200002
 MERGEINFO_PARSE_ERROR = 200020
 NODE_UNEXPECTED_KIND = 145001
@@ -211,6 +216,7 @@ REPOS_UNSUPPORTED_VERSION = 165005
 RESERVED_FILENAME_SPECIFIED = 200025
 REVNUM_PARSE_FAILURE = 200022
 SQLITE_BUSY = 200033
+SQLITE_CONSTRAINT = 200035
 SQLITE_ERROR = 200030
 SQLITE_READONLY = 200031
 SQLITE_RESETTING_FOR_ROLLBACK = 200034
@@ -263,6 +269,7 @@ WC_NOT_SYMLINK = 155034
 WC_NOT_UP_TO_DATE = 155011
 WC_NOT_WORKING_COPY = 155007
 WC_OBSTRUCTED_UPDATE = 155000
+WC_PATH_ACCESS_DENIED = 155039
 WC_PATH_FOUND = 155014
 WC_PATH_NOT_FOUND = 155010
 WC_PATH_UNEXPECTED_STATUS = 155035

Modified: subversion/trunk/tools/dev/gen-py-errors.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/gen-py-errors.py?rev=1337776&r1=1337775&r2=1337776&view=diff
==============================================================================
--- subversion/trunk/tools/dev/gen-py-errors.py (original)
+++ subversion/trunk/tools/dev/gen-py-errors.py Sun May 13 04:43:35 2012
@@ -23,44 +23,87 @@
 # ====================================================================
 #
 #
-#  Meant to be run from the root of a Subversion working copy.  If anybody
-#  wants to do some path magic to improve that use, feel free.
-
-import sys, os
-sys.path.append(os.path.join('subversion', 'bindings', 'swig',
-                             'python', 'tests'))
-
+# Locates svn_error_codes.h based on its relative location to this script.
+#
+# Generates to STDOUT. Typically, redirect this into svntest/err.py
+#
 
-import setup_path
+import sys
+import os
+import re
 
-header = '''#!/usr/bin/env python
+HEADER = '''#!/usr/bin/env python
 ### This file automatically generated by tools/dev/gen-py-error.py,
 ### which see for more information
 ###
 ### It is versioned for convenience.
-
 '''
 
+# Established by svn 1.0. May as well hard-code these.
+APR_OS_START_ERROR = 20000
+APR_OS_START_USERERR = APR_OS_START_ERROR + 50000 * 2
+SVN_ERR_CATEGORY_SIZE = 5000
+
+RE_CAT_NAME = re.compile(r'SVN_ERR_([A-Z_]+)_CATEG')
+RE_CAT_VALUE = re.compile(r'\d+')
+
+RE_DEF_NAME = re.compile(r'SVN_ERRDEF\(([A-Z0-9_]+)')
+RE_DEF_VALUE = re.compile(r'SVN_ERR_([A-Z_]+)_CATEG[^0-9]*([0-9]+)')
+
+
+def write_output(codes):
+  print HEADER
+
+  for name, value in codes:
+    # skip SVN_ERR_ on the name
+    print '%s = %d' % (name[8:], value)
+
+
+def main(codes_fname):
+  categ = { }
+  codes = [ ]
+
+  f = open(codes_fname)
+
+  # Parse all the category start values
+  while True:
+    line = f.next()
+    m = RE_CAT_NAME.search(line)
+    if m:
+      name = m.group(1)
+      m = RE_CAT_VALUE.search(f.next())
+      assert m
+      value = int(m.group(0))
+      categ[name] = APR_OS_START_USERERR + value * SVN_ERR_CATEGORY_SIZE
+
+    elif line.strip() == 'SVN_ERROR_START':
+      break
+
+  # Parse each of the error values
+  while True:
+    line = f.next()
+    m = RE_DEF_NAME.search(line)
+    if m:
+      name = m.group(1)
+      line = f.next()
+      m = RE_DEF_VALUE.search(line)
+      if not m:
+        # SVN_ERR_WC_NOT_DIRECTORY is defined as equal to NOT_WORKING_COPY
+        # rather than relative to SVN_ERR_WC_CATEGORY_START
+        #print 'SKIP:', line
+        continue
+      cat = m.group(1)
+      value = int(m.group(2))
+      codes.append((name, categ[cat] + value))
 
-def write_output(errs, filename):
-  out = open(filename, 'w')
-  out.write(header)
-
-  for name, val in errs:
-    out.write('%s = %d\n' % (name, val))
-
-  out.close()
-
-
-def main(output_filename):
-  import core
+    elif line.strip() == 'SVN_ERROR_END':
+      break
 
-  errs = [e for e in dir(core.svn.core) if e.startswith('SVN_ERR_')]
-  codes = []
-  for e in errs:
-    codes.append((e[8:], getattr(core.svn.core, e)))
-  write_output(codes, output_filename)
+  write_output(sorted(codes))
 
 
 if __name__ == '__main__':
-  main(os.path.join('subversion', 'tests', 'cmdline', 'svntest', 'err.py'))
+  this_dir = os.path.dirname(os.path.abspath(__file__))
+  codes_fname = os.path.join(this_dir, os.path.pardir, os.path.pardir,
+                             'subversion', 'include', 'svn_error_codes.h')
+  main(codes_fname)