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

Re: [PATCH] Revert and svn:needs-lock

From: D.J. Heap <dj_at_shadyvale.net>
Date: 2005-04-27 06:29:13 CEST

Is this better? I guess just looking at entry->lock_token to see if
they have the lock is sufficient since anything more would require
contacting the repo, wouldn't it?

Log:
Make revert restore the 'read-only-ness' of files with the
svn:needs-lock property if there is no lock token in the
working copy.

* subversion/libsvn_wc/adm_ops.c
   (revert_admin_things): If we don't have a lock token for the
   file, call svn_wc__maybe_set_read_only to look at the
   svn:needs-lock property and set read-only-ness accordingly.
* subversion/tests/clients/cmdline/lock_tests.py
   (revert_lock): Added new regression test for above change.

Index: subversion/libsvn_wc/adm_ops.c
===================================================================
--- subversion/libsvn_wc/adm_ops.c (revision 14458)
+++ subversion/libsvn_wc/adm_ops.c (working copy)
@@ -1382,6 +1382,10 @@
         }
     }
 
+ /* If necessary, tweak the read-only-ness of the file. */
+ if (! entry->lock_token)
+ SVN_ERR (svn_wc__maybe_set_read_only (NULL, fullpath, adm_access, pool));
+
   /* Remove conflict state (and conflict files), if any. */
   if (entry->prejfile || entry->conflict_old
       || entry->conflict_new || entry->conflict_wrk)
Index: subversion/tests/clients/cmdline/lock_tests.py
===================================================================
--- subversion/tests/clients/cmdline/lock_tests.py (revision 14458)
+++ subversion/tests/clients/cmdline/lock_tests.py (working copy)
@@ -750,6 +750,70 @@
                                      '--password', svntest.main.wc_passwd,
                                      '-m', '', file_path_b)
 
+#----------------------------------------------------------------------
+# Tests reverting a svn:needs-lock file
+def revert_lock(sbox):
+ "verify svn:needs-lock behavior with revert"
+
+ sbox.build()
+ wc_dir = sbox.wc_dir
+
+ iota_path = os.path.join(wc_dir, 'iota')
+
+ mode = stat.S_IWGRP | stat.S_IWOTH | stat.S_IWRITE
+
+ # set the prop in wc
+ svntest.main.run_svn(None, 'propset', 'svn:needs-lock', 'foo', iota_path)
+
+ # commit r2
+ svntest.main.run_svn(None, 'commit',
+ '--username', svntest.main.wc_author,
+ '--password', svntest.main.wc_passwd,
+ '-m', '', iota_path)
+
+ # make sure that iota got set to read-only
+ if (os.stat (iota_path)[0] & mode):
+ print "Committing a file with 'svn:needs-lock'"
+ print "did not set the file to read-only"
+ raise svntest.Failure
+
+ # remove read-only-ness
+ svntest.main.run_svn(None, 'propdel', 'svn:needs-lock', iota_path)
+
+ # make sure that iota got read-only-ness removed
+ if (os.stat (iota_path)[0] & mode == 0):
+ print "Deleting the 'svn:needs-lock' property "
+ print "did not remove read-only-ness"
+ raise svntest.Failure
+
+ # revert the change
+ svntest.main.run_svn(None, 'revert', iota_path)
+
+ # make sure that iota got set back to read-only
+ if (os.stat (iota_path)[0] & mode):
+ print "Reverting a file with 'svn:needs-lock'"
+ print "did not set the file back to read-only"
+ raise svntest.Failure
+
+ # now lock the file
+ svntest.main.run_svn(None, 'lock',
+ '--username', svntest.main.wc_author,
+ '--password', svntest.main.wc_passwd,
+ '-m', '', iota_path)
+
+ # modify it
+ svntest.main.file_append(iota_path, "This line added\n")
+
+ # revert it
+ svntest.main.run_svn(None, 'revert', iota_path)
+
+ # make sure it is still writable since we have the lock
+ if (os.stat (iota_path)[0] & mode == 0):
+ print "Reverting a 'svn:needs-lock' file (with lock in wc) "
+ print "did not leave the file writable"
+ raise svntest.Failure
+
+
 ########################################################################
 # Run the tests
 
@@ -772,6 +836,7 @@
               lock_non_existent_file,
               out_of_date,
               update_while_needing_lock,
+ revert_lock
              ]
 
 if __name__ == '__main__':

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Apr 27 06:30:19 2005

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