如何在出现确认提示后删除 SVN 目录?

发布于 2024-08-19 15:53:48 字数 453 浏览 4 评论 0原文

我希望能够从目录中删除 .SVN 文件夹。

我发现以下注册表黑客可以让您做到这一点...

http://weblogs.asp.net/jgalloway/archive/2007/02/24/shell-command-remove-svn-folders.aspx

然而,我不喜欢这个解决方案的是它根本不提供任何确认。我希望它执行此 cmd 脚本的操作,但首先会收到确认提示。

有什么想法吗?

编辑 我的理解是 SVN Export 不会复制未版本化的文件。这就是我提出这个要求的原因。

赛斯

I want to be able to remove the .SVN folders from a directory.

I found the following registry hack that will allow you to do just that...

http://weblogs.asp.net/jgalloway/archive/2007/02/24/shell-command-remove-svn-folders.aspx

However, the one thing I don't like about this solution is that it gives NO CONFIRMATION at all. I would like it to do what this cmd script does but get a confirmation prompt first.

Any ideas at all?

EDIT
My understanding is that SVN Export does not copy out the unversioned files. That is why I ask for this.

Seth

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

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

发布评论

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

评论(6

转身泪倾城 2024-08-26 15:53:48

您可以使用 Subversion 命令行并运行 svn export 如果您使用 TortoiseSVN,则可以使用 这个

You can use the Subversion command line and run svn export If you are using TortoiseSVN, you can use this.

魄砕の薆 2024-08-26 15:53:48

尝试对脚本进行此修改。它在运行目录删除之前添加一个提示:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && choice /m "Remove SVN folder" && if ERRORLEVEL 2 goto done && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" && :done \""

Try this modification of the script. It adds a single prompt before running the directory deletions:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && choice /m "Remove SVN folder" && if ERRORLEVEL 2 goto done && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" && :done \""
時窥 2024-08-26 15:53:48

删除隐藏在该脚本中的 RD 命令上的 /q 选项。

这应该会导致每次调用 rd (删除目录)时询问...

但同时,我会问为什么你不使用 svn 导出选项。

Remove the /q option on the RD command buried in that script.

That should cause each invocation of rd (remove directory) to ask...

At the same time, though, I'd ask why you don't use the svn export option instead.

哭泣的笑容 2024-08-26 15:53:48

如果将脚本的内容放入 cmd 文件,然后设置注册表以使其指向该 cmd 文件会怎么样?然后,您可以添加各种操作,例如 Wikipedia 中的示例。我希望这可以帮助您创建解决方案。

What if you put content of the script to the cmd file and then set registry so that it points to this cmd file? Then you could add various actions like in the examples at Wikipedia. I hope this helps you to create a solution.

森末i 2024-08-26 15:53:48

如果你完全使用 Perl,这里有一个我用来执行此操作的小脚本,再加上取出其他目录类型(对于 /bin 等很方便,来自 VS):

#!/usr/local/bin/perl -w
#-------------------------------------------------------------------------------
# removedirs.pl - Recursively removes directories from a given root folder
# Author: Nick Gotch
# Date: 07-13-2009
#-------------------------------------------------------------------------------
use strict;
use warnings;
use File::Path;

#-------------------------------------------------------------------------------
# User Setting Variables
#-------------------------------------------------------------------------------
my $basepath = 'C:\\Path\\to\\RootDir\\';

#-------------------------------------------------------------------------------
# Processing
#-------------------------------------------------------------------------------
# Prompt for Confirmation
syswrite(STDOUT, "Confirm removal of directories?\nPress 'Y' to confirm.\n");
$confirm = <STDIN>;
if($confirm =~ /^[Yy]$/)
{
    # Add lines here to remove other dirs...
    RemoveDir($basepath, ".svn");
    syswrite(STDOUT, "Done.\nPress <ENTER> to close.\n");
}
<STDIN>;

sub RemoveDir
{
    my ($directory, $dirtodelete) = @_;

    if(-e $directory.'\\'.$dirtodelete.'\\')
    {
        rmtree($directory.$dirtodelete.'\\');
        syswrite(STDOUT, "Removed: ".$directory.$dirtodelete.'\\'."\n");
    }

    opendir(DIR, $directory);
    my @subdirlist;

    while(my $subdir = readdir(DIR))
    {
        if(($subdir ne '.') && ($subdir ne '..') && (-d $directory.$subdir))
        {
            push(@subdirlist, $directory.$subdir.'\\');
        }
    }

    closedir(DIR);

    foreach my $subdir (@subdirlist) { RemoveDir($subdir, $dirtodelete); }
}

If you use Perl at all, here's a little script I have for doing this, plus taking out other dir types (handy for /bin, etc.. from VS):

#!/usr/local/bin/perl -w
#-------------------------------------------------------------------------------
# removedirs.pl - Recursively removes directories from a given root folder
# Author: Nick Gotch
# Date: 07-13-2009
#-------------------------------------------------------------------------------
use strict;
use warnings;
use File::Path;

#-------------------------------------------------------------------------------
# User Setting Variables
#-------------------------------------------------------------------------------
my $basepath = 'C:\\Path\\to\\RootDir\\';

#-------------------------------------------------------------------------------
# Processing
#-------------------------------------------------------------------------------
# Prompt for Confirmation
syswrite(STDOUT, "Confirm removal of directories?\nPress 'Y' to confirm.\n");
$confirm = <STDIN>;
if($confirm =~ /^[Yy]$/)
{
    # Add lines here to remove other dirs...
    RemoveDir($basepath, ".svn");
    syswrite(STDOUT, "Done.\nPress <ENTER> to close.\n");
}
<STDIN>;

sub RemoveDir
{
    my ($directory, $dirtodelete) = @_;

    if(-e $directory.'\\'.$dirtodelete.'\\')
    {
        rmtree($directory.$dirtodelete.'\\');
        syswrite(STDOUT, "Removed: ".$directory.$dirtodelete.'\\'."\n");
    }

    opendir(DIR, $directory);
    my @subdirlist;

    while(my $subdir = readdir(DIR))
    {
        if(($subdir ne '.') && ($subdir ne '..') && (-d $directory.$subdir))
        {
            push(@subdirlist, $directory.$subdir.'\\');
        }
    }

    closedir(DIR);

    foreach my $subdir (@subdirlist) { RemoveDir($subdir, $dirtodelete); }
}
我只土不豪 2024-08-26 15:53:48

尝试使用 Powershell 命令获取 reg 值:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& {if ((read-host '确认删除 .SVN 文件夹。按 Y 或N') -eq 'y') { Get-ChildItem '%1' -r *.svn | ?{$_.PSIsContainer} | 删除项目 -r -force -verbose -ea 0;退出' }}"

如果您不想看到文件被删除,请删除 -verbose。

Try this for the Powershell command for the reg value:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& {if ((read-host 'Confirm deletion of .SVN folder. Press Y or N') -eq 'y') { Get-ChildItem '%1' -r *.svn | ?{$_.PSIsContainer} | Remove-Item -r -force -verbose -ea 0; Read-Host 'Press enter to exit' }}"

Remove the -verbose if you don't want to see the files deleted.

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