示例#1
0
    def test_read_text_only(self):
        fh = StringIO("""
Node-path: a
Node-kind: file
Node-action: change
Text-content-length: 2
Text-content-md5: 009520053b00386d1173f3988c55d192
Text-content-sha1: 9063a9f0e032b6239403b719cbbba56ac4e4e45f
Content-length: 2

y


""")

        reader = SvnDumpReader(fh)
        lump = reader.read_lump()

        self.assertEqual(lump.get_header_keys(), [
            'Node-path', 'Node-kind', 'Node-action',
            'Text-content-length', 'Text-content-md5', 'Text-content-sha1',
            'Content-length'
        ])
        self.assertEqual(lump.get_header('Node-kind'), 'file')
        self.assertEqual(lump.properties.keys(), [ ] )
        out_fh = StringIO()
        lump.content.empty_to(out_fh)
        out_fh.seek(0)
        self.assertEqual(out_fh.read(), "y\n")
示例#2
0
    def test_read_add_node_without_md5sum(self):
        # With some versions of Subversion an 'add' node for an empty
        # file may come without MD5 sum.
        fh = StringIO("""
Node-path: bla
Node-kind: file
Node-action: add
Prop-content-length: 10
Text-content-length: 0
Content-length: 10

PROPS-END


""")

        reader = SvnDumpReader(fh)
        lump = reader.read_lump()

        self.assertEqual(lump.get_header_keys(), [
            'Node-path', 'Node-kind', 'Node-action',
            'Prop-content-length', 'Text-content-length',
            'Content-length'
        ])
        self.assertEqual(lump.get_header('Node-kind'), 'file')
        self.assertEqual(lump.get_header('Node-action'), 'add')
        out_fh = StringIO()
        lump.content.empty_to(out_fh)
        out_fh.seek(0)
        self.assertEqual(out_fh.read(), '')
示例#3
0
    def test_read_props_only(self):
        fh = StringIO("""
Revision-number: 5
Prop-content-length: 107
Content-length: 107

K 7
svn:log
V 5
Test

K 10
svn:author
V 8
wilhelmh
K 8
svn:date
V 27
2011-09-09T15:42:21.809782Z
PROPS-END


""")

        reader = SvnDumpReader(fh)
        lump = reader.read_lump()

        self.assertEqual(lump.get_header_keys(), [
            'Revision-number', 'Prop-content-length', 'Content-length'
        ])
        self.assertEqual(lump.get_header('Revision-number'), '5')
        self.assertEqual(lump.properties['svn:log'], "Test\n")
        self.assertEqual(lump.properties['svn:author'], "wilhelmh")
        self.assertEqual(lump.properties['svn:date'], "2011-09-09T15:42:21.809782Z")
        self.assertEqual(lump.content, None)
示例#4
0
    def test_read_props_and_text(self):
        fh = StringIO("""
Node-path: bla
Node-kind: file
Node-action: add
Prop-content-length: 27
Text-content-length: 16
Text-content-md5: 4b6209c3b1032d515731c4f992fff73a
Text-content-sha1: a1d199953be4046ac8067ef1724ce5796a791fe3
Content-length: 43

K 4
blub
V 3
XXX
PROPS-END
fsdfa
fgasdfgsd


""")

        reader = SvnDumpReader(fh)
        lump = reader.read_lump()

        self.assertEqual(lump.get_header_keys(), [
            'Node-path', 'Node-kind', 'Node-action',
            'Prop-content-length', 'Text-content-length',
            'Text-content-md5', 'Text-content-sha1',
            'Content-length'
        ])
        self.assertEqual(lump.get_header('Node-kind'), 'file')
        self.assertEqual(lump.get_header('Node-action'), 'add')
        self.assertEqual(lump.properties['blub'], 'XXX')
        out_fh = StringIO()
        lump.content.empty_to(out_fh)
        out_fh.seek(0)
        self.assertEqual(out_fh.read(), """fsdfa
fgasdfgsd
""")
示例#5
0
 def test_get_dump_file_handle_for_revision(self):
     lumps = [ ]
     with self.repo.get_dump_file_handle_for_revision(3) as fh:
         reader = SvnDumpReader(fh)
         self._check_lump(
             reader.read_lump(),
             [ 'SVN-fs-dump-format-version', '2' ],
             { },
             None
         )
         self._check_lump(
             reader.read_lump(),
             [ 'UUID', 'XXX' ],
             { },
             None
         )
         self._check_lump(
             reader.read_lump(),
             [ 'Revision-number', '3' ],
             { 'svn:log': "c3\nextra long\n", 'svn:author': 'testuser', 'svn:date': 'XXX' },
             None
         )
         self._check_lump(
             reader.read_lump(),
             [ 'Node-path', 'a/x1', 'Node-kind', 'file', 'Node-action', 'add',
               'Text-content-md5', 'cde333fcdaa0fbf09280e457333d72fd',
               'Text-content-sha1', '9558e4c4678259123b0553229c304db1a2ed4754'
             ],
             { },
             'x11111'
         )
         self._check_lump(
             reader.read_lump(),
             [ 'Node-path', 'a/x2', 'Node-kind', 'file', 'Node-action', 'add',
               'Text-content-md5', '56a20ee450b0936c3a976dcdaddb2dd1',
               'Text-content-sha1', 'e1b9077d3220006a05f7e740c6ce88bd242a0dfd'
             ],
             { },
             'x22222'
         )