Beispiel #1
0
    def list_dir(self, path):
        """Lists the contents of the specified path.

        The result will be an ordered dictionary of contents, mapping
        filenames or directory names with a dictionary containing:

        * ``path``        - The full path of the file or directory.
        * ``created_rev`` - The revision where the file or directory was
                            created.
        """
        result = SortedDict()

        if api_version()[:2] >= (1, 5):
            depth = 2  # Immediate files in this path. Only in 1.5+.
        else:
            depth = 0  # This will trigger recurse=False for SVN < 1.5.

        dirents = self.client.list(B(self.normalize_path(path)), None, depth)

        for name, dirent in six.iteritems(dirents):
            if name:
                result[six.text_type(name)] = {
                    'path': '%s/%s' % (path.strip('/'), name),
                    'created_rev': six.text_type(dirent['created_rev']),
                }

        return result
Beispiel #2
0
    def test_diff(self):
        r = ra.RemoteAccess(self.repos_url,
                auth=ra.Auth([ra.get_username_provider()]))
        dc = self.get_commit_editor(self.repos_url) 
        f = dc.add_file("foo")
        f.modify("foo1")
        dc.close()

        dc = self.get_commit_editor(self.repos_url) 
        f = dc.open_file("foo")
        f.modify("foo2")
        dc.close()

        if client.api_version() < (1, 5):
            self.assertRaises(NotImplementedError, self.client.diff, 1, 2,
                self.repos_url, self.repos_url)
            return # Skip test

        (outf, errf) = self.client.diff(1, 2, self.repos_url, self.repos_url)
        self.addCleanup(outf.close)
        self.addCleanup(errf.close)
        self.assertEqual("""Index: foo
===================================================================
--- foo\t(revision 1)
+++ foo\t(revision 2)
@@ -1 +1 @@
-foo1
\\ No newline at end of file
+foo2
\\ No newline at end of file
""", outf.read())
        self.assertEqual("", errf.read())
Beispiel #3
0
    def test_diff(self):
        dc = self.get_commit_editor(self.repos_url)
        f = dc.add_file("foo")
        f.modify(b"foo1")
        dc.close()

        dc = self.get_commit_editor(self.repos_url)
        f = dc.open_file("foo")
        f.modify(b"foo2")
        dc.close()

        if client.api_version() < (1, 5):
            self.assertRaises(
                NotImplementedError, self.client.diff, 1, 2,
                self.repos_url, self.repos_url)
            return  # Skip test

        (outf, errf) = self.client.diff(1, 2, self.repos_url, self.repos_url)
        self.addCleanup(outf.close)
        self.addCleanup(errf.close)
        self.assertEqual(b"""Index: foo
===================================================================
--- foo\t(revision 1)
+++ foo\t(revision 2)
@@ -1 +1 @@
-foo1
\\ No newline at end of file
+foo2
\\ No newline at end of file
""".splitlines(), outf.read().splitlines())
        self.assertEqual(b"", errf.read())
Beispiel #4
0
    def list_dir(self, path):
        """Lists the contents of the specified path.

        The result will be an ordered dictionary of contents, mapping
        filenames or directory names with a dictionary containing:

        * ``path``        - The full path of the file or directory.
        * ``created_rev`` - The revision where the file or directory was
                            created.
        """
        result = OrderedDict()

        if api_version()[:2] >= (1, 5):
            depth = 2  # Immediate files in this path. Only in 1.5+.
        else:
            depth = 0  # This will trigger recurse=False for SVN < 1.5.

        # subvertpy asserts that svn_uri not ends with slash
        norm_path = self.normalize_path(path).rstrip('/')

        dirents = self.client.list(norm_path, None, depth)

        for name, dirent in six.iteritems(dirents):
            if name:
                result[six.text_type(name)] = {
                    'path': '%s/%s' % (path.strip('/'), name),
                    'created_rev': six.text_type(dirent['created_rev']),
                }

        return result
