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

📄 commit.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
            }        }      else        {          /* This will recursively lock the base_dir further down */          lock_base_dir_recursive = TRUE;        }    }  else    {      apr_pool_t *subpool = svn_pool_create(pool);      SVN_ERR(adjust_rel_targets(&base_dir, &rel_targets,                                 base_dir, rel_targets,                                 pool));      for (i = 0; i < rel_targets->nelts; i++)        {          const char *parent_dir, *name;          svn_node_kind_t kind;          svn_pool_clear(subpool);          target = svn_path_join(base_dir,                                 APR_ARRAY_IDX(rel_targets, i, const char *),                                 subpool);          SVN_ERR(svn_io_check_path(target, &kind, subpool));          /* If the final target is a dir, we want to lock it */          if (kind == svn_node_dir)            {              if (recurse)                APR_ARRAY_PUSH(dirs_to_lock_recursive,                                const char *) = apr_pstrdup(pool, target);              else                /* Don't lock if target is the base_dir, base_dir will be                    locked anyway and we can't lock it twice */                if (strcmp(target, base_dir) != 0)                  APR_ARRAY_PUSH(dirs_to_lock,                                  const char *) = apr_pstrdup(pool, target);            }          /* Now we need to iterate over the parent paths of this path             adding them to the set of directories we want to lock.              Do nothing if target is already the base_dir. */          if (strcmp(target, base_dir) != 0)             {              svn_path_split(target, &parent_dir, &name, subpool);              target = parent_dir;              while (strcmp(target, base_dir) != 0)                {                  if ((target[0] == '/' && target[1] == '\0') ||                     (target[0] == '\0'))                    abort();                  APR_ARRAY_PUSH(dirs_to_lock,                                 const char *) = apr_pstrdup(pool, target);                  target = svn_path_dirname(target, subpool);                }            }        }      svn_pool_destroy(subpool);    }  SVN_ERR(svn_wc_adm_open3(&base_dir_access, NULL, base_dir,                           TRUE,  /* Write lock */                           lock_base_dir_recursive ? -1 : 0, /* Depth */                           ctx->cancel_func, ctx->cancel_baton,                           pool));  if (!lock_base_dir_recursive)    {      svn_wc_adm_access_t *adm_access;      apr_array_header_t *unique_dirs_to_lock;      /* Sort the paths in a depth-last directory-ish order. */      qsort(dirs_to_lock->elts, dirs_to_lock->nelts,            dirs_to_lock->elt_size, svn_sort_compare_paths);      qsort(dirs_to_lock_recursive->elts, dirs_to_lock_recursive->nelts,            dirs_to_lock_recursive->elt_size, svn_sort_compare_paths);      /* Remove any duplicates */      SVN_ERR(svn_path_remove_redundancies(&unique_dirs_to_lock,                                           dirs_to_lock_recursive,                                           pool));      dirs_to_lock_recursive = unique_dirs_to_lock;      /* Remove dirs and descendants from dirs_to_lock if there is         any ancestor in dirs_to_lock_recursive */      SVN_ERR(remove_redundancies(&unique_dirs_to_lock,                                  dirs_to_lock,                                  dirs_to_lock_recursive,                                  pool));      dirs_to_lock = unique_dirs_to_lock;      /* First lock all the dirs to be locked non-recursively */      if (dirs_to_lock)        {          for (i = 0; i < dirs_to_lock->nelts ; ++i)            {              target = APR_ARRAY_IDX(dirs_to_lock, i, const char *);              SVN_ERR(svn_wc_adm_open3(&adm_access, base_dir_access,                                       target,                                       TRUE,  /* Write lock */                                       0,     /* Depth */                                       ctx->cancel_func,                                       ctx->cancel_baton,                                       pool));            }        }      /* Lock the rest of the targets (recursively) */      if (dirs_to_lock_recursive)        {          for (i = 0; i < dirs_to_lock_recursive->nelts ; ++i)            {              target = APR_ARRAY_IDX(dirs_to_lock_recursive, i, const char *);              SVN_ERR(svn_wc_adm_open3(&adm_access, base_dir_access,                                       target,                                       TRUE, /* Write lock */                                       -1,   /* Depth */                                       ctx->cancel_func,                                       ctx->cancel_baton,                                       pool));            }        }    }  /* One day we might support committing from multiple working copies, but     we don't yet.  This check ensures that we don't silently commit a     subset of the targets.     At the same time, if a non-recursive commit is desired, do not     allow a deleted directory as one of the targets. */  for (i = 0; i < targets->nelts; ++i)    {      svn_wc_adm_access_t *adm_access;      SVN_ERR(svn_path_get_absolute(&target,                                    APR_ARRAY_IDX(targets, i, const char *),                                    pool));      SVN_ERR_W(svn_wc_adm_probe_retrieve(&adm_access, base_dir_access,                                          target, pool),                _("Are all the targets part of the same working copy?"));      if (!recurse)        {          svn_wc_status2_t *status;          svn_node_kind_t kind;                    SVN_ERR(svn_io_check_path(target, &kind, pool));          if (kind == svn_node_dir)            {              SVN_ERR(svn_wc_status2(&status, target, adm_access, pool));              if (status->text_status == svn_wc_status_deleted ||                  status->text_status == svn_wc_status_replaced)                return svn_error_create(SVN_ERR_UNSUPPORTED_FEATURE, NULL,                                        _("Cannot non-recursively commit a "                                          "directory deletion"));            }        }    }  /* Crawl the working copy for commit items. */  if ((cmt_err = svn_client__harvest_committables(&committables,                                                  &lock_tokens,                                                  base_dir_access,                                                  rel_targets,                                                   recurse ? FALSE : TRUE,                                                  ! keep_locks,                                                  ctx,                                                  pool)))    goto cleanup;  /* ### todo: Currently there should be only one hash entry, which     has a hacked name until we have the entries files storing     canonical repository URLs.  Then, the hacked name can go away     and be replaced with a canonical repos URL, and from there we     are poised to started handling nested working copies.  See     http://subversion.tigris.org/issues/show_bug.cgi?id=960. */  if (! ((commit_items = apr_hash_get(committables,                                      SVN_CLIENT__SINGLE_REPOS_NAME,                                       APR_HASH_KEY_STRING))))    goto cleanup;  /* If our array of targets contains only locks (and no actual file     or prop modifications), then we return here to avoid committing a     revision with no changes. */  {    svn_boolean_t found_changed_path = FALSE;    for (i = 0; i < commit_items->nelts; ++i)      {        svn_client_commit_item2_t *item;        item = APR_ARRAY_IDX(commit_items, i, svn_client_commit_item2_t *);                if (item->state_flags != SVN_CLIENT_COMMIT_ITEM_LOCK_TOKEN)           {            found_changed_path = TRUE;            break;          }      }    if (!found_changed_path)      goto cleanup;  }  /* Go get a log message.  If an error occurs, or no log message is     specified, abort the operation. */  if (ctx->log_msg_func ||  ctx->log_msg_func2)    {      const char *tmp_file;      cmt_err = svn_client__get_log_msg(&log_msg, &tmp_file, commit_items,                                        ctx, pool);      if (cmt_err || (! log_msg))        goto cleanup;    }  else    log_msg = "";  /* Sort and condense our COMMIT_ITEMS. */  if ((cmt_err = svn_client__condense_commit_items(&base_url,                                                   commit_items,                                                   pool)))    goto cleanup;  /* Collect our lock tokens with paths relative to base_url. */  if ((cmt_err = collect_lock_tokens(&lock_tokens, lock_tokens, base_url,                                     pool)))    goto cleanup;  if ((cmt_err = get_ra_editor(&ra_session, NULL,                               &editor, &edit_baton, ctx,                               base_url, base_dir, base_dir_access,                               log_msg, commit_items, commit_info_p,                               TRUE, lock_tokens, keep_locks, pool)))    goto cleanup;  /* Make a note that we have a commit-in-progress. */  commit_in_progress = TRUE;  /* Determine prefix to strip from the commit notify messages */  if ((cmt_err = svn_path_get_absolute(&display_dir,                                       display_dir, pool)))    goto cleanup;  display_dir = svn_path_get_longest_ancestor(display_dir, base_dir, pool);  /* Perform the commit. */  cmt_err = svn_client__do_commit(base_url, commit_items, base_dir_access,                                  editor, edit_baton,                                   display_dir,                                  &tempfiles, &digests, ctx, pool);  /* Handle a successful commit. */  if ((! cmt_err)      || (cmt_err->apr_err == SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED))    {      apr_pool_t *subpool = svn_pool_create(pool);      /* Make a note that our commit is finished. */      commit_in_progress = FALSE;      for (i = 0; i < commit_items->nelts; i++)        {          svn_client_commit_item2_t *item            = APR_ARRAY_IDX(commit_items, i, svn_client_commit_item2_t *);          svn_boolean_t loop_recurse = FALSE;          const char *adm_access_path;          svn_wc_adm_access_t *adm_access;          const svn_wc_entry_t *entry;          svn_boolean_t remove_lock;          /* Clear the subpool here because there are some 'continue'             statements in this loop. */          svn_pool_clear(subpool);          if (item->kind == svn_node_dir)            adm_access_path = item->path;          else            svn_path_split(item->path, &adm_access_path, NULL, subpool);          bump_err = svn_wc_adm_retrieve(&adm_access, base_dir_access,                                         adm_access_path, subpool);          if (bump_err)            {              if (bump_err->apr_err == SVN_ERR_WC_NOT_LOCKED)                {                  if (have_processed_parent(commit_items, i,                                            item->path, subpool))                    {                      /* This happens when the item is a directory that is                         deleted, and it has been processed as a child of an                         earlier item. */                      svn_error_clear(bump_err);                      bump_err = SVN_NO_ERROR;                      continue;                    }                  /* Is it a directory that was deleted in the commit? */                  if (item->kind == svn_node_dir                      && item->state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE)                    {                      /* It better be missing then.  Assuming it is,                         mark as deleted in parent.  If not, then                         something is way bogus. */                      svn_error_clear(bump_err);                      bump_err = svn_wc_mark_missing_deleted(item->path,                                                             base_dir_access,                                                             subpool);                      if (bump_err)                        goto cleanup;                      continue;                                          }                                  }              goto cleanup;                          }          if ((bump_err = svn_wc_entry(&entry, item->path, adm_access, TRUE,                                       subpool)))            goto cleanup;          if (! entry              && have_processed_parent(commit_items, i, item->path, subpool))            /* This happens when the item is a file that is deleted, and it               has been processed as a child of an earlier item. */            continue;          if ((item->state_flags & SVN_CLIENT_COMMIT_ITEM_ADD)               && (item->kind == svn_node_dir)              && (item->copyfrom_url))            loop_recurse = TRUE;          remove_lock = (! keep_locks && (item->state_flags                                          & SVN_CLIENT_COMMIT_ITEM_LOCK_TOKEN));          assert(*commit_info_p);          if ((bump_err = svn_wc_process_committed3               (item->path, adm_access,                loop_recurse,                (*commit_info_p)->revision,                (*commit_info_p)->date,                (*commit_info_p)->author,                item->wcprop_changes,                remove_lock,                apr_hash_get(digests, item->path, APR_HASH_KEY_STRING),                subpool)))            break;        }      /* Destroy the subpool. */      svn_pool_destroy(subpool);    }  /* Sleep to ensure timestamp integrity. */  svn_sleep_for_timestamps(); cleanup:  /* Abort the commit if it is still in progress. */  if (commit_in_progress)    svn_error_clear(editor->abort_edit(edit_baton, pool));  /* A bump error is likely to occur while running a working copy log file,     explicitly unlocking and removing temporary files would be wrong in     that case.  A commit error (cmt_err) should only occur before any     attempt to modify the working copy, so it doesn't prevent explicit     clean-up. */  if (! bump_err)    {      unlock_err = svn_wc_adm_close(base_dir_access);      if (! unlock_err)        cleanup_err = remove_tmpfiles(tempfiles, pool);    }  return reconcile_errors(cmt_err, unlock_err, bump_err, cleanup_err, pool);}svn_error_t *svn_client_commit2(svn_client_commit_info_t **commit_info_p,                   const apr_array_header_t *targets,                   svn_boolean_t recurse,                   svn_boolean_t keep_locks,                   svn_client_ctx_t *ctx,                   apr_pool_t *pool){  svn_commit_info_t *commit_info = NULL;  svn_error_t *err;  err = svn_client_commit3(&commit_info, targets, recurse, keep_locks,                           ctx, pool);  /* These structs have the same layout for the common fields. */  *commit_info_p = (svn_client_commit_info_t *) commit_info;  return err;}svn_error_t *svn_client_commit(svn_client_commit_info_t **commit_info_p,                  const apr_array_header_t *targets,                  svn_boolean_t nonrecursive,                  svn_client_ctx_t *ctx,                  apr_pool_t *pool){  return svn_client_commit2(commit_info_p, targets,                            nonrecursive ? FALSE : TRUE,                             TRUE,                            ctx, pool);}

⌨️ 快捷键说明

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