Exemple #1
0
    def update(self,
               paths=[""],
               revnum=None,
               recurse=True,
               ignore_externals=True):
        """Update paths to a given revision number.

        Returns an array of revision numbers to which the revision number was
        resolved.

        Keyword arguments:
        paths -- list of path to be updated (defaults to WC root)
        revnum -- revision number to update to (defaults to head revision)
        recurse -- if True, the contents of directories will also be updated
                   (default True)
        ignore_externals -- if True, externals will not be updated (default
                            True)"""

        rev = svn_opt_revision_t()
        if revnum is not None:
            rev.kind = svn_opt_revision_number
            rev.value.number = revnum
        else:
            rev.kind = svn_opt_revision_head

        result_revs = _types.Array(svn_revnum_t, svn_revnum_t())

        svn_client_update2(byref(result_revs.header),
                           self._build_path_list(paths), byref(rev), recurse,
                           ignore_externals, self.client, self.iterpool)

        self.iterpool.clear()
        return result_revs
Exemple #2
0
    def _log_func_wrapper(self, log_msg, tmp_file, commit_items, baton, pool):
        log_msg[0].raw = NULL
        tmp_file[0] = NULL

        if self._log_func:
            [log, file] = self._log_func(_types.Array(String, commit_items))

            if log:
                log_msg[0].raw = apr_pstrdup(pool, String(log)).raw
            if file:
                tmp_file[0] = apr_pstrdup(pool, String(file)).raw
Exemple #3
0
    def _log_func_wrapper(self, log_msg, tmp_file, commit_items, baton, pool):
        """Internal wrapper for log function callback."""
        if self._log_func:
            [log, file] = self._log_func(_types.Array(String, commit_items))

            if log:
                log_msg = pointer(c_char_p(log))
            else:
                log_msg = NULL

            if file:
                tmp_file = pointer(c_char_p(file))
            else:
                tmp_file = NULL
Exemple #4
0
    def merge(self,
              source1,
              revnum1,
              source2,
              revnum2,
              target_wcpath,
              recurse=True,
              ignore_ancestry=False,
              force=False,
              dry_run=False,
              merge_options=[]):
        """Merge changes.

        This method merges the changes from source1@revnum1 to
        source2@revnum2 into target_wcpath.

        Keyword arguments:
        source1 -- path for beginning revision of changes to be merged
        revnum1 -- starting revnum
        source2 -- path for ending revision of changes to merge
        revnum2 -- ending revnum
        target_wcpath -- path to apply changes to
        recurse -- if True, apply changes recursively
        ignore_ancestry -- if True, relatedness will not be checked (False by
            default)
        force -- if False and the merge involves deleting locally modified
            files the merge will fail (default False)
        dry_run -- if True, notification will be provided but no local files
            will be modified (default False)
        merge_options -- a list of options to be passed to the diff process
            (default no options)"""
        revision1 = svn_opt_revision_t()
        revision1.kind = svn_opt_revision_number
        revision1.value.number = revnum1

        revision2 = svn_opt_revision_t()
        revision2.kind = svn_opt_revision_number
        revision2.value.number = revnum2

        merge_options = _types.Array(c_char_p, merge_options)

        svn_client_merge2(source1, byref(revision1), source2, byref(revision2),
                          target_wcpath, recurse, ignore_ancestry, force,
                          dry_run, merge_options.header, self.client,
                          self.iterpool)

        self.iterpool.clear()
Exemple #5
0
    def log(self,
            start_rev,
            end_rev,
            paths=None,
            limit=0,
            discover_changed_paths=FALSE,
            stop_on_copy=FALSE):
        """A generator function which returns information about the revisions
           between START_REV and END_REV. Each return value is a
           csvn.types.LogEntry object which describes a revision.

           For details on what fields are contained in a LogEntry object,
           please see the documentation from csvn.types.LogEntry.

           You can iterate through the log information for several revisions
           using a regular for loop. For example:
             for entry in session.log(start_rev, end_rev):
               print("Revision %d" % entry.revision)
               ...

           ARGUMENTS:

             If PATHS is not None and has one or more elements, then only
             show revisions in which at least one of PATHS was changed (i.e.,
             if file, text or props changed; if dir, props changed or an entry
             was added or deleted). Each PATH should be relative to the current
             session's root.

             If LIMIT is non-zero, only the first LIMIT logs are returned.

             If DISCOVER_CHANGED_PATHS is True, then changed_paths will contain
             a list of paths affected by this revision.

             If STOP_ON_COPY is True, then this function will not cross
             copies while traversing history.

             If START_REV or END_REV is a non-existent revision, we throw
             a SVN_ERR_FS_NO_SUCH_REVISION SubversionException, without
             returning any logs.

        """

        paths = _types.Array(c_char_p, paths is None and [""] or paths)
        return iter(
            _LogMessageReceiver(self, start_rev, end_rev, paths, limit,
                                discover_changed_paths, stop_on_copy))
Exemple #6
0
    def _build_path_list(self, paths):
        """Build a list of canonicalized WC paths.

        In general, the user does not need to call this method, paths will be
        canonicalized as needed for you.

        Returns an array of canonicalized paths.

        Keyword arguments:
        paths -- list of paths to be canonicalized"""

        # If the user passed in a string, the user made a mistake.
        # The user should be passing in a list of paths.
        assert not isinstance(paths, str)

        canonicalized_paths = [self._build_path(path) for path in paths]
        return _types.Array(String, canonicalized_paths)
Exemple #7
0
    def proplist(self, target="", recurse=True):
        """List the values of the normal properties of target.

        Returns an array of svn_client_proplist_item_t objects.

        Keyword arguments:
        target -- path to list properties for (defaults to WC root)
        recurse -- if True, the operation will recurse (default True)"""
        peg_revision = svn_opt_revision_t()
        peg_revision.kind = svn_opt_revision_unspecified

        revision = svn_opt_revision_t()
        revision.kind = svn_opt_revision_working

        props = _types.Array(svn_client_proplist_item_t)

        svn_client_proplist2(byref(props.header), self._build_path(target),
                             byref(peg_revision), byref(revision), recurse,
                             self.client, props.pool)

        self.iterpool.clear()

        return props
Exemple #8
0
 def test_array(self):
     self.pyarray = ["vini", "vidi", "vici"]
     self.svnarray = _types.Array(c_char_p, self.pyarray)
     self.assertEqual(self.svnarray[0], "vini")
     self.assertEqual(self.svnarray[2], "vici")
     self.assertEqual(self.svnarray[1], "vidi")