コード例 #1
0
ファイル: wc.py プロジェクト: yinjinzhong/mycode
 def test_entry(self):
     wc_entry = wc.entry(self.path, self.wc, True)
コード例 #2
0
ファイル: wc.py プロジェクト: vocho/openqnx
 def test_entry(self):
     wc_entry = wc.entry(self.path, self.wc, True)
コード例 #3
0
ファイル: wc.py プロジェクト: yinjinzhong/mycode
    def test_commit(self):
        # Replace README.txt's contents, using binary mode so we know the
        # exact contents even on Windows, and therefore the MD5 checksum.
        readme_path = '%s/trunk/README.txt' % self.path
        fp = open(readme_path, 'wb')
        fp.write('hello\n')
        fp.close()

        # Setup ra_ctx.
        ra.initialize()
        callbacks = ra.Callbacks()
        ra_ctx = ra.open2(REPOS_URL, callbacks, None, None)

        # Get commit editor.
        commit_info = [None]

        def commit_cb(_commit_info, pool):
            commit_info[0] = _commit_info

        (editor, edit_baton) = ra.get_commit_editor2(ra_ctx, 'log message',
                                                     commit_cb, None, False)

        # Drive the commit.
        checksum = [None]

        def driver_cb(parent, path, pool):
            baton = editor.open_file(path, parent, -1, pool)
            adm_access = wc.adm_probe_retrieve(self.wc, readme_path, pool)
            (_,
             checksum[0]) = wc.transmit_text_deltas2(readme_path, adm_access,
                                                     False, editor, baton,
                                                     pool)
            return baton

        try:
            delta.path_driver(editor, edit_baton, -1, ['trunk/README.txt'],
                              driver_cb)
            editor.close_edit(edit_baton)
        except:
            try:
                editor.abort_edit(edit_baton)
            except:
                # We already have an exception in progress, not much we can do
                # about this.
                pass
            raise
        (checksum, ) = checksum
        (commit_info, ) = commit_info

        # Assert the commit.
        self.assertEquals(binascii.b2a_hex(checksum),
                          'b1946ac92492d2347c6235b4d2611184')
        self.assertEquals(commit_info.revision, 13)

        # Bump working copy state.
        wc.process_committed4(
            readme_path, wc.adm_retrieve(self.wc,
                                         os.path.dirname(readme_path)), False,
            commit_info.revision, commit_info.date, commit_info.author, None,
            False, False, checksum)

        # Assert bumped state.
        entry = wc.entry(readme_path, self.wc, False)
        self.assertEquals(entry.revision, commit_info.revision)
        self.assertEquals(entry.schedule, wc.schedule_normal)
        self.assertEquals(entry.cmt_rev, commit_info.revision)
        self.assertEquals(entry.cmt_date,
                          core.svn_time_from_cstring(commit_info.date))
コード例 #4
0
ファイル: wc.py プロジェクト: vocho/openqnx
    def test_commit(self):
        # Replace README.txt's contents, using binary mode so we know the
        # exact contents even on Windows, and therefore the MD5 checksum.
        readme_path = "%s/trunk/README.txt" % self.path
        fp = open(readme_path, "wb")
        fp.write("hello\n")
        fp.close()

        # Setup ra_ctx.
        ra.initialize()
        callbacks = ra.Callbacks()
        ra_ctx = ra.open2(REPOS_URL, callbacks, None, None)

        # Get commit editor.
        commit_info = [None]

        def commit_cb(_commit_info, pool):
            commit_info[0] = _commit_info

        (editor, edit_baton) = ra.get_commit_editor2(ra_ctx, "log message", commit_cb, None, False)

        # Drive the commit.
        checksum = [None]

        def driver_cb(parent, path, pool):
            baton = editor.open_file(path, parent, -1, pool)
            adm_access = wc.adm_probe_retrieve(self.wc, readme_path, pool)
            (_, checksum[0]) = wc.transmit_text_deltas2(readme_path, adm_access, False, editor, baton, pool)
            return baton

        try:
            delta.path_driver(editor, edit_baton, -1, ["trunk/README.txt"], driver_cb)
            editor.close_edit(edit_baton)
        except:
            try:
                editor.abort_edit(edit_baton)
            except:
                # We already have an exception in progress, not much we can do
                # about this.
                pass
            raise
        (checksum,) = checksum
        (commit_info,) = commit_info

        # Assert the commit.
        self.assertEquals(binascii.b2a_hex(checksum), "b1946ac92492d2347c6235b4d2611184")
        self.assertEquals(commit_info.revision, 13)

        # Bump working copy state.
        wc.process_committed4(
            readme_path,
            wc.adm_retrieve(self.wc, os.path.dirname(readme_path)),
            False,
            commit_info.revision,
            commit_info.date,
            commit_info.author,
            None,
            False,
            False,
            checksum,
        )

        # Assert bumped state.
        entry = wc.entry(readme_path, self.wc, False)
        self.assertEquals(entry.revision, commit_info.revision)
        self.assertEquals(entry.schedule, wc.schedule_normal)
        self.assertEquals(entry.cmt_rev, commit_info.revision)
        self.assertEquals(entry.cmt_date, core.svn_time_from_cstring(commit_info.date))