如何在 Subversion 中递归释放锁?

发布于 2024-09-07 22:51:45 字数 283 浏览 4 评论 0原文

我在 Subversion 中遇到版本控制问题。我从存储库中签出了一份工作副本,并锁定了它的所有文件。然后,在没有释放锁定的情况下,我从磁盘中删除了该文件夹。

  • 我无法从存储库中删除该文件夹,因为它有一个锁。
  • 如果 I 并尝试递归地释放锁,它会说没有要释放的锁。
  • 在浏览存储库视图中,我只能递归地打破特定文件夹的锁定,而不能打破文件夹的锁定。

如何打破存储库中的锁?我在 Windows 上使用 TortoiseSVN。 是否有命令可以递归地解除文件夹的锁定?

I am having a problem with version control in Subversion. I checked out a working copy from respository and got locks on all of its files. Then, without releasing the locks I have deleted the folder from disk.

  • I can't delete the folder from repository, since its got a lock
  • If the I and try to release the locks recursively, it says there are no locks to be released.
  • In Browse Repository view, I can only break the locks on particular, not folders recursively.

How can I break the locks residing in repository? I am using TortoiseSVN on Windows.
Is there a command to break locks recursively for a folder?

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

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

发布评论

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

评论(10

命比纸薄 2024-09-14 22:51:45

好的,我明白了。这对我有用。

  • 查看一个
    工作副本
  • 然后进入 Windows 资源管理器菜单,
    乌龟SVN->检查
    修改...
  • 单击检查存储库按钮
  • 选择所有文件,右键单击并
    选择打破锁定选项
  • 删除工作副本和
    在存储库中。瞧! :)

Ok I got it. Here's what worked for me.

  • Check out a
    working copy
  • Then go in Windows explorer menu,
    TortoiseSVN -> Check for
    modifications...
  • Click on Check repository button
  • Select All the files, right click and
    select the break lock option
  • Delete the working copy and the one
    in repository. Voila! :)
青丝拂面 2024-09-14 22:51:45

执行 SVN 清理也会释放锁:

$ svn cleanup

Doing an SVN cleanup will release the lock as well:

$ svn cleanup
世界和平 2024-09-14 22:51:45

来自 高级锁定部分

$ svn status -u
M              23   bar.c
M    O         32   raisin.jpg
       *       72   foo.h
Status against revision:     105
$ svn unlock raisin.jpg
svn: 'raisin.jpg' is not locked in this working copy

这仅仅意味着该文件是未锁定在当前工作目录中
,但如果它仍然在存储库级别锁定,您可以强制解锁(“打破锁定”)