Beispiel #5
0
    def list_dir(self, path):
        """Lists the contents of the specified path.

        The result will be an ordered dictionary of contents, mapping
        filenames or directory names with a dictionary containing:

        * ``path``        - The full path of the file or directory.
        * ``created_rev`` - The revision where the file or directory was
                            created.
        """
        result = SortedDict()

        if api_version()[:2] >= (1, 5):
            depth = 2  # Immediate files in this path. Only in 1.5+.
        else:
            depth = 0  # This will trigger recurse=False for SVN < 1.5.

        # subvertpy asserts that svn_uri not ends with slash
        norm_path = B(self.normalize_path(path)).rstrip("/")

        dirents = self.client.list(norm_path, None, depth)

        for name, dirent in six.iteritems(dirents):
            if name:
                result[six.text_type(name)] = {
                    "path": "%s/%s" % (path.strip("/"), name),
                    "created_rev": six.text_type(dirent["created_rev"]),
                }

        return result
Beispiel #6
0
    def test_diff(self):
        r = ra.RemoteAccess(self.repos_url,
                            auth=ra.Auth([ra.get_username_provider()]))
        dc = self.get_commit_editor(self.repos_url)
        f = dc.add_file("foo")
        f.modify("foo1")
        dc.close()

        dc = self.get_commit_editor(self.repos_url)
        f = dc.open_file("foo")
        f.modify("foo2")
        dc.close()

        if client.api_version() < (1, 5):
            self.assertRaises(NotImplementedError, self.client.diff, 1, 2,
                              self.repos_url, self.repos_url)
            return  # Skip test

        (outf, errf) = self.client.diff(1, 2, self.repos_url, self.repos_url)
        self.addCleanup(outf.close)
        self.addCleanup(errf.close)
        self.assertEqual(
            """Index: foo
===================================================================
--- foo\t(revision 1)
+++ foo\t(revision 2)
@@ -1 +1 @@
-foo1
\\ No newline at end of file
+foo2
\\ No newline at end of file
""", outf.read())
        self.assertEqual("", errf.read())
Beispiel #7
0
 def test_info(self):
     self.build_tree({"dc/foo": "bla"})
     self.client.add("dc/foo")
     self.client.log_msg_func = lambda c: "Commit"
     self.client.commit(["dc"])
     info = self.client.info("dc/foo")
     self.assertEqual(["foo"], info.keys())
     self.assertEqual(1, info["foo"].revision)
     self.assertEqual(3L, info["foo"].size)
     if client.api_version() < (1, 7):
         # TODO: Why is this failing on 1.7?
         self.assertEqual(wc.SCHEDULE_NORMAL, info["foo"].wc_info.schedule)
     self.build_tree({"dc/bar": "blablabla"})
     self.client.add(os.path.abspath("dc/bar"))
Beispiel #8
0
 def test_info(self):
     self.build_tree({"dc/foo": "bla"})
     self.client.add("dc/foo")
     self.client.log_msg_func = lambda c: "Commit"
     self.client.commit(["dc"])
     info = self.client.info("dc/foo")
     self.assertEqual(["foo"], info.keys())
     self.assertEqual(1, info["foo"].revision)
     self.assertEqual(3L, info["foo"].size)
     if client.api_version() < (1, 7):
         # TODO: Why is this failing on 1.7?
         self.assertEqual(wc.SCHEDULE_NORMAL, info["foo"].wc_info.schedule)
     self.build_tree({"dc/bar": "blablabla"})
     self.client.add(os.path.abspath("dc/bar"))
Beispiel #9
0
 def test_api_version_later_same(self):
     self.assertTrue(client.api_version() <= client.version())
Beispiel #10
0
 def test_api_version_length(self):
     self.assertEqual(4, len(client.api_version()))
Beispiel #11
0
 def test_api_version_later_same(self):
     self.assertTrue(client.api_version() <= client.version())
Beispiel #12
0
 def test_api_version_length(self):
     self.assertEqual(4, len(client.api_version()))