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

📄 diff.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
     from do_diff(), at least not without some more logic here.     What a nightmare.          For now, to distinguish the two paths, we'll just put the     unique portions of the original targets in parentheses after     the received path, with ellipses for handwaving.  This makes     the labels a bit clumsy, but at least distinctive.  Better     solutions are possible, they'll just take more thought. */  path1 = diff_cmd_baton->orig_path_1;  path2 = diff_cmd_baton->orig_path_2;    for (i = 0; path1[i] && path2[i] && (path1[i] == path2[i]); i++)    ;    /* Make sure the prefix is made of whole components. (Issue #1771) */  if (path1[i] || path2[i])    {      for ( ; (i > 0) && (path1[i] != '/'); i--)        ;    }    path1 = path1 + i;  path2 = path2 + i;    /* ### Should diff labels print paths in local style?  Is there     already a standard for this?  In any case, this code depends on     a particular style, so not calling svn_path_local_style() on the     paths below.*/  if (path1[0] == '\0')    path1 = apr_psprintf(subpool, "%s", path);  else if (path1[0] == '/')    path1 = apr_psprintf(subpool, "%s\t(...%s)", path, path1);  else    path1 = apr_psprintf(subpool, "%s\t(.../%s)", path, path1);    if (path2[0] == '\0')    path2 = apr_psprintf(subpool, "%s", path);  else if (path2[0] == '/')    path2 = apr_psprintf(subpool, "%s\t(...%s)", path, path2);  else    path2 = apr_psprintf(subpool, "%s\t(.../%s)", path, path2);    label1 = diff_label(path1, rev1, subpool);  label2 = diff_label(path2, rev2, subpool);  /* Possible easy-out: if either mime-type is binary and force was not     specified, don't attempt to generate a viewable diff at all.     Print a warning and exit. */  if (mimetype1)    mt1_binary = svn_mime_type_is_binary(mimetype1);  if (mimetype2)    mt2_binary = svn_mime_type_is_binary(mimetype2);  if (! diff_cmd_baton->force_binary && (mt1_binary || mt2_binary))    {      /* Print out the diff header. */      SVN_ERR(svn_stream_printf_from_utf8              (os, diff_cmd_baton->header_encoding, subpool,               "Index: %s" APR_EOL_STR "%s" APR_EOL_STR, path, equal_string));      SVN_ERR(svn_stream_printf_from_utf8              (os, diff_cmd_baton->header_encoding, subpool,               _("Cannot display: file marked as a binary type.%s"),               APR_EOL_STR));            if (mt1_binary && !mt2_binary)        SVN_ERR(svn_stream_printf_from_utf8                (os, diff_cmd_baton->header_encoding, subpool,                 "svn:mime-type = %s" APR_EOL_STR, mimetype1));      else if (mt2_binary && !mt1_binary)        SVN_ERR(svn_stream_printf_from_utf8                (os, diff_cmd_baton->header_encoding, subpool,                 "svn:mime-type = %s" APR_EOL_STR, mimetype2));      else if (mt1_binary && mt2_binary)        {          if (strcmp(mimetype1, mimetype2) == 0)            SVN_ERR(svn_stream_printf_from_utf8                    (os, diff_cmd_baton->header_encoding, subpool,                     "svn:mime-type = %s" APR_EOL_STR,                     mimetype1));          else            SVN_ERR(svn_stream_printf_from_utf8                    (os, diff_cmd_baton->header_encoding, subpool,                     "svn:mime-type = (%s, %s)" APR_EOL_STR,                     mimetype1, mimetype2));        }      /* Exit early. */      svn_pool_destroy(subpool);      return SVN_NO_ERROR;    }  /* Find out if we need to run an external diff */  if (diff_cmd_baton->config)    {      svn_config_t *cfg = apr_hash_get(diff_cmd_baton->config,                                       SVN_CONFIG_CATEGORY_CONFIG,                                       APR_HASH_KEY_STRING);      svn_config_get(cfg, &diff_cmd, SVN_CONFIG_SECTION_HELPERS,                     SVN_CONFIG_OPTION_DIFF_CMD, NULL);    }  if (diff_cmd)    {      /* Print out the diff header. */      SVN_ERR(svn_stream_printf_from_utf8              (os, diff_cmd_baton->header_encoding, subpool,               "Index: %s" APR_EOL_STR "%s" APR_EOL_STR, path, equal_string));      /* Close the stream (flush) */      SVN_ERR(svn_stream_close(os));      SVN_ERR(svn_io_run_diff(".", args, nargs, label1, label2,                              tmpfile1, tmpfile2,                               &exitcode, diff_cmd_baton->outfile, errfile,                              diff_cmd, subpool));    }  else   /* use libsvn_diff to generate the diff  */    {      svn_diff_t *diff;      svn_diff_file_options_t *opts = svn_diff_file_options_create(subpool);      if (diff_cmd_baton->options)        SVN_ERR(svn_diff_file_options_parse(opts, diff_cmd_baton->options,                                            subpool));      SVN_ERR(svn_diff_file_diff_2(&diff, tmpfile1, tmpfile2, opts,                                   subpool));      if (svn_diff_contains_diffs(diff) || diff_cmd_baton->force_empty)        {          /* Print out the diff header. */          SVN_ERR(svn_stream_printf_from_utf8                  (os, diff_cmd_baton->header_encoding, subpool,                   "Index: %s" APR_EOL_STR "%s" APR_EOL_STR,                   path, equal_string));          /* Output the actual diff */          SVN_ERR(svn_diff_file_output_unified2                  (os, diff, tmpfile1, tmpfile2, label1, label2,                   diff_cmd_baton->header_encoding, subpool));        }    }  /* ### todo: someday we'll need to worry about whether we're going     to need to write a diff plug-in mechanism that makes use of the     two paths, instead of just blindly running SVN_CLIENT_DIFF.  */  /* Destroy the subpool. */  svn_pool_destroy(subpool);  return SVN_NO_ERROR;}/* A svn_wc_diff_callbacks2_t function. */static svn_error_t *diff_file_changed(svn_wc_adm_access_t *adm_access,                  svn_wc_notify_state_t *content_state,                  svn_wc_notify_state_t *prop_state,                  const char *path,                  const char *tmpfile1,                  const char *tmpfile2,                  svn_revnum_t rev1,                  svn_revnum_t rev2,                  const char *mimetype1,                  const char *mimetype2,                  const apr_array_header_t *prop_changes,                  apr_hash_t *original_props,                  void *diff_baton){  if (tmpfile1)    SVN_ERR(diff_content_changed(path,                                 tmpfile1, tmpfile2, rev1, rev2,                                 mimetype1, mimetype2, diff_baton));  if (prop_changes->nelts > 0)    SVN_ERR(diff_props_changed(adm_access, prop_state, path, prop_changes,                               original_props, diff_baton));  if (content_state)    *content_state = svn_wc_notify_state_unknown;  if (prop_state)    *prop_state = svn_wc_notify_state_unknown;  return SVN_NO_ERROR;}/* Because the repos-diff editor passes at least one empty file to   each of these next two functions, they can be dumb wrappers around   the main workhorse routine. *//* A svn_wc_diff_callbacks2_t function. */static svn_error_t *diff_file_added(svn_wc_adm_access_t *adm_access,                svn_wc_notify_state_t *content_state,                svn_wc_notify_state_t *prop_state,                const char *path,                const char *tmpfile1,                const char *tmpfile2,                svn_revnum_t rev1,                svn_revnum_t rev2,                const char *mimetype1,                const char *mimetype2,                const apr_array_header_t *prop_changes,                apr_hash_t *original_props,                void *diff_baton){  struct diff_cmd_baton *diff_cmd_baton = diff_baton;  /* We want diff_file_changed to unconditionally show diffs, even if     the diff is empty (as would be the case if an empty file were     added.)  It's important, because 'patch' would still see an empty     diff and create an empty file.  It's also important to let the     user see that *something* happened. */  diff_cmd_baton->force_empty = TRUE;  SVN_ERR(diff_file_changed(adm_access, content_state, prop_state, path,                            tmpfile1, tmpfile2,                             rev1, rev2,                            mimetype1, mimetype2,                            prop_changes, original_props, diff_baton));    diff_cmd_baton->force_empty = FALSE;  return SVN_NO_ERROR;}/* A svn_wc_diff_callbacks2_t function. */static svn_error_t *diff_file_deleted_with_diff(svn_wc_adm_access_t *adm_access,                            svn_wc_notify_state_t *state,                            const char *path,                            const char *tmpfile1,                            const char *tmpfile2,                            const char *mimetype1,                            const char *mimetype2,                            apr_hash_t *original_props,                            void *diff_baton){  struct diff_cmd_baton *diff_cmd_baton = diff_baton;  /* We don't list all the deleted properties. */  return diff_file_changed(adm_access, state, NULL, path,                           tmpfile1, tmpfile2,                            diff_cmd_baton->revnum1, diff_cmd_baton->revnum2,                           mimetype1, mimetype2,                           apr_array_make(diff_cmd_baton->pool, 1,                                          sizeof(svn_prop_t)),                           apr_hash_make(diff_cmd_baton->pool), diff_baton);}/* A svn_wc_diff_callbacks2_t function. */static svn_error_t *diff_file_deleted_no_diff(svn_wc_adm_access_t *adm_access,                          svn_wc_notify_state_t *state,                          const char *path,                          const char *tmpfile1,                          const char *tmpfile2,                          const char *mimetype1,                          const char *mimetype2,                          apr_hash_t *original_props,                          void *diff_baton){  struct diff_cmd_baton *diff_cmd_baton = diff_baton;  if (state)    *state = svn_wc_notify_state_unknown;  SVN_ERR(file_printf_from_utf8          (diff_cmd_baton->outfile,           diff_cmd_baton->header_encoding,           "Index: %s (deleted)" APR_EOL_STR "%s" APR_EOL_STR,            path, equal_string));  return SVN_NO_ERROR;}/* A svn_wc_diff_callbacks2_t function.   For now, let's have 'svn diff' send feedback to the top-level   application, so that something reasonable about directories and   propsets gets printed to stdout. */static svn_error_t *diff_dir_added(svn_wc_adm_access_t *adm_access,               svn_wc_notify_state_t *state,               const char *path,               svn_revnum_t rev,               void *diff_baton){  if (state)    *state = svn_wc_notify_state_unknown;  /* ### todo:  send feedback to app */  return SVN_NO_ERROR;}/* A svn_wc_diff_callbacks2_t function. */static svn_error_t *diff_dir_deleted(svn_wc_adm_access_t *adm_access,                 svn_wc_notify_state_t *state,                 const char *path,                 void *diff_baton){  if (state)    *state = svn_wc_notify_state_unknown;  return SVN_NO_ERROR;}  /*-----------------------------------------------------------------*//*** Callbacks for 'svn merge', invoked by the repos-diff editor. ***/struct merge_cmd_baton {  svn_boolean_t force;  svn_boolean_t dry_run;  const char *added_path;             /* Set to the dir path whenever the                                         dir is added as a child of a                                         versioned dir (dry-run only) */  const char *target;                 /* Working copy target of merge */  const char *url;                    /* The second URL in the merge */  const char *path;                   /* The wc path of the second target, this                                         can be NULL if we don't have one. */  const svn_opt_revision_t *revision; /* Revision of second URL in the merge */  svn_client_ctx_t *ctx;  /* Whether invocation of the merge_file_added() callback required     delegation to the merge_file_changed() function for the file     currently being merged.  This info is used to detect whether a     file on the left side of a 3-way merge actually exists (important     because it's created as an empty temp file on disk regardless).*/  svn_boolean_t add_necessitated_merge;  /* The list of paths for entries we've deleted, used only when in     dry_run mode. */  apr_hash_t *dry_run_deletions;  /* The diff3_cmd in ctx->config, if any, else null.  We could just     extract this as needed, but since more than one caller uses it,     we just set it up when this baton is created. */  const char *diff3_cmd;  const apr_array_header_t *merge_options;  apr_pool_t *pool;};apr_hash_t *svn_client__dry_run_deletions(void *merge_cmd_baton){  struct merge_cmd_baton *merge_b = merge_cmd_baton;  return merge_b->dry_run_deletions;}/* Used to avoid spurious notifications (e.g. conflicts) from a merge   attempt into an existing target which would have been deleted if we   weren't in dry_run mode (issue #2584).  Assumes that WCPATH is   still versioned (e.g. has an associated entry). */static APR_INLINE svn_boolean_tdry_run_deleted_p(struct merge_cmd_baton *merge_b, const char *wcpath){    return (merge_b->dry_run &&            apr_hash_get(merge_b->dry_run_deletions, wcpath,                         APR_HASH_KEY_STRING) != NULL);}/* A svn_wc_diff_callbacks2_t function.  Used for both file and directory   property merges. */static svn_error_t *merge_props_changed(svn_wc_adm_access_t *adm_access,

⌨️ 快捷键说明

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