⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log.c

📁 linux subdivision ying gai ke yi le ba
💻 C
📖 第 1 页 / 共 2 页
字号:

  SVN_ERR (svn_fs_youngest_rev (&head, fs, pool));

  if (! SVN_IS_VALID_REVNUM (start))
    start = head;

  if (! SVN_IS_VALID_REVNUM (end))
    end = head;

  /* Check that revisions are sane before ever invoking receiver. */
  if (start > head)
    return svn_error_createf
      (SVN_ERR_FS_NO_SUCH_REVISION, 0,
       _("No such revision %ld"), start);
  if (end > head)
    return svn_error_createf
      (SVN_ERR_FS_NO_SUCH_REVISION, 0,
       _("No such revision %ld"), end);

  /* If paths were specified, then we only really care about revisions
     in which those paths were changed.  So we ask the filesystem for
     all the revisions in which any of the paths was changed.

     SPECIAL CASE: If we were given only path, and that path is empty,
     then the results are the same as if we were passed no paths at
     all.  Why?  Because the answer to the question "In which
     revisions was the root of the filesystem changed?" is always
     "Every single one of them."  And since this section of code is
     only about answering that question, and we already know the
     answer ... well, you get the picture.
  */
  if (paths 
      && (((paths->nelts == 1) 
           && (! svn_path_is_empty (APR_ARRAY_IDX (paths, 0, const char *))))
          || (paths->nelts > 1)))
    {
      /* If there is only one path, we'll just get its sorted changed
         revisions.  Else, we'll be combining all our findings into a
         hash (to remove duplicates) and then generating a sorted
         array from that hash. */
      if (paths->nelts == 1)
        {
          /* Get the changed revisions for this path. */
          const char *this_path = APR_ARRAY_IDX (paths, 0, const char *);
          revs = apr_array_make (pool, 64, sizeof (svn_revnum_t));
          SVN_ERR (svn_repos_history2 (fs, this_path,
                                       history_to_revs_array, revs,
                                       authz_read_func, authz_read_baton,
                                       start, end, 
                                       strict_node_history ? FALSE : TRUE, 
                                       pool));
        }
      else
        {
          int i;
          apr_hash_t *all_revs = apr_hash_make (pool);
          apr_hash_index_t *hi;

          /* And the search is on... */
          for (i = 0; i < paths->nelts; i++)
            {
              const char *this_path = APR_ARRAY_IDX (paths, i, const char *);
              apr_array_header_t *changed_revs = 
                apr_array_make (pool, 64, sizeof (svn_revnum_t));
              int j;

              /* Get the changed revisions for this path, and add them to
                 the hash (this will eliminate duplicates). */
              SVN_ERR (svn_repos_history2 (fs, this_path,
                                           history_to_revs_array, changed_revs,
                                           authz_read_func, authz_read_baton,
                                           start, end, 
                                           strict_node_history ? FALSE : TRUE, 
                                           pool));
              for (j = 0; j < changed_revs->nelts; j++)
                {
                  /* We're re-using the memory allocated for the array
                     here in order to avoid more allocations.  */
                  svn_revnum_t *chrev = 
                    (((svn_revnum_t *)(changed_revs)->elts) + j);
                  apr_hash_set (all_revs, (void *)chrev, sizeof (chrev), 
                                (void *)1);
                }
            }

          /* Now that we have a hash of all the revisions in which any of
             our paths changed, we can convert that back into a sorted
             array. */
          revs = apr_array_make (pool, apr_hash_count (all_revs), 
                                 sizeof (svn_revnum_t));
          for (hi = apr_hash_first (pool, all_revs); 
               hi; 
               hi = apr_hash_next (hi))
            {
              const void *key;
              svn_revnum_t revision;
              
              apr_hash_this (hi, &key, NULL, NULL);
              revision = *((const svn_revnum_t *)key);
              (*((svn_revnum_t *) apr_array_push (revs))) = revision;
            }

          /* Now sort the array */
          qsort ((revs)->elts, (revs)->nelts, (revs)->elt_size, 
                 svn_sort_compare_revisions);
        }

      /* If no revisions were found for these entries, we have nothing
         to show. Just return now before we break a sweat.  */
      if (! (revs && revs->nelts))
        return SVN_NO_ERROR;
    }

  for (this_rev = start;
       ((start >= end) ? (this_rev >= end) : (this_rev <= end));
       ((start >= end) ? this_rev-- : this_rev++))
    {
      svn_string_t *author, *date, *message;
      apr_hash_t *changed_paths = NULL;

      /* If we have a list of revs for use, check to make sure this is
         one of them.  */
      if (revs)
        {
          int i, matched = 0;
          for (i = 0; ((i < revs->nelts) && (! matched)); i++)
            {
              if (this_rev == ((svn_revnum_t *)(revs->elts))[i])
                matched = 1;
            }

          if (! matched)
            continue;
        }

      SVN_ERR (svn_fs_revision_prop
               (&author, fs, this_rev, SVN_PROP_REVISION_AUTHOR, subpool));
      SVN_ERR (svn_fs_revision_prop
               (&date, fs, this_rev, SVN_PROP_REVISION_DATE, subpool));
      SVN_ERR (svn_fs_revision_prop
               (&message, fs, this_rev, SVN_PROP_REVISION_LOG, subpool));

      /* ### Below, we discover changed paths if the user requested
         them (i.e., "svn log -v" means `discover_changed_paths' will
         be non-zero here).  */


      if ((this_rev > 0)        
          && (authz_read_func || discover_changed_paths))
        {
          svn_fs_root_t *newroot;
          svn_error_t *patherr;

          SVN_ERR (svn_fs_revision_root (&newroot, fs, this_rev, subpool));
          patherr = detect_changed (&changed_paths,
                                    newroot, fs,
                                    authz_read_func, authz_read_baton,
                                    subpool);

          if (patherr
              && patherr->apr_err == SVN_ERR_AUTHZ_UNREADABLE)
            {
              /* All changed-paths are unreadable, so clear all fields. */
              svn_error_clear (patherr);              
              changed_paths = NULL;
              author = NULL;
              date = NULL;
              message = NULL;
            }
          else if (patherr
                   && patherr->apr_err == SVN_ERR_AUTHZ_PARTIALLY_READABLE)
            {
              /* At least one changed-path was unreadable, so omit the
                 log message.  (The unreadable paths are already
                 missing from the hash.) */
              svn_error_clear (patherr);
              message = NULL;
            }
          else if (patherr)
            return patherr;

          /* It may be the case that an authz func was passed in, but
             the user still doesn't want to see any changed-paths. */
          if (! discover_changed_paths)
            changed_paths = NULL;
        }

      SVN_ERR ((*receiver) (receiver_baton,
                            changed_paths,
                            this_rev,
                            author ? author->data : NULL,
                            date ? date->data : NULL,
                            message ? message->data : NULL,
                            subpool));
      
      svn_pool_clear (subpool);
    }

  svn_pool_destroy (subpool);

  return SVN_NO_ERROR;
}


/* The 1.0 version of the function.  ### Remove in 2.0. */
svn_error_t *
svn_repos_get_logs (svn_repos_t *repos,
                    const apr_array_header_t *paths,
                    svn_revnum_t start,
                    svn_revnum_t end,
                    svn_boolean_t discover_changed_paths,
                    svn_boolean_t strict_node_history,
                    svn_log_message_receiver_t receiver,
                    void *receiver_baton,
                    apr_pool_t *pool)
{
  return svn_repos_get_logs2 (repos, paths, start, end,
                              discover_changed_paths, strict_node_history,
                              NULL, NULL, /* no authz stuff */
                              receiver, receiver_baton, pool);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -