You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/12/13 22:43:57 UTC

svn commit: r1045385 - in /subversion/trunk/subversion: libsvn_client/status.c tests/cmdline/stat_tests.py

Author: hwright
Date: Mon Dec 13 21:43:57 2010
New Revision: 1045385

URL: http://svn.apache.org/viewvc?rev=1045385&view=rev
Log:
Simplify a conditional by removing a redundant error destruction.

* subversion/tests/cmdline/stat_tests.py
  (status_unversioned_dir): Update expectation for abspath.
 
* subversion/libsvn_client/status.c
  (svn_client_status5): Remove redundant error destruction, creation.

Modified:
    subversion/trunk/subversion/libsvn_client/status.c
    subversion/trunk/subversion/tests/cmdline/stat_tests.py

Modified: subversion/trunk/subversion/libsvn_client/status.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/status.c?rev=1045385&r1=1045384&r2=1045385&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/status.c (original)
+++ subversion/trunk/subversion/libsvn_client/status.c Mon Dec 13 21:43:57 2010
@@ -292,17 +292,16 @@ svn_client_status5(svn_revnum_t *result_
     SVN_ERR(svn_io_check_path(target_abspath, &disk_kind, pool));
     err = svn_wc_read_kind(&kind, ctx->wc_ctx, target_abspath, FALSE, pool);
 
-    if (err && ((err->apr_err == SVN_ERR_WC_MISSING) ||
-                (err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY)))
-    {
-      /* This error code is checked for in svn to continue after an error */
-      svn_error_clear(err);
-      return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
-                               _("'%s' is not a working copy"),
-                               svn_dirent_local_style(path, pool));
-    }
-
-    SVN_ERR(err);
+    if (err && (err->apr_err == SVN_ERR_WC_MISSING))
+      {
+        /* Calling code expects SVN_ERR_WC_NOT_WORKING_COPY. */
+        svn_error_clear(err);
+        return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
+                                 _("'%s' is not a working copy"),
+                                 svn_dirent_local_style(path, pool));
+      }
+    else if (err)
+      return err;
 
     /* Dir must be an existing directory or the status editor fails */
     if (kind == svn_node_dir && disk_kind == svn_node_dir)

Modified: subversion/trunk/subversion/tests/cmdline/stat_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/stat_tests.py?rev=1045385&r1=1045384&r2=1045385&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/stat_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/stat_tests.py Mon Dec 13 21:43:57 2010
@@ -964,8 +964,10 @@ def status_unversioned_dir(sbox):
   "status on unversioned dir (issue 2030)"
   sbox.build(read_only = True)
   dir = sbox.repo_dir
-  expected_err = ["svn: warning: '" + dir + "' is not a working copy\n",
-                  "svn: warning: '" + dir + "' is not a working copy\n"]
+  expected_err = ["svn: warning: '" + os.path.abspath(dir) +
+                  "' is not a working copy\n",
+                  "svn: warning: '" + os.path.abspath(dir) +
+                  "' is not a working copy\n"]
   svntest.actions.run_and_verify_svn2(None, [], expected_err, 0,
                                       "status", dir, dir)
 



Re: svn commit: r1045385 - in /subversion/trunk/subversion: libsvn_client/status.c tests/cmdline/stat_tests.py

Posted by "Hyrum K. Wright" <hy...@mail.utexas.edu>.
On Mon, Dec 13, 2010 at 8:16 PM, C. Michael Pilato <cm...@collab.net> wrote:
> On 12/13/2010 04:43 PM, hwright@apache.org wrote:
>> Modified: subversion/trunk/subversion/libsvn_client/status.c
>> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/status.c?rev=1045385&r1=1045384&r2=1045385&view=diff
>> ==============================================================================
>> --- subversion/trunk/subversion/libsvn_client/status.c (original)
>> +++ subversion/trunk/subversion/libsvn_client/status.c Mon Dec 13 21:43:57 2010
>> @@ -292,17 +292,16 @@ svn_client_status5(svn_revnum_t *result_
>>      SVN_ERR(svn_io_check_path(target_abspath, &disk_kind, pool));
>>      err = svn_wc_read_kind(&kind, ctx->wc_ctx, target_abspath, FALSE, pool);
>>
>> -    if (err && ((err->apr_err == SVN_ERR_WC_MISSING) ||
>> -                (err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY)))
>> -    {
>> -      /* This error code is checked for in svn to continue after an error */
>> -      svn_error_clear(err);
>> -      return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
>> -                               _("'%s' is not a working copy"),
>> -                               svn_dirent_local_style(path, pool));
>> -    }
>> -
>> -    SVN_ERR(err);
>> +    if (err && (err->apr_err == SVN_ERR_WC_MISSING))
>> +      {
>> +        /* Calling code expects SVN_ERR_WC_NOT_WORKING_COPY. */
>> +        svn_error_clear(err);
>> +        return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
>> +                                 _("'%s' is not a working copy"),
>> +                                 svn_dirent_local_style(path, pool));
>> +      }
>
> You might not be able to answer this, Hyrum, but:  why do we clear 'err'
> instead of feeding it into the svn_error_createf() as the child error?  Are
> we losing any useful information with the current approach?

I can't answer, but the same thought did occur to me.  I just forgot
to make it a composition call before committing.  +1 to the idea,
though.

-Hyrum

Re: svn commit: r1045385 - in /subversion/trunk/subversion: libsvn_client/status.c tests/cmdline/stat_tests.py

Posted by "C. Michael Pilato" <cm...@collab.net>.
On 12/13/2010 04:43 PM, hwright@apache.org wrote:
> Modified: subversion/trunk/subversion/libsvn_client/status.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/status.c?rev=1045385&r1=1045384&r2=1045385&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_client/status.c (original)
> +++ subversion/trunk/subversion/libsvn_client/status.c Mon Dec 13 21:43:57 2010
> @@ -292,17 +292,16 @@ svn_client_status5(svn_revnum_t *result_
>      SVN_ERR(svn_io_check_path(target_abspath, &disk_kind, pool));
>      err = svn_wc_read_kind(&kind, ctx->wc_ctx, target_abspath, FALSE, pool);
>  
> -    if (err && ((err->apr_err == SVN_ERR_WC_MISSING) ||
> -                (err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY)))
> -    {
> -      /* This error code is checked for in svn to continue after an error */
> -      svn_error_clear(err);
> -      return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
> -                               _("'%s' is not a working copy"),
> -                               svn_dirent_local_style(path, pool));
> -    }
> -
> -    SVN_ERR(err);
> +    if (err && (err->apr_err == SVN_ERR_WC_MISSING))
> +      {
> +        /* Calling code expects SVN_ERR_WC_NOT_WORKING_COPY. */
> +        svn_error_clear(err);
> +        return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
> +                                 _("'%s' is not a working copy"),
> +                                 svn_dirent_local_style(path, pool));
> +      }

You might not be able to answer this, Hyrum, but:  why do we clear 'err'
instead of feeding it into the svn_error_createf() as the child error?  Are
we losing any useful information with the current approach?

-- 
C. Michael Pilato <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand