[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Stop resurrecting deleted files in ~/.subversion

From: <epg_at_pretzelnet.org>
Date: 2003-01-25 00:28:13 CET

Log message and patch follow. But first i have a question. This
function has a comment that says errors should be ignored.
Failing to create the default config directory and/or files
should not cause whatever operation the user actually requested
to fail. I agree with that 100%. Unfortunately, the comment is
inaccurate; this function *will* bomb if creating the files
fails. Can i fix that in this patch also? The correct behavior
for this function, IMNSHO, is never to fail.

Here is what i mean:

0 ~% mv .subversion .subversion.cur
0 ~% touch .subversion
0 ~% chmod 0 .subversion
0 ~% svn st -Nq
/u/epg/work/svn/trunk/subversion/libsvn_subr/config_file.c:354:
(apr_err=125001)
svn: Bogus filename
svn: Can't open config file /u/epg/.subversion/config

That is broken.

Current log message and patch (doesn't fix that issue yet, only
the one in the Subject):

Currently, svn has the annoying behavior of restoring files i have
deleted from the .subversion configuration directory. See how
annoying it is:

0 .subversion% svn st
? README
M servers
0 .subversion% rm README
0 .subversion% ls README
ls: README: No such file or directory
1 .subversion% svn st
? README
M servers

Grrrrr.

* subversion/libsvn_subr/config_file.c:

  (svn_config_ensure): When the .subversion directory does not exist,
  attempt to create it and the default files. Do not attempt to
  create the default files when the directory already exists.

Index: subversion/libsvn_subr/config_file.c
===================================================================
--- subversion/libsvn_subr/config_file.c (revision 4549)
+++ subversion/libsvn_subr/config_file.c (working copy)
@@ -450,6 +450,12 @@
   apr_status_t apr_err;
   svn_error_t *err;
 
+ /* XXX: I agree with this comment, but it is not in fact followed.
+ Hopefully people agree i should fix that... */
+ /* If we get errors trying to do things below, just stop and return
+ success. There's no _need_ to init a config directory if
+ something's preventing it. */
+
   /* Ensure that the user-specific config directory exists. */
   SVN_ERR (svn_config__user_config_path (path, NULL, pool));
 
@@ -462,31 +468,22 @@
       apr_err = apr_dir_make (path, APR_OS_DEFAULT, pool);
       if (apr_err)
         return SVN_NO_ERROR;
- }
- else if (kind != svn_node_dir)
- return SVN_NO_ERROR;
-
- /* Else, there's a configuration directory. */
-
- /* If we get errors trying to do things below, just stop and return
- success. There's no _need_ to init a config directory if
- something's preventing it. */
 
- /** Ensure that the `README' file exists. **/
- SVN_ERR (svn_config__user_config_path
- (path, SVN_CONFIG__USR_README_FILE, pool));
+ /** Ensure that the `README' file exists. **/
+ SVN_ERR (svn_config__user_config_path
+ (path, SVN_CONFIG__USR_README_FILE, pool));
 
- if (! path) /* highly unlikely, since a previous call succeeded */
- return SVN_NO_ERROR;
+ if (! path) /* highly unlikely, since a previous call succeeded */
+ return SVN_NO_ERROR;
 
- err = svn_io_check_path (path, kind, pool);
- if (err)
- return SVN_NO_ERROR;
+ err = svn_io_check_path (path, kind, pool);
+ if (err)
+ return SVN_NO_ERROR;
 
