subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1742950 - in /subversion/trunk/subversion/tests/cmdline: log_tests.py svnadmin_tests.py svnlook_tests.py svnrdump_tests.py svntest/verify.py
Date Mon, 09 May 2016 13:33:36 GMT
Author: stefan2
Date: Mon May  9 13:33:36 2016
New Revision: 1742950

URL: http://svn.apache.org/viewvc?rev=1742950&view=rev
Log:
Dumps are binary data, therefore explicitly use byte strings for
all operations on them.  This is relevant for Python 3 where char
strings and byte strings are no longer interchangeable.

The string constants to look for are verbatim dump content, regex
and sub-strings to find as well as UUIDs.

* subversion/tests/cmdline/log_tests.py
  (escape_control_chars):  All dump-related string constants must
                           be byte strings.

* subversion/tests/cmdline/svnadmin_tests.py
  (clean_dumpfile,
   extra_headers,
   extra_blockcontent,
   inconsistent_headers,
   empty_date,
   load_bad_props,
   load_no_svndate_r0,
   dump_revprops): Same.

* subversion/tests/cmdline/svnlook_tests.py
  (test_misc,
   info_bad_newlines): Same.

* subversion/tests/cmdline/svnrdump_tests.py
  (compile,
   run_dump_test, 
   run_load_test,
   basic_dump): Same.

* subversion/tests/cmdline/svntest/verify.py
  (DumpParser.*,
   compare_dump_files): Same.

Modified:
    subversion/trunk/subversion/tests/cmdline/log_tests.py
    subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
    subversion/trunk/subversion/tests/cmdline/svnlook_tests.py
    subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py
    subversion/trunk/subversion/tests/cmdline/svntest/verify.py

Modified: subversion/trunk/subversion/tests/cmdline/log_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/log_tests.py?rev=1742950&r1=1742949&r2=1742950&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/log_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/log_tests.py Mon May  9 13:33:36 2016
@@ -937,7 +937,7 @@ def log_through_copyfrom_history(sbox):
 def escape_control_chars(sbox):
   "mod_dav_svn must escape invalid XML control chars"
 
