Exemplo n.º 1
0
def check_subversion_version():
    """Check that Subversion is compatible.

    """
    # Installed ?
    from subvertpy import ra, __version__ as subvertpy_version
    ra_version = ra.version()
    if (ra_version[1] >= 5 and getattr(ra, 'SVN_REVISION', None)
            and 27729 <= ra.SVN_REVISION < 31470):
        raise DependencyNotPresent(
            "subvertpy",
            'bzr-svn: Installed Subversion has buggy svn.ra.get_log() '
            'implementation, please install newer.')

    from breezy.trace import mutter
    versions = ["Subversion %d.%d.%d (%s)" % ra_version]
    if getattr(ra, "api_version",
               None) is not None and ra.api_version() != ra_version:
        versions.append("Subversion API %d.%d.%d (%s)" % ra.api_version())
    versions.append("subvertpy %d.%d.%d" % subvertpy_version)
    mutter("bzr-svn: using " + ", ".join(versions))

    if subvertpy_version < subvertpy_minimum_version:
        raise DependencyNotPresent(
            "subvertpy",
            "bzr-svn: at least subvertpy %d.%d.%d is required, %d.%d.%d is installed."
            % (subvertpy_minimum_version + subvertpy_version))
Exemplo n.º 2
0
    def test_get_commit_editor_custom_revprops(self):
        if ra.version()[:2] < (1,5):
            return
        def mycb(paths, rev, revprops):
            pass
        editor = self.ra.get_commit_editor({"svn:log": "foo", "bar:foo": "bla", "svn:custom:blie": "bloe"}, mycb)
        root = editor.open_root()
        root.add_directory("somedir").close()
        root.close()
        editor.close()

        self.assertEqual(set(['bar:foo', 'svn:author', 'svn:custom:blie', 'svn:date', 'svn:log']), set(self.ra.rev_proplist(1).keys()))
Exemplo n.º 3
0
    def test_follow_branch_switched_parents(self):
        repos_url = self.make_svn_repository('a')

        cb = self.get_commit_editor(repos_url)
        pykleur = cb.add_dir("pykleur")
        trunk = pykleur.add_dir("pykleur/trunk")
        nested = trunk.add_dir("pykleur/trunk/pykleur")
        cb.close()  #1

        cb = self.get_commit_editor(repos_url)
        pykleur = cb.open_dir("pykleur")
        trunk = pykleur.open_dir("pykleur/trunk")
        nested = trunk.open_dir("pykleur/trunk/pykleur")
        afile = nested.add_file("pykleur/trunk/pykleur/afile")
        afile.modify(b"contents")
        afile.close()
        cb.close()  #2

        cb = self.get_commit_editor(repos_url)
        cb.add_dir("pygments", "pykleur", 1)
        cb.delete("pykleur")
        cb.close()  #3

        repos = Repository.open(repos_url)
        repos.set_layout(TrunkLayout(1))
        results = repos._revmeta_provider.iter_reverse_branch_changes(
            "pygments/trunk", 3, 0)

        # Results differ per Subversion version, yay
        # For <= 1.4:
        if ra.version()[1] <= 4:
            self.assertRevmetaLogEquals(
                [('pygments/trunk', {
                    'pygments': (u'A', 'pykleur', 1, NODE_DIR),
                    'pygments/trunk': (u'R', 'pykleur/trunk', 2, NODE_DIR),
                    'pykleur': (u'D', None, -1, NODE_DIR)
                }, 3),
                 ('pykleur/trunk', {
                     'pykleur/trunk/pykleur/afile': (u'A', None, -1, NODE_DIR)
                 }, 2),
                 ('pykleur/trunk', {
                     'pykleur': (u'A', None, -1, NODE_DIR),
                     'pykleur/trunk': (u'A', None, -1, NODE_DIR),
                     'pykleur/trunk/pykleur': (u'A', None, -1, NODE_DIR)
                 }, 1)], results)
        else:
            self.assertRevmetaLogEquals([('pykleur/trunk', {
                'pykleur': (u'A', None, -1, NODE_DIR),
                'pykleur/trunk': (u'A', None, -1, NODE_DIR),
                'pykleur/trunk/pykleur': (u'A', None, -1, NODE_DIR)
            }, 1)], results)
