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

📄 locking_commands.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * locking_commands.c:  Implementation of lock and unlock. * * ==================================================================== * Copyright (c) 2000-2006 CollabNet.  All rights reserved. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution.  The terms * are also available at http://subversion.tigris.org/license-1.html. * If newer versions of this license are posted there, you may use a * newer version instead, at your option. * * This software consists of voluntary contributions made by many * individuals.  For exact contribution history, see the revision * history and logs, available at http://subversion.tigris.org/. * ==================================================================== *//* ==================================================================== *//*** Includes. ***/#include "svn_client.h"#include "client.h"#include "svn_path.h"#include "svn_xml.h"#include "svn_pools.h"#include "svn_private_config.h"/*** Code. ***//* For use with store_locks_callback, below. */struct lock_baton{  svn_wc_adm_access_t *adm_access;  apr_hash_t *urls_to_paths;  svn_client_ctx_t *ctx;  apr_pool_t *pool;};/* This callback is called by the ra_layer for each path locked. * BATON is a 'struct lock_baton *', PATH is the path being locked, * and LOCK is the lock itself. * * If BATON->adm_access is not null, then this function either stores * the LOCK on REL_URL or removes any lock tokens from REL_URL * (depending on whether DO_LOCK is true or false respectively), but * only if RA_ERR is null, or (in the unlock case) is something other * than SVN_ERR_FS_LOCK_OWNER_MISMATCH. */static svn_error_t *store_locks_callback(void *baton,                      const char *rel_url,                      svn_boolean_t do_lock,                     const svn_lock_t *lock,                     svn_error_t *ra_err, apr_pool_t *pool){  struct lock_baton *lb = baton;  svn_wc_adm_access_t *adm_access;  const char *abs_path;  svn_wc_notify_t *notify;  /* Create the notify struct first, so we can tweak it below. */  notify = svn_wc_create_notify(rel_url,                                do_lock                                ? (ra_err                                   ? svn_wc_notify_failed_lock                                   : svn_wc_notify_locked)                                : (ra_err                                   ? svn_wc_notify_failed_unlock                                   : svn_wc_notify_unlocked),                                pool);  notify->lock = lock;  notify->err = ra_err;  if (lb->adm_access)    {      char *path = apr_hash_get(lb->urls_to_paths, rel_url,                                APR_HASH_KEY_STRING);      abs_path = svn_path_join(svn_wc_adm_access_path(lb->adm_access),                                path, lb->pool);      SVN_ERR(svn_wc_adm_probe_retrieve(&adm_access, lb->adm_access,                                        abs_path, lb->pool));      if (do_lock)        {          if (!ra_err)            {              SVN_ERR(svn_wc_add_lock(abs_path, lock, adm_access, lb->pool));              notify->lock_state = svn_wc_notify_lock_state_locked;            }          else            notify->lock_state = svn_wc_notify_lock_state_unchanged;        }      else /* unlocking */        {          /* Remove our wc lock token either a) if we got no error, or b) if             we got any error except for owner mismatch.  Note that the only             errors that are handed to this callback will be locking-related             errors. */          if (!ra_err ||              (ra_err && (ra_err->apr_err != SVN_ERR_FS_LOCK_OWNER_MISMATCH)))            {              SVN_ERR(svn_wc_remove_lock(abs_path, adm_access, lb->pool));              notify->lock_state = svn_wc_notify_lock_state_unlocked;            }          else            notify->lock_state = svn_wc_notify_lock_state_unchanged;        }    }    if (lb->ctx->notify_func2)    lb->ctx->notify_func2(lb->ctx->notify_baton2, notify, pool);  return SVN_NO_ERROR;}/* Set *COMMON_PARENT to the nearest common parent of all TARGETS.  If * TARGETS are local paths, then the entry for each path is examined * and *COMMON_PARENT is set to the common parent URL for all the * targets (as opposed to the common local path). * * If all the targets are local paths within the same wc, i.e., they * share a common parent at some level, set and *PARENT_ADM_ACCESS_P * to and adm_access of that common parent.  *PARENT_ADM_ACCESS_P will * be associated with adm_access objects for all the other paths, * which are locked in the working copy while we lock them in the * repository. * * If all the targets are URLs in the same repository, i.e. sharing a * common parent URL prefix, then set *PARENT_ADM_ACCESS_P to null. * * If there is no common parent, either because the targets are a * mixture of URLs and local paths, or because they simply do not * share a common parent, then return SVN_ERR_UNSUPPORTED_FEATURE. * * DO_LOCK is TRUE for locking TARGETS, and FALSE for unlocking them. * FORCE is TRUE for breaking or stealing locks, and FALSE otherwise. * * Each key stored in *REL_TARGETS_P is a path relative to * *COMMON_PARENT.  If TARGETS are local paths, then: if DO_LOCK is * true, the value is a pointer to the corresponding base_revision * (allocated in POOL) for the path, else the value is the lock token * (or "" if no token found in the wc). * * If TARGETS is an array of urls, REL_FS_PATHS_P is set to NULL. * Otherwise each key in REL_FS_PATHS_P is an repository path (relative to * COMMON_PARENT) mapped to the target path for TARGET (relative to * the common parent WC path). working copy targets that they "belong" to. * * If *COMMON_PARENT is a URL, then the values are a pointer to * SVN_INVALID_REVNUM (allocated in pool) if DO_LOCK, else "". * * TARGETS may not be empty. */static svn_error_t *organize_lock_targets(const char **common_parent,                      svn_wc_adm_access_t **parent_adm_access_p,                      apr_hash_t **rel_targets_p,                      apr_hash_t **rel_fs_paths_p,                      const apr_array_header_t *targets,                      svn_boolean_t do_lock,                      svn_boolean_t force,                      svn_client_ctx_t *ctx,                      apr_pool_t *pool){  int i;  apr_array_header_t *rel_targets = apr_array_make(pool, 1,                                                   sizeof(const char *));  apr_hash_t *rel_targets_ret = apr_hash_make(pool);  apr_pool_t *subpool = svn_pool_create(pool);   /* Get the common parent and all relative paths */  SVN_ERR(svn_path_condense_targets(common_parent, &rel_targets, targets,                                     FALSE, pool));  /* svn_path_condense_targets leaves paths empty if TARGETS only had     1 member, so we special case that. */  if (apr_is_empty_array(rel_targets))    {      char *base_name = svn_path_basename(*common_parent, pool);      *common_parent = svn_path_dirname(*common_parent, pool);      APR_ARRAY_PUSH(rel_targets, char *) = base_name;    }  if (*common_parent == NULL || (*common_parent)[0] == '\0')    return svn_error_create      (SVN_ERR_UNSUPPORTED_FEATURE, NULL,       _("No common parent found, unable to operate on disjoint arguments"));    if (svn_path_is_url(*common_parent))    {      svn_revnum_t *invalid_revnum;      invalid_revnum = apr_palloc(pool, sizeof(*invalid_revnum));      *invalid_revnum = SVN_INVALID_REVNUM;      *parent_adm_access_p = NULL;      for (i = 0; i < rel_targets->nelts; i++)        {          const char *target = ((const char **) (rel_targets->elts))[i];          apr_hash_set(rel_targets_ret, svn_path_uri_decode(target, pool),                       APR_HASH_KEY_STRING,                       do_lock ? (const void *) invalid_revnum                       : (const void *) "");        }      *rel_fs_paths_p = NULL;    }  else  /* common parent is a local path */    {      int max_depth = 0;      apr_array_header_t *rel_urls;      apr_array_header_t *urls = apr_array_make(pool, 1,                                                sizeof(const char *));      apr_hash_t *urls_hash = apr_hash_make(pool);      const char *common_url;      /* Calculate the maximum number of components in the rel_targets, which         is the depth to which we need to lock the WC. */      for (i = 0; i < rel_targets->nelts; ++i)        {          const char *target = ((const char **) (rel_targets->elts))[i];          int n = svn_path_component_count(target);          if (n > max_depth)            max_depth = n;        }      SVN_ERR(svn_wc_adm_probe_open3(parent_adm_access_p, NULL,                                     *common_parent,                                      TRUE, max_depth, ctx->cancel_func,                                      ctx->cancel_baton, pool));        /* Get the url for each target and verify all paths. */      for (i = 0; i < rel_targets->nelts; i++)

⌨️ 快捷键说明

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