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

📄 props.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
                      (NULL, path, value->data, pool));            }        }      else if (strcmp(name, SVN_PROP_KEYWORDS) == 0)        {          new_value = svn_stringbuf_create_from_string(value, pool);          svn_stringbuf_strip_whitespace(new_value);        }    }  if (entry->kind == svn_node_file && strcmp(name, SVN_PROP_EXECUTABLE) == 0)    {      /* If the svn:executable property was set, then chmod +x.         If the svn:executable property was deleted (NULL value passed         in), then chmod -x. */      if (value == NULL)        {          SVN_ERR(svn_io_set_file_executable(path, FALSE, TRUE, pool));        }      else        {          /* Since we only check if the property exists or not, force the             property value to a specific value */          static const svn_string_t executable_value =            {              SVN_PROP_EXECUTABLE_VALUE,              sizeof(SVN_PROP_EXECUTABLE_VALUE) - 1            };          value = &executable_value;          SVN_ERR(svn_io_set_file_executable(path, TRUE, TRUE, pool));        }    }  if (entry->kind == svn_node_file && strcmp(name, SVN_PROP_NEEDS_LOCK) == 0)    {      /* If the svn:needs-lock property was set to NULL, set the file         to read-write */      if (value == NULL)        {          SVN_ERR(svn_io_set_file_read_write(path, FALSE, pool));        }      else        {          /* Since we only check if the property exists or not, force the             property value to a specific value */          static const svn_string_t needs_lock_value =            {              SVN_PROP_NEEDS_LOCK_VALUE,              sizeof(SVN_PROP_NEEDS_LOCK_VALUE) - 1            };          value = &needs_lock_value;          /* And we'll set the file to read-only at commit time. */        }    }  if (new_value)    value = svn_string_create_from_buf(new_value, pool);  err = svn_wc__load_props(&base_prophash, &prophash, adm_access, base_name,                           pool);  if (err)    return      svn_error_quick_wrap      (err, _("Failed to load properties from disk"));  /* If we're changing this file's list of expanded keywords, then   * we'll need to invalidate its text timestamp, since keyword   * expansion affects the comparison of working file to text base.   *   * Here we retrieve the old list of expanded keywords; after the   * property is set, we'll grab the new list and see if it differs   * from the old one.   */  if (entry->kind == svn_node_file && strcmp(name, SVN_PROP_KEYWORDS) == 0)    {      svn_string_t *old_value = apr_hash_get(prophash, SVN_PROP_KEYWORDS,                                             APR_HASH_KEY_STRING);      apr_hash_t *old_keywords, *new_keywords;      SVN_ERR(svn_wc__get_keywords(&old_keywords, path, adm_access,                                   old_value ? old_value->data : "", pool));      SVN_ERR(svn_wc__get_keywords(&new_keywords, path, adm_access,                                   value ? value->data : "", pool));      if (svn_subst_keywords_differ2(old_keywords, new_keywords, FALSE, pool))        {          svn_wc_entry_t tmp_entry;          /* If we changed the keywords or newlines, void the entry             timestamp for this file, so svn_wc_text_modified_p() does             a real (albeit slow) check later on. */          tmp_entry.kind = svn_node_file;          tmp_entry.text_time = 0;          SVN_ERR(svn_wc__loggy_entry_modify(&log_accum, adm_access,                                             base_name, &tmp_entry,                                             SVN_WC__ENTRY_MODIFY_TEXT_TIME,                                             pool));        }    }  /* Now we have all the properties in our hash.  Simply merge the new     property into it. */  apr_hash_set(prophash, name, APR_HASH_KEY_STRING, value);    SVN_ERR(svn_wc__install_props(&log_accum, adm_access, base_name,                                base_prophash, prophash, FALSE, pool));  SVN_ERR(svn_wc__write_log(adm_access, 0, log_accum, pool));  SVN_ERR(svn_wc__run_log(adm_access, NULL, pool));  return SVN_NO_ERROR;}svn_error_t *svn_wc_prop_set(const char *name,                const svn_string_t *value,                const char *path,                svn_wc_adm_access_t *adm_access,                apr_pool_t *pool){  return svn_wc_prop_set2(name, value, path, adm_access, FALSE, pool);}svn_boolean_tsvn_wc_is_normal_prop(const char *name){  enum svn_prop_kind kind = svn_property_kind(NULL, name);  return (kind == svn_prop_regular_kind);}svn_boolean_tsvn_wc_is_wc_prop(const char *name){  enum svn_prop_kind kind = svn_property_kind(NULL, name);  return (kind == svn_prop_wc_kind);}svn_boolean_tsvn_wc_is_entry_prop(const char *name){  enum svn_prop_kind kind = svn_property_kind(NULL, name);  return (kind == svn_prop_entry_kind);}/* Helper to optimize svn_wc_props_modified_p().   If PATH_TO_PROP_FILE is nonexistent, is empty, or is of size 4 bytes   ("END\n"), then set EMPTY_P to true.   Otherwise set EMPTY_P to false,   which means that the file must contain real properties.  */static svn_error_t *empty_props_p(svn_boolean_t *empty_p,              const char *path_to_prop_file,              apr_pool_t *pool){  svn_error_t *err;  apr_finfo_t finfo;  err = svn_io_stat(&finfo, path_to_prop_file, APR_FINFO_MIN | APR_FINFO_TYPE,                    pool);  if (err)    {      if (! APR_STATUS_IS_ENOENT(err->apr_err)          && ! APR_STATUS_IS_ENOTDIR(err->apr_err))        return err;      /* nonexistent */      svn_error_clear(err);      *empty_p = TRUE;    }  else    {      /* If we remove props from a propfile, eventually the file will         be empty, or, for working copies written by pre-1.3 libraries, will         contain nothing but "END\n" */      if (finfo.filetype == APR_REG && (finfo.size == 4 || finfo.size == 0))        *empty_p = TRUE;      else        *empty_p = FALSE;      /* If the size is between 1 and 4, then something is corrupt.         If the size is between 4 and 16, then something is corrupt,         because 16 is the -smallest- the file can possibly be if it         contained only one property.  So long as we say it is "not         empty", we will discover such corruption later when we try         to read the properties from the file. */    }  return SVN_NO_ERROR;}/* Simple wrapper around empty_props_p, and inversed. */svn_error_t *svn_wc__has_props(svn_boolean_t *has_props,                  const char *path,                  svn_wc_adm_access_t *adm_access,                  apr_pool_t *pool){  svn_boolean_t is_empty;  const char *prop_path;  const svn_wc_entry_t *entry;  svn_boolean_t has_propcaching =    svn_wc__adm_wc_format(adm_access) > SVN_WC__NO_PROPCACHING_VERSION;  SVN_ERR(svn_wc_entry(&entry, path, adm_access, FALSE, pool));  /*### Maybe assert (entry); calling svn_wc__has_props    for an unversioned path is bogus */  if (! entry)    {      *has_props = FALSE;      return SVN_NO_ERROR;    }  /* Use the flag in the entry if the WC is recent enough. */  if (has_propcaching)    {      *has_props = entry->has_props;      return SVN_NO_ERROR;    }  /* The rest is for compatibility with WCs that don't have propcaching. */  SVN_ERR(svn_wc__prop_path(&prop_path, path, entry->kind, FALSE, pool));  SVN_ERR(empty_props_p(&is_empty, prop_path, pool));  if (is_empty)    *has_props = FALSE;  else    *has_props = TRUE;  return SVN_NO_ERROR;}svn_error_t *svn_wc_props_modified_p(svn_boolean_t *modified_p,                        const char *path,                        svn_wc_adm_access_t *adm_access,                        apr_pool_t *pool){  svn_boolean_t bempty, wempty;  const char *prop_path;  const char *prop_base_path;  svn_boolean_t different_filesizes, equal_timestamps;  const svn_wc_entry_t *entry;  apr_pool_t *subpool = svn_pool_create(pool);  int wc_format = svn_wc__adm_wc_format(adm_access);  SVN_ERR(svn_wc_entry(&entry, path, adm_access, TRUE, subpool));    /* If we have no entry, we can't have any prop mods. */  if (! entry)    {      *modified_p = FALSE;      goto cleanup;    }  /* For newer WCs, if there is an entry for the path, we have a fast   * and nice way to retrieve the information from the entry. */  if (wc_format > SVN_WC__NO_PROPCACHING_VERSION)    {      *modified_p = entry->has_prop_mods;      goto cleanup;    }        /* So, we have a WC in an older format... We... Have some work to do... */  /* First, get the paths of the working and 'base' prop files. */  SVN_ERR(svn_wc__prop_path(&prop_path, path, entry->kind, FALSE, subpool));  SVN_ERR(svn_wc__prop_base_path(&prop_base_path, path, entry->kind, FALSE,                                 subpool));  /* Decide if either path is "empty" of properties. */  SVN_ERR(empty_props_p(&wempty, prop_path, subpool));  SVN_ERR(empty_props_p(&bempty, prop_base_path, subpool));  /* If something is scheduled for replacement, we do *not* want to     pay attention to any base-props;  they might be residual from the     old deleted file. */  if (entry->schedule == svn_wc_schedule_replace)    {      *modified_p = wempty ? FALSE : TRUE;      goto cleanup;            }  /* Easy out:  if the base file is empty, we know the answer     immediately. */  if (bempty)    {      if (! wempty)        {          /* base is empty, but working is not */          *modified_p = TRUE;          goto cleanup;        }      else        {          /* base and working are both empty */          *modified_p = FALSE;          goto cleanup;        }    }  /* OK, so the base file is non-empty.  One more easy out: */  if (wempty)    {      /* base exists, working is empty */      *modified_p = TRUE;      goto cleanup;    }  /* At this point, we know both files exists.  Therefore we have no     choice but to start checking their contents. */    /* There are at least three tests we can try in succession. */    /* Easy-answer attempt #1:  (### this stat's the files again) */    /* Check if the local and prop-base file have *definitely* different     filesizes. */  SVN_ERR(svn_io_filesizes_different_p(&different_filesizes,                                       prop_path,                                       prop_base_path,                                       subpool));  if (different_filesizes)     {      *modified_p = TRUE;      goto cleanup;    }    /* Easy-answer attempt #2:  (### this stat's the files again) */        /* See if the local file's prop timestamp is the same as the one     recorded in the administrative directory.  */  SVN_ERR(svn_wc__timestamps_equal_p(&equal_timestamps, path, adm_access,                                     svn_wc__prop_time, subpool));  if (equal_timestamps)    {      *modified_p = FALSE;      goto cleanup;    }    /* Last ditch attempt:  */    /* If we get here, then we know that the filesizes are the same,     but the timestamps are different.  That's still not enough     evidence to make a correct decision;  we need to look at the     files' contents directly.     However, doing a byte-for-byte comparison won't work.  The two     properties files may have the *exact* same name/value pairs, but     arranged in a different order.  (Our hashdump format makes no     guarantees about ordering.)     Therefore, rather than use contents_identical_p(), we use     svn_prop_diffs(). */  {    apr_array_header_t *local_propchanges;    apr_hash_t *localprops = apr_hash_make(subpool);    apr_hash_t *baseprops = apr_hash_make(subpool);    /* ### Amazingly, this stats the files again! */    SVN_ERR(svn_wc__load_prop_file(prop_path, localprops, subpool));    SVN_ERR(svn_wc__load_prop_file(prop_base_path,                                   baseprops,                                   subpool));    SVN_ERR(svn_prop_diffs(&local_propchanges, localprops,                            baseprops, subpool));                                             if (local_propchanges->nelts > 0)      *modified_p = TRUE;    else      *modified_p = FALSE;  }  cleanup:  svn_pool_destroy(subpool)

⌨️ 快捷键说明

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