コード例 #1
0
    def load(self,
             dumpfile,
             feedbackfile=None,
             uuid_action=svn_repos_load_uuid_default,
             parent_dir="",
             use_pre_commit_hook=False,
             use_post_commit_hook=False,
             cancel_func=None):
        """Read and parse dumpfile-formatted DUMPFILE, reconstructing
        filesystem revisions. Dumpfile should be an open python file object
        or file like object. UUID will be handled according to UUID_ACTION
        which defaults to svn_repos_load_uuid_default.

        If FEEDBACKFILE is provided (in the form of a python file object or
        file like object), feedback will be sent to it.

        If PARENT_DIR is provided, everything loaded from the dump will be
        reparented to PARENT_DIR.

        USE_PRE_COMMIT_HOOK and USE_POST_COMMIT_HOOK are False by default,
        if either is set to True that hook will be used.

        If CANCEL_FUNC is provided, it will be called at various points to
        allow the operation to be cancelled. The cancel baton will be the
        LocalRepository object."""

        if not cancel_func:
            cancel_func = svn_cancel_func_t()

        apr_dump = _types.APRFile(dumpfile)
        stream_dump = svn_stream_from_aprfile2(apr_dump._as_parameter_, False,
                                               self.iterpool)

        if feedbackfile:
            apr_feedback = _types.APRFile(feedbackfile)
            stream_feedback = svn_stream_from_aprfile2(
                apr_feedback._as_parameter_, False, self.iterpool)
        else:
            stream_feedback = NULL

        svn_repos_load_fs2(self._as_parameter_, stream_dump, stream_feedback,
                           uuid_action, parent_dir, use_pre_commit_hook,
                           use_post_commit_hook, cancel_func, c_void_p(),
                           self.iterpool)

        apr_dump.close()
        if feedbackfile:
            apr_feedback.close()

        self.iterpool.clear()
コード例 #2
0
ファイル: wc.py プロジェクト: sleepingwit/jal123
    def diff(self,
             path1="",
             revnum1=None,
             path2=None,
             revnum2=None,
             diff_options=[],
             recurse=True,
             ignore_ancestry=True,
             no_diff_deleted=False,
             ignore_content_type=False,
             header_encoding="",
             outfile=sys.stdout,
             errfile=sys.stderr):
        """Produce svn diff output that describes the difference between
        PATH1 at REVISION1 and PATH2 at REVISION2.

        Keyword arguments:
        path1 -- path to compare in diff (defaults to working copy root)
        revnum1 -- revision to look at path1 at (defaults to base revision)
        path2 -- second path to compare in diff (defaults to path1)
        revnum2 -- revision to look at path2 at (defaults to working revision)
        diff_options -- list of options to be passed to the diff process
            (defaults to an empty list)
        recurse -- if True, contents of directories will also be diffed
            (default True)
        ignore_ancestry -- if True then items will not be checked for
            relatedness before being diffed (default True)
        no_diff_deleted -- if True then deleted items will not be included in
            the diff (default False)
        ignore_content_type -- if True diffs will be generated for binary file
            types (default False)
        header_encoding -- generated headers will be encoded using this
            encoding (defaults to "")
        outfile -- file to save output to, which can be a file like object
            (defaults to sys.stdout)
        errfile -- file to save output to, which can be a file like object
            (defaults to sys.stderr)"""

        diff_options = self._build_path_list(diff_options)

        rev1 = svn_opt_revision_t()
        if revnum1:
            rev1.kind = svn_opt_revision_number
            rev1.value.number = revnum1
        else:
            rev1.kind = svn_opt_revision_base

        rev2 = svn_opt_revision_t()
        if revnum2:
            rev2.kind = svn_opt_revision_number
            rev2.value.number = revnum2
        else:
            rev2.kind = svn_opt_revision_working

        path1 = self._build_path(path1)
        if path2:
            path2 = self._build_path(path2)
        else:
            path2 = path1

        # Create temporary objects for output and errors
        apr_outfile = _types.APRFile(outfile)
        apr_errfile = _types.APRFile(errfile)

        svn_client_diff3(diff_options, path1, byref(rev1), path2, byref(rev2),
                         recurse, ignore_ancestry, no_diff_deleted,
                         ignore_content_type, header_encoding, apr_outfile,
                         apr_errfile, self.client, self.iterpool)

        # Close the APR wrappers
        apr_outfile.close()
        apr_errfile.close()

        self.iterpool.clear()