3

I'm trying to find a way to remove zombie locks using the Subversion command line tools. The eventual goal is to do this from a hook script, but I haven't been able to work out the command line to use when you only have a physical repository path. (Using svnadmin rmlocks only seems to work for locks which exist in the HEAD revision.)

Ideally, I'd like to do this via the post-commit hook script using the command line tools. (I'm aware of the python script for this purpose, but we'd prefer not to install python on that server for this single use.) We're a .NET shop, so creating a tool with the SharpSVN library is also a possibility, but the only unlock capability there appears to be in the SVNClient class.

So it's really two questions: Is there a way to do this with the command line tools? If not, is there a way to do it from SharpSVN? (Or perhaps another library?)

== Update Dec 3, 2012 ==

I've had to revisit this problem recently and discovered this question is still drawing traffic. The python script mentioned in the original question and Don's answer has since moved to: http://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/remove-zombie-locks.py (I assume that's what most folks are looking for.)

Ironically, even though the repository has moved to Linux, we're using the C solution.

ThatBlairGuy
  • 2,426
  • 1
  • 19
  • 33

4 Answers4

3

There's a Python script (referenced here: http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2369399). I'd either use that, or translate it to .NET if you needed to.

Don
  • 3,654
  • 1
  • 26
  • 47
  • That's the script I referred to in my question. I haven't been able to find a command-line equivalent to the svn_repos_fs_unlock method. (svnadmin rmlocks only seems to work for lock in the HEAD revision.) Likewise, with SharpSVN, the only unlock method available is on the client side. – ThatBlairGuy Mar 01 '10 at 15:10
  • Sorry; don't know how I skipped over the fact that you mentioned the Python script. I basically answered you with your own question... SharpSVN is a .NET wrapper around the client API, so the same call should be available if the developers have implemented it. I searched for the svn_repos_fs_unlock method in the source and did not find it. You might want to ask on the SharpSVN forum, http://sharpsvn.open.collab.net/ds/viewForumSummary.do?dsForumId=728, just to make sure. If you're comfortable with C, you could call the API directly. – Don Mar 01 '10 at 17:18
  • Thanks. If it comes down to that, calling the API is a possibility, thought I'd just as soon avoid that if a suitable wheel already exists. – ThatBlairGuy Mar 01 '10 at 17:32
  • Because he says "We're a .NET shop". Thanks for the helpful comment, though. – Don Mar 19 '10 at 18:18
  • Unfortunately pointed article curreltly doesn't offer python script. It is redirected directly to https://subversion.apache.org/source-code without any explanation. – Znik May 29 '17 at 07:51
  • The script has moved to http://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/remove-zombie-locks.py ;-) – ThatBlairGuy Oct 25 '18 at 22:05
1

It looks like the answer is "You can't get there from here."

  • Svnadmin provides a command-line for removing locks with a repository path, but it doesn't seem to work with zombie locks.
  • SharpSVN is primarily client-side; it does have a few methods for connecting with a repository path, but those (per the docs) are mostly for use in the library's unit tests.

So rewriting the python script in C using the Subversion API library.

ThatBlairGuy
  • 2,426
  • 1
  • 19
  • 33
  • **but it doesn't seem to work with zombie locks.** Nope, it works if you know the path to the stale lock. – bahrep Oct 27 '14 at 12:21
  • @bahrep - I tested it before writing this answer. As I recall (it *was* 4 1/2 years ago), svnadmin worked fine for a file which existed in the current revision, but if the file had been marked as deleted, it failed. It's possible things have changed since then. This question still generates a fair bit of traffic, so if you can provide a hook script which uses svnadmin to accomplish the task, it will likely be of use to others and I'll happily change my accepted answer. – ThatBlairGuy Nov 18 '14 at 18:51
1

If you know the repository path to the deleted file that is zombie-locked, it is so simple that I couldn't believe it at first:

svn unlock --force https://path/to/my/file

This works even though the deleted file does (by definition) not exist in the repository's head. No peg revision required nor allowed. The force option is only necessary if the lock is from another user.

0

Common problem with zombie lock is, svn prevent removal of a directory till lock is removed from all files and sub-folder under it. Suppose you want to remove a folder named codes from your svn repo "svn://192.168.0.1/trunk/codes". You can use command line tool svn in following way to accomplish the folder removal. svn rm -m "not required" svn://192.168.0.1/trunk/codes Now svn responds with error like svn: warning: W160040: No lock on path '/trunk/codes/abc.txt You can then unlock this non-existent abc.txt via following command svn unlock --force svn://192.168.0.1/trunk/codes/abc.txt (see use of svn path instead of local path) If no more locked non-exitent file present, next command to remove the folder ie. svn rm -m "not required" svn://192.168.0.1/trunk/codes is success.

Ali
  • 181
  • 1
  • 3