Esempio n. 1
0
    def test_modify_branch(self):
        """Modification of branch directory properties"""
        [dump, log] = self.make_repo((
            dict(nodes=(dict(action="add", path="trunk", kind="dir"),)),
            dict(nodes=(
                dict(action="change", path="trunk", props={"name": "value"}),
            )),
        ))
        output = os.path.join(self.dir, "output")
        with svnex.FastExportFile(output) as fex, log:
            exporter = svnex.Exporter(dump, fex, root="", git_svn=True, quiet=True)
            exporter.export("refs/ref", "trunk")
        with open(output, "r", encoding="ascii") as output:
            self.assertMultiLineEqual("""\
commit refs/ref
mark :1
committer (no author) <(no author)@00000000-0000-0000-0000-000000000000> 0 +0000
data 60


git-svn-id: /trunk@1 00000000-0000-0000-0000-000000000000


commit refs/ref
mark :2
committer (no author) <(no author)@00000000-0000-0000-0000-000000000000> 0 +0000
data 60


git-svn-id: /trunk@2 00000000-0000-0000-0000-000000000000


""",
                output.read())
Esempio n. 2
0
    def test_branch_no_commit(self):
        """Test branching when no commits are involved"""
        [dump, log] = self.make_repo((
            dict(nodes=(
                dict(action="add", path="trunk", kind="dir"),
                dict(action="add", path="branches", kind="dir"),
                dict(action="add", path="trunk/file", kind="file",
                    content=b""),
            )),
            dict(nodes=(
                dict(action="add", path="branches/branch",
                    copyfrom_path="trunk", copyfrom_rev=1),
            )),
        ))
        output = os.path.join(self.dir, "output")
        with svnex.FastExportFile(output) as fex, log:
            rev_map = {"trunk": {1: "trunk"}}
            exporter = svnex.Exporter(dump, fex, root="", rev_map=rev_map,
                quiet=True)
            exporter.export("refs/heads/branch", "branches/branch")
        with open(output, "r", encoding="ascii") as output:
            self.assertMultiLineEqual("""\
reset refs/heads/branch
from trunk
""",
                output.read())
Esempio n. 3
0
    def test_export_copies(self):
        """Test the "--export-copies" mode"""
        [dump, log] = self.make_repo((
            dict(nodes=(
                dict(action="add", path="trunk", kind="dir"),
                dict(action="add", path="trunk/file", kind="file",
                    content=b""),
            )),
            dict(nodes=(dict(action="add", path="branch",
                copyfrom_path="trunk", copyfrom_rev=1),)),
            dict(nodes=(dict(action="change", path="branch/file",
                content=b"mod\n"),)),
        ))
        output = os.path.join(self.dir, "output")
        with svnex.FastExportFile(output) as fex, log:
            exporter = svnex.Exporter(dump, fex, root="",
                export_copies=True, git_svn=True, quiet=True)
            exporter.export("refs/branch", "branch")
        with open(output, "r", encoding="ascii") as output:
            self.assertMultiLineEqual("""\
blob
mark :1
data 0

commit refs/branch
mark :2
committer (no author) <(no author)@00000000-0000-0000-0000-000000000000> 0 +0000
data 60


git-svn-id: /trunk@1 00000000-0000-0000-0000-000000000000

M 644 :1 file

commit refs/branch
mark :3
committer (no author) <(no author)@00000000-0000-0000-0000-000000000000> 0 +0000
data 61


git-svn-id: /branch@2 00000000-0000-0000-0000-000000000000


blob
mark :1
data 4
mod

commit refs/branch
mark :4
committer (no author) <(no author)@00000000-0000-0000-0000-000000000000> 0 +0000
data 61


git-svn-id: /branch@3 00000000-0000-0000-0000-000000000000

M 644 :1 file

""",
                output.read())
Esempio n. 4
0
 def test_authors(self):
     """Authors mapping"""
     [dump, log] = self.make_repo((
         dict(props={"svn:author": "user"}, nodes=(
             dict(action="add", path="file", kind="file", content=b""),
         )),
     ))
     output = os.path.join(self.dir, "output")
     authors = {"user": "******"}
     with svnex.FastExportFile(output) as output, log:
         exporter = svnex.Exporter(dump, output,
             author_map=authors, quiet=True)
         exporter.export("refs/ref")
Esempio n. 5
0
    def test_first_mergeinfo(self):
        """Handling of mergeinfo in first exported commit"""
        [dump, log] = self.make_repo((
            dict(nodes=(
                dict(action="add", path="trunk", kind="dir"),
                dict(action="add", path="trunk/file", kind="file",
                    content=b"original\n"),
            )),
            dict(nodes=(
                dict(action="add", path="branch",
                    copyfrom_path="trunk", copyfrom_rev=1),
                dict(action="change", path="branch/file",
                    content=b"branched\n"),
            )),
            dict(nodes=(
                dict(action="change", path="trunk",
                    props={"svn:mergeinfo": "/branch:2"}),
                dict(action="change", path="trunk/file",
                    content=b"branched\n"),
            )),
            dict(nodes=(
                dict(action="change", path="trunk/file", content=b"new\n"),
            )),
        ))
        output = os.path.join(self.dir, "output")
        with svnex.FastExportFile(output) as fex, log:
            exporter = svnex.Exporter(dump, fex, root="",
                rev_map={"/trunk": {3: "refs/trunk"}}, git_svn=True, quiet=True)
            exporter.export("refs/trunk", "trunk")
        with open(output, "r", encoding="ascii") as output:
            self.assertMultiLineEqual("""\
blob
mark :1
data 4
new

commit refs/trunk
mark :2
committer (no author) <(no author)@00000000-0000-0000-0000-000000000000> 0 +0000
data 60


git-svn-id: /trunk@4 00000000-0000-0000-0000-000000000000

from refs/trunk
M 644 :1 file

""",
                output.read())
