在 Subversion 中删除僵尸锁

发布于 2024-08-23 06:44:47 字数 780 浏览 10 评论 0原文

我正在尝试找到一种使用 Subversion 命令行工具删除僵尸锁的方法。最终目标是通过挂钩脚本来完成此操作,但我无法计算出当您只有物理存储库路径时要使用的命令行。 (使用 svnadmin rmlocks 似乎仅适用于 HEAD 版本中存在的锁。)

理想情况下,我想使用命令行工具通过提交后挂钩脚本来完成此操作。 (我知道用于此目的的 python 脚本,但我们不希望在该服务器上安装 python 用于此单一用途。)我们是一家 .NET 商店,因此使用 SharpSVN 库创建一个工具也是一种方法可能性,但唯一的解锁功能似乎是在 SVNClient 类中。

所以这实际上是两个问题:有没有办法使用命令行工具来做到这一点?如果没有,SharpSVN 有没有办法做到这一点? (或者也许是另一个库?)

== 2012 年 12 月 3 日更新 ==

我最近不得不重新审视这个问题,发现这个问题仍然吸引着流量。原始问题和唐的答案中提到的python脚本已移至: http://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/remove-zombie-locks.py (我认为这就是大多数人都在寻找。)

具有讽刺意味的是,即使存储库已转移到 Linux,我们仍在使用 C 解决方案。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

魔法唧唧 2024-08-30 06:44:47

有一个 Python 脚本(此处引用:http://subversion.tigris.org/ ds/viewMessage.do?dsForumId=1065&dsMessageId=2369399)。我要么使用它,要么将其转换为 .NET(如果需要)。

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.

洛阳烟雨空心柳 2024-08-30 06:44:47

看起来答案是“你无法从这里到达那里”。

  • Svnadmin 提供了一个命令行,用于删除带有存储库路径的锁,但它似乎不适用于僵尸锁。
  • SharpSVN 主要是客户端;它确实有一些与存储库路径连接的方法,但这些(根据文档)主要用于库的单元测试。

因此,使用 Subversion API 库用 C 语言重写 python 脚本。

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.

老街孤人 2024-08-30 06:44:47

如果您知道被僵尸锁定的已删除文件的存储库路径,那么它是如此简单,以至于我一开始都无法相信:

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

即使已删除的文件(根据定义)不存在于存储库的头部,这仍然有效。不需要也不允许修改挂钩。仅当锁来自其他用户时才需要 force 选项。

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.

巾帼英雄 2024-08-30 06:44:47

僵尸锁的常见问题是,svn 会阻止删除目录,直到该目录下的所有文件和子文件夹的锁被删除为止。假设您要从 svn 存储库“svn://192.168.0.1/trunk/codes”中删除名为codes 的文件夹。
您可以通过以下方式使用命令行工具 svn 来完成文件夹删除。
svn rm -m“不需要” svn://192.168.0.1/trunk/codes
现在 svn 响应错误,如 svn: warning: W160040: No lock on path '/trunk/codes/abc.txt
然后您可以通过以下命令解锁这个不存在的 abc.txt
svn unlock --force svn://192.168.0.1/trunk/codes/abc.txt (请参阅使用 svn 路径而不是本地路径)
如果不再存在锁定的不存在文件,则下一个命令将删除该文件夹,即。 svn rm -m "not required" svn://192.168.0.1/trunk/codes 成功。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文