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

📄 diff-diff3-test.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
                          "Cc\n"                          "Dd\n"                          "Ee\n"                          "Ff\n"                          "Gg\n"                          "Hh\n",                          "Aa\n"                          "Ff\n"                          "Gg\n"                          "Hh\n"                          "Bb\n"                          "Cc\n"                          "Xx\n"                          "Dd\n"                          "Ee\n"                          "Yy\n"                          "Ff\n"                          "Gg\n"                          "Hh\n",                          "Aa\n"                          "Bb\n"                          "Cc\n"                          "Xx\n"                          "Dd\n"                          "Ee\n"                          "Ff\n"                          "Gg\n"                          "Zz\n"                          "Hh\n",                          "Aa\n"                          "Ff\n"                          "Gg\n"                          "Hh\n"                          "Bb\n"                          "Cc\n"                          "Xx\n"                          "Dd\n"                          "Ee\n"                          "Yy\n"                          "Ff\n"                          "Gg\n"                          "Zz\n"                          "Hh\n",                          NULL, pool));  return SVN_NO_ERROR;}static svn_error_t *test_three_way_merge_with_conflict(const char **msg,                                   svn_boolean_t msg_only,                                   svn_test_opts_t *opts,                                   apr_pool_t *pool){  *msg = "3-way merge, conflicting overlapping changes";  if (msg_only)    return SVN_NO_ERROR;  SVN_ERR(three_way_merge("dig1", "dug1", "dag1",                          "Aa\n"                          "Bb\n"                          "Cc\n",                          "",                          "",                          "",                          NULL, pool));  SVN_ERR(three_way_merge("dig2", "dug2", "dag2",                          "Aa\n"                          "Bb\n"                          "Cc\n",                          "Aa\n"                          "Bb\n"                          "Cc\n"                          "Dd\n"                          "Ee\n"                          "Ff\n",                          "",                          "<<<<<<< dug2\n"                          "Aa\n"                          "Bb\n"                          "Cc\n"                          "Dd\n"                          "Ee\n"                          "Ff\n"                          "=======\n"                          ">>>>>>> dag2\n",                          NULL, pool));  SVN_ERR(three_way_merge("dig2a", "dug2a", "dag2a",                          "Aa\r\n"                          "Bb\r\n"                          "Cc\r\n",                          "Aa\r\n"                          "Bb\r\n"                          "Cc\r\n"                          "Dd\r\n"                          "Ee\r\n"                          "Ff\r\n",                          "",                          "<<<<<<< dug2a\r\n"                          "Aa\r\n"                          "Bb\r\n"                          "Cc\r\n"                          "Dd\r\n"                          "Ee\r\n"                          "Ff\r\n"                          "=======\r\n"                          ">>>>>>> dag2a\r\n",                          NULL, pool));  SVN_ERR(three_way_merge("dig2b", "dug2b", "dag2b",                          "Aa\n"                          "Bb\n"                          "Cc\n",                          "Aa\r"                          "Bb\r"                          "Cc\r"                          "Dd\r"                          "Ee\r"                          "Ff\r",                          "",                          "<<<<<<< dug2b\r"                          "Aa\r"                          "Bb\r"                          "Cc\r"                          "Dd\r"                          "Ee\r"                          "Ff\r"                          "=======\r"                          ">>>>>>> dag2b\r",                          NULL, pool));  SVN_ERR(three_way_merge("dig3", "dug3", "dag3",                          "Aa\n"                          "Bb\n"                          "Cc\n",                          "Aa\n"                          "Bb\n"                          "Cc\n"                          "Dd\n"                          "Ee\n"                          "Ff\n",                          "Aa\n"                          "Bb\n",                          "Aa\n"                          "Bb\n"                          "<<<<<<< dug3\n"                          "Cc\n"                          "Dd\n"                          "Ee\n"                          "Ff\n"                          "=======\n"                          ">>>>>>> dag3\n",                          NULL, pool));  SVN_ERR(three_way_merge("dig4", "dug4", "dag4",                          "Aa\n"                          "Bb\n"                          "Cc\n",                          "Aa\n"                          "Bb\n"                          "Cc\n"                          "Dd",                          "Aa\n"                          "Bb\n"                          "Cc\n"                          "Ee",                          "Aa\n"                          "Bb\n"                          "Cc\n"                          "<<<<<<< dug4\n"                          "Dd=======\n"                          "Ee>>>>>>> dag4\n",                          NULL, pool));  return SVN_NO_ERROR;}static svn_error_t *random_trivial_merge(const char **msg,                     svn_boolean_t msg_only,                     svn_test_opts_t *opts,                     apr_pool_t *pool){  int i;  apr_pool_t *subpool = svn_pool_create(pool);  *msg = apr_psprintf(pool, "random trivial merge (seed:%u)", seed_val());  if (msg_only)    return SVN_NO_ERROR;  for (i = 0; i < 5; ++i)    {      const char *filename1 = "trivial1";      const char *filename2 = "trivial2";      int min_lines = 1000;      int max_lines = 1100;      int var_lines = 50;      int block_lines = 10;      svn_stringbuf_t *contents1, *contents2;      SVN_ERR(make_random_file(filename1,                               min_lines, max_lines, var_lines, block_lines,                               i % 3, subpool));      SVN_ERR(make_random_file(filename2,                               min_lines, max_lines, var_lines, block_lines,                               i % 2, subpool));      SVN_ERR(svn_stringbuf_from_file(&contents1, filename1, subpool));      SVN_ERR(svn_stringbuf_from_file(&contents2, filename2, subpool));      SVN_ERR(three_way_merge(filename1, filename2, filename1,                              contents1->data, contents2->data,                              contents1->data, contents2->data, NULL,                              subpool));      SVN_ERR(three_way_merge(filename2, filename1, filename2,                              contents2->data, contents1->data,                              contents2->data, contents1->data, NULL,                              subpool));      svn_pool_clear(subpool);    }  svn_pool_destroy(subpool);  return SVN_NO_ERROR;}/* The "original" file has a number of distinct lines.  We generate two   random modifications by selecting two subsets of the original lines and   for each selected line either adding an additional line, replacing the   line, or deleting the line.  The two subsets are chosen so that each   selected line is distinct and no two selected lines are adjacent. This   means the two sets of changes should merge without conflict.  */static svn_error_t *random_three_way_merge(const char **msg,                       svn_boolean_t msg_only,                       svn_test_opts_t *opts,                       apr_pool_t *pool){  int i;  apr_pool_t *subpool = svn_pool_create(pool);  *msg = apr_psprintf(pool, "random 3-way merge (seed:%u)", seed_val());  if (msg_only)    return SVN_NO_ERROR;  for (i = 0; i < 20; ++i)    {      const char *filename1 = "original";      const char *filename2 = "modified1";      const char *filename3 = "modified2";      const char *filename4 = "combined";      svn_stringbuf_t *original, *modified1, *modified2, *combined;      int num_lines = 100, num_src = 10, num_dst = 10;      svn_boolean_t *lines = apr_pcalloc(subpool, sizeof(*lines) * num_lines);      struct random_mod *src_lines = apr_palloc(subpool,                                                sizeof(*src_lines) * num_src);      struct random_mod *dst_lines = apr_palloc(subpool,                                                sizeof(*dst_lines) * num_dst);      struct random_mod *mrg_lines = apr_palloc(subpool,                                                (sizeof(*mrg_lines)                                                 * (num_src + num_dst)));            select_lines(src_lines, num_src, lines, num_lines);      select_lines(dst_lines, num_dst, lines, num_lines);      memcpy(mrg_lines, src_lines, sizeof(*mrg_lines) * num_src);      memcpy(mrg_lines + num_src, dst_lines, sizeof(*mrg_lines) * num_dst);      SVN_ERR(make_random_merge_file(filename1, num_lines, NULL, 0, pool));      SVN_ERR(make_random_merge_file(filename2, num_lines, src_lines, num_src,                                     pool));      SVN_ERR(make_random_merge_file(filename3, num_lines, dst_lines, num_dst,                                     pool));      SVN_ERR(make_random_merge_file(filename4, num_lines, mrg_lines,                                     num_src + num_dst, pool));      SVN_ERR(svn_stringbuf_from_file(&original, filename1, pool));      SVN_ERR(svn_stringbuf_from_file(&modified1, filename2, pool));      SVN_ERR(svn_stringbuf_from_file(&modified2, filename3, pool));      SVN_ERR(svn_stringbuf_from_file(&combined, filename4, pool));      SVN_ERR(three_way_merge(filename1, filename2, filename3,                              original->data, modified1->data,                              modified2->data, combined->data, NULL, subpool));      SVN_ERR(three_way_merge(filename1, filename3, filename2,                              original->data, modified2->data,                              modified1->data, combined->data, NULL, subpool));      SVN_ERR(svn_io_remove_file(filename4, pool));      svn_pool_clear(subpool);    }  svn_pool_destroy(subpool);  return SVN_NO_ERROR;}/* This is similar to random_three_way_merge above, except this time half   of the original-to-modified1 changes are already present in modified2   (or, equivalently, half the original-to-modified2 changes are already   present in modified1).  Since the overlapping changes match exactly the   merge should work without a conflict. */static svn_error_t *merge_with_part_already_present(const char **msg,                                svn_boolean_t msg_only,                                svn_test_opts_t *opts,                                apr_pool_t *pool){  int i;  apr_pool_t *subpool = svn_pool_create(pool);  *msg = apr_psprintf(pool, "merge with part already present (seed:%u)",                      seed_val());  if (msg_only)    return SVN_NO_ERROR;  for (i = 0; i < 20; ++i)    {      const char *filename1 = "pap-original";      const char *filename2 = "pap-modified1";      const char *filename3 = "pap-modified2";      const char *filename4 = "pap-combined";      svn_stringbuf_t *original, *modified1, *modified2, *combined;      int num_lines = 200, num_src = 20, num_dst = 20;      svn_boolean_t *lines = apr_pcalloc(subpool, sizeof(*lines) * num_lines);      struct random_mod *src_lines = apr_palloc(subpool,                                                sizeof(*src_lines) * num_src);      struct random_mod *dst_lines = apr_palloc(subpool,                                                sizeof(*dst_lines) * num_dst);      struct random_mod *mrg_lines = apr_palloc(subpool,                                                (sizeof(*mrg_lines)                                                 * (num_src + num_dst / 2)));            select_lines(src_lines, num_src, lines, num_lines);      /* Select half the destination changes at random */      select_lines(dst_lines, num_dst / 2, lines, num_lines);      /* Copy the other half from the source changes */      memcpy(dst_lines + num_dst / 2, src_lines,             sizeof(*dst_lines) * (num_dst - num_dst / 2));      memcpy(mrg_lines, src_lines, sizeof(*mrg_lines) * num_src);      memcpy(mrg_lines + num_src, dst_lines,             sizeof(*mrg_lines) * num_dst / 2);      SVN_ERR(make_random_merge_file(filename1, num_lines, NULL, 0, pool));      SVN_ERR(make_random_merge_file(filename2, num_lines, src_lines, num_src,                                     pool));      SVN_ERR(make_random_merge_file(filename3, num_lines, dst_lines, num_dst,                                     pool));      SVN_ERR(make_random_merge_file(filename4, num_lines, mrg_lines,                                     num_src + num_dst / 2, pool));      SVN_ERR(svn_stringbuf_from_file(&original, filename1, pool));      SVN_ERR(svn_stringbuf_from_file(&modified1, filename2, pool));      SVN_ERR(svn_stringbuf_from_file(&modified2, filename3, pool));      SVN_ERR(svn_stringbuf_from_file(&combined, filename4, pool));      SVN_ERR(three_way_merge(filename1, filename2, filename3,                              original->data, modified1->data,                              modified2->data, combined->data, NULL, subpool));      SVN_ERR(three_way_merge(filename1, filename3, filename2,                              original->data, modified2->data,                              modified1->data, combined->data, NULL, subpool));      SVN_ERR(svn_io_remove_file(filename4, pool));      svn_pool_clear(subpool);    }  svn_pool_destroy(subpool);  return SVN_NO_ERROR;}/* Merge is more "aggressive" about resolving conflicts than traditional * patch or diff3.  Some people consider this behaviour to be a bug, see * http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=35014 */static svn_error_t *merge_adjacent_changes(const char **msg,                       svn_boolean_t msg_only,                       svn_test_opts_t *opts,                       apr_pool_t *pool){  *msg = "3-way merge, adjacent changes";  if (msg_only)    return SVN_NO_ERROR;  SVN_ERR(three_way_merge("adj1", "adj2", "adj3",                          "foo\n"                          "bar\n"                          "baz\n",                          "foo\n"                          "new_bar\n"                          "baz\n",                          "zig\n"                          "foo\n"                          "bar\n"                          "new_baz\n",                            "zig\n"                          "foo\n"                          "new_bar\n"                          "new_baz\n",                          NULL, pool));  return SVN_NO_ERROR;}/* ========================================================================== */struct svn_test_descriptor_t test_funcs[] =  {    SVN_TEST_NULL,    SVN_TEST_PASS(dump_core),    SVN_TEST_PASS(test_two_way_unified),    SVN_TEST_PASS(test_two_way_unified_suspect),    SVN_TEST_PASS(test_three_way_merge_no_overlap),    SVN_TEST_PASS(test_three_way_merge_with_overlap),    SVN_TEST_PASS(test_three_way_merge_with_conflict),    SVN_TEST_PASS(random_trivial_merge),    SVN_TEST_PASS(random_three_way_merge),    SVN_TEST_PASS(merge_with_part_already_present),    SVN_TEST_PASS(merge_adjacent_changes),    SVN_TEST_NULL  };

⌨️ 快捷键说明

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