You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2011/04/21 17:47:25 UTC

svn commit: r1095756 - in /subversion/trunk: build.conf subversion/tests/cmdline/lock-wc-dir.c subversion/tests/cmdline/svntest/actions.py subversion/tests/cmdline/svntest/main.py

Author: rhuijben
Date: Thu Apr 21 15:47:25 2011
New Revision: 1095756

URL: http://svn.apache.org/viewvc?rev=1095756&view=rev
Log:
Resolve a few more test errors by adding a small tool which obtains a
working copy lock. Either a recursive one, or a wc-1.0 compatible per
directory lock.

* build.conf
  (lock-wc-dir): New app.

* subversion/tests/cmdline/lock-wc-dir.c
  New file.

* subversion/tests/cmdline/svntest/actions.py
  (lock_admin_dir): Reimplement using lock_wc_dir.

* subversion/tests/cmdline/svntest/main.py
  (lock_wc_dir_binary): New variable.
  (run_lock_wc_dir): New function.

Added:
    subversion/trunk/subversion/tests/cmdline/lock-wc-dir.c   (with props)
Modified:
    subversion/trunk/build.conf
    subversion/trunk/subversion/tests/cmdline/svntest/actions.py
    subversion/trunk/subversion/tests/cmdline/svntest/main.py

Modified: subversion/trunk/build.conf
URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=1095756&r1=1095755&r2=1095756&view=diff
==============================================================================
--- subversion/trunk/build.conf (original)
+++ subversion/trunk/build.conf Thu Apr 21 15:47:25 2011
@@ -1026,6 +1026,12 @@ install = test
 libs = libsvn_ra libsvn_subr apriconv apr
 testing = skip
 
+[lock-wc-dir]
+type = exe
+path = subversion/tests/cmdline
+sources = lock-wc-dir.c
+install = test
+libs = libsvn_wc libsvn_subr apriconv apr
 
 
 # ----------------------------------------------------------------------------

Added: subversion/trunk/subversion/tests/cmdline/lock-wc-dir.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/lock-wc-dir.c?rev=1095756&view=auto
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/lock-wc-dir.c (added)
+++ subversion/trunk/subversion/tests/cmdline/lock-wc-dir.c Thu Apr 21 15:47:25 2011
@@ -0,0 +1,122 @@
+/*
+ * lock-wc-dir.c :  wrapper around svn_wc__acquire_write_lock()
+ *
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "svn_types.h"
+#include "svn_pools.h"
+
+#include "svn_cmdline.h"
+#include "svn_dirent_uri.h"
+#include "svn_path.h"
+#include "svn_wc.h"
+
+#include "private/svn_wc_private.h"
+#include "../../libsvn_wc/wc.h"
+#include "../../libsvn_wc/wc_db.h"
+
+#include "svn_private_config.h"
+
+
+#define KEY_OLD_PROPVAL "old_value_p"
+#define KEY_NEW_PROPVAL "value"
+
+#define USAGE_MSG \
+  "Usage: %s [-r|-1] DIRNAME\n" \
+  "\n" \
+  "Locks one directory (-1), or a tree recursively (-r)\n"
+
+static svn_error_t *
+obtain_lock(const char *path, svn_boolean_t recursive,
+            apr_pool_t *scratch_pool)
+{
+  const char *local_abspath;
+  svn_wc_context_t *wc_ctx;
+
+  SVN_ERR(svn_path_cstring_to_utf8(&path, path, scratch_pool));
+  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, scratch_pool));
+
+      SVN_ERR(svn_wc_context_create(&wc_ctx, NULL, scratch_pool,
+                                    scratch_pool));
+
+  if (recursive)
+    {
+      /* The WC-NG way */
+      SVN_ERR(svn_wc__acquire_write_lock(NULL, wc_ctx, local_abspath, FALSE,
+                                         scratch_pool, scratch_pool));
+    }
+  else
+    {
+      SVN_ERR(svn_wc__db_wclock_obtain(wc_ctx->db, local_abspath, 0, FALSE,
+                                       scratch_pool));
+    }
+
+  SVN_ERR(svn_cmdline_printf(scratch_pool, "Lock on '%s' obtained (and we "
+                             "are not going to release it...\n",
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool)));
+
+  return SVN_NO_ERROR;
+}
+
+int
+main(int argc, const char *argv[])
+{
+  apr_pool_t *pool;
+  int exit_code = EXIT_SUCCESS;
+  svn_error_t *err;
+  svn_boolean_t recursive;
+
+  if (argc < 2 || argc > 3)
+    {
+      fprintf(stderr, USAGE_MSG, argv[0]);
+      exit(1);
+    }
+
+  if (apr_initialize() != APR_SUCCESS)
+    {
+      fprintf(stderr, "apr_initialize() failed.\n");
+      exit(1);
+    }
+
+  /* set up the global pool */
+  pool = svn_pool_create(NULL);
+
+  recursive = (strcmp(argv[1], "-1") != 0);
+
+  err = obtain_lock(argv[2], recursive, pool);
+
+  if (err)
+    {
+      svn_handle_error2(err, stderr, FALSE, "lock-wc-dir: ");
+      svn_error_clear(err);
+      exit_code = EXIT_FAILURE;
+    }
+
+  /* Clean up, and get outta here */
+  svn_pool_destroy(pool);
+  apr_terminate();
+
+  return exit_code;
+}

Propchange: subversion/trunk/subversion/tests/cmdline/lock-wc-dir.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=1095756&r1=1095755&r2=1095756&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Thu Apr 21 15:47:25 2011
@@ -1700,11 +1700,7 @@ def lock_admin_dir(wc_dir):
   "Lock a SVN administrative directory"
   db, root_path, relpath = wc.open_wc_db(wc_dir)
 
-  db.execute('insert into wc_lock (wc_id, local_dir_relpath, locked_levels) '
-             + 'values (?, ?, ?)',
-             (1, relpath, 0))
-  db.commit()
-  db.close()
+  svntest.main.run_lock_wc_dir(False, wc_dir)
 
 def get_wc_uuid(wc_dir):
   "Return the UUID of the working copy at WC_DIR."

Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=1095756&r1=1095755&r2=1095756&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Thu Apr 21 15:47:25 2011
@@ -163,6 +163,7 @@ svndumpfilter_binary = os.path.abspath('
 entriesdump_binary = os.path.abspath('entries-dump' + _exe)
 atomic_ra_revprop_change_binary = os.path.abspath('atomic-ra-revprop-change' + \
                                                   _exe)
+lock_wc_dir_binary = os.path.abspath('lock-wc-dir' + _exe)
 
 # Location to the pristine repository, will be calculated from test_area_url
 # when we know what the user specified for --url.
@@ -653,6 +654,14 @@ def run_atomic_ra_revprop_change(url, re
                      url, revision, propname, skel,
                      options.http_library, want_error and 1 or 0)
 
+def run_lock_wc_dir(recursive, path):
+  "Run the wc-lock obtainer tool, returning its exit code, stdout and stderr"
+  if recursive:
+    option = "-r"
+  else:
+    option = "-1"
+  return run_command(lock_wc_dir_binary, False, False, option, path)
+
 
 def youngest(repos_path):
   "run 'svnlook youngest' on REPOS_PATH, returns revision as int"



Re: svn commit: r1095756 - in /subversion/trunk: build.conf subversion/tests/cmdline/lock-wc-dir.c subversion/tests/cmdline/svntest/actions.py subversion/tests/cmdline/svntest/main.py

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
rhuijben@apache.org wrote on Thu, Apr 21, 2011 at 15:47:25 -0000:
> +int
> +main(int argc, const char *argv[])
> +{
> +  apr_pool_t *pool;
> +  int exit_code = EXIT_SUCCESS;
> +  svn_error_t *err;
> +  svn_boolean_t recursive;
> +
> +  if (argc < 2 || argc > 3)
> +    {
> +      fprintf(stderr, USAGE_MSG, argv[0]);
> +      exit(1);
> +    }
> +

This allows argc == 2,

> +  if (apr_initialize() != APR_SUCCESS)
> +    {
> +      fprintf(stderr, "apr_initialize() failed.\n");
> +      exit(1);
> +    }
> +
> +  /* set up the global pool */
> +  pool = svn_pool_create(NULL);
> +
> +  recursive = (strcmp(argv[1], "-1") != 0);
> +
> +  err = obtain_lock(argv[2], recursive, pool);

in which case argv[2] == NULL,

> +static svn_error_t *
> +obtain_lock(const char *path, svn_boolean_t recursive,
> +            apr_pool_t *scratch_pool)
> +{
> +  const char *local_abspath;
> +  svn_wc_context_t *wc_ctx;
> +
> +  SVN_ERR(svn_path_cstring_to_utf8(&path, path, scratch_pool));

which is then passed to to this function, which ultimately calls
strlen() on its second argument.

> +}
> +

In short: did you mean "if (argc != 3)"?

Re: svn commit: r1095756 - in /subversion/trunk: build.conf subversion/tests/cmdline/lock-wc-dir.c subversion/tests/cmdline/svntest/actions.py subversion/tests/cmdline/svntest/main.py

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
rhuijben@apache.org wrote on Thu, Apr 21, 2011 at 15:47:25 -0000:
> +int
> +main(int argc, const char *argv[])
> +{
> +  apr_pool_t *pool;
> +  int exit_code = EXIT_SUCCESS;
> +  svn_error_t *err;
> +  svn_boolean_t recursive;
> +
> +  if (argc < 2 || argc > 3)
> +    {
> +      fprintf(stderr, USAGE_MSG, argv[0]);
> +      exit(1);
> +    }
> +

This allows argc == 2,

> +  if (apr_initialize() != APR_SUCCESS)
> +    {
> +      fprintf(stderr, "apr_initialize() failed.\n");
> +      exit(1);
> +    }
> +
> +  /* set up the global pool */
> +  pool = svn_pool_create(NULL);
> +
> +  recursive = (strcmp(argv[1], "-1") != 0);
> +
> +  err = obtain_lock(argv[2], recursive, pool);

in which case argv[2] == NULL,

> +static svn_error_t *
> +obtain_lock(const char *path, svn_boolean_t recursive,
> +            apr_pool_t *scratch_pool)
> +{
> +  const char *local_abspath;
> +  svn_wc_context_t *wc_ctx;
> +
> +  SVN_ERR(svn_path_cstring_to_utf8(&path, path, scratch_pool));

which is then passed to to this function, which ultimately calls
strlen() on its second argument.

> +}
> +

In short: did you mean "if (argc != 3)"?

Re: svn commit: r1095756 - in /subversion/trunk: build.conf subversion/tests/cmdline/lock-wc-dir.c subversion/tests/cmdline/svntest/actions.py subversion/tests/cmdline/svntest/main.py

Posted by Greg Stein <gs...@gmail.com>.
On Thu, Apr 21, 2011 at 11:47,  <rh...@apache.org> wrote:
>...
> +++ subversion/trunk/build.conf Thu Apr 21 15:47:25 2011
> @@ -1026,6 +1026,12 @@ install = test
>  libs = libsvn_ra libsvn_subr apriconv apr
>  testing = skip
>
> +[lock-wc-dir]
> +type = exe
> +path = subversion/tests/cmdline
> +sources = lock-wc-dir.c
> +install = test
> +libs = libsvn_wc libsvn_subr apriconv apr
>

there should be a 'testing = skip' line here so that the test suite
doesn't try to run it.

>...

Cheers,
-g

Re: svn commit: r1095756 - in /subversion/trunk: build.conf subversion/tests/cmdline/lock-wc-dir.c subversion/tests/cmdline/svntest/actions.py subversion/tests/cmdline/svntest/main.py

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
rhuijben@apache.org wrote on Thu, Apr 21, 2011 at 15:47:25 -0000:
> +#define KEY_OLD_PROPVAL "old_value_p"
> +#define KEY_NEW_PROPVAL "value"
> +

Unused constant.

Re: svn commit: r1095756 - in /subversion/trunk: build.conf subversion/tests/cmdline/lock-wc-dir.c subversion/tests/cmdline/svntest/actions.py subversion/tests/cmdline/svntest/main.py

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
rhuijben@apache.org wrote on Thu, Apr 21, 2011 at 15:47:25 -0000:
> +#define KEY_OLD_PROPVAL "old_value_p"
> +#define KEY_NEW_PROPVAL "value"
> +

Unused constant.