Hi,

I'm keen to get the atomic-revprop feature working, so I've had a
go at writing patches for some of the missing bits.

This first patch gives a unique error code for the case where the
old_value passed to the revprop change function doesn't match the
real old value.  This allows it to be detected easily.  (The
branch currently overloads SVN_ERR_BAD_PROPERTY_VALUE for this,
but the same error code is also used if the new value is illegal).

This feature is on the BRANCH-README's TODO list.

The patch is against the atomic-revprop branch, but it also
applies to trunk.

[[[
Use a new, distinct error code if svn_fs_change_rev_prop2's old_value_p
doesn't match.

* subversion/include/svn_error_codes.h:
  (SVN_ERR_BAD_OLD_VALUE): New error code.

* subversion/libsvn_fs_fs/fs_fs.c:
  (change_rev_prop_body): Use SVN_ERR_BAD_OLD_VALUE when appropriate.

* subversion/libsvn_fs_base/revs-txns.c:
  (svn_fs_base__set_rev_prop): Use SVN_ERR_BAD_OLD_VALUE when
appropriate.

* subversion/include/svn_fs.h:
  (svn_fs_change_rev_prop2): Update documentation.

* subversion/tests/libsvn_fs/fs-test.c:
  (FAILS_WITH_BPV): Rename to...
  (FAILS_WITH_BOV): ... this.  Change to test for SVN_ERR_BAD_OLD_VALUE.
  (revision_props): Change to use FAILS_WITH_BOV instead of
FAILS_WITH_BPV.

Patch by: Jon Foster <jon.fos...@cabot.co.uk>
]]]

Kind regards,

Jon


**********************************************************************
This email and its attachments may be confidential and are intended solely for 
the use of the individual to whom it is addressed. Any views or opinions 
expressed are solely those of the author and do not necessarily represent those 
of Cabot Communications Ltd.

If you are not the intended recipient of this email and its attachments, you 
must take no action based upon them, nor must you copy or show them to anyone.

Cabot Communications Limited
Verona House, Filwood Road, Bristol BS16 3RY, UK
+44 (0) 1179584232

Co. Registered in England number 02817269

Please contact the sender if you believe you have received this email in error.

**********************************************************************


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Index: subversion/include/svn_error_codes.h
===================================================================
--- subversion/include/svn_error_codes.h        (revision 998620)
+++ subversion/include/svn_error_codes.h        (working copy)
@@ -219,6 +219,11 @@
              SVN_ERR_BAD_CATEGORY_START + 13,
              "Unknown string value of token")
 
+  /** @since New in 1.7. */
+  SVN_ERRDEF(SVN_ERR_BAD_OLD_VALUE,
+             SVN_ERR_BAD_CATEGORY_START + 14,
+             "Old value doesn't match repository")
+
   /* xml errors */
 
   SVN_ERRDEF(SVN_ERR_XML_ATTRIB_NOT_FOUND,
Index: subversion/libsvn_fs_fs/fs_fs.c
===================================================================
--- subversion/libsvn_fs_fs/fs_fs.c     (revision 998620)
+++ subversion/libsvn_fs_fs/fs_fs.c     (working copy)
@@ -7312,7 +7312,7 @@
               && !svn_string_compare(wanted_value, present_value)))
         {
           /* What we expected isn't what we found. */
-          return svn_error_createf(SVN_ERR_BAD_PROPERTY_VALUE, NULL,
+          return svn_error_createf(SVN_ERR_BAD_OLD_VALUE, NULL,
                                    _("revprop '%s' has unexpected value in "
                                      "filesystem"),
                                    cb->name);
Index: subversion/libsvn_fs_base/revs-txns.c
===================================================================
--- subversion/libsvn_fs_base/revs-txns.c       (revision 998620)
+++ subversion/libsvn_fs_base/revs-txns.c       (working copy)
@@ -270,7 +270,7 @@
               && !svn_string_compare(wanted_value, present_value)))
         {
           /* What we expected isn't what we found. */
-          return svn_error_createf(SVN_ERR_BAD_PROPERTY_VALUE, NULL,
+          return svn_error_createf(SVN_ERR_BAD_OLD_VALUE, NULL,
                                    _("revprop '%s' has unexpected value in "
                                      "filesystem"),
                                    name);
Index: subversion/include/svn_fs.h
===================================================================
--- subversion/include/svn_fs.h (revision 998620)
+++ subversion/include/svn_fs.h (working copy)
@@ -1896,8 +1896,8 @@
  * - @a name is the name of the property to change.
  * - if @a old_value_p is not @c NULL, then @a *old_value_p is the expected old
  *   value of the property, and changing the value will fail with error
- *   #SVN_ERR_BAD_PROPERTY_VALUE if the present value of the property is not @a
- *   *old_value_p.
+ *   #SVN_ERR_BAD_OLD_VALUE if the present value of the property is not @a
+ *   *old_value_p.  (This is an atomic test-and-set).
  * - @a value is the new value of the property, or zero if the property should
  *   be removed altogether.
  *
Index: subversion/tests/libsvn_fs/fs-test.c
===================================================================
--- subversion/tests/libsvn_fs/fs-test.c        (revision 998620)
+++ subversion/tests/libsvn_fs/fs-test.c        (working copy)
@@ -586,12 +586,12 @@
 }
 
 
-/* If EXPR raises SVN_ERR_BAD_PROPERTY_VALUE, continue; else, fail
+/* If EXPR raises SVN_ERR_BAD_OLD_VALUE, continue; else, fail
  * the test. */
-#define FAILS_WITH_BPV(expr) \
+#define FAILS_WITH_BOV(expr) \
   do { \
       svn_error_t *__err = (expr); \
-      if (!__err || __err->apr_err != SVN_ERR_BAD_PROPERTY_VALUE) \
+      if (!__err || __err->apr_err != SVN_ERR_BAD_OLD_VALUE) \
         return svn_error_create(SVN_ERR_TEST_FAILED, __err, \
                                 "svn_fs_change_rev_prop2() failed to " \
                                 "detect unexpected old value"); \
@@ -662,18 +662,18 @@
 
       /* Value of "flower" is 's1'. */
 
-      FAILS_WITH_BPV(svn_fs_change_rev_prop2(fs, 0, "flower", &s2_p, s1_p, 
pool));
+      FAILS_WITH_BOV(svn_fs_change_rev_prop2(fs, 0, "flower", &s2_p, s1_p, 
pool));
       s1_dup = svn_string_dup(&s1, pool);
       SVN_ERR(svn_fs_change_rev_prop2(fs, 0, "flower", &s1_dup, s2_p, pool));
 
       /* Value of "flower" is 's2'. */
 
-      FAILS_WITH_BPV(svn_fs_change_rev_prop2(fs, 0, "flower", &s1_p, NULL, 
pool));
+      FAILS_WITH_BOV(svn_fs_change_rev_prop2(fs, 0, "flower", &s1_p, NULL, 
pool));
       SVN_ERR(svn_fs_change_rev_prop2(fs, 0, "flower", &s2_p, NULL, pool));
 
       /* Value of "flower" is <not set>. */
 
-      FAILS_WITH_BPV(svn_fs_change_rev_prop2(fs, 0, "flower", &s2_p, s1_p, 
pool));
+      FAILS_WITH_BOV(svn_fs_change_rev_prop2(fs, 0, "flower", &s2_p, s1_p, 
pool));
       SVN_ERR(svn_fs_change_rev_prop2(fs, 0, "flower", &unset, s1_p, pool));
 
       /* Value of "flower" is 's1'. */

Reply via email to