如何在Win XP上找到所有“SVN工作副本” [英] How to find all 'SVN working copies' on Win XP

查看:182
本文介绍了如何在Win XP上找到所有“SVN工作副本”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Windows XP。我想将我的 TortoiseSVN升级到1.7版
为了做到这一点,我需要确保能在我的电脑上找到所有的SVN工作副本。所以他们可以更新。

我找到了一个类似的问题,但它是特定于Powershell的。所以,我想知道是否有一个更一般的解决方案来找到Win XP上的所有SVN工作副本。

如果我知道Windows上的'linux find'相当于我自己写的。
但是我希望可能有一个bash脚本已经在那里(或者一些解决方案,甚至更简单),我和其他人可以使用。


  • 扫描计算机

  • 如果找到包含名为.svn的目录


    • 回显该名称,

    • 不再搜索该目录



解决方案

只要你有PowerShell,我可以提供我的完整脚本升级工作副本到1.7

  $ prev =^ $
$ workingCopies = Get-ChildItem -Recurse -Force -Include.svn-Pathd:\Projects\\ \\{?{$ _。PSIsContainer -and $ _。Fullname.StartsWith($ prev)-eq $ false} |%{$ prev = $ _。Fullname.TrimEnd(。svn); $ prev}

foreach($ copy in $ workingCopies)
{
&C:\程序文件\TortoiseSVN\bin\svn.exe升级$复印件;





我没有访问权限到系统卷目录的问题(那是只是偶然,因为我把我所有的来源存储在一个文件夹我有充分的权利..)。
至于你的问题与执行政策 - 这里很好的伎俩,以避免设置它回来。
您可以使用特殊选项运行powershell,以避免执行策略,用户特定的配置文件设置(可能因为不同的原因而被破坏)等问题:

 %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -FileC:\Projects\ConvertSvnToVersion17.ps1

另外我可以澄清一下这个脚本究竟做了什么(如果你感兴趣):

  $ prev =^ $

将$ prev初始化为空匹配正则表达式 - ^ $从不匹配任何含义值(startline-endline除外)。这是需要通过初始检查

  Get-ChildItem -Recurse -Force -Include.svn-Pathd:\\ \\ Project \

获取名称为.svn的所有对象(在我们的例子中 - 和具有确切名称.svn的文件夹),从Path开始递归地开始。
并将其传递给下一个构造:

$ $ $ $ $。$ PSIsContainer和$ _。Fullname.StartsWith $ prev)-eq $ false}

?{... statements ...} Where-Objectcmdlet,$ _是从管道处理每个条目的方式。
它可以被重写为类似于

$ foreach($ entry in $ entriesFromSomewhere)
{
如果($ entry.PSIsContainer -eq $ true和$ entry.Fullname.StartsWith($ prev)-eq $ false)
{
如果entry是目录和fullname不是以value开始从$ prev
...通过条目到下一个构造...
}
}

但是为了简洁起见,我把它写成一行

 %{$ prev = $ _ .Fullname.TrimEnd( SVN。); $ prev} 

%{}是Foreach =的快捷方式)
这个构造做2
$ b


  1. 将没有.svn尾的文件夹全名分配给$ prev

  2. 通过$ prev进一步到下一个管道接收器。

将整个结果集分配给$ workingCopies作为数组(任何超过1项的结果都是数组)

$ p $ foreach($ copy in $ workingCopies)
{
&C:\Program Files \TortoiseSVN\bin\svn.exeupgrade $ copy;



$ b $ foreach中的元素 - 执行命令(& sign forexecute as command )... \svn.exe升级



这里所有的魔术都是回溯$ prev元素:
在第一个.svn入口$ prev包含不匹配的值,所以首先检查where将被缩减为If entry is directory。然后分配步骤将把文件夹父目录。防爆。如果发现目录全名是 c:\projects\project1.root\trunk.svn - $ prev将被分配给 c:\projects\project1。 root\trunk\ 即可。
这个技巧将帮助我们过滤所有低级别的.svn目录:
c:\projects\project1.root\trunk\SubProject1.svn 条目 - 将不会通过检查不以$ prev开始
这样,我们将只筛选第一级.svn dirs,导致所有嵌套的.snv将被 StartsWith($ prev)-eq $ false

所以它很简单,但显示为一些魔术=)