$ svn unlock http://svn.example.com/repos/project/raisin.jpg
svn: Unlock request failed: 403 Forbidden (http://svn.example.com)
$ svn unlock --force http://svn.example.com/repos/project/raisin.jpg
'raisin.jpg' unlocked.

(这是您通过 TortoiseSVN GUI 所做的)

From the advance locking section

$ svn status -u
M              23   bar.c
M    O         32   raisin.jpg
       *       72   foo.h
Status against revision:     105
$ svn unlock raisin.jpg
svn: 'raisin.jpg' is not locked in this working copy

That simply means the file is not locked in your current working directory
, but if it is still locked at the repository level, you can force the unlock ("breaking the lock")

$ svn unlock http://svn.example.com/repos/project/raisin.jpg
svn: Unlock request failed: 403 Forbidden (http://svn.example.com)
$ svn unlock --force http://svn.example.com/repos/project/raisin.jpg
'raisin.jpg' unlocked.

(which is what you did through the TortoiseSVN GUI)

战皆罪 2024-09-14 22:51:45

如果其他人远程锁定了文件,我发现使用 TortoiseSVN 1.7.11 执行以下操作可以成功在我的工作副本中解锁它们。 (类似于vikkun的答案)

  • 右键单击工作副本>检查修改
  • 单击检查存储库按钮
  • 选择您想要解锁的文件
  • 右键单击​​ >获取锁定
  • 勾选“窃取锁定”复选框
  • 锁定被窃取后,再次选择
  • 右键> >释放锁定

工作副本中的文件现在应该被解锁。

If somebody else has locked the files remotely, I found that using TortoiseSVN 1.7.11 to do the following successfully unlocked them in my working copy. (similar to vikkun's answer)

  • Right click working copy > Check for modifications
  • Click Check repository button
  • Select files you wish to unlock
  • Right click > Get lock
  • Check "Steal the lock" checkbox
  • After lock is stolen, select again
  • Right click > Release lock

Files in working copy should now be unlocked.

意中人 2024-09-14 22:51:45

除非您拥有 svn 机器的管理员访问权限并且可以使用“svnadmin”工具,否则最好的选择似乎是这样:

  1. 使用 svn checkout --ignore-externals *your_repo* 检查有问题的目录
  2. 使用 < code>svn status --show-updates 在签出的存储库上查找哪些文件可能被锁定(如果有人找到有关状态代码含义的文档,请发表评论)。
  3. 对 2 中找到的文件使用 svn unlock --force *some_file*。

我使用以下单行代码来自动化 2. 和 3.:

svn status -u | head -n -1 | awk '{ print $3 }' | xargs svn unlock --force

Unless you have admin access to the svn machine and can use the 'svnadmin' tool, your best option seems to be this:

  1. Checkout the problematic directory using svn checkout --ignore-externals *your_repo*
  2. Use svn status --show-updates on the checked out repository to find out which files are potentially locked (if someone finds the documentation on the meaning of the status codes please comment).
  3. Use svn unlock --force *some_file* on the files found at 2.

I've used the following one-liner to automate 2. and 3.:

svn status -u | head -n -1 | awk '{ print $3 }' | xargs svn unlock --force
梦断已成空 2024-09-14 22:51:45

如果您有权访问存储库服务器中的 svnadmin 工具,则可以使用此替代方案来删除所有锁定(基于 VonC 发布的脚本)

svnadmin lslocks <path_to_repo> |grep -B2 Owner |grep Path |sed "s/Path: \///" | xargs svnadmin rmlocks <path_to_repo>

If you have access to the svnadmin tool in the repo server, you can use this alternative to remove all locks (based on the script posted by VonC)

svnadmin lslocks <path_to_repo> |grep -B2 Owner |grep Path |sed "s/Path: \///" | xargs svnadmin rmlocks <path_to_repo>
絕版丫頭 2024-09-14 22:51:45

存储库管理员可以(递归地)删除锁,对有问题的目录内的数百个文件进行操作——但只能通过脚本来操作,因为 svnadmin rmlocks 没有 --recursive 选项。

$repopath=/var/svn/repos/myproject/;
$problemdirectory=trunk/bikeshed/
IFS=

此解决方案适用于其中包含空格的文件名。

\n'; for f in $(sudo svnadmin lslocks $repopath $problemdirectory \ | grep 'Path: ' \ | sed "s/Path: \///") ; \ do sudo svnadmin rmlocks $repopath "$f" ; done

此解决方案适用于其中包含空格的文件名。

The repository administrator can remove the locks (recursively), operating on hundreds of files inside a problematic directory -- but only by scripting since there is not a --recursive option to svnadmin rmlocks.

$repopath=/var/svn/repos/myproject/;
$problemdirectory=trunk/bikeshed/
IFS=

This solution works with filenames that have spaces in them.

\n'; for f in $(sudo svnadmin lslocks $repopath $problemdirectory \ | grep 'Path: ' \ | sed "s/Path: \///") ; \ do sudo svnadmin rmlocks $repopath "$f" ; done

This solution works with filenames that have spaces in them.

于我来说 2024-09-14 22:51:45

对我来说,删除 .svn 内的锁定文件不起作用,因为在尝试更新文件后我收到了错误的校验和消息。

在目录中执行 svn cleanup 后,我收到以下消息:

svn: In directory ''
svn:无法将 '.svn/tmp/text-base/file_name.svn-base' 复制到 'filename.3.tmp':没有这样的文件或目录

所以我将文件复制到 .svn/tmp/text-base并将名称更改为 file_name.svn-base。然后清理和更新工作正常。

For me deleting the lock file inside .svn did not work since I got bad checksum msg after trying to update the file.

I got the following msg after executing svn cleanup inside the directory:

svn: In directory ''
svn: Can't copy '.svn/tmp/text-base/file_name.svn-base' to 'filename.3.tmp': No such file or directory

So I copied my file to .svn/tmp/text-base and changed the name to file_name.svn-base. Then cleanup and update worked fine.

不回头走下去 2024-09-14 22:51:45

当我尝试按照最初提供的方式运行上面的脚本时,在尝试设置变量时出现错误:
./scriptname: line1: =/svn/repo/path/: 没有这样的文件或目录
./scriptname: line2: =directory/: No such file or directory

我从前两行中删除了“$”,此后工作完美。

repopath=/var/svn/repos/myproject/;
problemdirectory=trunk/bikeshed/
IFS=
\n'; for f in $(sudo svnadmin lslocks $repopath $problemdirectory \
| grep 'Path: ' \
| sed "s/Path: \///") ; \
do sudo svnadmin rmlocks $repopath "$f" ; done

When I tried to run the script from above as originally provided, I was getting an error when it tried to set the variables:
./scriptname: line1: =/svn/repo/path/: No such file or directory
./scriptname: line2: =directory/: No such file or directory

I removed the '$' from the first two lines and this worked perfectly after that.

repopath=/var/svn/repos/myproject/;
problemdirectory=trunk/bikeshed/
IFS=
\n'; for f in $(sudo svnadmin lslocks $repopath $problemdirectory \
| grep 'Path: ' \
| sed "s/Path: \///") ; \
do sudo svnadmin rmlocks $repopath "$f" ; done
预谋 2024-09-14 22:51:45

您可以使用具有 777 权限的 chmod

$ chmod -R 777 <directory-name>

让我解释一下这个命令:
chmod 命令用于更改文件和文件夹的访问权限。

文件权限由三个数字定义。每个数字可以是 0 到 7 之间的任何数字。数字代表不同的权限,数字的顺序代表该权限适用于谁。具体来说,第一个数字代表文件所有者的权限,第二个数字代表拥有该文件的组,第三个数字代表其他所有人。

每个数字的含义如下:

  • 0:无权限
  • 1:仅执行
  • 2:仅写入
  • 3:写入并执行 (1+2)
  • 4:只读
  • 5:读取并执行 (4+1)
  • 6:读取并写入 (4+ ) 2)
  • 7:读、写、执行(4+2+1)

所以777意味着每个人(文件所有者、组成员、其他用户)都可以读、写、执行文件。

-R 标志意味着递归地授予所有子文件夹此权限。

You can use chmod with 777 permission

$ chmod -R 777 <directory-name>

Let me explain this command:
chmod command is used to change the access permissions of files and folders.

File permissions are defined by three numbers. Each number can be anything from 0-7. The numbers represent different permissions, and the order of the numbers represents who the permissions apply to. Specifically, the first number represents permissions for the file owner, the second for the group that owns the file, and the third for everyone else.

Here's what each number means:

  • 0: No permissions
  • 1: Execute only
  • 2: Write only
  • 3: Write and execute (1+2)
  • 4: Read only
  • 5: Read and execute (4+1)
  • 6: Read and write (4+2)
  • 7: Read, write, and execute (4+2+1)

So 777 means that everyone (file owner, group members, other users) can read, write, and execute the files.

And -R flag means recursively give all the subfolders this permission.

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