Exemplo n.º 1
0
 def test_add_repos_file(self):
     self.make_client("repos", "checkout")
     adm = wc.Adm(None, "checkout", True)
     if wc.api_version() < (1, 6):
         self.assertRaises(
                 NotImplementedError,
                 adm.add_repos_file, "checkout/bar",
                 BytesIO(b"basecontents"), BytesIO(b"contents"), {}, {})
     else:
         adm.add_repos_file("checkout/bar", BytesIO(b"basecontents"),
                            BytesIO(b"contents"), {}, {})
         if wc.api_version() >= (1, 7):
             self.skipTest("TODO: doesn't yet work with svn >= 1.7")
         self.assertEqual(b"basecontents",
                          wc.get_pristine_contents("checkout/bar").read())
Exemplo n.º 2
0
 def test_match_ignore_list(self):
     if wc.api_version() < (1, 5):
         self.assertRaises(NotImplementedError, wc.match_ignore_list, "foo", [])
         return # Skip test
     self.assertTrue(wc.match_ignore_list("foo", [ "f*"]))
     self.assertTrue(wc.match_ignore_list("foo", ["foo"]))
     self.assertFalse(wc.match_ignore_list("foo", []))
     self.assertFalse(wc.match_ignore_list("foo", ["bar"]))
Exemplo n.º 3
0
 def test_mark_missing_deleted(self):
     if wc.api_version() >= (1, 7):
         self.skipTest("TODO: doesn't yet work with svn >= 1.7")
     self.make_client("repos", "checkout")
     self.build_tree({"checkout/bar": b"\x00 \x01"})
     self.client_add('checkout/bar')
     adm = wc.Adm(None, "checkout", True)
     os.remove("checkout/bar")
     adm.mark_missing_deleted("checkout/bar")
     self.assertFalse(os.path.exists("checkout/bar"))
Exemplo n.º 4
0
 def test_lock(self):
     if wc.api_version() >= (1, 9):
         self.skipTest("TODO: doesn't yet work with svn >= 1.9")
     self.make_client("repos", "checkout")
     self.build_tree({"checkout/bar": b"la"})
     self.client_add('checkout/bar')
     adm = wc.Adm(None, "checkout", True)
     lock = wc.Lock()
     lock.token = b"blah"
     adm.add_lock("checkout", lock)
     adm.remove_lock("checkout")
Exemplo n.º 5
0
 def test_process_committed_queue(self):
     if wc.api_version() >= (1, 7):
         self.skipTest("TODO: doesn't yet work with svn >= 1.7")
     self.make_client("repos", "checkout")
     adm = wc.Context()
     self.build_tree({"checkout/bar": b"blala"})
     self.client_add('checkout/bar')
     adm.add_lock("checkout", wc.Lock(token=b'foo'))
     cq = wc.CommittedQueue()
     cq.queue("checkout/bar", adm)
     adm.process_committed_queue(cq, 1, "2010-05-31T08:49:22.430000Z",
                                 "jelmer")
Exemplo n.º 6
0
 def test_add_from_disk(self):
     if wc.api_version() >= (1, 7):
         self.skipTest("TODO: doesn't yet work with svn >= 1.7")
     self.make_client("repos", "checkout")
     with open('checkout/bla.txt', 'w') as f:
         f.write("modified")
     context = wc.Context()
     lock = wc.Lock(token=b'foo')
     lock.path = os.path.abspath('checkout')+"/"
     context.add_lock("checkout", lock)
     context.add_from_disk('checkout/bla.txt')
     context.remove_lock("checkout", lock)
Exemplo n.º 7
0
 def test_locking(self):
     if wc.api_version() >= (1, 7):
         self.skipTest("TODO: doesn't yet work with svn >= 1.7")
     self.make_client("repos", "checkout")
     with open('checkout/bla.txt', 'w') as f:
         f.write("modified")
     self.client_add("checkout/bla.txt")
     context = wc.Context()
     lock = wc.Lock(token=b'foo')
     self.assertEqual((False, False), context.locked("checkout"))
     context.add_lock("checkout/", lock)
     self.assertEqual((True, True), context.locked("checkout"))
     context.remove_lock("checkout/", lock)