Exemplo n.º 4
0
    def test_get_commit_editor_custom_revprops(self):
        if ra.version()[:2] < (1, 5):
            return

        def mycb(paths, rev, revprops):
            pass

        editor = self.ra.get_commit_editor(
            {
                "svn:log": "foo",
                "bar:foo": "bla",
                "svn:custom:blie": "bloe"
            }, mycb)
        root = editor.open_root()
        root.add_directory("somedir").close()
        root.close()
        editor.close()

        self.assertEqual(
            set([
                'bar:foo', 'svn:author', 'svn:custom:blie', 'svn:date',
                'svn:log'
            ]), set(self.ra.rev_proplist(1).keys()))
Exemplo n.º 5
0
 def test_api_version_later_same(self):
     self.assertTrue(ra.api_version() <= ra.version())
Exemplo n.º 6
0
 def test_version_length(self):
     self.assertEqual(4, len(ra.version()))
Exemplo n.º 7
0
    def test_control_code_msg(self):
        if ra.version()[1] >= 5:
            raise TestSkipped("Test not runnable with Subversion >= 1.5")

        repos_url = self.make_svn_repository('d')

        cb = self.get_commit_editor(repos_url)
        cb.add_dir("trunk")
        cb.close("\x24")

        cb = self.get_commit_editor(repos_url)
        trunk = cb.open_dir("trunk")
        hosts = trunk.add_file("trunk/hosts")
        hosts.modify(b"hej2")
        cb.close("bla\xfcbla")  #2

        cb = self.get_commit_editor(repos_url)
        trunk = cb.open_dir("trunk")
        trunk.open_file("trunk/hosts").modify(b"hej3")
        cb.close("a\x0cb")  #3

        cb = self.get_commit_editor(repos_url)
        branches = cb.add_dir("branches")
        foobranch = branches.add_dir("branches/foobranch")
        foobranch.add_file("branches/foobranch/file").modify()
        cb.close("foohosts")  #4

        oldrepos = Repository.open(repos_url)
        oldrepos.set_layout(TrunkLayout(0))
        dir = ControlDir.create("f")
        newrepos = dir.create_repository()
        oldrepos.copy_content_into(newrepos)

        mapping = oldrepos.get_mapping()

        self.assertTrue(
            newrepos.has_revision(
                oldrepos.generate_revision_id(1, "trunk", mapping)))
        self.assertTrue(
            newrepos.has_revision(
                oldrepos.generate_revision_id(2, "trunk", mapping)))
        self.assertTrue(
            newrepos.has_revision(
                oldrepos.generate_revision_id(3, "trunk", mapping)))
        self.assertTrue(
            newrepos.has_revision(
                oldrepos.generate_revision_id(4, "branches/foobranch",
                                              mapping)))
        self.assertFalse(
            newrepos.has_revision(
                oldrepos.generate_revision_id(4, "trunk", mapping)))
        self.assertFalse(
            newrepos.has_revision(oldrepos.generate_revision_id(
                2, "", mapping)))

        rev = newrepos.get_revision(
            oldrepos.generate_revision_id(1, "trunk", mapping))
        self.assertEqual("$", rev.message)

        rev = newrepos.get_revision(
            oldrepos.generate_revision_id(2, "trunk", mapping))
        self.assertEqual('bla\xc3\xbcbla', rev.message.encode("utf-8"))

        rev = newrepos.get_revision(
            oldrepos.generate_revision_id(3, "trunk", mapping))
        self.assertEqual(u"a\\x0cb", rev.message)
Exemplo n.º 8
0
 def test_api_version_later_same(self):
     self.assertTrue(ra.api_version() <= ra.version())
Exemplo n.º 9
0
 def test_version_length(self):
     self.assertEqual(4, len(ra.version()))