Esempio n. 6
0
    def test_first_branch(self):
        """Handling of branch copy as first exported commit"""
        [dump, log] = self.make_repo((
            dict(nodes=(
                dict(action="add", path="trunk", kind="dir"),
                dict(action="add", path="branches", kind="dir"),
                dict(action="add", path="trunk/file", kind="file",
                    content=b"initial\n"),
            )),
            dict(nodes=(
                dict(action="add", path="branch",
                    copyfrom_path="trunk", copyfrom_rev=1),
            )),
            dict(nodes=(
                dict(action="change", path="branch/file",
                    content=b"branched\n"),
            )),
        ))
        output = os.path.join(self.dir, "output")
        with svnex.FastExportFile(output) as fex, log:
            rev_map = {"trunk": {1: "trunk"}}
            exporter = svnex.Exporter(dump, fex, root="", rev_map=rev_map,
                git_svn=True, quiet=True)
            exporter.export("refs/branch", "branch")
        with open(output, "r", encoding="ascii") as output:
            self.assertMultiLineEqual("""\
reset refs/branch
from trunk
blob
mark :1
data 9
branched

commit refs/branch
mark :2
committer (no author) <(no author)@00000000-0000-0000-0000-000000000000> 0 +0000
data 61


git-svn-id: /branch@3 00000000-0000-0000-0000-000000000000

from trunk
M 644 :1 file

""",
                output.read())
Esempio n. 7
0
    def test_first_delete(self):
        """Detection of deletion in first commit"""
        [dump, log] = self.make_repo((
            dict(nodes=(
                dict(action="add", path="file", kind="file", content=b""),
                dict(action="add", path="igfile", kind="file", content=b""),
                dict(action="add", path="igdir/", kind="dir"),
                dict(action="add", path="igdir/file", kind="file",
                    content=b""),
            )),
            dict(nodes=(
                dict(action="delete", path="file"),
                dict(action="delete", path="igfile"),
                dict(action="delete", path="igdir/file"),
            )),
        ))
        output = os.path.join(self.dir, "output")
        with svnex.FastExportFile(output) as fex, log:
            exporter = svnex.Exporter(dump, fex, root="",
                rev_map={"": {1: "refs/ref"}}, ignore=("igfile", "igdir"),
                git_svn=True, quiet=True)
            exporter.export("refs/ref")
        with open(output, "r", encoding="ascii") as output:
            self.assertMultiLineEqual("""\
commit refs/ref
mark :1
committer (no author) <(no author)@00000000-0000-0000-0000-000000000000> 0 +0000
data 54


git-svn-id: @2 00000000-0000-0000-0000-000000000000

from refs/ref
D file

""",
                output.read())
Esempio n. 8
0
    def test_merge(self):
        """Test a merge followed by a normal commit"""
        [dump, log] = self.make_repo((
            dict(nodes=(
                dict(action="add", path="trunk", kind="dir"),
                dict(action="add", path="trunk/file", kind="file",
                    content=b"original\n"),
            )),
            dict(nodes=(
                dict(action="add", path="branch",
                    copyfrom_path="trunk", copyfrom_rev=1),
                dict(action="change", path="branch/file",
                    content=b"branched\n"),
            )),
            dict(nodes=(
                dict(action="change", path="trunk",
                    props={"svn:mergeinfo": "/branch:2"}),
                dict(action="change", path="trunk/file",
                    content=b"branched\n"),
            )),
            dict(nodes=(
                dict(action="change", path="trunk/file",
                    content=b"normal\n"),
            )),
        ))
        output = os.path.join(self.dir, "output")
        with svnex.FastExportFile(output) as fex, log:
            exporter = svnex.Exporter(dump, fex, root="", git_svn=True, quiet=True)
            exporter.export("refs/trunk", "trunk")
        with open(output, "r", encoding="ascii") as output:
            self.assertMultiLineEqual("""\
blob
mark :1
data 9
original

commit refs/trunk
mark :2
committer (no author) <(no author)@00000000-0000-0000-0000-000000000000> 0 +0000
data 60


git-svn-id: /trunk@1 00000000-0000-0000-0000-000000000000

M 644 :1 file

blob
mark :1
data 9
branched

blob
mark :1
data 9
branched

commit refs/trunk
mark :3
committer (no author) <(no author)@00000000-0000-0000-0000-000000000000> 0 +0000
data 61


git-svn-id: /branch@2 00000000-0000-0000-0000-000000000000

from :2
M 644 :1 file

commit refs/trunk
mark :4
committer (no author) <(no author)@00000000-0000-0000-0000-000000000000> 0 +0000
data 60


git-svn-id: /trunk@3 00000000-0000-0000-0000-000000000000

from :2
merge :3
M 644 :1 file

blob
mark :1
data 7
normal

commit refs/trunk
mark :5
committer (no author) <(no author)@00000000-0000-0000-0000-000000000000> 0 +0000
data 60


git-svn-id: /trunk@4 00000000-0000-0000-0000-000000000000

M 644 :1 file

""",
                output.read())