Exemplo n.º 8
0
    def test_transmit_text_deltas(self):
        if wc.api_version() >= (1, 7):
            self.skipTest("TODO: doesn't yet work with svn >= 1.7")
        self.make_client("repos", ".")
        self.build_tree({"bar": b"blala"})
        self.client_add('bar')
        adm = wc.Adm(None, ".", True)

        class Editor(object):
            """Editor"""

            def __init__(self):
                self._windows = []
                self._prop = {}

            def change_prop(self, name, value):
                self._prop[name] = value

            def apply_textdelta(self, checksum):
                def window_handler(window):
                    self._windows.append(window)
                return window_handler

            def close(self):
                pass
        editor = Editor()
        (tmpfile, md5_digest) = adm.transmit_text_deltas("bar", True, editor)
        self.assertEqual(editor._windows,
                         [(0, 0, 5, 0, [(2, 0, 5)], b'blala'), None])
        self.assertIsInstance(tmpfile, str)
        self.assertEqual(16, len(md5_digest))
        self.assertEqual(hashlib.md5(b'blala').digest(), md5_digest)

        bar = adm.entry("bar")
        self.assertEqual(-1, bar.cmt_rev)
        self.assertEqual(0, bar.revision)
        self.assertIn(bar.checksum, (None, hashlib.md5(b'blala').hexdigest()))

        cq = wc.CommittedQueue()
        cq.queue("bar", adm, wcprop_changes=editor._prop,
                 md5_digest=md5_digest)
        adm.process_committed_queue(cq, 1, "2010-05-31T08:49:22.430000Z",
                                    "jelmer")
        bar = adm.entry("bar")
        self.assertEqual("bar", bar.name)
        self.assertEqual(NODE_FILE, bar.kind)
        self.assertEqual(wc.SCHEDULE_NORMAL, bar.schedule)
        self.assertIn(bar.checksum, (None, hashlib.md5(b'blala').hexdigest()))
        self.assertEqual(1, bar.cmt_rev)
        self.assertEqual(1, bar.revision)
Exemplo n.º 9
0
    def test_process_committed(self):
        if wc.api_version() >= (1, 7):
            self.skipTest("TODO: doesn't yet work with svn >= 1.7")
        self.make_client("repos", ".")
        self.build_tree({"bar": b"la"})
        self.client_add('bar')
        adm = wc.Adm(None, ".", True)

        class Editor(object):
            """Editor"""

            def __init__(self):
                self._windows = []

            def apply_textdelta(self, checksum):
                def window_handler(window):
                    self._windows.append(window)
                return window_handler

            def close(self):
                pass
        editor = Editor()
        (tmpfile, digest) = adm.transmit_text_deltas("bar", True, editor)
        self.assertEqual(editor._windows,
                         [(0, 0, 2, 0, [(2, 0, 2)], b'la'), None])
        self.assertIsInstance(tmpfile, str)
        self.assertEqual(16, len(digest))
        self.assertEqual(hashlib.md5(b'la').digest(), digest)
        bar = adm.entry("bar")
        self.assertEqual(-1, bar.cmt_rev)
        self.assertEqual(0, bar.revision)

        adm.process_committed(
            "bar", False, 1, "2010-05-31T08:49:22.430000Z", "jelmer")
        bar = adm.entry("bar")
        self.assertEqual("bar", bar.name)
        self.assertEqual(NODE_FILE, bar.kind)
        self.assertEqual(wc.SCHEDULE_NORMAL, bar.schedule)
Exemplo n.º 10
0
 def test_api_version_later_same(self):
     self.assertTrue(wc.api_version() <= wc.version())
Exemplo n.º 11
0
 def test_api_version_length(self):
     self.assertEqual(4, len(wc.api_version()))
Exemplo n.º 12
0
 def setUp(self):
     super(ContextTests, self).setUp()
     if wc.api_version() < (1, 7):
         self.skipTest("context API not available on Subversion < 1.7")
Exemplo n.º 13
0
 def test_api_version_length(self):
     self.assertEqual(4, len(wc.api_version()))
Exemplo n.º 14
0
 def test_api_version_later_same(self):
     self.assertTrue(wc.api_version() <= wc.version())