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

Re: svn commit invokes $EDITOR not where svn run from

From: Alexis Huxley <ahuxley_at_gmx.net>
Date: 2002-08-20 21:08:37 CEST

> > So my question is: should I start learning Python so I can code
> > this, or is it sufficiently un-cross-platformy or integratable
> > to warrant not bothering? :-)
>
> Well, "cat >" is certainly not portable enough to put in the test
> suite. I'm not sure what a portable solution to the editor problem
> would be, unless we want to write a special Python program, that our
> test suite just uses to *be* the editor. Hmmm, you know, that might
> just be the trick. Want to try that way?

Ok, it's taking me a bit longer to get round to writing the test
than I'd hoped. In the mean time here's the first version of the
patch ...

Alexis

Index: subversion/clients/cmdline/util.c
===================================================================
--- subversion/clients/cmdline/util.c
+++ subversion/clients/cmdline/util.c 2002-08-20 21:02:20.000000000 +0200
@@ -382,31 +382,49 @@
   /* Convert file contents from UTF-8 */
   SVN_ERR (svn_utf_cstring_from_utf8 (&contents_native, contents, pool));
 
- /* Move to BASE_DIR to avoid getting characters that need quoting
- into tmpfile_name */
+ /* Get cwd - will be needed later if we cd anywhere searching for writable dir */
   apr_err = apr_filepath_get (&old_cwd, APR_FILEPATH_NATIVE, pool);
   if (apr_err)
     {
       return svn_error_create
- (apr_err, 0, NULL, pool, "failed to get current working directory");
- }
- SVN_ERR (svn_utf_cstring_from_utf8 (&base_dir_native, base_dir, pool));
- apr_err = apr_filepath_set (base_dir_native, pool);
- if (apr_err)
- {
- return svn_error_createf
- (apr_err, 0, NULL, pool,
- "failed to change working directory to '%s'", base_dir);
+ (apr_err, 0, NULL, pool, "failed to get current working directory");
     }
 
- /*** From here on, any problems that occur require us to cd back!! ***/
+ /*** From here on, if problems occur we cd back unconditionally, even if superfluous ***/
 
- /* Ask the working copy for a temporary file */
- err = svn_io_open_unique_file
- (&tmp_file, &tmpfile_name,
- "msg", ".tmp", FALSE, pool);
- if (err)
+ do { /* 1 loop only; 'do' facilitates 'break' */
+
+ /* first attempt: stay in cwd, and try opening here */
+ err = svn_io_open_unique_file (&tmp_file, &tmpfile_name, "msg", ".tmp", FALSE, pool);
+ if (!err)
+ break;
+ else if (err && err->apr_err != APR_EACCES)
+ goto cleanup2;
+
+ /*** Additional cd+open's go here (copy and edit the 'last attempt' block) ***/
+
+ /* last attempt: go to base of WC, and try opening there */
+ err = svn_utf_cstring_from_utf8 (&base_dir_native, base_dir, pool);
+ if (err)
+ goto cleanup2;
+ apr_err = apr_filepath_set (base_dir_native, pool);
+ if (apr_err)
+ {
+ err = svn_error_createf (apr_err, 0, NULL, pool,
+ "failed to change working directory to '%s'", base_dir);
+ goto cleanup2;
+ }
+ err = svn_io_open_unique_file (&tmp_file, &tmpfile_name, "msg", ".tmp", FALSE, pool);
+ if (!err)
+ break;
+ else if (err && err->apr_err != APR_EACCES)
+ goto cleanup2;
+
+ /* finally: give up and generate an error using last EACCESS error */
     goto cleanup2;
+
+ } while (0); /* facilitate goto without goto */
+
 
   /*** From here on, any problems that occur require us to cleanup
        the file we just created!! ***/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Aug 20 21:09:19 2002

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.