You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2015/01/27 16:20:29 UTC

svn commit: r1655064 - /subversion/trunk/subversion/tests/cmdline/svntest/verify.py

Author: julianfoad
Date: Tue Jan 27 15:20:29 2015
New Revision: 1655064

URL: http://svn.apache.org/r1655064
Log:
Fix test suite's parsing of dumpfiles, following r1655026 which changed the
order of headers in a node record.

* subversion/tests/cmdline/svntest/verify.py
  (DumpParser): When parsing node headers, do not require an ordering beyond
    that which is documented in notes/dump-load-format.txt.

Modified:
    subversion/trunk/subversion/tests/cmdline/svntest/verify.py

Modified: subversion/trunk/subversion/tests/cmdline/svntest/verify.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/verify.py?rev=1655064&r1=1655063&r2=1655064&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/verify.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/verify.py Tue Jan 27 15:20:29 2015
@@ -491,6 +491,22 @@ class DumpParser:
     self.current += 1
     return True
 
+  def parse_header(self, header):
+    regex = '([^:]*): (.*)$'
+    m = re.match(regex, self.lines[self.current])
+    if not m:
+      raise SVNDumpParseError("expected a header at line %d, but found:\n%s"
+                              % (self.current, self.lines[self.current]))
+    self.current += 1
+    return m.groups()
+
+  def parse_headers(self):
+    headers = []
+    while self.lines[self.current] != '\n':
+      key, val = self.parse_header(self)
+      headers.append((key, val))
+    return headers
+
   def parse_format(self):
     return self.parse_line('SVN-fs-dump-format-version: ([0-9]+)$')
 
@@ -590,17 +606,43 @@ class DumpParser:
 
   def parse_one_node(self):
     node = {}
+
+    # optional 'kind' and required 'action' must be next
     node['kind'] = self.parse_kind()
     action = self.parse_action()
-    node['copyfrom_rev'] = self.parse_copyfrom_rev()
-    node['copyfrom_path'] = self.parse_copyfrom_path()
-    node['copy_md5'] = self.parse_copy_md5()
-    node['copy_sha1'] = self.parse_copy_sha1()
-    node['prop_length'] = self.parse_prop_length(required=False)
-    node['text_length'] = self.parse_text_length()
-    node['text_md5'] = self.parse_text_md5()
-    node['text_sha1'] = self.parse_text_sha1()
-    node['content_length'] = self.parse_content_length(required=False)
+
+    # read any remaining headers
+    headers_list = self.parse_headers()
+    headers = dict(headers_list)
+
+    # Content-length must be last, if present
+    if 'Content-length' in headers and headers_list[-1][0] != 'Content-length':
+      raise SVNDumpParseError("'Content-length' header is not last, "
+                              "in header block ending at line %d"
+                              % (self.current,))
+
+    # parse the remaining optional headers and store in specific keys in NODE
+    for key, header, regex in [
+        ('copyfrom_rev',    'Node-copyfrom-rev',    '([0-9]+)$'),
+        ('copyfrom_path',   'Node-copyfrom-path',   '(.*)$'),
+        ('copy_md5',        'Text-copy-source-md5', '([0-9a-z]+)$'),
+        ('copy_sha1',       'Text-copy-source-sha1','([0-9a-z]+)$'),
+        ('prop_length',     'Prop-content-length',  '([0-9]+)$'),
+        ('text_length',     'Text-content-length',  '([0-9]+)$'),
+        ('text_md5',        'Text-content-md5',     '([0-9a-z]+)$'),
+        ('text_sha1',       'Text-content-sha1',    '([0-9a-z]+)$'),
+        ('content_length',  'Content-length',       '([0-9]+)$'),
+        ]:
+      if not header in headers:
+        node[key] = None
+        continue
+      m = re.match(regex, headers[header])
+      if not m:
+        raise SVNDumpParseError("expected '%s' at line %d\n%s"
+                                % (regex, self.current,
+                                   self.lines[self.current]))
+      node[key] = m.group(1)
+
     self.parse_blank()
     if node['prop_length']:
       node['props'] = self.get_props()