- if (kind == svn_node_none)
- {
- apr_file_t *f;
- const char *contents =
+ if (kind == svn_node_none)
+ {
+ apr_file_t *f;
+ const char *contents =
    This directory holds run-time configuration information for Subversion\n
    clients. The configuration files all share the same syntax, but you\n
    should examine a particular file to learn what configuration\n
@@ -595,40 +592,41 @@
      REGISTRY:HKCU\\Software\\Tigris.org\\Subversion\\Hairstyles\n
    \n;
 
- apr_err = apr_file_open (f, path,
- (APR_WRITE | APR_CREATE | APR_EXCL),
- APR_OS_DEFAULT,
- pool);
-
- if (! apr_err)
- {
- apr_err = apr_file_write_full (f, contents, strlen (contents), NULL);
- if (apr_err)
- return svn_error_createf (apr_err, NULL,
- writing config file `%s', path);
-
- apr_err = apr_file_close (f);
- if (apr_err)
- return svn_error_createf (apr_err, NULL,
- closing config file `%s', path);
+ apr_err = apr_file_open (f, path,
+ (APR_WRITE | APR_CREATE | APR_EXCL),
+ APR_OS_DEFAULT,
+ pool);
+
+ if (! apr_err)
+ {
+ apr_err = apr_file_write_full (f, contents, strlen (contents),
+ NULL);
+ if (apr_err)
+ return svn_error_createf (apr_err, NULL,
+ writing config file `%s', path);
+
+ apr_err = apr_file_close (f);
+ if (apr_err)
+ return svn_error_createf (apr_err, NULL,
+ closing config file `%s', path);
+ }
         }
- }
 
- /** Ensure that the `servers' file exists. **/
- SVN_ERR (svn_config__user_config_path
- (path, SVN_CONFIG__USR_SERVERS_FILE, pool));
+ /** Ensure that the `servers' file exists. **/
+ SVN_ERR (svn_config__user_config_path
+ (path, SVN_CONFIG__USR_SERVERS_FILE, pool));
 
- if (! path) /* highly unlikely, since a previous call succeeded */
- return SVN_NO_ERROR;
+ if (! path) /* highly unlikely, since a previous call succeeded */
+ return SVN_NO_ERROR;
 
- err = svn_io_check_path (path, kind, pool);
- if (err)
- return SVN_NO_ERROR;
-
- if (kind == svn_node_none)
- {
- apr_file_t *f;
- const char *contents =
+ err = svn_io_check_path (path, kind, pool);
+ if (err)
+ return SVN_NO_ERROR;
+
+ if (kind == svn_node_none)
+ {
+ apr_file_t *f;
+ const char *contents =
         ### This file specifies server-specific protocol parameters,\n
         ### including HTTP proxy information, HTTP timeout settings, and\n
         ### svn protocol tunnel agents (for running svn over ssh or similar\n
@@ -698,40 +696,41 @@
         # No http-timeout, so just use the builtin default.\n
         # No neon-debug-mask, so neon debugging is disabled.\n;
 
- apr_err = apr_file_open (f, path,
- (APR_WRITE | APR_CREATE | APR_EXCL),
- APR_OS_DEFAULT,
- pool);
-
- if (! apr_err)
- {
- apr_err = apr_file_write_full (f, contents, strlen (contents), NULL);
- if (apr_err)
- return svn_error_createf (apr_err, NULL,
- writing config file `%s', path);
-
- apr_err = apr_file_close (f);
- if (apr_err)
- return svn_error_createf (apr_err, NULL,
- closing config file `%s', path);
+ apr_err = apr_file_open (f, path,
+ (APR_WRITE | APR_CREATE | APR_EXCL),
+ APR_OS_DEFAULT,
+ pool);
+
+ if (! apr_err)
+ {
+ apr_err = apr_file_write_full (f, contents, strlen (contents),
+ NULL);
+ if (apr_err)
+ return svn_error_createf (apr_err, NULL,
+ writing config file `%s', path);
+
+ apr_err = apr_file_close (f);
+ if (apr_err)
+ return svn_error_createf (apr_err, NULL,
+ closing config file `%s', path);
+ }
         }
- }
 
- /** Ensure that the `config' file exists. **/
- SVN_ERR (svn_config__user_config_path
- (path, SVN_CONFIG__USR_CONFIG_FILE, pool));
+ /** Ensure that the `config' file exists. **/
+ SVN_ERR (svn_config__user_config_path
+ (path, SVN_CONFIG__USR_CONFIG_FILE, pool));
 
- if (! path) /* highly unlikely, since a previous call succeeded */
- return SVN_NO_ERROR;
+ if (! path) /* highly unlikely, since a previous call succeeded */
+ return SVN_NO_ERROR;
 
- err = svn_io_check_path (path, kind, pool);
- if (err)
- return SVN_NO_ERROR;
-
- if (kind == svn_node_none)
- {
- apr_file_t *f;
- const char *contents =
+ err = svn_io_check_path (path, kind, pool);
+ if (err)
+ return SVN_NO_ERROR;
+
+ if (kind == svn_node_none)
+ {
+ apr_file_t *f;
+ const char *contents =
         ### This file configures various client-side behaviors.\n
         ###\n
         ### The commented-out examples below are intended to demonstrate\n
@@ -739,7 +738,7 @@
         \n
         ### Section for authentication and authorization customizations.\n
         ### Set store-password to 'no' to avoid storing your subversion\n
- ### password in your working copies. It defaults to 'yes'.\n
+ ### password in your working copies. It defaults to 'yes'.\n
         # [auth]\n
         # store-password = no\n
         \n
@@ -773,27 +772,29 @@
         # global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#*
         \n
         ### Set compression to 'no' to avoid compressing requests\n
- ### to a DAV-enabled Subversion server. It defaults to 'yes'.\n
+ ### to a DAV-enabled Subversion server. It defaults to 'yes'.\n
         # compression = yes\n
         ### See http://subversion.tigris.org/issues/show_bug.cgi?id=668\n
         ### for what else will soon be customized in this file.\n;
-
- apr_err = apr_file_open (f, path,
- (APR_WRITE | APR_CREATE | APR_EXCL),
- APR_OS_DEFAULT,
- pool);
 
- if (! apr_err)
- {
- apr_err = apr_file_write_full (f, contents, strlen (contents), NULL);
- if (apr_err)
- return svn_error_createf (apr_err, NULL,
- writing config file `%s', path);
-
- apr_err = apr_file_close (f);
- if (apr_err)
- return svn_error_createf (apr_err, NULL,
- closing config file `%s', path);
+ apr_err = apr_file_open (f, path,
+ (APR_WRITE | APR_CREATE | APR_EXCL),
+ APR_OS_DEFAULT,
+ pool);
+
+ if (! apr_err)
+ {
+ apr_err = apr_file_write_full (f, contents, strlen (contents),
+ NULL);
+ if (apr_err)
+ return svn_error_createf (apr_err, NULL,
+ writing config file `%s', path);
+
+ apr_err = apr_file_close (f);
+ if (apr_err)
+ return svn_error_createf (apr_err, NULL,
+ closing config file `%s', path);
+ }
         }
     }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 14 02:16:08 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.