-  dump_str = """SVN-fs-dump-format-version: 2
+  dump_str = b"""SVN-fs-dump-format-version: 2
 
 UUID: ffcae364-69ee-0310-a980-ca5f10462af2
 

Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1742950&r1=1742949&r2=1742950&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Mon May  9 13:33:36 2016
@@ -448,25 +448,25 @@ def set_changed_path_list(sbox, revision
 
 def clean_dumpfile():
   return \
-  [ "SVN-fs-dump-format-version: 2\n\n",
-    "UUID: 668cc64a-31ed-0310-8ccb-b75d75bb44e3\n\n",
-    "Revision-number: 0\n",
-    "Prop-content-length: 56\n",
-    "Content-length: 56\n\n",
-    "K 8\nsvn:date\nV 27\n2005-01-08T21:48:13.838745Z\nPROPS-END\n\n\n",
-    "Revision-number: 1\n",
-    "Prop-content-length: 98\n",
-    "Content-length: 98\n\n",
-    "K 7\nsvn:log\nV 0\n\nK 10\nsvn:author\nV 4\nerik\n",
-    "K 8\nsvn:date\nV 27\n2005-01-08T21:51:16.313791Z\nPROPS-END\n\n\n",
-    "Node-path: A\n",
-    "Node-kind: file\n",
-    "Node-action: add\n",
-    "Prop-content-length: 35\n",
-    "Text-content-length: 5\n",
-    "Text-content-md5: e1cbb0c3879af8347246f12c559a86b5\n",
-    "Content-length: 40\n\n",
-    "K 12\nsvn:keywords\nV 2\nId\nPROPS-END\ntext\n\n\n"]
+  [ b"SVN-fs-dump-format-version: 2\n\n",
+    b"UUID: 668cc64a-31ed-0310-8ccb-b75d75bb44e3\n\n",
+    b"Revision-number: 0\n",
+    b"Prop-content-length: 56\n",
+    b"Content-length: 56\n\n",
+    b"K 8\nsvn:date\nV 27\n2005-01-08T21:48:13.838745Z\nPROPS-END\n\n\n",
+    b"Revision-number: 1\n",
+    b"Prop-content-length: 98\n",
+    b"Content-length: 98\n\n",
+    b"K 7\nsvn:log\nV 0\n\nK 10\nsvn:author\nV 4\nerik\n",
+    b"K 8\nsvn:date\nV 27\n2005-01-08T21:51:16.313791Z\nPROPS-END\n\n\n",
+    b"Node-path: A\n",
+    b"Node-kind: file\n",
+    b"Node-action: add\n",
+    b"Prop-content-length: 35\n",
+    b"Text-content-length: 5\n",
+    b"Text-content-md5: e1cbb0c3879af8347246f12c559a86b5\n",
+    b"Content-length: 40\n\n",
+    b"K 12\nsvn:keywords\nV 2\nId\nPROPS-END\ntext\n\n\n"]
 
 dumpfile_revisions = \
   [ svntest.wc.State('', { 'A' : svntest.wc.StateItem(contents="text\n") }) ]
@@ -480,7 +480,7 @@ def extra_headers(sbox):
   dumpfile = clean_dumpfile()
 
   dumpfile[3:3] = \
-       [ "X-Comment-Header: Ignored header normally not in dump stream\n" ]
+       [ b"X-Comment-Header: Ignored header normally not in dump stream\n" ]
 
   load_and_verify_dumpstream(sbox,[],[], dumpfile_revisions, False, dumpfile,
                              '--ignore-uuid')
@@ -496,10 +496,10 @@ def extra_blockcontent(sbox):
 
   # Replace "Content-length" line with two lines
   dumpfile[8:9] = \
-       [ "Extra-content-length: 10\n",
-         "Content-length: 108\n\n" ]
+       [ b"Extra-content-length: 10\n",
+         b"Content-length: 108\n\n" ]
   # Insert the extra content after "PROPS-END\n"
-  dumpfile[11] = dumpfile[11][:-2] + "extra text\n\n\n"
+  dumpfile[11] = dumpfile[11][:-2] + b"extra text\n\n\n"
 
   load_and_verify_dumpstream(sbox,[],[], dumpfile_revisions, False, dumpfile,
                              '--ignore-uuid')
@@ -512,7 +512,7 @@ def inconsistent_headers(sbox):
 
   dumpfile = clean_dumpfile()
 
-  dumpfile[-2] = "Content-length: 30\n\n"
+  dumpfile[-2] = b"Content-length: 30\n\n"
 
   load_and_verify_dumpstream(sbox, [], svntest.verify.AnyOutput,
                              dumpfile_revisions, False, dumpfile)
@@ -530,9 +530,9 @@ def empty_date(sbox):
 
   # Replace portions of the revision data to drop the svn:date revprop.
   dumpfile[7:11] = \
-       [ "Prop-content-length: 52\n",
-         "Content-length: 52\n\n",
-         "K 7\nsvn:log\nV 0\n\nK 10\nsvn:author\nV 4\nerik\nPROPS-END\n\n\n"
+       [ b"Prop-content-length: 52\n",
+         b"Content-length: 52\n\n",
+         b"K 7\nsvn:log\nV 0\n\nK 10\nsvn:author\nV 4\nerik\nPROPS-END\n\n\n"
          ]
 
   load_and_verify_dumpstream(sbox,[],[], dumpfile_revisions, False, dumpfile,
@@ -1565,7 +1565,7 @@ def hotcopy_symlink(sbox):
 def load_bad_props(sbox):
   "svnadmin load with invalid svn: props"
 
-  dump_str = """SVN-fs-dump-format-version: 2
+  dump_str = b"""SVN-fs-dump-format-version: 2
 
 UUID: dc40867b-38f6-0310-9f5f-f81aa277e06f
 
@@ -3159,12 +3159,12 @@ def load_no_svndate_r0(sbox):
                                          'proplist', '--revprop', '-r0',
                                          sbox.repo_dir)
 
-  dump_old = ["SVN-fs-dump-format-version: 2\n", "\n",
-              "UUID: bf52886d-358d-4493-a414-944a6e5ad4f5\n", "\n",
-              "Revision-number: 0\n",
-              "Prop-content-length: 10\n",
-              "Content-length: 10\n", "\n",
-              "PROPS-END\n", "\n"]
+  dump_old = [b"SVN-fs-dump-format-version: 2\n", b"\n",
+              b"UUID: bf52886d-358d-4493-a414-944a6e5ad4f5\n", b"\n",
+              b"Revision-number: 0\n",
+              b"Prop-content-length: 10\n",
+              b"Content-length: 10\n", b"\n",
+              b"PROPS-END\n", b"\n"]
   svntest.actions.run_and_verify_load(sbox.repo_dir, dump_old)
   
   # svn:date should have been removed
@@ -3255,7 +3255,7 @@ def dump_revprops(sbox):
 
   # We expect the dump to contain no path changes
   for line in dump_contents:
-    if line.find("Node-path: ") > -1:
+    if line.find(b"Node-path: ") > -1:
       logger.warn("Error: path change found in revprops-only dump.")
       raise svntest.Failure
 

Modified: subversion/trunk/subversion/tests/cmdline/svnlook_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnlook_tests.py?rev=1742950&r1=1742949&r2=1742950&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnlook_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnlook_tests.py Mon May  9 13:33:36 2016
@@ -98,11 +98,11 @@ def test_misc(sbox):
                                         expected_status)
 
   # give the repo a new UUID
-  uuid = "01234567-89ab-cdef-89ab-cdef01234567"
+  uuid = b"01234567-89ab-cdef-89ab-cdef01234567"
   svntest.main.run_command_stdin(svntest.main.svnadmin_binary, None, 0, True,
-                           ["SVN-fs-dump-format-version: 2\n",
-                            "\n",
-                            "UUID: ", uuid, "\n",
+                           [b"SVN-fs-dump-format-version: 2\n",
+                            b"\n",
+                            b"UUID: ", uuid, b"\n",
                            ],
                            'load', '--force-uuid', repo_dir)
 
@@ -301,7 +301,7 @@ def test_print_property_diffs(sbox):
 def info_bad_newlines(sbox):
   "svnlook info must allow inconsistent newlines"
 
-  dump_str = """SVN-fs-dump-format-version: 2
+  dump_str = b"""SVN-fs-dump-format-version: 2
 
 UUID: dc40867b-38f6-0310-9f5f-f81aa277e06e
 

Modified: subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py?rev=1742950&r1=1742949&r2=1742950&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py Mon May  9 13:33:36 2016
@@ -53,8 +53,8 @@ Item = svntest.wc.StateItem
 # the logic for differentiating between these two cases.
 
 mismatched_headers_re = re.compile(
-    "Prop-delta: .*|Text-content-sha1: .*|Text-copy-source-md5: .*|"
-    "Text-copy-source-sha1: .*|Text-delta-base-sha1: .*"
+    b"Prop-delta: .*|Text-content-sha1: .*|Text-copy-source-md5: .*|" +
+    b"Text-copy-source-sha1: .*|Text-delta-base-sha1: .*"
 )
 
 ######################################################################
@@ -124,9 +124,9 @@ def run_dump_test(sbox, dumpfile_name, e
     # Compare the output from stdout
     if ignore_base_checksums:
       expected_dumpfile = [l for l in expected_dumpfile
-                                    if not l.startswith('Text-delta-base-md5')]
+                                    if not l.startswith(b'Text-delta-base-md5')]
       svnrdump_dumpfile = [l for l in svnrdump_dumpfile
-                                    if not l.startswith('Text-delta-base-md5')]
+                                    if not l.startswith(b'Text-delta-base-md5')]
     expected_dumpfile = [l for l in expected_dumpfile
                                   if not mismatched_headers_re.match(l)]
     svnrdump_dumpfile = [l for l in svnrdump_dumpfile
@@ -165,7 +165,7 @@ def run_load_test(sbox, dumpfile_name, e
 
   # Set the UUID of the sbox repository to the UUID specified in the
   # dumpfile ### RA layer doesn't have a set_uuid functionality
-  uuid = original_dumpfile[2].split(' ')[1][:-1]
+  uuid = original_dumpfile[2].split(b' ')[1][:-1]
   svntest.actions.run_and_verify_svnadmin2(None, None, 0,
                                            'setuuid', sbox.repo_dir,
                                            uuid)
@@ -203,7 +203,7 @@ def basic_dump(sbox):
                                               [], 0, '-q', 'dump',
                                               sbox.repo_url)
 
-  if not out[0].startswith('SVN-fs-dump-format-version:'):
+  if not out[0].startswith(b'SVN-fs-dump-format-version:'):
     raise svntest.Failure('No valid output')
 
 def revision_0_dump(sbox):

Modified: subversion/trunk/subversion/tests/cmdline/svntest/verify.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/verify.py?rev=1742950&r1=1742949&r2=1742950&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/verify.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/verify.py Mon May  9 13:33:36 2016
@@ -484,7 +484,7 @@ class DumpParser:
     return m.group(1)
 
   def parse_blank(self, required=True):
-    if self.lines[self.current] != '\n':  # Works on Windows
+    if self.lines[self.current] != b'\n':  # Works on Windows
       if required:
         raise SVNDumpParseError("expected blank at line %d\n%s"
                                 % (self.current, self.lines[self.current]))
@@ -494,7 +494,7 @@ class DumpParser:
     return True
 
   def parse_header(self, header):
-    regex = '([^:]*): (.*)$'
+    regex = b'([^:]*): (.*)$'
     m = re.match(regex, self.lines[self.current])
     if not m:
       raise SVNDumpParseError("expected a header at line %d, but found:\n%s"
@@ -504,48 +504,48 @@ class DumpParser:
 
   def parse_headers(self):
     headers = []
-    while self.lines[self.current] != '\n':
+    while self.lines[self.current] != b'\n':
       key, val = self.parse_header(self)
       headers.append((key, val))
     return headers
 
 
   def parse_boolean(self, header, required):
-    return self.parse_line(header + ': (false|true)$', required)
+    return self.parse_line(header + b': (false|true)$', required)
 
   def parse_format(self):
-    return self.parse_line('SVN-fs-dump-format-version: ([0-9]+)$')
+    return self.parse_line(b'SVN-fs-dump-format-version: ([0-9]+)$')
 
   def parse_uuid(self):
-    return self.parse_line('UUID: ([0-9a-z-]+)$')
+    return self.parse_line(b'UUID: ([0-9a-z-]+)$')
 
   def parse_revision(self):
-    return self.parse_line('Revision-number: ([0-9]+)$')
+    return self.parse_line(b'Revision-number: ([0-9]+)$')
 
   def parse_prop_delta(self):
-    return self.parse_line('Prop-delta: (false|true)$', required=False)
+    return self.parse_line(b'Prop-delta: (false|true)$', required=False)
 
   def parse_prop_length(self, required=True):
-    return self.parse_line('Prop-content-length: ([0-9]+)$', required)
+    return self.parse_line(b'Prop-content-length: ([0-9]+)$', required)
 
   def parse_content_length(self, required=True):
-    return self.parse_line('Content-length: ([0-9]+)$', required)
+    return self.parse_line(b'Content-length: ([0-9]+)$', required)
 
   def parse_path(self):
-    path = self.parse_line('Node-path: (.*)$', required=False)
+    path = self.parse_line(b'Node-path: (.*)$', required=False)
     return path
 
   def parse_kind(self):
-    return self.parse_line('Node-kind: (.+)$', required=False)
+    return self.parse_line(b'Node-kind: (.+)$', required=False)
 
   def parse_action(self):
-    return self.parse_line('Node-action: ([0-9a-z-]+)$')
+    return self.parse_line(b'Node-action: ([0-9a-z-]+)$')
 
   def parse_copyfrom_rev(self):
-    return self.parse_line('Node-copyfrom-rev: ([0-9]+)$', required=False)
+    return self.parse_line(b'Node-copyfrom-rev: ([0-9]+)$', required=False)
 
   def parse_copyfrom_path(self):
-    path = self.parse_line('Node-copyfrom-path: (.+)$', required=False)
+    path = self.parse_line(b'Node-copyfrom-path: (.+)$', required=False)
     if not path and self.lines[self.current] == 'Node-copyfrom-path: \n':
       self.current += 1
       path = ''
@@ -743,7 +743,7 @@ def compare_dump_files(message, label, e
   for parsed in [parsed_expected, parsed_actual]:
     for rev_name, rev_record in parsed.items():
       #print "Found %s" % (rev_name,)
-      if 'nodes' in rev_record:
+      if b'nodes' in rev_record:
         #print "Found %s.%s" % (rev_name, 'nodes')
         for path_name, path_record in rev_record['nodes'].items():
           #print "Found %s.%s.%s" % (rev_name, 'nodes', path_name)



Mime
View raw message