BTW谢谢你自己在这里回答 - 你的努力极大地鼓舞了我写这个评论,并澄清整个脚本。

语法怪杰应该被传唤给这个评论以清理和改写我的所谓英语;)

I have Windows XP. I'd like to upgrade my TortoiseSVN to version 1.7. In order to do that I need to ensure that I can find all SVN working copies on my PC. So they can be updated.

I have found a similar question but it is specific to Powershell. So, I was wondering if there was a more general solution to find all 'SVN working copies' on Win XP.

If I knew the equivalent of 'linux find' on windows I could probably write it myself. But I'm hoping that there may be a bash script out there already (or maybe some solution that's even simpler) that me and others could use.

  • scans the computer
  • if it finds a directory that contains a directory called ".svn"
    • echo that name, and
    • breaks from searching that directory any more

解决方案

As soon as you have powershell, I could provide my full script to upgrade working copies to 1.7

$prev = "^$"
$workingCopies = Get-ChildItem -Recurse -Force -Include ".svn" -Path "d:\Projects\" |?{$_.PSIsContainer -and $_.Fullname.StartsWith($prev)-eq $false} |%{$prev=$_.Fullname.TrimEnd(".svn"); $prev}

foreach($copy in $workingCopies)
{
    &"C:\Program Files\TortoiseSVN\bin\svn.exe" upgrade $copy;
}

I dont had issues with access rights to "System Volume" dir (that was just accidentially, cause I store all my sources in one folder I have full rights to..). As for your issue with Execution Policy - here nice trick to avoid set it forth and back. You could run powershell with special options to avoid issues with execution policy, user specific profile settings (which could be broken for different reasons) etc:

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -File "C:\Projects\ConvertSvnToVersion17.ps1"

Also I could clarify what exactly this script do (if you are interested):

$prev = "^$"

Initialize $prev to empty-matching regex - ^$ never match any meaning value (except startline-endline). This was needed to pass initial check

Get-ChildItem -Recurse -Force -Include ".svn" -Path "d:\Projects\" 

Get all objects with name ".svn" (in our case - all files and folders with exact name ".svn"), started from Path, Recursively. And pipe it to next construct:

?{$_.PSIsContainer -and $_.Fullname.StartsWith($prev)-eq $false} 

?{...statements... } is shortcut to "Where-Object" cmdlet, $_ is the way to address "each" entry from pipe. It could be rewritten similar to

foreach($entry in $entriesFromSomewhere)
{
    If($entry.PSIsContainer -eq $true -and $entry.Fullname.StartsWith($prev) -eq $false)
    {
        "If entry is directory" and  "fullname not start with value from $prev"
        ...Pass entry to next construct...
    }
}

But I wrote it as one-liner for the brevity

%{$prev=$_.Fullname.TrimEnd(".svn"); $prev}

%{} is shortcut for Foreach =) And this construct doing 2 things :

  1. Assign folder fullname without ".svn" tail to $prev
  2. Pass $prev further to next pipeline sink.

And entire result set assigned to $workingCopies as array (any result with more than 1 item will be array)

foreach($copy in $workingCopies)
{
    &"C:\Program Files\TortoiseSVN\bin\svn.exe" upgrade $copy;
}

Foreach element in array - execute command (& sign for "execute as command") "…\svn.exe upgrade "

All the magic here is going to that backtracking $prev element: On first ".svn" entry $prev contains non-matching value so first check in "where" will be reduced to "If entry is directory". Then assigning step will put folder parent dir. Ex. If found dir fullname is c:\projects\project1.root\trunk.svn - $prev will be assigned to "c:\projects\project1.root\trunk\". This trick will help us to filter all lower-level .svn dirs: c:\projects\project1.root\trunk\SubProject1.svn entry - will not pass check "not starts with $prev" And this way we will filter only first level .svn dirs, cause all nested .snv will be filtered by StartsWith($prev) -eq $false

So its pretty simple but appears as some magic =)

BTW Thank you for your own answer here - your efforts greatly inspired me to write this comment and clarify entire script.

Grammar geeks should be summoned to this comment for cleaning and rephrasing my "so-called-English" ;)

这篇关于如何在Win XP上找到所有“SVN工作副本”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